All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH] qdev: Make -device FOO, help help again when FOO is not pluggable
@ 2015-03-16 17:33 ` Markus Armbruster
  0 siblings, 0 replies; 10+ messages in thread
From: Markus Armbruster @ 2015-03-16 17:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, ehabkost, afaerber

Doesn't work since commit 31bed55 changed qdev_device_help() to reject
abstract devices and devices that have
cannot_instantiate_with_device_add_yet set.

The former makes sense: abstract devices are purely internal, and the
implementation of the help feature can't cope with them.

The latter makes less sense: the implementation works fine, and even
though you can't -device such a device, the help may still be useful
elsewhere, for instance with -global.

Revert the latter by moving the cannot_instantiate_with_device_add_yet
check back to the other caller of qdev_get_device_class(),
qdev_device_add().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qdev-monitor.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/qdev-monitor.c b/qdev-monitor.c
index 5d30ac5..b0b8cf1 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -180,10 +180,14 @@ static const char *find_typename_by_alias(const char *alias)
     return NULL;
 }
 
+
+/**
+ * Return DeviceClass for concrete device type @driver.
+ * On error, store an error through @errp if non-null, and 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) {
@@ -206,15 +210,7 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
         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;
+    return DEVICE_CLASS(oc);
 }
 
 
@@ -512,6 +508,12 @@ DeviceState *qdev_device_add(QemuOpts *opts)
         error_free(err);
         return NULL;
     }
+    if (dc->cannot_instantiate_with_device_add_yet ||
+        (qdev_hotplug && !dc->hotpluggable)) {
+        qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver",
+                      "pluggable device type");
+        return NULL;
+    }
 
     /* find bus */
     path = qemu_opt_get(opts, "bus");
-- 
1.9.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-03-17 14:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-16 17:33 [Qemu-trivial] [PATCH] qdev: Make -device FOO, help help again when FOO is not pluggable Markus Armbruster
2015-03-16 17:33 ` [Qemu-devel] " Markus Armbruster
2015-03-16 17:37 ` [Qemu-trivial] " Paolo Bonzini
2015-03-16 17:37   ` [Qemu-devel] " Paolo Bonzini
2015-03-16 18:13 ` [Qemu-trivial] " Eduardo Habkost
2015-03-16 18:13   ` [Qemu-devel] " Eduardo Habkost
2015-03-17  7:15   ` [Qemu-trivial] " Markus Armbruster
2015-03-17  7:15     ` Markus Armbruster
2015-03-17 14:57     ` [Qemu-trivial] " Eduardo Habkost
2015-03-17 14:57       ` Eduardo Habkost

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.