From: Anthony Liguori Date: Mon, 12 Dec 2011 20:29:36 +0000 (-0600) Subject: qdev: add explicitly named devices to the root complex X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1bdaacb18fc86366cf5a855b72247bbb1014cc21;p=qemu-xen-4.2-testing.git 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 --- diff --git a/hw/qdev.c b/hw/qdev.c index d4482754b..cb3fc6e56 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);