qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] QOM: Can devices having link properties be user-creatable?
@ 2018-10-12 12:47 Philippe Mathieu-Daudé
  2018-10-12 13:01 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-12 12:47 UTC (permalink / raw)
  To: QEMU Developers, Eduardo Habkost, Thomas Huth, Peter Maydell; +Cc: Mao Zhongyi

While looking at Mao's series
(https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg02519.html) I
wondered if devices having link properties can be user-creatable.

Using the following patch (I don't think this is correct to put qdev
code into qobject, but I used this as PoC):

-- >8 --
diff --git a/qom/object.c b/qom/object.c
index 547dcf97c3..2dd3a25531 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -16,4 +16,5 @@
 #include "qom/object_interfaces.h"
 #include "qemu/cutils.h"
+#include "qemu/error-report.h"
 #include "qapi/visitor.h"
 #include "qapi/string-input-visitor.h"
@@ -1662,4 +1663,11 @@ void object_property_add_link(Object *obj, const
char *name,
     gchar *full_type;
     ObjectProperty *op;
+    ObjectClass *klass = object_get_class(obj);
+
+    if (klass && object_dynamic_cast(obj, TYPE_DEVICE) &&
+                 DEVICE_CLASS(klass)->user_creatable == false) {
+        warn_report("Device type '%s' is user_creatable "
+                    "(linked property: '%s')", type, name);
+    }

     prop->child = child;
---

I get:

$ aarch64-softmmu/qemu-system-aarch64 -M virt
qemu-system-aarch64: warning: Device type 'bus' is user_creatable
(linked property: 'parent_bus')
qemu-system-aarch64: warning: Device type 'qemu:memory-region' is
user_creatable (linked property: 'memory')
qemu-system-aarch64: warning: Device type 'bus' is user_creatable
(linked property: 'parent_bus')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'unnamed-gpio-out[0]')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'unnamed-gpio-out[1]')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'unnamed-gpio-out[2]')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'unnamed-gpio-out[3]')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'gicv3-maintenance-interrupt[0]')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'pmu-interrupt[0]')
qemu-system-aarch64: warning: Device type 'qemu:memory-region' is
user_creatable (linked property: 'secure-memory')
qemu-system-aarch64: warning: Device type 'bus' is user_creatable
(linked property: 'parent_bus')
qemu-system-aarch64: warning: Device type 'bus' is user_creatable
(linked property: 'parent_bus')
qemu-system-aarch64: warning: Device type 'bus' is user_creatable
(linked property: 'parent_bus')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'sysbus-irq[0]')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'sysbus-irq[1]')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'sysbus-irq[2]')
qemu-system-aarch64: warning: Device type 'irq' is user_creatable
(linked property: 'sysbus-irq[3]')

Are we incorrectly using user_creatable = true in those devices/
Am I missing something?

Thanks,

Phil.

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

end of thread, other threads:[~2018-10-12 13:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-12 12:47 [Qemu-devel] QOM: Can devices having link properties be user-creatable? Philippe Mathieu-Daudé
2018-10-12 13:01 ` Peter Maydell
2018-10-12 13:06   ` Philippe Mathieu-Daudé
2018-10-12 13:14     ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).