提交 213f0c4f 编写于 作者: A Andreas Färber

qom: Pass available size to object_initialize()

To be passed on to object_initialize_with_type().

Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> (virtio-ccw)
Signed-off-by: NAndreas Färber <afaerber@suse.de>
上级 fb17dfe0
...@@ -473,7 +473,7 @@ static void bus_unparent(Object *obj) ...@@ -473,7 +473,7 @@ static void bus_unparent(Object *obj)
void qbus_create_inplace(void *bus, size_t size, const char *typename, void qbus_create_inplace(void *bus, size_t size, const char *typename,
DeviceState *parent, const char *name) DeviceState *parent, const char *name)
{ {
object_initialize(bus, typename); object_initialize(bus, size, typename);
qbus_realize(bus, parent, name); qbus_realize(bus, parent, name);
} }
......
...@@ -579,8 +579,10 @@ static void xilinx_axidma_init(Object *obj) ...@@ -579,8 +579,10 @@ static void xilinx_axidma_init(Object *obj)
(Object **) &s->tx_control_dev, &errp); (Object **) &s->tx_control_dev, &errp);
assert_no_error(errp); assert_no_error(errp);
object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_DMA_DATA_STREAM); object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
object_initialize(&s->rx_control_dev, TYPE_XILINX_AXI_DMA_CONTROL_STREAM); TYPE_XILINX_AXI_DMA_DATA_STREAM);
object_initialize(&s->rx_control_dev, sizeof(s->rx_control_dev),
TYPE_XILINX_AXI_DMA_CONTROL_STREAM);
object_property_add_child(OBJECT(s), "axistream-connected-target", object_property_add_child(OBJECT(s), "axistream-connected-target",
(Object *)&s->rx_data_dev, &errp); (Object *)&s->rx_data_dev, &errp);
assert_no_error(errp); assert_no_error(errp);
......
...@@ -650,7 +650,7 @@ static void xics_realize(DeviceState *dev, Error **errp) ...@@ -650,7 +650,7 @@ static void xics_realize(DeviceState *dev, Error **errp)
icp->ss = g_malloc0(icp->nr_servers*sizeof(ICPState)); icp->ss = g_malloc0(icp->nr_servers*sizeof(ICPState));
for (i = 0; i < icp->nr_servers; i++) { for (i = 0; i < icp->nr_servers; i++) {
char buffer[32]; char buffer[32];
object_initialize(&icp->ss[i], TYPE_ICP); object_initialize(&icp->ss[i], sizeof(icp->ss[i]), TYPE_ICP);
snprintf(buffer, sizeof(buffer), "icp[%d]", i); snprintf(buffer, sizeof(buffer), "icp[%d]", i);
object_property_add_child(OBJECT(icp), buffer, OBJECT(&icp->ss[i]), NULL); object_property_add_child(OBJECT(icp), buffer, OBJECT(&icp->ss[i]), NULL);
qdev_init_nofail(DEVICE(&icp->ss[i])); qdev_init_nofail(DEVICE(&icp->ss[i]));
......
...@@ -202,11 +202,12 @@ static int macio_oldworld_initfn(PCIDevice *d) ...@@ -202,11 +202,12 @@ static int macio_oldworld_initfn(PCIDevice *d)
return 0; return 0;
} }
static void macio_init_ide(MacIOState *s, MACIOIDEState *ide, int index) static void macio_init_ide(MacIOState *s, MACIOIDEState *ide, size_t ide_size,
int index)
{ {
gchar *name; gchar *name;
object_initialize(ide, TYPE_MACIO_IDE); object_initialize(ide, ide_size, TYPE_MACIO_IDE);
qdev_set_parent_bus(DEVICE(ide), sysbus_get_default()); qdev_set_parent_bus(DEVICE(ide), sysbus_get_default());
memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) * 0x1000), memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) * 0x1000),
&ide->mem); &ide->mem);
...@@ -224,13 +225,13 @@ static void macio_oldworld_init(Object *obj) ...@@ -224,13 +225,13 @@ static void macio_oldworld_init(Object *obj)
qdev_init_gpio_out(DEVICE(obj), os->irqs, ARRAY_SIZE(os->irqs)); qdev_init_gpio_out(DEVICE(obj), os->irqs, ARRAY_SIZE(os->irqs));
object_initialize(&os->nvram, TYPE_MACIO_NVRAM); object_initialize(&os->nvram, sizeof(os->nvram), TYPE_MACIO_NVRAM);
dev = DEVICE(&os->nvram); dev = DEVICE(&os->nvram);
qdev_prop_set_uint32(dev, "size", 0x2000); qdev_prop_set_uint32(dev, "size", 0x2000);
qdev_prop_set_uint32(dev, "it_shift", 4); qdev_prop_set_uint32(dev, "it_shift", 4);
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
macio_init_ide(s, &os->ide[i], i); macio_init_ide(s, &os->ide[i], sizeof(os->ide[i]), i);
} }
} }
...@@ -310,7 +311,7 @@ static void macio_newworld_init(Object *obj) ...@@ -310,7 +311,7 @@ static void macio_newworld_init(Object *obj)
qdev_init_gpio_out(DEVICE(obj), ns->irqs, ARRAY_SIZE(ns->irqs)); qdev_init_gpio_out(DEVICE(obj), ns->irqs, ARRAY_SIZE(ns->irqs));
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
macio_init_ide(s, &ns->ide[i], i); macio_init_ide(s, &ns->ide[i], sizeof(ns->ide[i]), i);
} }
} }
...@@ -321,7 +322,7 @@ static void macio_instance_init(Object *obj) ...@@ -321,7 +322,7 @@ static void macio_instance_init(Object *obj)
memory_region_init(&s->bar, NULL, "macio", 0x80000); memory_region_init(&s->bar, NULL, "macio", 0x80000);
object_initialize(&s->cuda, TYPE_CUDA); object_initialize(&s->cuda, sizeof(s->cuda), TYPE_CUDA);
qdev_set_parent_bus(DEVICE(&s->cuda), sysbus_get_default()); qdev_set_parent_bus(DEVICE(&s->cuda), sysbus_get_default());
object_property_add_child(obj, "cuda", OBJECT(&s->cuda), NULL); object_property_add_child(obj, "cuda", OBJECT(&s->cuda), NULL);
......
...@@ -990,8 +990,10 @@ static void xilinx_enet_init(Object *obj) ...@@ -990,8 +990,10 @@ static void xilinx_enet_init(Object *obj)
(Object **) &s->tx_control_dev, &errp); (Object **) &s->tx_control_dev, &errp);
assert_no_error(errp); assert_no_error(errp);
object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_ENET_DATA_STREAM); object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
object_initialize(&s->rx_control_dev, TYPE_XILINX_AXI_ENET_CONTROL_STREAM); TYPE_XILINX_AXI_ENET_DATA_STREAM);
object_initialize(&s->rx_control_dev, sizeof(s->rx_control_dev),
TYPE_XILINX_AXI_ENET_CONTROL_STREAM);
object_property_add_child(OBJECT(s), "axistream-connected-target", object_property_add_child(OBJECT(s), "axistream-connected-target",
(Object *)&s->rx_data_dev, &errp); (Object *)&s->rx_data_dev, &errp);
assert_no_error(errp); assert_no_error(errp);
......
...@@ -159,7 +159,7 @@ static void raven_pcihost_initfn(Object *obj) ...@@ -159,7 +159,7 @@ static void raven_pcihost_initfn(Object *obj)
address_space_mem, address_space_io, 0, TYPE_PCI_BUS); address_space_mem, address_space_io, 0, TYPE_PCI_BUS);
h->bus = &s->pci_bus; h->bus = &s->pci_bus;
object_initialize(&s->pci_dev, TYPE_RAVEN_PCI_DEVICE); object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_RAVEN_PCI_DEVICE);
pci_dev = DEVICE(&s->pci_dev); pci_dev = DEVICE(&s->pci_dev);
qdev_set_parent_bus(pci_dev, BUS(&s->pci_bus)); qdev_set_parent_bus(pci_dev, BUS(&s->pci_bus));
object_property_set_int(OBJECT(&s->pci_dev), PCI_DEVFN(0, 0), "addr", object_property_set_int(OBJECT(&s->pci_dev), PCI_DEVFN(0, 0), "addr",
......
...@@ -133,7 +133,7 @@ static void q35_host_initfn(Object *obj) ...@@ -133,7 +133,7 @@ static void q35_host_initfn(Object *obj)
memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb, memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb,
"pci-conf-data", 4); "pci-conf-data", 4);
object_initialize(&s->mch, TYPE_MCH_PCI_DEVICE); object_initialize(&s->mch, sizeof(s->mch), TYPE_MCH_PCI_DEVICE);
object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL); object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL);
qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false); qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
......
...@@ -389,7 +389,7 @@ static void pci_vpb_init(Object *obj) ...@@ -389,7 +389,7 @@ static void pci_vpb_init(Object *obj)
PCI_DEVFN(11, 0), TYPE_PCI_BUS); PCI_DEVFN(11, 0), TYPE_PCI_BUS);
h->bus = &s->pci_bus; h->bus = &s->pci_bus;
object_initialize(&s->pci_dev, TYPE_VERSATILE_PCI_HOST); object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_VERSATILE_PCI_HOST);
qdev_set_parent_bus(DEVICE(&s->pci_dev), BUS(&s->pci_bus)); qdev_set_parent_bus(DEVICE(&s->pci_dev), BUS(&s->pci_bus));
/* Window sizes for VersatilePB; realview_pci's init will override */ /* Window sizes for VersatilePB; realview_pci's init will override */
......
...@@ -171,7 +171,7 @@ static int s390_virtio_net_init(VirtIOS390Device *s390_dev) ...@@ -171,7 +171,7 @@ static int s390_virtio_net_init(VirtIOS390Device *s390_dev)
static void s390_virtio_net_instance_init(Object *obj) static void s390_virtio_net_instance_init(Object *obj)
{ {
VirtIONetS390 *dev = VIRTIO_NET_S390(obj); VirtIONetS390 *dev = VIRTIO_NET_S390(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_NET); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -190,7 +190,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *s390_dev) ...@@ -190,7 +190,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
static void s390_virtio_blk_instance_init(Object *obj) static void s390_virtio_blk_instance_init(Object *obj)
{ {
VirtIOBlkS390 *dev = VIRTIO_BLK_S390(obj); VirtIOBlkS390 *dev = VIRTIO_BLK_S390(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_BLK); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BLK);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -231,7 +231,7 @@ static int s390_virtio_serial_init(VirtIOS390Device *s390_dev) ...@@ -231,7 +231,7 @@ static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
static void s390_virtio_serial_instance_init(Object *obj) static void s390_virtio_serial_instance_init(Object *obj)
{ {
VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(obj); VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_SERIAL); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SERIAL);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -263,7 +263,7 @@ static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev) ...@@ -263,7 +263,7 @@ static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
static void s390_virtio_scsi_instance_init(Object *obj) static void s390_virtio_scsi_instance_init(Object *obj)
{ {
VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(obj); VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_SCSI); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -284,7 +284,7 @@ static int s390_vhost_scsi_init(VirtIOS390Device *s390_dev) ...@@ -284,7 +284,7 @@ static int s390_vhost_scsi_init(VirtIOS390Device *s390_dev)
static void s390_vhost_scsi_instance_init(Object *obj) static void s390_vhost_scsi_instance_init(Object *obj)
{ {
VHostSCSIS390 *dev = VHOST_SCSI_S390(obj); VHostSCSIS390 *dev = VHOST_SCSI_S390(obj);
object_initialize(&dev->vdev, TYPE_VHOST_SCSI); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
#endif #endif
...@@ -310,7 +310,7 @@ static int s390_virtio_rng_init(VirtIOS390Device *s390_dev) ...@@ -310,7 +310,7 @@ static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)
static void s390_virtio_rng_instance_init(Object *obj) static void s390_virtio_rng_instance_init(Object *obj)
{ {
VirtIORNGS390 *dev = VIRTIO_RNG_S390(obj); VirtIORNGS390 *dev = VIRTIO_RNG_S390(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_RNG); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL); (Object **)&dev->vdev.conf.rng, NULL);
......
...@@ -660,7 +660,7 @@ static int virtio_ccw_net_init(VirtioCcwDevice *ccw_dev) ...@@ -660,7 +660,7 @@ static int virtio_ccw_net_init(VirtioCcwDevice *ccw_dev)
static void virtio_ccw_net_instance_init(Object *obj) static void virtio_ccw_net_instance_init(Object *obj)
{ {
VirtIONetCcw *dev = VIRTIO_NET_CCW(obj); VirtIONetCcw *dev = VIRTIO_NET_CCW(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_NET); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -680,7 +680,7 @@ static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev) ...@@ -680,7 +680,7 @@ static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
static void virtio_ccw_blk_instance_init(Object *obj) static void virtio_ccw_blk_instance_init(Object *obj)
{ {
VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj); VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_BLK); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BLK);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -713,7 +713,7 @@ static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev) ...@@ -713,7 +713,7 @@ static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev)
static void virtio_ccw_serial_instance_init(Object *obj) static void virtio_ccw_serial_instance_init(Object *obj)
{ {
VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(obj); VirtioSerialCcw *dev = VIRTIO_SERIAL_CCW(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_SERIAL); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SERIAL);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -759,7 +759,7 @@ static void balloon_ccw_stats_set_poll_interval(Object *obj, struct Visitor *v, ...@@ -759,7 +759,7 @@ static void balloon_ccw_stats_set_poll_interval(Object *obj, struct Visitor *v,
static void virtio_ccw_balloon_instance_init(Object *obj) static void virtio_ccw_balloon_instance_init(Object *obj)
{ {
VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(obj); VirtIOBalloonCcw *dev = VIRTIO_BALLOON_CCW(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_BALLOON); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BALLOON);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
object_property_add(obj, "guest-stats", "guest statistics", object_property_add(obj, "guest-stats", "guest statistics",
...@@ -799,7 +799,7 @@ static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev) ...@@ -799,7 +799,7 @@ static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
static void virtio_ccw_scsi_instance_init(Object *obj) static void virtio_ccw_scsi_instance_init(Object *obj)
{ {
VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj); VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_SCSI); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -820,7 +820,7 @@ static int vhost_ccw_scsi_init(VirtioCcwDevice *ccw_dev) ...@@ -820,7 +820,7 @@ static int vhost_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
static void vhost_ccw_scsi_instance_init(Object *obj) static void vhost_ccw_scsi_instance_init(Object *obj)
{ {
VHostSCSICcw *dev = VHOST_SCSI_CCW(obj); VHostSCSICcw *dev = VHOST_SCSI_CCW(obj);
object_initialize(&dev->vdev, TYPE_VHOST_SCSI); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
#endif #endif
...@@ -1171,7 +1171,7 @@ static const TypeInfo vhost_ccw_scsi = { ...@@ -1171,7 +1171,7 @@ static const TypeInfo vhost_ccw_scsi = {
static void virtio_ccw_rng_instance_init(Object *obj) static void virtio_ccw_rng_instance_init(Object *obj)
{ {
VirtIORNGCcw *dev = VIRTIO_RNG_CCW(obj); VirtIORNGCcw *dev = VIRTIO_RNG_CCW(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_RNG); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL); (Object **)&dev->vdev.conf.rng, NULL);
......
...@@ -919,7 +919,7 @@ static void virtio_9p_pci_class_init(ObjectClass *klass, void *data) ...@@ -919,7 +919,7 @@ static void virtio_9p_pci_class_init(ObjectClass *klass, void *data)
static void virtio_9p_pci_instance_init(Object *obj) static void virtio_9p_pci_instance_init(Object *obj)
{ {
V9fsPCIState *dev = VIRTIO_9P_PCI(obj); V9fsPCIState *dev = VIRTIO_9P_PCI(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_9P); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_9P);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -1079,7 +1079,7 @@ static void virtio_blk_pci_class_init(ObjectClass *klass, void *data) ...@@ -1079,7 +1079,7 @@ static void virtio_blk_pci_class_init(ObjectClass *klass, void *data)
static void virtio_blk_pci_instance_init(Object *obj) static void virtio_blk_pci_instance_init(Object *obj)
{ {
VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(obj); VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_BLK); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BLK);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -1149,7 +1149,7 @@ static void virtio_scsi_pci_class_init(ObjectClass *klass, void *data) ...@@ -1149,7 +1149,7 @@ static void virtio_scsi_pci_class_init(ObjectClass *klass, void *data)
static void virtio_scsi_pci_instance_init(Object *obj) static void virtio_scsi_pci_instance_init(Object *obj)
{ {
VirtIOSCSIPCI *dev = VIRTIO_SCSI_PCI(obj); VirtIOSCSIPCI *dev = VIRTIO_SCSI_PCI(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_SCSI); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -1206,7 +1206,7 @@ static void vhost_scsi_pci_class_init(ObjectClass *klass, void *data) ...@@ -1206,7 +1206,7 @@ static void vhost_scsi_pci_class_init(ObjectClass *klass, void *data)
static void vhost_scsi_pci_instance_init(Object *obj) static void vhost_scsi_pci_instance_init(Object *obj)
{ {
VHostSCSIPCI *dev = VHOST_SCSI_PCI(obj); VHostSCSIPCI *dev = VHOST_SCSI_PCI(obj);
object_initialize(&dev->vdev, TYPE_VHOST_SCSI); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -1287,7 +1287,7 @@ static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data) ...@@ -1287,7 +1287,7 @@ static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data)
static void virtio_balloon_pci_instance_init(Object *obj) static void virtio_balloon_pci_instance_init(Object *obj)
{ {
VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj); VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_BALLOON); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BALLOON);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
object_property_add(obj, "guest-stats", "guest statistics", object_property_add(obj, "guest-stats", "guest statistics",
...@@ -1373,7 +1373,7 @@ static void virtio_serial_pci_class_init(ObjectClass *klass, void *data) ...@@ -1373,7 +1373,7 @@ static void virtio_serial_pci_class_init(ObjectClass *klass, void *data)
static void virtio_serial_pci_instance_init(Object *obj) static void virtio_serial_pci_instance_init(Object *obj)
{ {
VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(obj); VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_SERIAL); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SERIAL);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -1432,7 +1432,7 @@ static void virtio_net_pci_class_init(ObjectClass *klass, void *data) ...@@ -1432,7 +1432,7 @@ static void virtio_net_pci_class_init(ObjectClass *klass, void *data)
static void virtio_net_pci_instance_init(Object *obj) static void virtio_net_pci_instance_init(Object *obj)
{ {
VirtIONetPCI *dev = VIRTIO_NET_PCI(obj); VirtIONetPCI *dev = VIRTIO_NET_PCI(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_NET); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
} }
...@@ -1488,7 +1488,7 @@ static void virtio_rng_pci_class_init(ObjectClass *klass, void *data) ...@@ -1488,7 +1488,7 @@ static void virtio_rng_pci_class_init(ObjectClass *klass, void *data)
static void virtio_rng_initfn(Object *obj) static void virtio_rng_initfn(Object *obj)
{ {
VirtIORngPCI *dev = VIRTIO_RNG_PCI(obj); VirtIORngPCI *dev = VIRTIO_RNG_PCI(obj);
object_initialize(&dev->vdev, TYPE_VIRTIO_RNG); object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL); (Object **)&dev->vdev.conf.rng, NULL);
......
...@@ -597,13 +597,14 @@ void object_initialize_with_type(void *data, Type type); ...@@ -597,13 +597,14 @@ void object_initialize_with_type(void *data, Type type);
/** /**
* object_initialize: * object_initialize:
* @obj: A pointer to the memory to be used for the object. * @obj: A pointer to the memory to be used for the object.
* @size: The maximum size available at @obj for the object.
* @typename: The name of the type of the object to instantiate. * @typename: The name of the type of the object to instantiate.
* *
* This function will initialize an object. The memory for the object should * This function will initialize an object. The memory for the object should
* have already been allocated. The returned object has a reference count of 1, * have already been allocated. The returned object has a reference count of 1,
* and will be finalized when the last reference is dropped. * and will be finalized when the last reference is dropped.
*/ */
void object_initialize(void *obj, const char *typename); void object_initialize(void *obj, size_t size, const char *typename);
/** /**
* object_dynamic_cast: * object_dynamic_cast:
......
...@@ -329,7 +329,7 @@ void object_initialize_with_type(void *data, TypeImpl *type) ...@@ -329,7 +329,7 @@ void object_initialize_with_type(void *data, TypeImpl *type)
object_post_init_with_type(obj, type); object_post_init_with_type(obj, type);
} }
void object_initialize(void *data, const char *typename) void object_initialize(void *data, size_t size, const char *typename)
{ {
TypeImpl *type = type_get_by_name(typename); TypeImpl *type = type_get_by_name(typename);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册