qom: introduce root device
This is based on Jan's suggestion for how to do unique naming. The root device is the root of composition. All devices are reachable via child<> links from this device. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
a5296ca9df
commit
a10f07a7d0
|
@ -278,7 +278,7 @@ hw-obj-$(CONFIG_LSI_SCSI_PCI) += lsi53c895a.o
|
||||||
hw-obj-$(CONFIG_ESP) += esp.o
|
hw-obj-$(CONFIG_ESP) += esp.o
|
||||||
|
|
||||||
hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
|
hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
|
||||||
hw-obj-y += qdev-addr.o
|
hw-obj-y += qdev-addr.o container.o
|
||||||
|
|
||||||
# VGA
|
# VGA
|
||||||
hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o
|
hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include "sysbus.h"
|
||||||
|
|
||||||
|
static int container_initfn(SysBusDevice *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SysBusDeviceInfo container_info = {
|
||||||
|
.init = container_initfn,
|
||||||
|
.qdev.name = "container",
|
||||||
|
.qdev.size = sizeof(SysBusDevice),
|
||||||
|
.qdev.no_user = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void container_init(void)
|
||||||
|
{
|
||||||
|
sysbus_register_withprop(&container_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
device_init(container_init);
|
12
hw/qdev.c
12
hw/qdev.c
|
@ -1161,3 +1161,15 @@ void qdev_property_add_legacy(DeviceState *dev, Property *prop,
|
||||||
|
|
||||||
g_free(type);
|
g_free(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceState *qdev_get_root(void)
|
||||||
|
{
|
||||||
|
static DeviceState *qdev_root;
|
||||||
|
|
||||||
|
if (!qdev_root) {
|
||||||
|
qdev_root = qdev_create(NULL, "container");
|
||||||
|
qdev_init_nofail(qdev_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
return qdev_root;
|
||||||
|
}
|
||||||
|
|
|
@ -482,4 +482,12 @@ const char *qdev_property_get_type(DeviceState *dev, const char *name,
|
||||||
*/
|
*/
|
||||||
void qdev_property_add_legacy(DeviceState *dev, Property *prop, Error **errp);
|
void qdev_property_add_legacy(DeviceState *dev, Property *prop, Error **errp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @qdev_get_root - returns the root device of the composition tree
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* The root of the composition tree.
|
||||||
|
*/
|
||||||
|
DeviceState *qdev_get_root(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue