qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] qdev: Make -device FOO, help help again when FOO is


From: Markus Armbruster
Subject: [Qemu-devel] [PATCH] qdev: Make -device FOO, help help again when FOO is not pluggable
Date: Mon, 16 Mar 2015 18:33:52 +0100

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 <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]