qemu-patch-raspberry4/include
Eric Auger db57fef1e2 qom: Introduce object_property_try_add_child()
object_property_add() does not allow object_property_try_add()
to gracefully fail as &error_abort is passed as an error handle.

However such failure can easily be triggered from the QMP shell when,
for instance, one attempts to create an object with an id that already
exists. This is achieved from the following call path:

qmp_object_add -> user_creatable_add_dict -> user_creatable_add_type ->
object_property_add_child -> object_property_add

For instance, from the qmp-shell, call twice:
object-add qom-type=memory-backend-ram id=mem1 props.size=1073741824
and QEMU aborts.

This behavior is undesired as a user/management application mistake
in reusing a property ID shouldn't result in loss of the VM and live
data within.

This patch introduces a new function, object_property_try_add_child()
which takes an error handle and turn object_property_try_add() into
a non-static one.

Now the call path becomes:

user_creatable_add_type -> object_property_try_add_child ->
object_property_try_add

and the error is returned gracefully to the QMP client.

(QEMU) object-add qom-type=memory-backend-ram id=mem2  props.size=4294967296
{"return": {}}
(QEMU) object-add qom-type=memory-backend-ram id=mem2  props.size=4294967296
{"error": {"class": "GenericError", "desc": "attempt to add duplicate property
'mem2' to object (type 'container')"}}

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Fixes: d2623129a7 ("qom: Drop parameter @errp of object_property_add() & friends")
Reviewed-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Greg Kurz <groug@kaod.org>
Tested-by: Greg Kurz <groug@kaod.org>
Message-Id: <20200629193424.30280-2-eric.auger@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-07-10 18:02:16 -04:00
..
authz Include generated QAPI headers less 2019-08-16 13:31:51 +02:00
block nbd: Use ERRP_GUARD() 2020-07-10 15:18:09 +02:00
chardev chardev: Use QEMUChrEvent enum in IOEventHandler typedef 2020-01-08 11:15:35 +01:00
crypto firmware (and crypto) patches 2020-07-09 20:01:43 +01:00
disas disas: include an optional note for the start of disassembly 2020-05-15 15:25:16 +01:00
exec virtio,acpi: features, fixes, cleanups. 2020-07-07 17:37:44 +01:00
fpu softfloat,m68k: disable floatx80_invalid_encoding() for m68k 2020-07-06 21:41:52 +02:00
hw qdev: Make functions taking Error ** return bool, not void 2020-07-10 15:18:08 +02:00
io io/task: Move 'qom/object.h' header to source 2020-06-10 12:09:37 -04:00
libdecnumber include: Make headers more self-contained 2019-08-16 13:31:51 +02:00
migration migration/colo: Use ram_block_discard_disable() 2020-07-02 05:54:59 -04:00
monitor hmp: Implement qom-get HMP command 2020-06-01 18:44:27 +01:00
net vhost-vdpa: introduce vhost-vdpa net client 2020-07-07 07:59:51 -04:00
qapi scripts: Coccinelle script to use ERRP_GUARD() 2020-07-10 15:18:09 +02:00
qemu util/qemu-error: prepend guest name to error message to identify affected VM owner 2020-07-10 18:02:15 -04:00
qom qom: Introduce object_property_try_add_child() 2020-07-10 18:02:16 -04:00
scsi scsi: explicitly list guest-recoverable sense codes 2019-07-15 11:20:42 +02:00
standard-headers Linux headers: update 2020-06-18 12:13:36 +02:00
sysemu virtio-balloon: Rip out qemu_balloon_inhibit() 2020-07-02 05:54:59 -04:00
tcg tcg: call qemu_spin_destroy for tb->jmp_lock 2020-06-16 14:49:05 +01:00
ui ui/win32-kbd-hook: handle AltGr in a hook procedure 2020-05-19 09:06:44 +02:00
user linux-user: Include trace-root.h in syscall-trace.h 2020-01-15 15:13:09 -10:00
elf.h target/arm/arch_dump: Add SVE notes 2020-01-23 15:34:04 +00:00
glib-compat.h glib: bump min required glib library version to 2.48 2019-08-22 10:46:34 +01:00
qemu-common.h Update copyright date for user-facing copyright strings 2020-03-22 11:16:21 +00:00
qemu-io.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
trace-tcg.h trace: get rid of generated-events.h/generated-events.c 2016-10-12 09:54:52 +02:00