summary refs log tree commit diff stats
path: root/hw/qdev.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-12-12 14:29:36 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2011-12-15 09:20:48 -0600
commit1bdaacb18fc86366cf5a855b72247bbb1014cc21 (patch)
tree842a338cc2a2c947372655e8b0ad2ede715a3642 /hw/qdev.c
parenteb6e8ea5c38b47a3c6cf27f4780abd92bc079caa (diff)
downloadfocaccia-qemu-1bdaacb18fc86366cf5a855b72247bbb1014cc21.tar.gz
focaccia-qemu-1bdaacb18fc86366cf5a855b72247bbb1014cc21.zip
qdev: add explicitly named devices to the root complex
We first add a 'peripheral' container to the root device that we add user
created devices to.  This provides all user created devices with a unique and
isolated namespace.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r--hw/qdev.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index d4482754b0..cb3fc6e56d 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -227,6 +227,19 @@ int qdev_device_help(QemuOpts *opts)
     return 1;
 }
 
+static DeviceState *qdev_get_peripheral(void)
+{
+    static DeviceState *dev;
+
+    if (dev == NULL) {
+        dev = qdev_create(NULL, "container");
+        qdev_property_add_child(qdev_get_root(), "peripheral", dev, NULL);
+        qdev_init_nofail(dev);
+    }
+
+    return dev;
+}
+
 DeviceState *qdev_device_add(QemuOpts *opts)
 {
     const char *driver, *path, *id;
@@ -278,6 +291,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
     id = qemu_opts_id(opts);
     if (id) {
         qdev->id = id;
+        qdev_property_add_child(qdev_get_peripheral(), qdev->id, qdev, NULL);
     }
     if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
         qdev_free(qdev);