summaryrefslogtreecommitdiff
path: root/hw/core/qdev.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-01-20 10:04:07 +0100
committerMichael S. Tsirkin <mst@redhat.com>2015-02-26 12:42:18 +0100
commit25f8dd96598042a88fdd970d5531584b589b10e4 (patch)
tree6f4402af58d8a0316fea1fe09db567f149cf1618 /hw/core/qdev.c
parentd313858dfc2b0b5e6c126f1920863fe43dc9d5b6 (diff)
downloadqemu-25f8dd96598042a88fdd970d5531584b589b10e4.tar.gz
qdev: Don't exit when running into bad -global
-global lets you set a nice booby-trap for yourself: $ qemu-system-x86_64 -nodefaults -S -display none -usb -monitor stdio -global usb-mouse.usb_version=l QEMU 2.1.94 monitor - type 'help' for more information (qemu) device_add usb-mouse Parameter 'usb_version' expects an int64 value or range $ echo $? 1 Not nice. Until commit 3196270 we even abort()ed. The same error triggers if you manage to screw up a machine type's compat_props. To demonstrate, change HW_COMPAT_2_1's entry to .driver = "usb-mouse",\ .property = "usb_version",\ .value = "1", \ Then run $ qemu-system-x86_64 -usb -M pc-i440fx-2.1 -device usb-mouse upstream-qemu: -device usb-mouse: Parameter 'usb_version' expects an int64 value or range $ echo $? 1 One of our creatively cruel error messages. Since this is actually a coding error, we *should* abort() here. Replace the error by an assertion failure in this case. But turn the fatal error into a mere warning when the faulty GlobalProperty comes from the user. Looks like this: $ qemu-system-x86_64 -nodefaults -S -display none -usb -monitor stdio -global usb-mouse.usb_version=l QEMU 2.1.94 monitor - type 'help' for more information (qemu) device_add usb-mouse Warning: global usb-mouse.usb_version=l ignored (Parameter 'usb_version' expects an int64 value or range) (qemu) This is consistent with how we handle similarly unusable -global in qdev_prop_check_globals(). You could argue that the error should make device_add fail. Would be harder, because we're running within TypeInfo's instance_post_init() method device_post_init(), which can't fail. Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r--hw/core/qdev.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 44c6b93727..5f63c5bbde 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -1186,13 +1186,7 @@ static void device_initfn(Object *obj)
static void device_post_init(Object *obj)
{
- Error *err = NULL;
- qdev_prop_set_globals(DEVICE(obj), &err);
- if (err) {
- qerror_report_err(err);
- error_free(err);
- exit(EXIT_FAILURE);
- }
+ qdev_prop_set_globals(DEVICE(obj));
}
/* Unlink device from bus and free the structure. */