QOM devices patch queue 2014-11-04
Hello Peter,
This is my QOM (devices) patch queue. Please pull.
Regards,
Andreas
The following changes since commit 1bc8dae31baa8b02a1b8e70c3244232e03bbb3b2:
Merge remote-tracking branch 'remotes/kraxel/tags/pull-gtk-20141104-2' into staging (2014-11-04 15:00:17 +0000)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-peter
for you to fetch changes up to 31bed5509dfcbdfc293154ce81086a4dbd7a80b6:
qdev: Use qdev_get_device_class() for -device <type>,help (2014-11-04 17:50:00 +0100)
----------------------------------------------------------------
QOM infrastructure fixes and device conversions
* Fixes for -device foo,help
----------------------------------------------------------------
Eduardo Habkost (3):
qdev: Create qdev_get_device_class() function
qdev: Move error printing to the end of qdev_device_help()
qdev: Use qdev_get_device_class() for -device <type>,help
qdev-monitor.c | 88 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 37 deletions(-)
[Qemu-devel] [PULL 3/3] qdev: Use qdev_get_device_class() for -device <type>, help
From: Eduardo Habkost <[email protected]>
Make sure we try to list properties from classes that can be safely used with "-device".
Fixes the following crashes:
$ qemu-system-x86_64 -device x86_64-cpu,help ** ERROR:qom/object.c:336:object_initialize_with_type: assertion failed: (type->abstract == false) Aborted (core dumped) $ qemu-system-x86_64 -device host-x86_64-cpu,help qemu-system-x86_64: [...]/target-i386/cpu.c:1329: host_x86_cpu_initfn: Assertion `(kvm_allowed)' failed. Aborted (core dumped)
After applying this patch:
$ qemu-system-x86_64 -device x86_64-cpu,help Parameter 'driver' expects non-abstract device type $ qemu-system-x86_64 -device host-x86_64-cpu,help Parameter 'driver' expects pluggable device type
--- qdev-monitor.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
qdev-monitor.c +3 -6
@@ -235,12 +235,9 @@ int qdev_device_help(QemuOpts *opts)return 0 ; } -if (!object_class_by_name (driver)) { -const char *typename =find_typename_by_alias (driver); - -if (typename) { - driver = typename; - } +qdev_get_device_class (&driver, &local_err); +if (local_err) { + goto error; } prop_list =qmp_device_list_properties (driver, &local_err);
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL 2/3] qdev: Move error printing to the end of qdev_device_help()
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
--- qdev-monitor.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
qdev-monitor.c +6 -3
@@ -245,9 +245,7 @@ int qdev_device_help(QemuOpts *opts) prop_list =qmp_device_list_properties (driver, &local_err);if (local_err) { -error_printf ("%s\n" ,error_get_pretty (local_err)); -error_free (local_err); -return 1 ; + goto error; }for (prop = prop_list; prop; prop = prop->next) {
@@ -263,6 +261,11 @@ int qdev_device_help(QemuOpts *opts)qapi_free_DevicePropertyInfoList (prop_list);return 1 ; + +error: +error_printf ("%s\n" ,error_get_pretty (local_err)); +error_free (local_err); +return 1 ; }static Object *qdev_get_peripheral (void )
Signature · 1 line
1.8.4.5
[Qemu-devel] [PULL 1/3] qdev: Create qdev_get_device_class() function
In reply to Andreas FärberFrom: Eduardo Habkost <[email protected]>
Extract the DeviceClass lookup from qdev_device_add() to a separate function.
--- qdev-monitor.c | 70 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 28 deletions(-)
qdev-monitor.c +42 -28
@@ -180,6 +180,44 @@ static const char *find_typename_by_alias(const char *alias)return NULL ; } +static DeviceClass *qdev_get_device_class (const char **driver,Error **errp) +{ +ObjectClass *oc; +DeviceClass *dc; + + oc =object_class_by_name (*driver); +if (!oc) { +const char *typename =find_typename_by_alias (*driver); + +if (typename) { + *driver = typename; + oc =object_class_by_name (*driver); + } + } + +if (!object_class_dynamic_cast (oc,TYPE_DEVICE )) { +error_setg (errp,"'%s' is not a valid device model name" , *driver); +return NULL ; + } + +if (object_class_is_abstract (oc)) { +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"driver" , +"non-abstract device type" ); +return NULL ; + } + + dc =DEVICE_CLASS (oc); +if (dc->cannot_instantiate_with_device_add_yet || + (qdev_hotplug && !dc->hotpluggable)) { +error_set (errp,QERR_INVALID_PARAMETER_VALUE ,"driver" , +"pluggable device type" ); +return NULL ; + } + +return dc; +} + +int qdev_device_help (QemuOpts *opts) {Error *local_err =NULL ;
@@ -455,7 +493,6 @@ static BusState *qbus_find(const char *path)DeviceState *qdev_device_add (QemuOpts *opts) { -ObjectClass *oc;DeviceClass *dc;const char *driver, *path, *id;DeviceState *dev;
@@ -469,33 +506,10 @@ DeviceState *qdev_device_add(QemuOpts *opts) }/* find driver */ - oc =object_class_by_name (driver); -if (!oc) { -const char *typename =find_typename_by_alias (driver); - -if (typename) { - driver = typename; - oc =object_class_by_name (driver); - } - } - -if (!object_class_dynamic_cast (oc,TYPE_DEVICE )) { -qerror_report (ERROR_CLASS_GENERIC_ERROR , -"'%s' is not a valid device model name" , driver); -return NULL ; - } - -if (object_class_is_abstract (oc)) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"driver" , -"non-abstract device type" ); -return NULL ; - } - - dc =DEVICE_CLASS (oc); -if (dc->cannot_instantiate_with_device_add_yet || - (qdev_hotplug && !dc->hotpluggable)) { -qerror_report (QERR_INVALID_PARAMETER_VALUE ,"driver" , -"pluggable device type" ); + dc =qdev_get_device_class (&driver, &err); +if (err) { +qerror_report_err (err); +error_free (err);return NULL ; }
Signature · 1 line
1.8.4.5
Peter Maydell
AppliedQuoted 22 lines · Andreas Färber
Hello Peter,
This is my QOM (devices) patch queue. Please pull.
Regards,
AndreasCc Peter Maydell <[email protected]>Cc Eduardo Habkost <[email protected]>The following changes since commit
1bc8dae31baa8b02a1b8e70c3244232e03bbb3b2:Merge remote-tracking branch 'remotes/kraxel/tags/pull-gtk-20141104-2' into staging (2014-11-04 15:00:17 +0000)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.gittags/qom-devices-for-peterfor you to fetch changes up to
31bed5509dfcbdfc293154ce81086a4dbd7a80b6:
Quoted 8 lines
qdev: Use
qdev_get_device_class()for -device <type>,help (2014-11-04 17:50:00 +0100)----------------------------------------------------------------
QOM infrastructure fixes and device conversions* Fixes for -device foo,help
----------------------------------------------------------------
Applied, thanks.
-- PMM