* [Qemu-devel] [PATCH 01/16] qom: Fix object_initialize_with_type() argument name in documentation
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 02/16] intel-hda: Pass size to hda_codec_bus_init() Andreas Färber
` (16 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Andreas Färber, anthony
@obj -> @data.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
include/qom/object.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index 48109de..c463ced 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -585,7 +585,7 @@ Object *object_new_with_type(Type type);
/**
* object_initialize_with_type:
- * @obj: A pointer to the memory to be used for the object.
+ * @data: A pointer to the memory to be used for the object.
* @type: The type of the object to instantiate.
*
* This function will initialize an object. The memory for the object should
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 02/16] intel-hda: Pass size to hda_codec_bus_init()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 01/16] qom: Fix object_initialize_with_type() argument name in documentation Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 03/16] ipack: Pass size to ipack_bus_new_inplace() Andreas Färber
` (15 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Vassili Karpov (malc), Andreas Färber,
anthony
To be passed to qbus_create_inplace().
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/audio/intel-hda.c | 4 ++--
hw/audio/intel-hda.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 32e44ad..9c2fa88 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -40,7 +40,7 @@ static const TypeInfo hda_codec_bus_info = {
.instance_size = sizeof(HDACodecBus),
};
-void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
+void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size,
hda_codec_response_func response,
hda_codec_xfer_func xfer)
{
@@ -1142,7 +1142,7 @@ static int intel_hda_init(PCIDevice *pci)
msi_init(&d->pci, 0x50, 1, true, false);
}
- hda_codec_bus_init(DEVICE(pci), &d->codecs,
+ hda_codec_bus_init(DEVICE(pci), &d->codecs, sizeof(d->codecs),
intel_hda_response, intel_hda_xfer);
return 0;
diff --git a/hw/audio/intel-hda.h b/hw/audio/intel-hda.h
index 2544f0a..d784bcf 100644
--- a/hw/audio/intel-hda.h
+++ b/hw/audio/intel-hda.h
@@ -48,7 +48,7 @@ struct HDACodecDevice {
uint32_t cad; /* codec address */
};
-void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
+void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size,
hda_codec_response_func response,
hda_codec_xfer_func xfer);
HDACodecDevice *hda_codec_find(HDACodecBus *bus, uint32_t cad);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 03/16] ipack: Pass size to ipack_bus_new_inplace()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 01/16] qom: Fix object_initialize_with_type() argument name in documentation Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 02/16] intel-hda: Pass size to hda_codec_bus_init() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-26 7:23 ` Wenchao Xia
2013-08-24 0:00 ` [Qemu-devel] [PATCH 04/16] ide: Pass size to ide_bus_new() Andreas Färber
` (14 subsequent siblings)
17 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Andreas Färber, anthony
To be passed to qbus_create_inplace().
Simplify DEVICE() cast to avoid parent field access.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/char/ipack.c | 3 ++-
hw/char/ipack.h | 3 ++-
hw/char/tpci200.c | 2 +-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/char/ipack.c b/hw/char/ipack.c
index f890471..5fb7073 100644
--- a/hw/char/ipack.c
+++ b/hw/char/ipack.c
@@ -24,7 +24,8 @@ IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot)
return NULL;
}
-void ipack_bus_new_inplace(IPackBus *bus, DeviceState *parent,
+void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
+ DeviceState *parent,
const char *name, uint8_t n_slots,
qemu_irq_handler handler)
{
diff --git a/hw/char/ipack.h b/hw/char/ipack.h
index f2b7a12..f8dc0f2 100644
--- a/hw/char/ipack.h
+++ b/hw/char/ipack.h
@@ -72,7 +72,8 @@ extern const VMStateDescription vmstate_ipack_device;
VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
-void ipack_bus_new_inplace(IPackBus *bus, DeviceState *parent,
+void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
+ DeviceState *parent,
const char *name, uint8_t n_slots,
qemu_irq_handler handler);
diff --git a/hw/char/tpci200.c b/hw/char/tpci200.c
index d9e17b2..e04ff26 100644
--- a/hw/char/tpci200.c
+++ b/hw/char/tpci200.c
@@ -607,7 +607,7 @@ static int tpci200_initfn(PCIDevice *pci_dev)
pci_register_bar(&s->dev, 4, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->las2);
pci_register_bar(&s->dev, 5, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->las3);
- ipack_bus_new_inplace(&s->bus, DEVICE(&s->dev), NULL,
+ ipack_bus_new_inplace(&s->bus, sizeof(s->bus), DEVICE(pci_dev), NULL,
N_MODULES, tpci200_set_irq);
return 0;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 03/16] ipack: Pass size to ipack_bus_new_inplace()
2013-08-24 0:00 ` [Qemu-devel] [PATCH 03/16] ipack: Pass size to ipack_bus_new_inplace() Andreas Färber
@ 2013-08-26 7:23 ` Wenchao Xia
0 siblings, 0 replies; 32+ messages in thread
From: Wenchao Xia @ 2013-08-26 7:23 UTC (permalink / raw)
To: Andreas Färber; +Cc: peter.maydell, qemu-devel, anthony
> To be passed to qbus_create_inplace().
>
> Simplify DEVICE() cast to avoid parent field access.
s->dev will always point to pci_dev, so this change is safe.
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/char/ipack.c | 3 ++-
> hw/char/ipack.h | 3 ++-
> hw/char/tpci200.c | 2 +-
> 3 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/hw/char/ipack.c b/hw/char/ipack.c
> index f890471..5fb7073 100644
> --- a/hw/char/ipack.c
> +++ b/hw/char/ipack.c
> @@ -24,7 +24,8 @@ IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot)
> return NULL;
> }
>
> -void ipack_bus_new_inplace(IPackBus *bus, DeviceState *parent,
> +void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
> + DeviceState *parent,
> const char *name, uint8_t n_slots,
> qemu_irq_handler handler)
> {
> diff --git a/hw/char/ipack.h b/hw/char/ipack.h
> index f2b7a12..f8dc0f2 100644
> --- a/hw/char/ipack.h
> +++ b/hw/char/ipack.h
> @@ -72,7 +72,8 @@ extern const VMStateDescription vmstate_ipack_device;
> VMSTATE_STRUCT(_field, _state, 1, vmstate_ipack_device, IPackDevice)
>
> IPackDevice *ipack_device_find(IPackBus *bus, int32_t slot);
> -void ipack_bus_new_inplace(IPackBus *bus, DeviceState *parent,
> +void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
> + DeviceState *parent,
> const char *name, uint8_t n_slots,
> qemu_irq_handler handler);
>
> diff --git a/hw/char/tpci200.c b/hw/char/tpci200.c
> index d9e17b2..e04ff26 100644
> --- a/hw/char/tpci200.c
> +++ b/hw/char/tpci200.c
> @@ -607,7 +607,7 @@ static int tpci200_initfn(PCIDevice *pci_dev)
> pci_register_bar(&s->dev, 4, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->las2);
> pci_register_bar(&s->dev, 5, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->las3);
>
> - ipack_bus_new_inplace(&s->bus, DEVICE(&s->dev), NULL,
> + ipack_bus_new_inplace(&s->bus, sizeof(s->bus), DEVICE(pci_dev), NULL,
> N_MODULES, tpci200_set_irq);
>
> return 0;
>
--
Best Regards
Wenchao Xia
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 04/16] ide: Pass size to ide_bus_new()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (2 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 03/16] ipack: Pass size to ipack_bus_new_inplace() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 05/16] pci: Pass size to pci_bus_new_inplace() Andreas Färber
` (13 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, peter.maydell, Andreas Färber, anthony
To be passed to qbus_create_inplace().
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/ide/ahci.c | 2 +-
hw/ide/cmd646.c | 2 +-
hw/ide/internal.h | 3 ++-
hw/ide/isa.c | 2 +-
hw/ide/macio.c | 2 +-
hw/ide/mmio.c | 2 +-
hw/ide/piix.c | 2 +-
hw/ide/qdev.c | 3 ++-
hw/ide/via.c | 2 +-
9 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index bba150f..a71a4ca 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1175,7 +1175,7 @@ void ahci_init(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
for (i = 0; i < s->ports; i++) {
AHCIDevice *ad = &s->dev[i];
- ide_bus_new(&ad->port, qdev, i, 1);
+ ide_bus_new(&ad->port, sizeof(ad->port), qdev, i, 1);
ide_init2(&ad->port, irqs[i]);
ad->hba = s;
diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index d6ef799..0500a7a 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -289,7 +289,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
for (i = 0; i < 2; i++) {
- ide_bus_new(&d->bus[i], DEVICE(dev), i, 2);
+ ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(dev), i, 2);
ide_init2(&d->bus[i], irq[i]);
bmdma_init(&d->bus[i], &d->bmdma[i], d);
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index 048a052..5d1cf87 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -576,7 +576,8 @@ void ide_atapi_cmd(IDEState *s);
void ide_atapi_cmd_reply_end(IDEState *s);
/* hw/ide/qdev.c */
-void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id, int max_units);
+void ide_bus_new(IDEBus *idebus, size_t idebus_size, DeviceState *dev,
+ int bus_id, int max_units);
IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive);
#endif /* HW_IDE_INTERNAL_H */
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index bbc8c6b..afc24d4 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -70,7 +70,7 @@ static void isa_ide_realizefn(DeviceState *dev, Error **errp)
ISADevice *isadev = ISA_DEVICE(dev);
ISAIDEState *s = ISA_IDE(dev);
- ide_bus_new(&s->bus, dev, 0, 2);
+ ide_bus_new(&s->bus, sizeof(s->bus), dev, 0, 2);
ide_init_ioport(&s->bus, isadev, s->iobase, s->iobase2);
isa_init_irq(isadev, &s->irq, s->isairq);
ide_init2(&s->bus, s->irq);
diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index ef4ba2b..da94580 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -547,7 +547,7 @@ static void macio_ide_initfn(Object *obj)
SysBusDevice *d = SYS_BUS_DEVICE(obj);
MACIOIDEState *s = MACIO_IDE(obj);
- ide_bus_new(&s->bus, DEVICE(obj), 0, 2);
+ ide_bus_new(&s->bus, sizeof(s->bus), DEVICE(obj), 0, 2);
memory_region_init_io(&s->mem, obj, &pmac_ide_ops, s, "pmac-ide", 0x1000);
sysbus_init_mmio(d, &s->mem);
sysbus_init_irq(d, &s->irq);
diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c
index d251ff9..9f66a52 100644
--- a/hw/ide/mmio.c
+++ b/hw/ide/mmio.c
@@ -137,7 +137,7 @@ static void mmio_ide_initfn(Object *obj)
SysBusDevice *d = SYS_BUS_DEVICE(obj);
MMIOState *s = MMIO_IDE(obj);
- ide_bus_new(&s->bus, DEVICE(obj), 0, 2);
+ ide_bus_new(&s->bus, sizeof(s->bus), DEVICE(obj), 0, 2);
sysbus_init_irq(d, &s->irq);
}
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index e6e6c0b..ab36749 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -136,7 +136,7 @@ static void pci_piix_init_ports(PCIIDEState *d) {
int i;
for (i = 0; i < 2; i++) {
- ide_bus_new(&d->bus[i], DEVICE(d), i, 2);
+ ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase,
port_info[i].iobase2);
ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq));
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 1d84e15..8be76ab 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -47,7 +47,8 @@ static const TypeInfo ide_bus_info = {
.class_init = ide_bus_class_init,
};
-void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id, int max_units)
+void ide_bus_new(IDEBus *idebus, size_t idebus_size, DeviceState *dev,
+ int bus_id, int max_units)
{
qbus_create_inplace(&idebus->qbus, TYPE_IDE_BUS, dev, NULL);
idebus->bus_id = bus_id;
diff --git a/hw/ide/via.c b/hw/ide/via.c
index e5fb297..99468c7 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -159,7 +159,7 @@ static void vt82c686b_init_ports(PCIIDEState *d) {
int i;
for (i = 0; i < 2; i++) {
- ide_bus_new(&d->bus[i], DEVICE(d), i, 2);
+ ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2);
ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase,
port_info[i].iobase2);
ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq));
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 05/16] pci: Pass size to pci_bus_new_inplace()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (3 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 04/16] ide: Pass size to ide_bus_new() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 06/16] scsi: Pass size to scsi_bus_new() Andreas Färber
` (12 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Michael S. Tsirkin, Andreas Färber,
open list:PReP, Paul Brook, anthony, Andreas Färber
To be passed to qbus_create_inplace().
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/pci-host/prep.c | 2 +-
hw/pci-host/versatile.c | 2 +-
hw/pci/pci.c | 2 +-
include/hw/pci/pci.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index e120058..a62236b 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -155,7 +155,7 @@ static void raven_pcihost_initfn(Object *obj)
MemoryRegion *address_space_io = get_system_io();
DeviceState *pci_dev;
- pci_bus_new_inplace(&s->pci_bus, DEVICE(obj), NULL,
+ pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), NULL,
address_space_mem, address_space_io, 0, TYPE_PCI_BUS);
h->bus = &s->pci_bus;
diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c
index 9238d39..4b9359c 100644
--- a/hw/pci-host/versatile.c
+++ b/hw/pci-host/versatile.c
@@ -384,7 +384,7 @@ static void pci_vpb_init(Object *obj)
memory_region_init(&s->pci_io_space, OBJECT(s), "pci_io", 1ULL << 32);
memory_region_init(&s->pci_mem_space, OBJECT(s), "pci_mem", 1ULL << 32);
- pci_bus_new_inplace(&s->pci_bus, DEVICE(obj), "pci",
+ pci_bus_new_inplace(&s->pci_bus, sizeof(s->pci_bus), DEVICE(obj), "pci",
&s->pci_mem_space, &s->pci_io_space,
PCI_DEVFN(11, 0), TYPE_PCI_BUS);
h->bus = &s->pci_bus;
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 4c004f5..397555c 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -312,7 +312,7 @@ bool pci_bus_is_root(PCIBus *bus)
return !bus->parent_dev;
}
-void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
+void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index ccec2ba..051b6ed 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -348,7 +348,7 @@ typedef int (*pci_hotplug_fn)(DeviceState *qdev, PCIDevice *pci_dev,
bool pci_bus_is_express(PCIBus *bus);
bool pci_bus_is_root(PCIBus *bus);
-void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
+void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
const char *name,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 06/16] scsi: Pass size to scsi_bus_new()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (4 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 05/16] pci: Pass size to pci_bus_new_inplace() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-26 8:01 ` Paolo Bonzini
2013-08-24 0:00 ` [Qemu-devel] [PATCH 07/16] usb: Pass size to usb_bus_new() Andreas Färber
` (11 subsequent siblings)
17 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Alexander Graf, open list:sPAPR, Paul Brook,
anthony, Paolo Bonzini, Andreas Färber, Gerd Hoffmann
To be passed to qbus_create_inplace().
Use DEVICE() casts instead of direct parent field access.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/scsi/esp-pci.c | 2 +-
hw/scsi/esp.c | 2 +-
hw/scsi/lsi53c895a.c | 2 +-
hw/scsi/megasas.c | 3 ++-
hw/scsi/scsi-bus.c | 4 ++--
hw/scsi/spapr_vscsi.c | 3 ++-
hw/scsi/virtio-scsi.c | 3 ++-
hw/scsi/vmw_pvscsi.c | 3 ++-
hw/usb/dev-storage.c | 6 ++++--
hw/usb/dev-uas.c | 3 ++-
include/hw/scsi/scsi.h | 4 ++--
11 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index d7ec173..99bf8ec 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -363,7 +363,7 @@ static int esp_pci_scsi_init(PCIDevice *dev)
pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->io);
s->irq = dev->irq[0];
- scsi_bus_new(&s->bus, d, &esp_pci_scsi_info, NULL);
+ scsi_bus_new(&s->bus, sizeof(s->bus), d, &esp_pci_scsi_info, NULL);
if (!d->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 101e957..2d150bf 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -688,7 +688,7 @@ static void sysbus_esp_realize(DeviceState *dev, Error **errp)
qdev_init_gpio_in(dev, sysbus_esp_gpio_demux, 2);
- scsi_bus_new(&s->bus, dev, &esp_scsi_info, NULL);
+ scsi_bus_new(&s->bus, sizeof(s->bus), dev, &esp_scsi_info, NULL);
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
error_propagate(errp, err);
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 611f2aa..0c36842 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -2117,7 +2117,7 @@ static int lsi_scsi_init(PCIDevice *dev)
pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io);
QTAILQ_INIT(&s->queue);
- scsi_bus_new(&s->bus, d, &lsi_scsi_info, NULL);
+ scsi_bus_new(&s->bus, sizeof(s->bus), d, &lsi_scsi_info, NULL);
if (!d->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index a6d5285..09b51b3 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2171,7 +2171,8 @@ static int megasas_scsi_init(PCIDevice *dev)
s->frames[i].state = s;
}
- scsi_bus_new(&s->bus, DEVICE(dev), &megasas_scsi_info, NULL);
+ scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
+ &megasas_scsi_info, NULL);
if (!d->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index fbf9173..968bf23 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -72,8 +72,8 @@ static void scsi_device_unit_attention_reported(SCSIDevice *s)
}
/* Create a scsi bus, and attach devices to it. */
-void scsi_bus_new(SCSIBus *bus, DeviceState *host, const SCSIBusInfo *info,
- const char *bus_name)
+void scsi_bus_new(SCSIBus *bus, size_t bus_size, DeviceState *host,
+ const SCSIBusInfo *info, const char *bus_name)
{
qbus_create_inplace(&bus->qbus, TYPE_SCSI_BUS, host, bus_name);
bus->busnr = next_scsi_bus++;
diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index e9090e5..b2fcd4b 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -1020,7 +1020,8 @@ static int spapr_vscsi_init(VIOsPAPRDevice *dev)
dev->crq.SendFunc = vscsi_do_crq;
- scsi_bus_new(&s->bus, &dev->qdev, &vscsi_scsi_info, NULL);
+ scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
+ &vscsi_scsi_info, NULL);
if (!dev->qdev.hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 05da56b..3bd690d 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -627,7 +627,8 @@ static int virtio_scsi_device_init(VirtIODevice *vdev)
return ret;
}
- scsi_bus_new(&s->bus, qdev, &virtio_scsi_scsi_info, vdev->bus_name);
+ scsi_bus_new(&s->bus, sizeof(s->bus), qdev,
+ &virtio_scsi_scsi_info, vdev->bus_name);
if (!qdev->hotplugged) {
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index d42b359..819d671 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -1088,7 +1088,8 @@ pvscsi_init(PCIDevice *pci_dev)
return -ENOMEM;
}
- scsi_bus_new(&s->bus, &pci_dev->qdev, &pvscsi_scsi_info, NULL);
+ scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(pci_dev),
+ &pvscsi_scsi_info, NULL);
pvscsi_reset_state(s);
return 0;
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index a8dc2fa..1d81ac2 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -618,7 +618,8 @@ static int usb_msd_initfn_storage(USBDevice *dev)
usb_desc_create_serial(dev);
usb_desc_init(dev);
- scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_storage, NULL);
+ scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
+ &usb_msd_scsi_info_storage, NULL);
scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable,
s->conf.bootindex, dev->serial,
&err);
@@ -646,7 +647,8 @@ static int usb_msd_initfn_bot(USBDevice *dev)
usb_desc_create_serial(dev);
usb_desc_init(dev);
- scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_bot, NULL);
+ scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
+ &usb_msd_scsi_info_bot, NULL);
s->bus.qbus.allow_hotplug = 0;
usb_msd_handle_reset(dev);
diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index 63ad12e..1569d6e 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -888,7 +888,8 @@ static int usb_uas_init(USBDevice *dev)
QTAILQ_INIT(&uas->requests);
uas->status_bh = qemu_bh_new(usb_uas_send_status_bh, uas);
- scsi_bus_new(&uas->bus, &uas->dev.qdev, &usb_uas_scsi_info, NULL);
+ scsi_bus_new(&uas->bus, sizeof(uas->bus), DEVICE(dev),
+ &usb_uas_scsi_info, NULL);
return 0;
}
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index 8786531..1b66510 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -152,8 +152,8 @@ struct SCSIBus {
const SCSIBusInfo *info;
};
-void scsi_bus_new(SCSIBus *bus, DeviceState *host, const SCSIBusInfo *info,
- const char *bus_name);
+void scsi_bus_new(SCSIBus *bus, size_t bus_size, DeviceState *host,
+ const SCSIBusInfo *info, const char *bus_name);
static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
{
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 06/16] scsi: Pass size to scsi_bus_new()
2013-08-24 0:00 ` [Qemu-devel] [PATCH 06/16] scsi: Pass size to scsi_bus_new() Andreas Färber
@ 2013-08-26 8:01 ` Paolo Bonzini
0 siblings, 0 replies; 32+ messages in thread
From: Paolo Bonzini @ 2013-08-26 8:01 UTC (permalink / raw)
To: Andreas Färber
Cc: peter.maydell, Alexander Graf, qemu-devel, sPAPR, Gerd Hoffmann,
anthony, Paul Brook
Il 24/08/2013 02:00, Andreas Färber ha scritto:
> To be passed to qbus_create_inplace().
>
> Use DEVICE() casts instead of direct parent field access.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/scsi/esp-pci.c | 2 +-
> hw/scsi/esp.c | 2 +-
> hw/scsi/lsi53c895a.c | 2 +-
> hw/scsi/megasas.c | 3 ++-
> hw/scsi/scsi-bus.c | 4 ++--
> hw/scsi/spapr_vscsi.c | 3 ++-
> hw/scsi/virtio-scsi.c | 3 ++-
> hw/scsi/vmw_pvscsi.c | 3 ++-
> hw/usb/dev-storage.c | 6 ++++--
> hw/usb/dev-uas.c | 3 ++-
> include/hw/scsi/scsi.h | 4 ++--
> 11 files changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
> index d7ec173..99bf8ec 100644
> --- a/hw/scsi/esp-pci.c
> +++ b/hw/scsi/esp-pci.c
> @@ -363,7 +363,7 @@ static int esp_pci_scsi_init(PCIDevice *dev)
> pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->io);
> s->irq = dev->irq[0];
>
> - scsi_bus_new(&s->bus, d, &esp_pci_scsi_info, NULL);
> + scsi_bus_new(&s->bus, sizeof(s->bus), d, &esp_pci_scsi_info, NULL);
> if (!d->hotplugged) {
> scsi_bus_legacy_handle_cmdline(&s->bus, &err);
> if (err != NULL) {
> diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
> index 101e957..2d150bf 100644
> --- a/hw/scsi/esp.c
> +++ b/hw/scsi/esp.c
> @@ -688,7 +688,7 @@ static void sysbus_esp_realize(DeviceState *dev, Error **errp)
>
> qdev_init_gpio_in(dev, sysbus_esp_gpio_demux, 2);
>
> - scsi_bus_new(&s->bus, dev, &esp_scsi_info, NULL);
> + scsi_bus_new(&s->bus, sizeof(s->bus), dev, &esp_scsi_info, NULL);
> scsi_bus_legacy_handle_cmdline(&s->bus, &err);
> if (err != NULL) {
> error_propagate(errp, err);
> diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
> index 611f2aa..0c36842 100644
> --- a/hw/scsi/lsi53c895a.c
> +++ b/hw/scsi/lsi53c895a.c
> @@ -2117,7 +2117,7 @@ static int lsi_scsi_init(PCIDevice *dev)
> pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io);
> QTAILQ_INIT(&s->queue);
>
> - scsi_bus_new(&s->bus, d, &lsi_scsi_info, NULL);
> + scsi_bus_new(&s->bus, sizeof(s->bus), d, &lsi_scsi_info, NULL);
> if (!d->hotplugged) {
> scsi_bus_legacy_handle_cmdline(&s->bus, &err);
> if (err != NULL) {
> diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> index a6d5285..09b51b3 100644
> --- a/hw/scsi/megasas.c
> +++ b/hw/scsi/megasas.c
> @@ -2171,7 +2171,8 @@ static int megasas_scsi_init(PCIDevice *dev)
> s->frames[i].state = s;
> }
>
> - scsi_bus_new(&s->bus, DEVICE(dev), &megasas_scsi_info, NULL);
> + scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
> + &megasas_scsi_info, NULL);
> if (!d->hotplugged) {
> scsi_bus_legacy_handle_cmdline(&s->bus, &err);
> if (err != NULL) {
> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
> index fbf9173..968bf23 100644
> --- a/hw/scsi/scsi-bus.c
> +++ b/hw/scsi/scsi-bus.c
> @@ -72,8 +72,8 @@ static void scsi_device_unit_attention_reported(SCSIDevice *s)
> }
>
> /* Create a scsi bus, and attach devices to it. */
> -void scsi_bus_new(SCSIBus *bus, DeviceState *host, const SCSIBusInfo *info,
> - const char *bus_name)
> +void scsi_bus_new(SCSIBus *bus, size_t bus_size, DeviceState *host,
> + const SCSIBusInfo *info, const char *bus_name)
> {
> qbus_create_inplace(&bus->qbus, TYPE_SCSI_BUS, host, bus_name);
> bus->busnr = next_scsi_bus++;
> diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
> index e9090e5..b2fcd4b 100644
> --- a/hw/scsi/spapr_vscsi.c
> +++ b/hw/scsi/spapr_vscsi.c
> @@ -1020,7 +1020,8 @@ static int spapr_vscsi_init(VIOsPAPRDevice *dev)
>
> dev->crq.SendFunc = vscsi_do_crq;
>
> - scsi_bus_new(&s->bus, &dev->qdev, &vscsi_scsi_info, NULL);
> + scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
> + &vscsi_scsi_info, NULL);
> if (!dev->qdev.hotplugged) {
> scsi_bus_legacy_handle_cmdline(&s->bus, &err);
> if (err != NULL) {
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index 05da56b..3bd690d 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -627,7 +627,8 @@ static int virtio_scsi_device_init(VirtIODevice *vdev)
> return ret;
> }
>
> - scsi_bus_new(&s->bus, qdev, &virtio_scsi_scsi_info, vdev->bus_name);
> + scsi_bus_new(&s->bus, sizeof(s->bus), qdev,
> + &virtio_scsi_scsi_info, vdev->bus_name);
>
> if (!qdev->hotplugged) {
> scsi_bus_legacy_handle_cmdline(&s->bus, &err);
> diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
> index d42b359..819d671 100644
> --- a/hw/scsi/vmw_pvscsi.c
> +++ b/hw/scsi/vmw_pvscsi.c
> @@ -1088,7 +1088,8 @@ pvscsi_init(PCIDevice *pci_dev)
> return -ENOMEM;
> }
>
> - scsi_bus_new(&s->bus, &pci_dev->qdev, &pvscsi_scsi_info, NULL);
> + scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(pci_dev),
> + &pvscsi_scsi_info, NULL);
> pvscsi_reset_state(s);
>
> return 0;
> diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
> index a8dc2fa..1d81ac2 100644
> --- a/hw/usb/dev-storage.c
> +++ b/hw/usb/dev-storage.c
> @@ -618,7 +618,8 @@ static int usb_msd_initfn_storage(USBDevice *dev)
>
> usb_desc_create_serial(dev);
> usb_desc_init(dev);
> - scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_storage, NULL);
> + scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
> + &usb_msd_scsi_info_storage, NULL);
> scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable,
> s->conf.bootindex, dev->serial,
> &err);
> @@ -646,7 +647,8 @@ static int usb_msd_initfn_bot(USBDevice *dev)
>
> usb_desc_create_serial(dev);
> usb_desc_init(dev);
> - scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info_bot, NULL);
> + scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
> + &usb_msd_scsi_info_bot, NULL);
> s->bus.qbus.allow_hotplug = 0;
> usb_msd_handle_reset(dev);
>
> diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
> index 63ad12e..1569d6e 100644
> --- a/hw/usb/dev-uas.c
> +++ b/hw/usb/dev-uas.c
> @@ -888,7 +888,8 @@ static int usb_uas_init(USBDevice *dev)
> QTAILQ_INIT(&uas->requests);
> uas->status_bh = qemu_bh_new(usb_uas_send_status_bh, uas);
>
> - scsi_bus_new(&uas->bus, &uas->dev.qdev, &usb_uas_scsi_info, NULL);
> + scsi_bus_new(&uas->bus, sizeof(uas->bus), DEVICE(dev),
> + &usb_uas_scsi_info, NULL);
>
> return 0;
> }
> diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
> index 8786531..1b66510 100644
> --- a/include/hw/scsi/scsi.h
> +++ b/include/hw/scsi/scsi.h
> @@ -152,8 +152,8 @@ struct SCSIBus {
> const SCSIBusInfo *info;
> };
>
> -void scsi_bus_new(SCSIBus *bus, DeviceState *host, const SCSIBusInfo *info,
> - const char *bus_name);
> +void scsi_bus_new(SCSIBus *bus, size_t bus_size, DeviceState *host,
> + const SCSIBusInfo *info, const char *bus_name);
>
> static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
> {
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 07/16] usb: Pass size to usb_bus_new()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (5 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 06/16] scsi: Pass size to scsi_bus_new() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 08/16] virtio-pci: Pass size to virtio_pci_bus_new() Andreas Färber
` (10 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Andreas Färber, anthony, Gerd Hoffmann
To be passed to qbus_create_inplace().
Use DEVICE() cast to avoid a direct parent field access.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/usb/bus.c | 3 ++-
hw/usb/hcd-ehci.c | 2 +-
hw/usb/hcd-musb.c | 2 +-
hw/usb/hcd-ohci.c | 2 +-
hw/usb/hcd-uhci.c | 2 +-
hw/usb/hcd-xhci.c | 2 +-
include/hw/usb.h | 3 ++-
7 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index f83d1de..6aee262 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -67,7 +67,8 @@ const VMStateDescription vmstate_usb_device = {
}
};
-void usb_bus_new(USBBus *bus, USBBusOps *ops, DeviceState *host)
+void usb_bus_new(USBBus *bus, size_t bus_size,
+ USBBusOps *ops, DeviceState *host)
{
qbus_create_inplace(&bus->qbus, TYPE_USB_BUS, host, NULL);
bus->ops = ops;
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 010a0d0..540431a 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -2520,7 +2520,7 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
return;
}
- usb_bus_new(&s->bus, &ehci_bus_ops, dev);
+ usb_bus_new(&s->bus, sizeof(s->bus), &ehci_bus_ops, dev);
for (i = 0; i < s->portnr; i++) {
usb_register_port(&s->bus, &s->ports[i], s, i, &ehci_port_ops,
USB_SPEED_MASK_HIGH);
diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c
index 7968e17..251309f 100644
--- a/hw/usb/hcd-musb.c
+++ b/hw/usb/hcd-musb.c
@@ -383,7 +383,7 @@ struct MUSBState *musb_init(DeviceState *parent_device, int gpio_base)
musb_reset(s);
- usb_bus_new(&s->bus, &musb_bus_ops, parent_device);
+ usb_bus_new(&s->bus, sizeof(s->bus), &musb_bus_ops, parent_device);
usb_register_port(&s->bus, &s->port, s, 0, &musb_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index d7836d6..c4a21bc 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1881,7 +1881,7 @@ static int usb_ohci_init(OHCIState *ohci, DeviceState *dev,
return -1;
}
} else {
- usb_bus_new(&ohci->bus, &ohci_bus_ops, dev);
+ usb_bus_new(&ohci->bus, sizeof(ohci->bus), &ohci_bus_ops, dev);
for (i = 0; i < num_ports; i++) {
usb_register_port(&ohci->bus, &ohci->rhport[i].port,
ohci, i, &ohci_port_ops,
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index ac82833..f142abc 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -1253,7 +1253,7 @@ static int usb_uhci_common_initfn(PCIDevice *dev)
return -1;
}
} else {
- usb_bus_new(&s->bus, &uhci_bus_ops, &s->dev.qdev);
+ usb_bus_new(&s->bus, sizeof(s->bus), &uhci_bus_ops, DEVICE(dev));
for (i = 0; i < NB_PORTS; i++) {
usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 58c88b8..1879cf5 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3309,7 +3309,7 @@ static void usb_xhci_init(XHCIState *xhci)
usbports = MAX(xhci->numports_2, xhci->numports_3);
xhci->numports = xhci->numports_2 + xhci->numports_3;
- usb_bus_new(&xhci->bus, &xhci_bus_ops, dev);
+ usb_bus_new(&xhci->bus, sizeof(xhci->bus), &xhci_bus_ops, dev);
for (i = 0; i < usbports; i++) {
speedmask = 0;
diff --git a/include/hw/usb.h b/include/hw/usb.h
index 901b0da..1b8acba 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -496,7 +496,8 @@ struct USBBusOps {
void (*wakeup_endpoint)(USBBus *bus, USBEndpoint *ep, unsigned int stream);
};
-void usb_bus_new(USBBus *bus, USBBusOps *ops, DeviceState *host);
+void usb_bus_new(USBBus *bus, size_t bus_size,
+ USBBusOps *ops, DeviceState *host);
USBBus *usb_bus_find(int busnr);
void usb_legacy_register(const char *typename, const char *usbdevice_name,
USBDevice *(*usbdevice_init)(USBBus *bus,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 08/16] virtio-pci: Pass size to virtio_pci_bus_new()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (6 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 07/16] usb: Pass size to usb_bus_new() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 09/16] s390-virtio-bus: Pass size to virtio_s390_bus_new() Andreas Färber
` (9 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Andreas Färber, anthony
To be passed to qbus_create_inplace().
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/virtio/virtio-pci.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 9052484..313723f 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -92,7 +92,8 @@
/* HACK for virtio to determine if it's running a big endian guest */
bool virtio_is_big_endian(void);
-static void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
+static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
+ VirtIOPCIProxy *dev);
/* virtio device */
/* DeviceState to VirtIOPCIProxy. For use off data-path. TODO: use QOM. */
@@ -986,7 +987,7 @@ static int virtio_pci_init(PCIDevice *pci_dev)
{
VirtIOPCIProxy *dev = VIRTIO_PCI(pci_dev);
VirtioPCIClass *k = VIRTIO_PCI_GET_CLASS(pci_dev);
- virtio_pci_bus_new(&dev->bus, dev);
+ virtio_pci_bus_new(&dev->bus, sizeof(dev->bus), dev);
if (k->init != NULL) {
return k->init(dev);
}
@@ -1504,7 +1505,8 @@ static const TypeInfo virtio_rng_pci_info = {
/* virtio-pci-bus */
-static void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev)
+static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
+ VirtIOPCIProxy *dev)
{
DeviceState *qdev = DEVICE(dev);
BusState *qbus;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 09/16] s390-virtio-bus: Pass size to virtio_s390_bus_new()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (7 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 08/16] virtio-pci: Pass size to virtio_pci_bus_new() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 10/16] virtio-ccw: Pass size to virtio_ccw_bus_new() Andreas Färber
` (8 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Richard Henderson, Andreas Färber, anthony,
Alexander Graf
To be passed to qbus_create_inplace().
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/s390x/s390-virtio-bus.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index e46b8c8..579adbc 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -47,7 +47,8 @@
#define VIRTIO_EXT_CODE 0x2603
-static void virtio_s390_bus_new(VirtioBusState *bus, VirtIOS390Device *dev);
+static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
+ VirtIOS390Device *dev);
static const TypeInfo s390_virtio_bus_info = {
.name = TYPE_S390_VIRTIO_BUS,
@@ -585,7 +586,7 @@ static int s390_virtio_busdev_init(DeviceState *dev)
VirtIOS390Device *_dev = (VirtIOS390Device *)dev;
VirtIOS390DeviceClass *_info = VIRTIO_S390_DEVICE_GET_CLASS(dev);
- virtio_s390_bus_new(&_dev->bus, _dev);
+ virtio_s390_bus_new(&_dev->bus, sizeof(_dev->bus), _dev);
return _info->init(_dev);
}
@@ -691,7 +692,8 @@ static const TypeInfo s390_virtio_bridge_info = {
/* virtio-s390-bus */
-static void virtio_s390_bus_new(VirtioBusState *bus, VirtIOS390Device *dev)
+static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
+ VirtIOS390Device *dev)
{
DeviceState *qdev = DEVICE(dev);
BusState *qbus;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 10/16] virtio-ccw: Pass size to virtio_ccw_bus_new()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (8 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 09/16] s390-virtio-bus: Pass size to virtio_s390_bus_new() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-26 8:00 ` Cornelia Huck
2013-08-24 0:00 ` [Qemu-devel] [PATCH 11/16] virtio-mmio: Pass size to virtio_mmio_bus_new() Andreas Färber
` (7 subsequent siblings)
17 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Alexander Graf, anthony, Cornelia Huck,
Andreas Färber, Richard Henderson
To be passed to qbus_create_inplace().
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/s390x/virtio-ccw.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index e3b207f..36cbf42 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -27,7 +27,8 @@
#include "virtio-ccw.h"
#include "trace.h"
-static void virtio_ccw_bus_new(VirtioBusState *bus, VirtioCcwDevice *dev);
+static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
+ VirtioCcwDevice *dev);
static int virtual_css_bus_reset(BusState *qbus)
{
@@ -1209,7 +1210,7 @@ static int virtio_ccw_busdev_init(DeviceState *dev)
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
- virtio_ccw_bus_new(&_dev->bus, _dev);
+ virtio_ccw_bus_new(&_dev->bus, sizeof(_dev->bus), _dev);
return _info->init(_dev);
}
@@ -1289,7 +1290,8 @@ static const TypeInfo virtual_css_bridge_info = {
/* virtio-ccw-bus */
-static void virtio_ccw_bus_new(VirtioBusState *bus, VirtioCcwDevice *dev)
+static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
+ VirtioCcwDevice *dev)
{
DeviceState *qdev = DEVICE(dev);
BusState *qbus;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 11/16] virtio-mmio: Pass size to virtio_mmio_bus_new()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (9 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 10/16] virtio-ccw: Pass size to virtio_ccw_bus_new() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace() Andreas Färber
` (6 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Andreas Färber, anthony
To be passed to qbus_create_initialize().
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/virtio/virtio-mmio.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index 4bd2953..692979e 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -89,7 +89,8 @@ typedef struct {
VirtioBusState bus;
} VirtIOMMIOProxy;
-static void virtio_mmio_bus_new(VirtioBusState *bus, VirtIOMMIOProxy *dev);
+static void virtio_mmio_bus_new(VirtioBusState *bus, size_t bus_size,
+ VirtIOMMIOProxy *dev);
static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size)
{
@@ -360,7 +361,7 @@ static void virtio_mmio_realizefn(DeviceState *d, Error **errp)
VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
SysBusDevice *sbd = SYS_BUS_DEVICE(d);
- virtio_mmio_bus_new(&proxy->bus, proxy);
+ virtio_mmio_bus_new(&proxy->bus, sizeof(proxy->bus), proxy);
sysbus_init_irq(sbd, &proxy->irq);
memory_region_init_io(&proxy->iomem, OBJECT(d), &virtio_mem_ops, proxy,
TYPE_VIRTIO_MMIO, 0x200);
@@ -385,7 +386,8 @@ static const TypeInfo virtio_mmio_info = {
/* virtio-mmio-bus. */
-static void virtio_mmio_bus_new(VirtioBusState *bus, VirtIOMMIOProxy *dev)
+static void virtio_mmio_bus_new(VirtioBusState *bus, size_t bus_size,
+ VirtIOMMIOProxy *dev)
{
DeviceState *qdev = DEVICE(dev);
BusState *qbus;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (10 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 11/16] virtio-mmio: Pass size to virtio_mmio_bus_new() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-26 7:44 ` Wenchao Xia
2013-08-26 8:03 ` Cornelia Huck
2013-08-24 0:00 ` [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize() Andreas Färber
` (5 subsequent siblings)
17 siblings, 2 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, peter.maydell, Michael S. Tsirkin,
open list:New World, Alexander Graf, Cornelia Huck,
Vassili Karpov (malc), Gerd Hoffmann, anthony, Paolo Bonzini,
Amit Shah, Igor Mammedov, Andreas Färber, Richard Henderson
To be passed to object_initialize().
Since commit 39355c3826f5d9a2eb1ce3dc9b4cdd68893769d6 the argument is
void*, so drop some superfluous (BusState *) casts or direct parent
field usages.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/audio/intel-hda.c | 2 +-
hw/char/ipack.c | 2 +-
hw/char/virtio-serial-bus.c | 4 ++--
hw/core/qdev.c | 2 +-
hw/core/sysbus.c | 4 ++--
hw/cpu/icc_bus.c | 3 ++-
hw/ide/qdev.c | 2 +-
hw/misc/macio/cuda.c | 4 ++--
hw/pci/pci.c | 2 +-
hw/pci/pci_bridge.c | 3 ++-
hw/s390x/event-facility.c | 4 ++--
hw/s390x/s390-virtio-bus.c | 4 ++--
hw/s390x/virtio-ccw.c | 4 ++--
hw/scsi/scsi-bus.c | 2 +-
hw/usb/bus.c | 2 +-
hw/usb/dev-smartcard-reader.c | 3 ++-
hw/virtio/virtio-mmio.c | 2 +-
hw/virtio/virtio-pci.c | 2 +-
include/hw/qdev-core.h | 2 +-
19 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 9c2fa88..8800dfe 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -44,7 +44,7 @@ void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size,
hda_codec_response_func response,
hda_codec_xfer_func xfer)
{
- qbus_create_inplace(&bus->qbus, TYPE_HDA_BUS, dev, NULL);
+ qbus_create_inplace(bus, bus_size, TYPE_HDA_BUS, dev, NULL);
bus->response = response;
bus->xfer = xfer;
}
diff --git a/hw/char/ipack.c b/hw/char/ipack.c
index 5fb7073..b7e45be 100644
--- a/hw/char/ipack.c
+++ b/hw/char/ipack.c
@@ -29,7 +29,7 @@ void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
const char *name, uint8_t n_slots,
qemu_irq_handler handler)
{
- qbus_create_inplace(&bus->qbus, TYPE_IPACK_BUS, parent, name);
+ qbus_create_inplace(bus, bus_size, TYPE_IPACK_BUS, parent, name);
bus->n_slots = n_slots;
bus->set_irq = handler;
}
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index da417c7..d90fc2a 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -911,8 +911,8 @@ static int virtio_serial_device_init(VirtIODevice *vdev)
sizeof(struct virtio_console_config));
/* Spawn a new virtio-serial bus on which the ports will ride as devices */
- qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, qdev,
- vdev->bus_name);
+ qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
+ qdev, vdev->bus_name);
vser->bus.qbus.allow_hotplug = 1;
vser->bus.vser = vser;
QTAILQ_INIT(&vser->ports);
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 758de9f..81874da 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -470,7 +470,7 @@ static void bus_unparent(Object *obj)
}
}
-void qbus_create_inplace(void *bus, const char *typename,
+void qbus_create_inplace(void *bus, size_t size, const char *typename,
DeviceState *parent, const char *name)
{
object_initialize(bus, typename);
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 9004d8c..b84cd4a 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -276,8 +276,8 @@ static void main_system_bus_create(void)
/* assign main_system_bus before qbus_create_inplace()
* in order to make "if (bus != sysbus_get_default())" work */
main_system_bus = g_malloc0(system_bus_info.instance_size);
- qbus_create_inplace(main_system_bus, TYPE_SYSTEM_BUS, NULL,
- "main-system-bus");
+ qbus_create_inplace(main_system_bus, system_bus_info.instance_size,
+ TYPE_SYSTEM_BUS, NULL, "main-system-bus");
OBJECT(main_system_bus)->free = g_free;
object_property_add_child(container_get(qdev_get_machine(),
"/unattached"),
diff --git a/hw/cpu/icc_bus.c b/hw/cpu/icc_bus.c
index 8748cc5..9a4ea7e 100644
--- a/hw/cpu/icc_bus.c
+++ b/hw/cpu/icc_bus.c
@@ -90,7 +90,8 @@ static void icc_bridge_init(Object *obj)
ICCBridgeState *s = ICC_BRIGDE(obj);
SysBusDevice *sb = SYS_BUS_DEVICE(obj);
- qbus_create_inplace(&s->icc_bus, TYPE_ICC_BUS, DEVICE(s), "icc");
+ qbus_create_inplace(&s->icc_bus, sizeof(s->icc_bus), TYPE_ICC_BUS,
+ DEVICE(s), "icc");
/* Do not change order of registering regions,
* APIC must be first registered region, board maps it by 0 index
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 8be76ab..18c4b7e 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -50,7 +50,7 @@ static const TypeInfo ide_bus_info = {
void ide_bus_new(IDEBus *idebus, size_t idebus_size, DeviceState *dev,
int bus_id, int max_units)
{
- qbus_create_inplace(&idebus->qbus, TYPE_IDE_BUS, dev, NULL);
+ qbus_create_inplace(idebus, idebus_size, TYPE_IDE_BUS, dev, NULL);
idebus->bus_id = bus_id;
idebus->max_units = max_units;
}
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index c0fd7da..8e41459 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -711,8 +711,8 @@ static void cuda_initfn(Object *obj)
s->timers[i].index = i;
}
- qbus_create_inplace((BusState *)&s->adb_bus, TYPE_ADB_BUS, DEVICE(obj),
- "adb.0");
+ qbus_create_inplace(&s->adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS,
+ DEVICE(obj), "adb.0");
}
static void cuda_class_init(ObjectClass *oc, void *data)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 397555c..e688f4a 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -318,7 +318,7 @@ void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
MemoryRegion *address_space_io,
uint8_t devfn_min, const char *typename)
{
- qbus_create_inplace(bus, typename, parent, name);
+ qbus_create_inplace(bus, bus_size, typename, parent, name);
pci_bus_init(bus, parent, name, address_space_mem,
address_space_io, devfn_min);
}
diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
index a90671d..e6b22b8 100644
--- a/hw/pci/pci_bridge.c
+++ b/hw/pci/pci_bridge.c
@@ -367,7 +367,8 @@ int pci_bridge_initfn(PCIDevice *dev, const char *typename)
br->bus_name = dev->qdev.id;
}
- qbus_create_inplace(&sec_bus->qbus, typename, &dev->qdev, br->bus_name);
+ qbus_create_inplace(sec_bus, sizeof(br->sec_bus), typename, DEVICE(dev),
+ br->bus_name);
sec_bus->parent_dev = dev;
sec_bus->map_irq = br->map_irq ? br->map_irq : pci_swizzle_map_irq_fn;
sec_bus->address_space_mem = &br->address_space_mem;
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 0faade0..a3aceef 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -324,8 +324,8 @@ static int init_event_facility(S390SCLPDevice *sdev)
sdev->event_pending = event_pending;
/* Spawn a new sclp-events facility */
- qbus_create_inplace(&event_facility->sbus.qbus,
- TYPE_SCLP_EVENTS_BUS, (DeviceState *)sdev, NULL);
+ qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus),
+ TYPE_SCLP_EVENTS_BUS, DEVICE(sdev), NULL);
event_facility->sbus.qbus.allow_hotplug = 0;
event_facility->qdev = (DeviceState *) sdev;
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 579adbc..e95b831 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -699,8 +699,8 @@ static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
BusState *qbus;
char virtio_bus_name[] = "virtio-bus";
- qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_S390_BUS, qdev,
- virtio_bus_name);
+ qbus_create_inplace((BusState *)bus, bus_size, TYPE_VIRTIO_S390_BUS,
+ qdev, virtio_bus_name);
qbus = BUS(bus);
qbus->allow_hotplug = 1;
}
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 36cbf42..cf7075e 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1297,8 +1297,8 @@ static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
BusState *qbus;
char virtio_bus_name[] = "virtio-bus";
- qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_CCW_BUS, qdev,
- virtio_bus_name);
+ qbus_create_inplace((BusState *)bus, bus_size, TYPE_VIRTIO_CCW_BUS,
+ qdev, virtio_bus_name);
qbus = BUS(bus);
qbus->allow_hotplug = 1;
}
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 968bf23..5cd6137 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -75,7 +75,7 @@ static void scsi_device_unit_attention_reported(SCSIDevice *s)
void scsi_bus_new(SCSIBus *bus, size_t bus_size, DeviceState *host,
const SCSIBusInfo *info, const char *bus_name)
{
- qbus_create_inplace(&bus->qbus, TYPE_SCSI_BUS, host, bus_name);
+ qbus_create_inplace(bus, bus_size, TYPE_SCSI_BUS, host, bus_name);
bus->busnr = next_scsi_bus++;
bus->info = info;
bus->qbus.allow_hotplug = 1;
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 6aee262..82ca6a1 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -70,7 +70,7 @@ const VMStateDescription vmstate_usb_device = {
void usb_bus_new(USBBus *bus, size_t bus_size,
USBBusOps *ops, DeviceState *host)
{
- qbus_create_inplace(&bus->qbus, TYPE_USB_BUS, host, NULL);
+ qbus_create_inplace(bus, bus_size, TYPE_USB_BUS, host, NULL);
bus->ops = ops;
bus->busnr = next_usb_bus++;
bus->qbus.allow_hotplug = 1; /* Yes, we can */
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 2233c54..8c7a61e 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1309,7 +1309,8 @@ static int ccid_initfn(USBDevice *dev)
usb_desc_create_serial(dev);
usb_desc_init(dev);
- qbus_create_inplace(&s->bus.qbus, TYPE_CCID_BUS, &dev->qdev, NULL);
+ qbus_create_inplace(&s->bus, sizeof(s->bus), TYPE_CCID_BUS, DEVICE(dev),
+ NULL);
s->intr = usb_ep_get(dev, USB_TOKEN_IN, CCID_INT_IN_EP);
s->bus.qbus.allow_hotplug = 1;
s->card = NULL;
diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
index 692979e..29cf284 100644
--- a/hw/virtio/virtio-mmio.c
+++ b/hw/virtio/virtio-mmio.c
@@ -392,7 +392,7 @@ static void virtio_mmio_bus_new(VirtioBusState *bus, size_t bus_size,
DeviceState *qdev = DEVICE(dev);
BusState *qbus;
- qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_MMIO_BUS, qdev, NULL);
+ qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_MMIO_BUS, qdev, NULL);
qbus = BUS(bus);
qbus->allow_hotplug = 0;
}
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 313723f..a9a1893 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1512,7 +1512,7 @@ static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
BusState *qbus;
char virtio_bus_name[] = "virtio-bus";
- qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_PCI_BUS, qdev,
+ qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_PCI_BUS, qdev,
virtio_bus_name);
qbus = BUS(bus);
qbus->allow_hotplug = 1;
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 46972f4..a62f231 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -264,7 +264,7 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id);
typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
-void qbus_create_inplace(void *bus, const char *typename,
+void qbus_create_inplace(void *bus, size_t size, const char *typename,
DeviceState *parent, const char *name);
BusState *qbus_create(const char *typename, DeviceState *parent, const char *name);
/* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace()
2013-08-24 0:00 ` [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace() Andreas Färber
@ 2013-08-26 7:44 ` Wenchao Xia
2013-08-30 17:12 ` Andreas Färber
2013-08-26 8:03 ` Cornelia Huck
1 sibling, 1 reply; 32+ messages in thread
From: Wenchao Xia @ 2013-08-26 7:44 UTC (permalink / raw)
To: Andreas Färber
Cc: Kevin Wolf, peter.maydell, Michael S. Tsirkin, Alexander Graf,
qemu-devel, Amit Shah, Igor Mammedov, New World, Gerd Hoffmann,
anthony, Paolo Bonzini, Cornelia Huck, Vassili Karpov (malc),
Richard Henderson
于 2013-8-24 8:00, Andreas Färber 写道:
> To be passed to object_initialize().
>
> Since commit 39355c3826f5d9a2eb1ce3dc9b4cdd68893769d6 the argument is
> void*, so drop some superfluous (BusState *) casts or direct parent
> field usages.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/audio/intel-hda.c | 2 +-
> hw/char/ipack.c | 2 +-
> hw/char/virtio-serial-bus.c | 4 ++--
> hw/core/qdev.c | 2 +-
> hw/core/sysbus.c | 4 ++--
> hw/cpu/icc_bus.c | 3 ++-
> hw/ide/qdev.c | 2 +-
> hw/misc/macio/cuda.c | 4 ++--
> hw/pci/pci.c | 2 +-
> hw/pci/pci_bridge.c | 3 ++-
> hw/s390x/event-facility.c | 4 ++--
> hw/s390x/s390-virtio-bus.c | 4 ++--
> hw/s390x/virtio-ccw.c | 4 ++--
> hw/scsi/scsi-bus.c | 2 +-
> hw/usb/bus.c | 2 +-
> hw/usb/dev-smartcard-reader.c | 3 ++-
> hw/virtio/virtio-mmio.c | 2 +-
> hw/virtio/virtio-pci.c | 2 +-
> include/hw/qdev-core.h | 2 +-
> 19 files changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
> index 9c2fa88..8800dfe 100644
> --- a/hw/audio/intel-hda.c
> +++ b/hw/audio/intel-hda.c
> @@ -44,7 +44,7 @@ void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus, size_t bus_size,
> hda_codec_response_func response,
> hda_codec_xfer_func xfer)
> {
> - qbus_create_inplace(&bus->qbus, TYPE_HDA_BUS, dev, NULL);
> + qbus_create_inplace(bus, bus_size, TYPE_HDA_BUS, dev, NULL);
> bus->response = response;
> bus->xfer = xfer;
> }
> diff --git a/hw/char/ipack.c b/hw/char/ipack.c
> index 5fb7073..b7e45be 100644
> --- a/hw/char/ipack.c
> +++ b/hw/char/ipack.c
> @@ -29,7 +29,7 @@ void ipack_bus_new_inplace(IPackBus *bus, size_t bus_size,
> const char *name, uint8_t n_slots,
> qemu_irq_handler handler)
> {
> - qbus_create_inplace(&bus->qbus, TYPE_IPACK_BUS, parent, name);
> + qbus_create_inplace(bus, bus_size, TYPE_IPACK_BUS, parent, name);
> bus->n_slots = n_slots;
> bus->set_irq = handler;
> }
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index da417c7..d90fc2a 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -911,8 +911,8 @@ static int virtio_serial_device_init(VirtIODevice *vdev)
> sizeof(struct virtio_console_config));
>
> /* Spawn a new virtio-serial bus on which the ports will ride as devices */
> - qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, qdev,
> - vdev->bus_name);
> + qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
> + qdev, vdev->bus_name);
> vser->bus.qbus.allow_hotplug = 1;
> vser->bus.vser = vser;
> QTAILQ_INIT(&vser->ports);
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 758de9f..81874da 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -470,7 +470,7 @@ static void bus_unparent(Object *obj)
> }
> }
>
> -void qbus_create_inplace(void *bus, const char *typename,
> +void qbus_create_inplace(void *bus, size_t size, const char *typename,
> DeviceState *parent, const char *name)
> {
> object_initialize(bus, typename);
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index 9004d8c..b84cd4a 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -276,8 +276,8 @@ static void main_system_bus_create(void)
> /* assign main_system_bus before qbus_create_inplace()
> * in order to make "if (bus != sysbus_get_default())" work */
> main_system_bus = g_malloc0(system_bus_info.instance_size);
> - qbus_create_inplace(main_system_bus, TYPE_SYSTEM_BUS, NULL,
> - "main-system-bus");
> + qbus_create_inplace(main_system_bus, system_bus_info.instance_size,
> + TYPE_SYSTEM_BUS, NULL, "main-system-bus");
> OBJECT(main_system_bus)->free = g_free;
> object_property_add_child(container_get(qdev_get_machine(),
> "/unattached"),
> diff --git a/hw/cpu/icc_bus.c b/hw/cpu/icc_bus.c
> index 8748cc5..9a4ea7e 100644
> --- a/hw/cpu/icc_bus.c
> +++ b/hw/cpu/icc_bus.c
> @@ -90,7 +90,8 @@ static void icc_bridge_init(Object *obj)
> ICCBridgeState *s = ICC_BRIGDE(obj);
> SysBusDevice *sb = SYS_BUS_DEVICE(obj);
>
> - qbus_create_inplace(&s->icc_bus, TYPE_ICC_BUS, DEVICE(s), "icc");
> + qbus_create_inplace(&s->icc_bus, sizeof(s->icc_bus), TYPE_ICC_BUS,
> + DEVICE(s), "icc");
>
> /* Do not change order of registering regions,
> * APIC must be first registered region, board maps it by 0 index
> diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
> index 8be76ab..18c4b7e 100644
> --- a/hw/ide/qdev.c
> +++ b/hw/ide/qdev.c
> @@ -50,7 +50,7 @@ static const TypeInfo ide_bus_info = {
> void ide_bus_new(IDEBus *idebus, size_t idebus_size, DeviceState *dev,
> int bus_id, int max_units)
> {
> - qbus_create_inplace(&idebus->qbus, TYPE_IDE_BUS, dev, NULL);
> + qbus_create_inplace(idebus, idebus_size, TYPE_IDE_BUS, dev, NULL);
> idebus->bus_id = bus_id;
> idebus->max_units = max_units;
> }
> diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
> index c0fd7da..8e41459 100644
> --- a/hw/misc/macio/cuda.c
> +++ b/hw/misc/macio/cuda.c
> @@ -711,8 +711,8 @@ static void cuda_initfn(Object *obj)
> s->timers[i].index = i;
> }
>
> - qbus_create_inplace((BusState *)&s->adb_bus, TYPE_ADB_BUS, DEVICE(obj),
> - "adb.0");
> + qbus_create_inplace(&s->adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS,
> + DEVICE(obj), "adb.0");
> }
>
> static void cuda_class_init(ObjectClass *oc, void *data)
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 397555c..e688f4a 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -318,7 +318,7 @@ void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
> MemoryRegion *address_space_io,
> uint8_t devfn_min, const char *typename)
> {
> - qbus_create_inplace(bus, typename, parent, name);
> + qbus_create_inplace(bus, bus_size, typename, parent, name);
> pci_bus_init(bus, parent, name, address_space_mem,
> address_space_io, devfn_min);
> }
> diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
> index a90671d..e6b22b8 100644
> --- a/hw/pci/pci_bridge.c
> +++ b/hw/pci/pci_bridge.c
> @@ -367,7 +367,8 @@ int pci_bridge_initfn(PCIDevice *dev, const char *typename)
> br->bus_name = dev->qdev.id;
> }
>
> - qbus_create_inplace(&sec_bus->qbus, typename, &dev->qdev, br->bus_name);
> + qbus_create_inplace(sec_bus, sizeof(br->sec_bus), typename, DEVICE(dev),
wouldn't
qbus_create_inplace(sec_bus, sizeof(*sec_bus), typename, DEVICE(dev),
looks more straight?
> + br->bus_name);
> sec_bus->parent_dev = dev;
> sec_bus->map_irq = br->map_irq ? br->map_irq : pci_swizzle_map_irq_fn;
> sec_bus->address_space_mem = &br->address_space_mem;
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index 0faade0..a3aceef 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -324,8 +324,8 @@ static int init_event_facility(S390SCLPDevice *sdev)
> sdev->event_pending = event_pending;
>
> /* Spawn a new sclp-events facility */
> - qbus_create_inplace(&event_facility->sbus.qbus,
> - TYPE_SCLP_EVENTS_BUS, (DeviceState *)sdev, NULL);
> + qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus),
> + TYPE_SCLP_EVENTS_BUS, DEVICE(sdev), NULL);
> event_facility->sbus.qbus.allow_hotplug = 0;
> event_facility->qdev = (DeviceState *) sdev;
>
> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
> index 579adbc..e95b831 100644
> --- a/hw/s390x/s390-virtio-bus.c
> +++ b/hw/s390x/s390-virtio-bus.c
> @@ -699,8 +699,8 @@ static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
> BusState *qbus;
> char virtio_bus_name[] = "virtio-bus";
>
> - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_S390_BUS, qdev,
> - virtio_bus_name);
> + qbus_create_inplace((BusState *)bus, bus_size, TYPE_VIRTIO_S390_BUS,
> + qdev, virtio_bus_name);
> qbus = BUS(bus);
> qbus->allow_hotplug = 1;
> }
> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> index 36cbf42..cf7075e 100644
> --- a/hw/s390x/virtio-ccw.c
> +++ b/hw/s390x/virtio-ccw.c
> @@ -1297,8 +1297,8 @@ static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
> BusState *qbus;
> char virtio_bus_name[] = "virtio-bus";
>
> - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_CCW_BUS, qdev,
> - virtio_bus_name);
> + qbus_create_inplace((BusState *)bus, bus_size, TYPE_VIRTIO_CCW_BUS,
> + qdev, virtio_bus_name);
> qbus = BUS(bus);
> qbus->allow_hotplug = 1;
> }
> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
> index 968bf23..5cd6137 100644
> --- a/hw/scsi/scsi-bus.c
> +++ b/hw/scsi/scsi-bus.c
> @@ -75,7 +75,7 @@ static void scsi_device_unit_attention_reported(SCSIDevice *s)
> void scsi_bus_new(SCSIBus *bus, size_t bus_size, DeviceState *host,
> const SCSIBusInfo *info, const char *bus_name)
> {
> - qbus_create_inplace(&bus->qbus, TYPE_SCSI_BUS, host, bus_name);
> + qbus_create_inplace(bus, bus_size, TYPE_SCSI_BUS, host, bus_name);
> bus->busnr = next_scsi_bus++;
> bus->info = info;
> bus->qbus.allow_hotplug = 1;
> diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> index 6aee262..82ca6a1 100644
> --- a/hw/usb/bus.c
> +++ b/hw/usb/bus.c
> @@ -70,7 +70,7 @@ const VMStateDescription vmstate_usb_device = {
> void usb_bus_new(USBBus *bus, size_t bus_size,
> USBBusOps *ops, DeviceState *host)
> {
> - qbus_create_inplace(&bus->qbus, TYPE_USB_BUS, host, NULL);
> + qbus_create_inplace(bus, bus_size, TYPE_USB_BUS, host, NULL);
> bus->ops = ops;
> bus->busnr = next_usb_bus++;
> bus->qbus.allow_hotplug = 1; /* Yes, we can */
> diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
> index 2233c54..8c7a61e 100644
> --- a/hw/usb/dev-smartcard-reader.c
> +++ b/hw/usb/dev-smartcard-reader.c
> @@ -1309,7 +1309,8 @@ static int ccid_initfn(USBDevice *dev)
>
> usb_desc_create_serial(dev);
> usb_desc_init(dev);
> - qbus_create_inplace(&s->bus.qbus, TYPE_CCID_BUS, &dev->qdev, NULL);
> + qbus_create_inplace(&s->bus, sizeof(s->bus), TYPE_CCID_BUS, DEVICE(dev),
> + NULL);
> s->intr = usb_ep_get(dev, USB_TOKEN_IN, CCID_INT_IN_EP);
> s->bus.qbus.allow_hotplug = 1;
> s->card = NULL;
> diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
> index 692979e..29cf284 100644
> --- a/hw/virtio/virtio-mmio.c
> +++ b/hw/virtio/virtio-mmio.c
> @@ -392,7 +392,7 @@ static void virtio_mmio_bus_new(VirtioBusState *bus, size_t bus_size,
> DeviceState *qdev = DEVICE(dev);
> BusState *qbus;
>
> - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_MMIO_BUS, qdev, NULL);
> + qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_MMIO_BUS, qdev, NULL);
> qbus = BUS(bus);
> qbus->allow_hotplug = 0;
> }
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index 313723f..a9a1893 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1512,7 +1512,7 @@ static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
> BusState *qbus;
> char virtio_bus_name[] = "virtio-bus";
>
> - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_PCI_BUS, qdev,
> + qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_PCI_BUS, qdev,
> virtio_bus_name);
> qbus = BUS(bus);
> qbus->allow_hotplug = 1;
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 46972f4..a62f231 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -264,7 +264,7 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id);
> typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
> typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
>
> -void qbus_create_inplace(void *bus, const char *typename,
> +void qbus_create_inplace(void *bus, size_t size, const char *typename,
> DeviceState *parent, const char *name);
> BusState *qbus_create(const char *typename, DeviceState *parent, const char *name);
> /* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
>
--
Best Regards
Wenchao Xia
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace()
2013-08-26 7:44 ` Wenchao Xia
@ 2013-08-30 17:12 ` Andreas Färber
0 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-30 17:12 UTC (permalink / raw)
To: Wenchao Xia
Cc: Kevin Wolf, peter.maydell, Michael S. Tsirkin,
Vassili Karpov (malc), qemu-devel, Alexander Graf, Cornelia Huck,
New World, Gerd Hoffmann, anthony, Paolo Bonzini, Amit Shah,
Igor Mammedov, Richard Henderson
Am 26.08.2013 09:44, schrieb Wenchao Xia:
> 于 2013-8-24 8:00, Andreas Färber 写道:
>> To be passed to object_initialize().
>>
>> Since commit 39355c3826f5d9a2eb1ce3dc9b4cdd68893769d6 the argument is
>> void*, so drop some superfluous (BusState *) casts or direct parent
>> field usages.
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>> hw/audio/intel-hda.c | 2 +-
>> hw/char/ipack.c | 2 +-
>> hw/char/virtio-serial-bus.c | 4 ++--
>> hw/core/qdev.c | 2 +-
>> hw/core/sysbus.c | 4 ++--
>> hw/cpu/icc_bus.c | 3 ++-
>> hw/ide/qdev.c | 2 +-
>> hw/misc/macio/cuda.c | 4 ++--
>> hw/pci/pci.c | 2 +-
>> hw/pci/pci_bridge.c | 3 ++-
>> hw/s390x/event-facility.c | 4 ++--
>> hw/s390x/s390-virtio-bus.c | 4 ++--
>> hw/s390x/virtio-ccw.c | 4 ++--
>> hw/scsi/scsi-bus.c | 2 +-
>> hw/usb/bus.c | 2 +-
>> hw/usb/dev-smartcard-reader.c | 3 ++-
>> hw/virtio/virtio-mmio.c | 2 +-
>> hw/virtio/virtio-pci.c | 2 +-
>> include/hw/qdev-core.h | 2 +-
>> 19 files changed, 28 insertions(+), 25 deletions(-)
>>
>> diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
>> index 9c2fa88..8800dfe 100644
>> --- a/hw/audio/intel-hda.c
>> +++ b/hw/audio/intel-hda.c
>> @@ -44,7 +44,7 @@ void hda_codec_bus_init(DeviceState *dev,
>> HDACodecBus *bus, size_t bus_size,
>> hda_codec_response_func response,
>> hda_codec_xfer_func xfer)
>> {
>> - qbus_create_inplace(&bus->qbus, TYPE_HDA_BUS, dev, NULL);
>> + qbus_create_inplace(bus, bus_size, TYPE_HDA_BUS, dev, NULL);
>> bus->response = response;
>> bus->xfer = xfer;
>> }
>> diff --git a/hw/char/ipack.c b/hw/char/ipack.c
>> index 5fb7073..b7e45be 100644
>> --- a/hw/char/ipack.c
>> +++ b/hw/char/ipack.c
>> @@ -29,7 +29,7 @@ void ipack_bus_new_inplace(IPackBus *bus, size_t
>> bus_size,
>> const char *name, uint8_t n_slots,
>> qemu_irq_handler handler)
>> {
>> - qbus_create_inplace(&bus->qbus, TYPE_IPACK_BUS, parent, name);
>> + qbus_create_inplace(bus, bus_size, TYPE_IPACK_BUS, parent, name);
>> bus->n_slots = n_slots;
>> bus->set_irq = handler;
>> }
>> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
>> index da417c7..d90fc2a 100644
>> --- a/hw/char/virtio-serial-bus.c
>> +++ b/hw/char/virtio-serial-bus.c
>> @@ -911,8 +911,8 @@ static int virtio_serial_device_init(VirtIODevice
>> *vdev)
>> sizeof(struct virtio_console_config));
>>
>> /* Spawn a new virtio-serial bus on which the ports will ride as
>> devices */
>> - qbus_create_inplace(&vser->bus.qbus, TYPE_VIRTIO_SERIAL_BUS, qdev,
>> - vdev->bus_name);
>> + qbus_create_inplace(&vser->bus, sizeof(vser->bus),
>> TYPE_VIRTIO_SERIAL_BUS,
>> + qdev, vdev->bus_name);
>> vser->bus.qbus.allow_hotplug = 1;
>> vser->bus.vser = vser;
>> QTAILQ_INIT(&vser->ports);
>> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
>> index 758de9f..81874da 100644
>> --- a/hw/core/qdev.c
>> +++ b/hw/core/qdev.c
>> @@ -470,7 +470,7 @@ static void bus_unparent(Object *obj)
>> }
>> }
>>
>> -void qbus_create_inplace(void *bus, const char *typename,
>> +void qbus_create_inplace(void *bus, size_t size, const char *typename,
>> DeviceState *parent, const char *name)
>> {
>> object_initialize(bus, typename);
>> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
>> index 9004d8c..b84cd4a 100644
>> --- a/hw/core/sysbus.c
>> +++ b/hw/core/sysbus.c
>> @@ -276,8 +276,8 @@ static void main_system_bus_create(void)
>> /* assign main_system_bus before qbus_create_inplace()
>> * in order to make "if (bus != sysbus_get_default())" work */
>> main_system_bus = g_malloc0(system_bus_info.instance_size);
>> - qbus_create_inplace(main_system_bus, TYPE_SYSTEM_BUS, NULL,
>> - "main-system-bus");
>> + qbus_create_inplace(main_system_bus, system_bus_info.instance_size,
>> + TYPE_SYSTEM_BUS, NULL, "main-system-bus");
>> OBJECT(main_system_bus)->free = g_free;
>> object_property_add_child(container_get(qdev_get_machine(),
>> "/unattached"),
>> diff --git a/hw/cpu/icc_bus.c b/hw/cpu/icc_bus.c
>> index 8748cc5..9a4ea7e 100644
>> --- a/hw/cpu/icc_bus.c
>> +++ b/hw/cpu/icc_bus.c
>> @@ -90,7 +90,8 @@ static void icc_bridge_init(Object *obj)
>> ICCBridgeState *s = ICC_BRIGDE(obj);
>> SysBusDevice *sb = SYS_BUS_DEVICE(obj);
>>
>> - qbus_create_inplace(&s->icc_bus, TYPE_ICC_BUS, DEVICE(s), "icc");
>> + qbus_create_inplace(&s->icc_bus, sizeof(s->icc_bus), TYPE_ICC_BUS,
>> + DEVICE(s), "icc");
>>
>> /* Do not change order of registering regions,
>> * APIC must be first registered region, board maps it by 0 index
>> diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
>> index 8be76ab..18c4b7e 100644
>> --- a/hw/ide/qdev.c
>> +++ b/hw/ide/qdev.c
>> @@ -50,7 +50,7 @@ static const TypeInfo ide_bus_info = {
>> void ide_bus_new(IDEBus *idebus, size_t idebus_size, DeviceState *dev,
>> int bus_id, int max_units)
>> {
>> - qbus_create_inplace(&idebus->qbus, TYPE_IDE_BUS, dev, NULL);
>> + qbus_create_inplace(idebus, idebus_size, TYPE_IDE_BUS, dev, NULL);
>> idebus->bus_id = bus_id;
>> idebus->max_units = max_units;
>> }
>> diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
>> index c0fd7da..8e41459 100644
>> --- a/hw/misc/macio/cuda.c
>> +++ b/hw/misc/macio/cuda.c
>> @@ -711,8 +711,8 @@ static void cuda_initfn(Object *obj)
>> s->timers[i].index = i;
>> }
>>
>> - qbus_create_inplace((BusState *)&s->adb_bus, TYPE_ADB_BUS,
>> DEVICE(obj),
>> - "adb.0");
>> + qbus_create_inplace(&s->adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS,
>> + DEVICE(obj), "adb.0");
>> }
>>
>> static void cuda_class_init(ObjectClass *oc, void *data)
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index 397555c..e688f4a 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -318,7 +318,7 @@ void pci_bus_new_inplace(PCIBus *bus, size_t
>> bus_size, DeviceState *parent,
>> MemoryRegion *address_space_io,
>> uint8_t devfn_min, const char *typename)
>> {
>> - qbus_create_inplace(bus, typename, parent, name);
>> + qbus_create_inplace(bus, bus_size, typename, parent, name);
>> pci_bus_init(bus, parent, name, address_space_mem,
>> address_space_io, devfn_min);
>> }
>> diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c
>> index a90671d..e6b22b8 100644
>> --- a/hw/pci/pci_bridge.c
>> +++ b/hw/pci/pci_bridge.c
>> @@ -367,7 +367,8 @@ int pci_bridge_initfn(PCIDevice *dev, const char
>> *typename)
>> br->bus_name = dev->qdev.id;
>> }
>>
>> - qbus_create_inplace(&sec_bus->qbus, typename, &dev->qdev,
>> br->bus_name);
>> + qbus_create_inplace(sec_bus, sizeof(br->sec_bus), typename,
>> DEVICE(dev),
>
> wouldn't
> qbus_create_inplace(sec_bus, sizeof(*sec_bus), typename, DEVICE(dev),
> looks more straight?
That would defeat part of the purpose. sec_bus is a local variable of
type PCIBus*, to which the actual pointer &br->sec_bus is assigned.
Should that one grow larger, sec_bus can still be used but we don't want
it to assert.
Regards,
Andreas
>
>> + br->bus_name);
>> sec_bus->parent_dev = dev;
>> sec_bus->map_irq = br->map_irq ? br->map_irq :
>> pci_swizzle_map_irq_fn;
>> sec_bus->address_space_mem = &br->address_space_mem;
[snip]
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace()
2013-08-24 0:00 ` [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace() Andreas Färber
2013-08-26 7:44 ` Wenchao Xia
@ 2013-08-26 8:03 ` Cornelia Huck
2013-08-30 17:05 ` Andreas Färber
1 sibling, 1 reply; 32+ messages in thread
From: Cornelia Huck @ 2013-08-26 8:03 UTC (permalink / raw)
To: Andreas Färber
Cc: Kevin Wolf, peter.maydell, Michael S. Tsirkin,
open list:New World, qemu-devel, Alexander Graf,
Vassili Karpov (malc), Gerd Hoffmann, anthony, Paolo Bonzini,
Amit Shah, Igor Mammedov, Richard Henderson
On Sat, 24 Aug 2013 02:00:32 +0200
Andreas Färber <afaerber@suse.de> wrote:
> To be passed to object_initialize().
>
> Since commit 39355c3826f5d9a2eb1ce3dc9b4cdd68893769d6 the argument is
> void*, so drop some superfluous (BusState *) casts or direct parent
> field usages.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/audio/intel-hda.c | 2 +-
> hw/char/ipack.c | 2 +-
> hw/char/virtio-serial-bus.c | 4 ++--
> hw/core/qdev.c | 2 +-
> hw/core/sysbus.c | 4 ++--
> hw/cpu/icc_bus.c | 3 ++-
> hw/ide/qdev.c | 2 +-
> hw/misc/macio/cuda.c | 4 ++--
> hw/pci/pci.c | 2 +-
> hw/pci/pci_bridge.c | 3 ++-
> hw/s390x/event-facility.c | 4 ++--
> hw/s390x/s390-virtio-bus.c | 4 ++--
> hw/s390x/virtio-ccw.c | 4 ++--
> hw/scsi/scsi-bus.c | 2 +-
> hw/usb/bus.c | 2 +-
> hw/usb/dev-smartcard-reader.c | 3 ++-
> hw/virtio/virtio-mmio.c | 2 +-
> hw/virtio/virtio-pci.c | 2 +-
> include/hw/qdev-core.h | 2 +-
> 19 files changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
> index 579adbc..e95b831 100644
> --- a/hw/s390x/s390-virtio-bus.c
> +++ b/hw/s390x/s390-virtio-bus.c
> @@ -699,8 +699,8 @@ static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
> BusState *qbus;
> char virtio_bus_name[] = "virtio-bus";
>
> - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_S390_BUS, qdev,
> - virtio_bus_name);
> + qbus_create_inplace((BusState *)bus, bus_size, TYPE_VIRTIO_S390_BUS,
> + qdev, virtio_bus_name);
> qbus = BUS(bus);
> qbus->allow_hotplug = 1;
> }
> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> index 36cbf42..cf7075e 100644
> --- a/hw/s390x/virtio-ccw.c
> +++ b/hw/s390x/virtio-ccw.c
> @@ -1297,8 +1297,8 @@ static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
> BusState *qbus;
> char virtio_bus_name[] = "virtio-bus";
>
> - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_CCW_BUS, qdev,
> - virtio_bus_name);
> + qbus_create_inplace((BusState *)bus, bus_size, TYPE_VIRTIO_CCW_BUS,
> + qdev, virtio_bus_name);
> qbus = BUS(bus);
> qbus->allow_hotplug = 1;
> }
You'll probably want to drop the superflous casts here as well :)
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace()
2013-08-26 8:03 ` Cornelia Huck
@ 2013-08-30 17:05 ` Andreas Färber
0 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-30 17:05 UTC (permalink / raw)
To: Cornelia Huck
Cc: Kevin Wolf, peter.maydell, Michael S. Tsirkin, Alexander Graf,
qemu-devel, Igor Mammedov, qemu-ppc, Gerd Hoffmann, anthony,
Paolo Bonzini, Amit Shah, Vassili Karpov (malc),
Richard Henderson
Am 26.08.2013 10:03, schrieb Cornelia Huck:
> On Sat, 24 Aug 2013 02:00:32 +0200
> Andreas Färber <afaerber@suse.de> wrote:
>
>> To be passed to object_initialize().
>>
>> Since commit 39355c3826f5d9a2eb1ce3dc9b4cdd68893769d6 the argument is
>> void*, so drop some superfluous (BusState *) casts or direct parent
>> field usages.
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>> hw/audio/intel-hda.c | 2 +-
>> hw/char/ipack.c | 2 +-
>> hw/char/virtio-serial-bus.c | 4 ++--
>> hw/core/qdev.c | 2 +-
>> hw/core/sysbus.c | 4 ++--
>> hw/cpu/icc_bus.c | 3 ++-
>> hw/ide/qdev.c | 2 +-
>> hw/misc/macio/cuda.c | 4 ++--
>> hw/pci/pci.c | 2 +-
>> hw/pci/pci_bridge.c | 3 ++-
>> hw/s390x/event-facility.c | 4 ++--
>> hw/s390x/s390-virtio-bus.c | 4 ++--
>> hw/s390x/virtio-ccw.c | 4 ++--
>> hw/scsi/scsi-bus.c | 2 +-
>> hw/usb/bus.c | 2 +-
>> hw/usb/dev-smartcard-reader.c | 3 ++-
>> hw/virtio/virtio-mmio.c | 2 +-
>> hw/virtio/virtio-pci.c | 2 +-
>> include/hw/qdev-core.h | 2 +-
>> 19 files changed, 28 insertions(+), 25 deletions(-)
>>
>
>> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
>> index 579adbc..e95b831 100644
>> --- a/hw/s390x/s390-virtio-bus.c
>> +++ b/hw/s390x/s390-virtio-bus.c
>> @@ -699,8 +699,8 @@ static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
>> BusState *qbus;
>> char virtio_bus_name[] = "virtio-bus";
>>
>> - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_S390_BUS, qdev,
>> - virtio_bus_name);
>> + qbus_create_inplace((BusState *)bus, bus_size, TYPE_VIRTIO_S390_BUS,
>> + qdev, virtio_bus_name);
>> qbus = BUS(bus);
>> qbus->allow_hotplug = 1;
>> }
>> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
>> index 36cbf42..cf7075e 100644
>> --- a/hw/s390x/virtio-ccw.c
>> +++ b/hw/s390x/virtio-ccw.c
>> @@ -1297,8 +1297,8 @@ static void virtio_ccw_bus_new(VirtioBusState *bus, size_t bus_size,
>> BusState *qbus;
>> char virtio_bus_name[] = "virtio-bus";
>>
>> - qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_CCW_BUS, qdev,
>> - virtio_bus_name);
>> + qbus_create_inplace((BusState *)bus, bus_size, TYPE_VIRTIO_CCW_BUS,
>> + qdev, virtio_bus_name);
>> qbus = BUS(bus);
>> qbus->allow_hotplug = 1;
>> }
>
> You'll probably want to drop the superflous casts here as well :)
Fixed, thanks!
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (11 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 12/16] qdev: Pass size to qbus_create_inplace() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-26 8:09 ` Cornelia Huck
2013-08-26 8:11 ` Wenchao Xia
2013-08-24 0:00 ` [Qemu-devel] [PATCH 14/16] qom: Introduce type_get_instance_size() Andreas Färber
` (4 subsequent siblings)
17 siblings, 2 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Alexander Graf, Peter Crosthwaite,
Andreas Färber, open list:sPAPR, Paul Brook, anthony,
Cornelia Huck, Edgar E. Iglesias, Andreas Färber,
Richard Henderson
This is to avoid objects initializing beyond allocated memory.
Inspired-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/core/qdev.c | 2 +-
hw/dma/xilinx_axidma.c | 6 ++++--
hw/intc/xics.c | 2 +-
hw/misc/macio/macio.c | 13 +++++++------
hw/net/xilinx_axienet.c | 6 ++++--
hw/pci-host/prep.c | 2 +-
hw/pci-host/q35.c | 2 +-
hw/pci-host/versatile.c | 2 +-
hw/s390x/s390-virtio-bus.c | 12 ++++++------
hw/s390x/virtio-ccw.c | 14 +++++++-------
hw/virtio/virtio-pci.c | 16 ++++++++--------
include/qom/object.h | 6 ++++--
qom/object.c | 9 +++++----
13 files changed, 50 insertions(+), 42 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 81874da..533f6dd 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -473,7 +473,7 @@ static void bus_unparent(Object *obj)
void qbus_create_inplace(void *bus, size_t size, const char *typename,
DeviceState *parent, const char *name)
{
- object_initialize(bus, typename);
+ object_initialize(bus, size, typename);
qbus_realize(bus, parent, name);
}
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index a48e3ba..1e6a88d 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -578,8 +578,10 @@ static void xilinx_axidma_init(Object *obj)
(Object **) &s->tx_control_dev, &errp);
assert_no_error(errp);
- object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_DMA_DATA_STREAM);
- object_initialize(&s->rx_control_dev, TYPE_XILINX_AXI_DMA_CONTROL_STREAM);
+ object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
+ 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 *)&s->rx_data_dev, &errp);
assert_no_error(errp);
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 6b3c071..b96b041 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -650,7 +650,7 @@ static void xics_realize(DeviceState *dev, Error **errp)
icp->ss = g_malloc0(icp->nr_servers*sizeof(ICPState));
for (i = 0; i < icp->nr_servers; i++) {
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);
object_property_add_child(OBJECT(icp), buffer, OBJECT(&icp->ss[i]), NULL);
qdev_init_nofail(DEVICE(&icp->ss[i]));
diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index c0d0bf7..1bee3d8 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -202,11 +202,12 @@ static int macio_oldworld_initfn(PCIDevice *d)
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;
- object_initialize(ide, TYPE_MACIO_IDE);
+ object_initialize(ide, ide_size, TYPE_MACIO_IDE);
qdev_set_parent_bus(DEVICE(ide), sysbus_get_default());
memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) * 0x1000),
&ide->mem);
@@ -224,13 +225,13 @@ static void macio_oldworld_init(Object *obj)
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);
qdev_prop_set_uint32(dev, "size", 0x2000);
qdev_prop_set_uint32(dev, "it_shift", 4);
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)
qdev_init_gpio_out(DEVICE(obj), ns->irqs, ARRAY_SIZE(ns->irqs));
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)
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());
object_property_add_child(obj, "cuda", OBJECT(&s->cuda), NULL);
diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
index f173429..3eb7715 100644
--- a/hw/net/xilinx_axienet.c
+++ b/hw/net/xilinx_axienet.c
@@ -990,8 +990,10 @@ static void xilinx_enet_init(Object *obj)
(Object **) &s->tx_control_dev, &errp);
assert_no_error(errp);
- object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_ENET_DATA_STREAM);
- object_initialize(&s->rx_control_dev, TYPE_XILINX_AXI_ENET_CONTROL_STREAM);
+ object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
+ 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 *)&s->rx_data_dev, &errp);
assert_no_error(errp);
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index a62236b..0e71fdb 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -159,7 +159,7 @@ static void raven_pcihost_initfn(Object *obj)
address_space_mem, address_space_io, 0, TYPE_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);
qdev_set_parent_bus(pci_dev, BUS(&s->pci_bus));
object_property_set_int(OBJECT(&s->pci_dev), PCI_DEVFN(0, 0), "addr",
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 12314d8..e7d9712 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -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,
"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);
qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c
index 4b9359c..6b28929 100644
--- a/hw/pci-host/versatile.c
+++ b/hw/pci-host/versatile.c
@@ -389,7 +389,7 @@ static void pci_vpb_init(Object *obj)
PCI_DEVFN(11, 0), TYPE_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));
/* Window sizes for VersatilePB; realview_pci's init will override */
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index e95b831..9cb8b91 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -171,7 +171,7 @@ static int s390_virtio_net_init(VirtIOS390Device *s390_dev)
static void s390_virtio_net_instance_init(Object *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);
}
@@ -190,7 +190,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
static void s390_virtio_blk_instance_init(Object *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);
}
@@ -231,7 +231,7 @@ static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
static void s390_virtio_serial_instance_init(Object *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);
}
@@ -263,7 +263,7 @@ static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
static void s390_virtio_scsi_instance_init(Object *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);
}
@@ -284,7 +284,7 @@ static int s390_vhost_scsi_init(VirtIOS390Device *s390_dev)
static void s390_vhost_scsi_instance_init(Object *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);
}
#endif
@@ -310,7 +310,7 @@ static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)
static void s390_virtio_rng_instance_init(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL);
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index cf7075e..ea57b3e 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -660,7 +660,7 @@ static int virtio_ccw_net_init(VirtioCcwDevice *ccw_dev)
static void virtio_ccw_net_instance_init(Object *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);
}
@@ -680,7 +680,7 @@ static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
static void virtio_ccw_blk_instance_init(Object *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);
}
@@ -713,7 +713,7 @@ static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev)
static void virtio_ccw_serial_instance_init(Object *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);
}
@@ -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)
{
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(obj, "guest-stats", "guest statistics",
@@ -799,7 +799,7 @@ static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
static void virtio_ccw_scsi_instance_init(Object *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);
}
@@ -820,7 +820,7 @@ static int vhost_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
static void vhost_ccw_scsi_instance_init(Object *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);
}
#endif
@@ -1171,7 +1171,7 @@ static const TypeInfo vhost_ccw_scsi = {
static void virtio_ccw_rng_instance_init(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL);
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index a9a1893..811adb3 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -919,7 +919,7 @@ static void virtio_9p_pci_class_init(ObjectClass *klass, void *data)
static void virtio_9p_pci_instance_init(Object *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);
}
@@ -1079,7 +1079,7 @@ static void virtio_blk_pci_class_init(ObjectClass *klass, void *data)
static void virtio_blk_pci_instance_init(Object *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);
}
@@ -1149,7 +1149,7 @@ static void virtio_scsi_pci_class_init(ObjectClass *klass, void *data)
static void virtio_scsi_pci_instance_init(Object *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);
}
@@ -1206,7 +1206,7 @@ static void vhost_scsi_pci_class_init(ObjectClass *klass, void *data)
static void vhost_scsi_pci_instance_init(Object *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);
}
@@ -1287,7 +1287,7 @@ static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data)
static void virtio_balloon_pci_instance_init(Object *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(obj, "guest-stats", "guest statistics",
@@ -1373,7 +1373,7 @@ static void virtio_serial_pci_class_init(ObjectClass *klass, void *data)
static void virtio_serial_pci_instance_init(Object *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);
}
@@ -1432,7 +1432,7 @@ static void virtio_net_pci_class_init(ObjectClass *klass, void *data)
static void virtio_net_pci_instance_init(Object *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);
}
@@ -1488,7 +1488,7 @@ static void virtio_rng_pci_class_init(ObjectClass *klass, void *data)
static void virtio_rng_initfn(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
(Object **)&dev->vdev.conf.rng, NULL);
diff --git a/include/qom/object.h b/include/qom/object.h
index c463ced..1a7b71a 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -586,24 +586,26 @@ Object *object_new_with_type(Type type);
/**
* object_initialize_with_type:
* @data: A pointer to the memory to be used for the object.
+ * @size: The maximum size available at @data for the object.
* @type: The type of the object to instantiate.
*
* 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,
* and will be finalized when the last reference is dropped.
*/
-void object_initialize_with_type(void *data, Type type);
+void object_initialize_with_type(void *data, size_t size, Type type);
/**
* object_initialize:
* @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.
*
* 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,
* 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:
diff --git a/qom/object.c b/qom/object.c
index 74fd241..e90e382 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -311,7 +311,7 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
}
}
-void object_initialize_with_type(void *data, TypeImpl *type)
+void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
{
Object *obj = data;
@@ -320,6 +320,7 @@ void object_initialize_with_type(void *data, TypeImpl *type)
g_assert(type->instance_size >= sizeof(Object));
g_assert(type->abstract == false);
+ g_assert(size >= type->instance_size);
memset(obj, 0, type->instance_size);
obj->class = type->class;
@@ -329,11 +330,11 @@ void object_initialize_with_type(void *data, TypeImpl *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);
- object_initialize_with_type(data, type);
+ object_initialize_with_type(data, size, type);
}
static inline bool object_property_is_child(ObjectProperty *prop)
@@ -424,7 +425,7 @@ Object *object_new_with_type(Type type)
type_initialize(type);
obj = g_malloc(type->instance_size);
- object_initialize_with_type(obj, type);
+ object_initialize_with_type(obj, type->instance_size, type);
obj->free = g_free;
return obj;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize()
2013-08-24 0:00 ` [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize() Andreas Färber
@ 2013-08-26 8:09 ` Cornelia Huck
2013-08-26 8:11 ` Wenchao Xia
1 sibling, 0 replies; 32+ messages in thread
From: Cornelia Huck @ 2013-08-26 8:09 UTC (permalink / raw)
To: Andreas Färber
Cc: peter.maydell, Alexander Graf, qemu-devel, Peter Crosthwaite,
Andreas Färber, open list:sPAPR, Paul Brook, anthony,
Edgar E. Iglesias, Richard Henderson
On Sat, 24 Aug 2013 02:00:33 +0200
Andreas Färber <afaerber@suse.de> wrote:
> This is to avoid objects initializing beyond allocated memory.
>
> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/core/qdev.c | 2 +-
> hw/dma/xilinx_axidma.c | 6 ++++--
> hw/intc/xics.c | 2 +-
> hw/misc/macio/macio.c | 13 +++++++------
> hw/net/xilinx_axienet.c | 6 ++++--
> hw/pci-host/prep.c | 2 +-
> hw/pci-host/q35.c | 2 +-
> hw/pci-host/versatile.c | 2 +-
> hw/s390x/s390-virtio-bus.c | 12 ++++++------
> hw/s390x/virtio-ccw.c | 14 +++++++-------
> hw/virtio/virtio-pci.c | 16 ++++++++--------
> include/qom/object.h | 6 ++++--
> qom/object.c | 9 +++++----
> 13 files changed, 50 insertions(+), 42 deletions(-)
>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> [virtio-ccw]
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize()
2013-08-24 0:00 ` [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize() Andreas Färber
2013-08-26 8:09 ` Cornelia Huck
@ 2013-08-26 8:11 ` Wenchao Xia
2013-08-30 17:14 ` Andreas Färber
1 sibling, 1 reply; 32+ messages in thread
From: Wenchao Xia @ 2013-08-26 8:11 UTC (permalink / raw)
To: Andreas Färber
Cc: peter.maydell, qemu-devel, Alexander Graf, Peter Crosthwaite,
Andreas Färber, sPAPR, Paul Brook, anthony, Cornelia Huck,
Edgar E. Iglesias, Richard Henderson
于 2013-8-24 8:00, Andreas Färber 写道:
> This is to avoid objects initializing beyond allocated memory.
>
> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/core/qdev.c | 2 +-
> hw/dma/xilinx_axidma.c | 6 ++++--
> hw/intc/xics.c | 2 +-
> hw/misc/macio/macio.c | 13 +++++++------
> hw/net/xilinx_axienet.c | 6 ++++--
> hw/pci-host/prep.c | 2 +-
> hw/pci-host/q35.c | 2 +-
> hw/pci-host/versatile.c | 2 +-
> hw/s390x/s390-virtio-bus.c | 12 ++++++------
> hw/s390x/virtio-ccw.c | 14 +++++++-------
> hw/virtio/virtio-pci.c | 16 ++++++++--------
> include/qom/object.h | 6 ++++--
> qom/object.c | 9 +++++----
> 13 files changed, 50 insertions(+), 42 deletions(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 81874da..533f6dd 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -473,7 +473,7 @@ static void bus_unparent(Object *obj)
> void qbus_create_inplace(void *bus, size_t size, const char *typename,
> DeviceState *parent, const char *name)
> {
> - object_initialize(bus, typename);
> + object_initialize(bus, size, typename);
> qbus_realize(bus, parent, name);
> }
>
> diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
> index a48e3ba..1e6a88d 100644
> --- a/hw/dma/xilinx_axidma.c
> +++ b/hw/dma/xilinx_axidma.c
> @@ -578,8 +578,10 @@ static void xilinx_axidma_init(Object *obj)
> (Object **) &s->tx_control_dev, &errp);
> assert_no_error(errp);
>
> - object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_DMA_DATA_STREAM);
> - object_initialize(&s->rx_control_dev, TYPE_XILINX_AXI_DMA_CONTROL_STREAM);
> + object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
> + 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 *)&s->rx_data_dev, &errp);
> assert_no_error(errp);
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index 6b3c071..b96b041 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -650,7 +650,7 @@ static void xics_realize(DeviceState *dev, Error **errp)
> icp->ss = g_malloc0(icp->nr_servers*sizeof(ICPState));
> for (i = 0; i < icp->nr_servers; i++) {
> 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);
> object_property_add_child(OBJECT(icp), buffer, OBJECT(&icp->ss[i]), NULL);
> qdev_init_nofail(DEVICE(&icp->ss[i]));
> diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
> index c0d0bf7..1bee3d8 100644
> --- a/hw/misc/macio/macio.c
> +++ b/hw/misc/macio/macio.c
> @@ -202,11 +202,12 @@ static int macio_oldworld_initfn(PCIDevice *d)
> 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;
>
> - object_initialize(ide, TYPE_MACIO_IDE);
> + object_initialize(ide, ide_size, TYPE_MACIO_IDE);
> qdev_set_parent_bus(DEVICE(ide), sysbus_get_default());
> memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) * 0x1000),
> &ide->mem);
> @@ -224,13 +225,13 @@ static void macio_oldworld_init(Object *obj)
>
> 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);
> qdev_prop_set_uint32(dev, "size", 0x2000);
> qdev_prop_set_uint32(dev, "it_shift", 4);
>
> 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)
> qdev_init_gpio_out(DEVICE(obj), ns->irqs, ARRAY_SIZE(ns->irqs));
>
> 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)
>
> 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());
> object_property_add_child(obj, "cuda", OBJECT(&s->cuda), NULL);
>
> diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
> index f173429..3eb7715 100644
> --- a/hw/net/xilinx_axienet.c
> +++ b/hw/net/xilinx_axienet.c
> @@ -990,8 +990,10 @@ static void xilinx_enet_init(Object *obj)
> (Object **) &s->tx_control_dev, &errp);
> assert_no_error(errp);
>
> - object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_ENET_DATA_STREAM);
> - object_initialize(&s->rx_control_dev, TYPE_XILINX_AXI_ENET_CONTROL_STREAM);
> + object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
> + 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 *)&s->rx_data_dev, &errp);
> assert_no_error(errp);
> diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
> index a62236b..0e71fdb 100644
> --- a/hw/pci-host/prep.c
> +++ b/hw/pci-host/prep.c
> @@ -159,7 +159,7 @@ static void raven_pcihost_initfn(Object *obj)
> address_space_mem, address_space_io, 0, TYPE_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);
> qdev_set_parent_bus(pci_dev, BUS(&s->pci_bus));
> object_property_set_int(OBJECT(&s->pci_dev), PCI_DEVFN(0, 0), "addr",
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index 12314d8..e7d9712 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -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,
> "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);
> qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
> qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
> diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c
> index 4b9359c..6b28929 100644
> --- a/hw/pci-host/versatile.c
> +++ b/hw/pci-host/versatile.c
> @@ -389,7 +389,7 @@ static void pci_vpb_init(Object *obj)
> PCI_DEVFN(11, 0), TYPE_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));
>
> /* Window sizes for VersatilePB; realview_pci's init will override */
> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
> index e95b831..9cb8b91 100644
> --- a/hw/s390x/s390-virtio-bus.c
> +++ b/hw/s390x/s390-virtio-bus.c
> @@ -171,7 +171,7 @@ static int s390_virtio_net_init(VirtIOS390Device *s390_dev)
> static void s390_virtio_net_instance_init(Object *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);
> }
>
> @@ -190,7 +190,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
> static void s390_virtio_blk_instance_init(Object *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);
> }
>
> @@ -231,7 +231,7 @@ static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
> static void s390_virtio_serial_instance_init(Object *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);
> }
>
> @@ -263,7 +263,7 @@ static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
> static void s390_virtio_scsi_instance_init(Object *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);
> }
>
> @@ -284,7 +284,7 @@ static int s390_vhost_scsi_init(VirtIOS390Device *s390_dev)
> static void s390_vhost_scsi_instance_init(Object *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);
> }
> #endif
> @@ -310,7 +310,7 @@ static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)
> static void s390_virtio_rng_instance_init(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
> (Object **)&dev->vdev.conf.rng, NULL);
> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> index cf7075e..ea57b3e 100644
> --- a/hw/s390x/virtio-ccw.c
> +++ b/hw/s390x/virtio-ccw.c
> @@ -660,7 +660,7 @@ static int virtio_ccw_net_init(VirtioCcwDevice *ccw_dev)
> static void virtio_ccw_net_instance_init(Object *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);
> }
>
> @@ -680,7 +680,7 @@ static int virtio_ccw_blk_init(VirtioCcwDevice *ccw_dev)
> static void virtio_ccw_blk_instance_init(Object *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);
> }
>
> @@ -713,7 +713,7 @@ static int virtio_ccw_serial_init(VirtioCcwDevice *ccw_dev)
> static void virtio_ccw_serial_instance_init(Object *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);
> }
>
> @@ -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)
> {
> 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(obj, "guest-stats", "guest statistics",
> @@ -799,7 +799,7 @@ static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
> static void virtio_ccw_scsi_instance_init(Object *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);
> }
>
> @@ -820,7 +820,7 @@ static int vhost_ccw_scsi_init(VirtioCcwDevice *ccw_dev)
> static void vhost_ccw_scsi_instance_init(Object *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);
> }
> #endif
> @@ -1171,7 +1171,7 @@ static const TypeInfo vhost_ccw_scsi = {
> static void virtio_ccw_rng_instance_init(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
> (Object **)&dev->vdev.conf.rng, NULL);
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index a9a1893..811adb3 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -919,7 +919,7 @@ static void virtio_9p_pci_class_init(ObjectClass *klass, void *data)
> static void virtio_9p_pci_instance_init(Object *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);
> }
>
> @@ -1079,7 +1079,7 @@ static void virtio_blk_pci_class_init(ObjectClass *klass, void *data)
> static void virtio_blk_pci_instance_init(Object *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);
> }
>
> @@ -1149,7 +1149,7 @@ static void virtio_scsi_pci_class_init(ObjectClass *klass, void *data)
> static void virtio_scsi_pci_instance_init(Object *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);
> }
>
> @@ -1206,7 +1206,7 @@ static void vhost_scsi_pci_class_init(ObjectClass *klass, void *data)
> static void vhost_scsi_pci_instance_init(Object *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);
> }
>
> @@ -1287,7 +1287,7 @@ static void virtio_balloon_pci_class_init(ObjectClass *klass, void *data)
> static void virtio_balloon_pci_instance_init(Object *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(obj, "guest-stats", "guest statistics",
> @@ -1373,7 +1373,7 @@ static void virtio_serial_pci_class_init(ObjectClass *klass, void *data)
> static void virtio_serial_pci_instance_init(Object *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);
> }
>
> @@ -1432,7 +1432,7 @@ static void virtio_net_pci_class_init(ObjectClass *klass, void *data)
> static void virtio_net_pci_instance_init(Object *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);
> }
>
> @@ -1488,7 +1488,7 @@ static void virtio_rng_pci_class_init(ObjectClass *klass, void *data)
> static void virtio_rng_initfn(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
> (Object **)&dev->vdev.conf.rng, NULL);
> diff --git a/include/qom/object.h b/include/qom/object.h
> index c463ced..1a7b71a 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -586,24 +586,26 @@ Object *object_new_with_type(Type type);
> /**
> * object_initialize_with_type:
> * @data: A pointer to the memory to be used for the object.
> + * @size: The maximum size available at @data for the object.
> * @type: The type of the object to instantiate.
> *
> * 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,
> * and will be finalized when the last reference is dropped.
> */
> -void object_initialize_with_type(void *data, Type type);
> +void object_initialize_with_type(void *data, size_t size, Type type);
>
> /**
> * object_initialize:
> * @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.
> *
> * 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,
> * 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:
> diff --git a/qom/object.c b/qom/object.c
> index 74fd241..e90e382 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -311,7 +311,7 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
> }
> }
>
> -void object_initialize_with_type(void *data, TypeImpl *type)
> +void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
> {
> Object *obj = data;
>
> @@ -320,6 +320,7 @@ void object_initialize_with_type(void *data, TypeImpl *type)
>
> g_assert(type->instance_size >= sizeof(Object));
> g_assert(type->abstract == false);
> + g_assert(size >= type->instance_size);
I paid some time to find this line for several times, so if it can be
splitted as a separate patch as "qom: assert object init size", it will
make review easier.
>
> memset(obj, 0, type->instance_size);
> obj->class = type->class;
> @@ -329,11 +330,11 @@ void object_initialize_with_type(void *data, TypeImpl *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);
>
> - object_initialize_with_type(data, type);
> + object_initialize_with_type(data, size, type);
> }
>
> static inline bool object_property_is_child(ObjectProperty *prop)
> @@ -424,7 +425,7 @@ Object *object_new_with_type(Type type)
> type_initialize(type);
>
> obj = g_malloc(type->instance_size);
> - object_initialize_with_type(obj, type);
> + object_initialize_with_type(obj, type->instance_size, type);
> obj->free = g_free;
>
> return obj;
>
--
Best Regards
Wenchao Xia
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize()
2013-08-26 8:11 ` Wenchao Xia
@ 2013-08-30 17:14 ` Andreas Färber
0 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-30 17:14 UTC (permalink / raw)
To: Wenchao Xia
Cc: peter.maydell, qemu-devel, Alexander Graf, Peter Crosthwaite,
qemu-ppc, anthony, Cornelia Huck, Edgar E. Iglesias,
Richard Henderson
Am 26.08.2013 10:11, schrieb Wenchao Xia:
> 于 2013-8-24 8:00, Andreas Färber 写道:
>> This is to avoid objects initializing beyond allocated memory.
>>
>> Inspired-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>> hw/core/qdev.c | 2 +-
>> hw/dma/xilinx_axidma.c | 6 ++++--
>> hw/intc/xics.c | 2 +-
>> hw/misc/macio/macio.c | 13 +++++++------
>> hw/net/xilinx_axienet.c | 6 ++++--
>> hw/pci-host/prep.c | 2 +-
>> hw/pci-host/q35.c | 2 +-
>> hw/pci-host/versatile.c | 2 +-
>> hw/s390x/s390-virtio-bus.c | 12 ++++++------
>> hw/s390x/virtio-ccw.c | 14 +++++++-------
>> hw/virtio/virtio-pci.c | 16 ++++++++--------
>> include/qom/object.h | 6 ++++--
>> qom/object.c | 9 +++++----
>> 13 files changed, 50 insertions(+), 42 deletions(-)
>>
>> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
>> index 81874da..533f6dd 100644
>> --- a/hw/core/qdev.c
>> +++ b/hw/core/qdev.c
>> @@ -473,7 +473,7 @@ static void bus_unparent(Object *obj)
>> void qbus_create_inplace(void *bus, size_t size, const char *typename,
>> DeviceState *parent, const char *name)
>> {
>> - object_initialize(bus, typename);
>> + object_initialize(bus, size, typename);
>> qbus_realize(bus, parent, name);
>> }
>>
>> diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
>> index a48e3ba..1e6a88d 100644
>> --- a/hw/dma/xilinx_axidma.c
>> +++ b/hw/dma/xilinx_axidma.c
>> @@ -578,8 +578,10 @@ static void xilinx_axidma_init(Object *obj)
>> (Object **) &s->tx_control_dev, &errp);
>> assert_no_error(errp);
>>
>> - object_initialize(&s->rx_data_dev, TYPE_XILINX_AXI_DMA_DATA_STREAM);
>> - object_initialize(&s->rx_control_dev,
>> TYPE_XILINX_AXI_DMA_CONTROL_STREAM);
>> + object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
>> + 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 *)&s->rx_data_dev, &errp);
>> assert_no_error(errp);
>> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
>> index 6b3c071..b96b041 100644
>> --- a/hw/intc/xics.c
>> +++ b/hw/intc/xics.c
>> @@ -650,7 +650,7 @@ static void xics_realize(DeviceState *dev, Error
>> **errp)
>> icp->ss = g_malloc0(icp->nr_servers*sizeof(ICPState));
>> for (i = 0; i < icp->nr_servers; i++) {
>> 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);
>> object_property_add_child(OBJECT(icp), buffer,
>> OBJECT(&icp->ss[i]), NULL);
>> qdev_init_nofail(DEVICE(&icp->ss[i]));
>> diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
>> index c0d0bf7..1bee3d8 100644
>> --- a/hw/misc/macio/macio.c
>> +++ b/hw/misc/macio/macio.c
>> @@ -202,11 +202,12 @@ static int macio_oldworld_initfn(PCIDevice *d)
>> 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;
>>
>> - object_initialize(ide, TYPE_MACIO_IDE);
>> + object_initialize(ide, ide_size, TYPE_MACIO_IDE);
>> qdev_set_parent_bus(DEVICE(ide), sysbus_get_default());
>> memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) *
>> 0x1000),
>> &ide->mem);
>> @@ -224,13 +225,13 @@ static void macio_oldworld_init(Object *obj)
>>
>> 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);
>> qdev_prop_set_uint32(dev, "size", 0x2000);
>> qdev_prop_set_uint32(dev, "it_shift", 4);
>>
>> 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)
>> qdev_init_gpio_out(DEVICE(obj), ns->irqs, ARRAY_SIZE(ns->irqs));
>>
>> 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)
>>
>> 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());
>> object_property_add_child(obj, "cuda", OBJECT(&s->cuda), NULL);
>>
>> diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c
>> index f173429..3eb7715 100644
>> --- a/hw/net/xilinx_axienet.c
>> +++ b/hw/net/xilinx_axienet.c
>> @@ -990,8 +990,10 @@ static void xilinx_enet_init(Object *obj)
>> (Object **) &s->tx_control_dev, &errp);
>> assert_no_error(errp);
>>
>> - object_initialize(&s->rx_data_dev,
>> TYPE_XILINX_AXI_ENET_DATA_STREAM);
>> - object_initialize(&s->rx_control_dev,
>> TYPE_XILINX_AXI_ENET_CONTROL_STREAM);
>> + object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev),
>> + 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 *)&s->rx_data_dev, &errp);
>> assert_no_error(errp);
>> diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
>> index a62236b..0e71fdb 100644
>> --- a/hw/pci-host/prep.c
>> +++ b/hw/pci-host/prep.c
>> @@ -159,7 +159,7 @@ static void raven_pcihost_initfn(Object *obj)
>> address_space_mem, address_space_io, 0,
>> TYPE_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);
>> qdev_set_parent_bus(pci_dev, BUS(&s->pci_bus));
>> object_property_set_int(OBJECT(&s->pci_dev), PCI_DEVFN(0, 0),
>> "addr",
>> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
>> index 12314d8..e7d9712 100644
>> --- a/hw/pci-host/q35.c
>> +++ b/hw/pci-host/q35.c
>> @@ -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,
>> "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);
>> qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
>> qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
>> diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c
>> index 4b9359c..6b28929 100644
>> --- a/hw/pci-host/versatile.c
>> +++ b/hw/pci-host/versatile.c
>> @@ -389,7 +389,7 @@ static void pci_vpb_init(Object *obj)
>> PCI_DEVFN(11, 0), TYPE_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));
>>
>> /* Window sizes for VersatilePB; realview_pci's init will
>> override */
>> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
>> index e95b831..9cb8b91 100644
>> --- a/hw/s390x/s390-virtio-bus.c
>> +++ b/hw/s390x/s390-virtio-bus.c
>> @@ -171,7 +171,7 @@ static int s390_virtio_net_init(VirtIOS390Device
>> *s390_dev)
>> static void s390_virtio_net_instance_init(Object *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);
>> }
>>
>> @@ -190,7 +190,7 @@ static int s390_virtio_blk_init(VirtIOS390Device
>> *s390_dev)
>> static void s390_virtio_blk_instance_init(Object *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);
>> }
>>
>> @@ -231,7 +231,7 @@ static int
>> s390_virtio_serial_init(VirtIOS390Device *s390_dev)
>> static void s390_virtio_serial_instance_init(Object *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);
>> }
>>
>> @@ -263,7 +263,7 @@ static int s390_virtio_scsi_init(VirtIOS390Device
>> *s390_dev)
>> static void s390_virtio_scsi_instance_init(Object *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);
>> }
>>
>> @@ -284,7 +284,7 @@ static int s390_vhost_scsi_init(VirtIOS390Device
>> *s390_dev)
>> static void s390_vhost_scsi_instance_init(Object *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);
>> }
>> #endif
>> @@ -310,7 +310,7 @@ static int s390_virtio_rng_init(VirtIOS390Device
>> *s390_dev)
>> static void s390_virtio_rng_instance_init(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
>> (Object **)&dev->vdev.conf.rng, NULL);
>> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
>> index cf7075e..ea57b3e 100644
>> --- a/hw/s390x/virtio-ccw.c
>> +++ b/hw/s390x/virtio-ccw.c
>> @@ -660,7 +660,7 @@ static int virtio_ccw_net_init(VirtioCcwDevice
>> *ccw_dev)
>> static void virtio_ccw_net_instance_init(Object *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);
>> }
>>
>> @@ -680,7 +680,7 @@ static int virtio_ccw_blk_init(VirtioCcwDevice
>> *ccw_dev)
>> static void virtio_ccw_blk_instance_init(Object *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);
>> }
>>
>> @@ -713,7 +713,7 @@ static int virtio_ccw_serial_init(VirtioCcwDevice
>> *ccw_dev)
>> static void virtio_ccw_serial_instance_init(Object *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);
>> }
>>
>> @@ -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)
>> {
>> 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(obj, "guest-stats", "guest statistics",
>> @@ -799,7 +799,7 @@ static int virtio_ccw_scsi_init(VirtioCcwDevice
>> *ccw_dev)
>> static void virtio_ccw_scsi_instance_init(Object *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);
>> }
>>
>> @@ -820,7 +820,7 @@ static int vhost_ccw_scsi_init(VirtioCcwDevice
>> *ccw_dev)
>> static void vhost_ccw_scsi_instance_init(Object *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);
>> }
>> #endif
>> @@ -1171,7 +1171,7 @@ static const TypeInfo vhost_ccw_scsi = {
>> static void virtio_ccw_rng_instance_init(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
>> (Object **)&dev->vdev.conf.rng, NULL);
>> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
>> index a9a1893..811adb3 100644
>> --- a/hw/virtio/virtio-pci.c
>> +++ b/hw/virtio/virtio-pci.c
>> @@ -919,7 +919,7 @@ static void virtio_9p_pci_class_init(ObjectClass
>> *klass, void *data)
>> static void virtio_9p_pci_instance_init(Object *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);
>> }
>>
>> @@ -1079,7 +1079,7 @@ static void
>> virtio_blk_pci_class_init(ObjectClass *klass, void *data)
>> static void virtio_blk_pci_instance_init(Object *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);
>> }
>>
>> @@ -1149,7 +1149,7 @@ static void
>> virtio_scsi_pci_class_init(ObjectClass *klass, void *data)
>> static void virtio_scsi_pci_instance_init(Object *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);
>> }
>>
>> @@ -1206,7 +1206,7 @@ static void
>> vhost_scsi_pci_class_init(ObjectClass *klass, void *data)
>> static void vhost_scsi_pci_instance_init(Object *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);
>> }
>>
>> @@ -1287,7 +1287,7 @@ static void
>> virtio_balloon_pci_class_init(ObjectClass *klass, void *data)
>> static void virtio_balloon_pci_instance_init(Object *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(obj, "guest-stats", "guest statistics",
>> @@ -1373,7 +1373,7 @@ static void
>> virtio_serial_pci_class_init(ObjectClass *klass, void *data)
>> static void virtio_serial_pci_instance_init(Object *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);
>> }
>>
>> @@ -1432,7 +1432,7 @@ static void
>> virtio_net_pci_class_init(ObjectClass *klass, void *data)
>> static void virtio_net_pci_instance_init(Object *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);
>> }
>>
>> @@ -1488,7 +1488,7 @@ static void
>> virtio_rng_pci_class_init(ObjectClass *klass, void *data)
>> static void virtio_rng_initfn(Object *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_link(obj, "rng", TYPE_RNG_BACKEND,
>> (Object **)&dev->vdev.conf.rng, NULL);
>> diff --git a/include/qom/object.h b/include/qom/object.h
>> index c463ced..1a7b71a 100644
>> --- a/include/qom/object.h
>> +++ b/include/qom/object.h
>> @@ -586,24 +586,26 @@ Object *object_new_with_type(Type type);
>> /**
>> * object_initialize_with_type:
>> * @data: A pointer to the memory to be used for the object.
>> + * @size: The maximum size available at @data for the object.
>> * @type: The type of the object to instantiate.
>> *
>> * 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,
>> * and will be finalized when the last reference is dropped.
>> */
>> -void object_initialize_with_type(void *data, Type type);
>> +void object_initialize_with_type(void *data, size_t size, Type type);
>>
>> /**
>> * object_initialize:
>> * @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.
>> *
>> * 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,
>> * 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:
>> diff --git a/qom/object.c b/qom/object.c
>> index 74fd241..e90e382 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -311,7 +311,7 @@ static void object_post_init_with_type(Object
>> *obj, TypeImpl *ti)
>> }
>> }
>>
>> -void object_initialize_with_type(void *data, TypeImpl *type)
>> +void object_initialize_with_type(void *data, size_t size, TypeImpl
>> *type)
>> {
>> Object *obj = data;
>>
>> @@ -320,6 +320,7 @@ void object_initialize_with_type(void *data,
>> TypeImpl *type)
>>
>> g_assert(type->instance_size >= sizeof(Object));
>> g_assert(type->abstract == false);
>> + g_assert(size >= type->instance_size);
> I paid some time to find this line for several times, so if it can be
> splitted as a separate patch as "qom: assert object init size", it will
> make review easier.
That's a good idea, it also allows me to properly credit Peter via
Suggested-by on the actual assertion patch. Done.
Thanks for your review!
Regards,
Andreas
>
>>
>> memset(obj, 0, type->instance_size);
>> obj->class = type->class;
>> @@ -329,11 +330,11 @@ void object_initialize_with_type(void *data,
>> TypeImpl *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);
>>
>> - object_initialize_with_type(data, type);
>> + object_initialize_with_type(data, size, type);
>> }
>>
>> static inline bool object_property_is_child(ObjectProperty *prop)
>> @@ -424,7 +425,7 @@ Object *object_new_with_type(Type type)
>> type_initialize(type);
>>
>> obj = g_malloc(type->instance_size);
>> - object_initialize_with_type(obj, type);
>> + object_initialize_with_type(obj, type->instance_size, type);
>> obj->free = g_free;
>>
>> return obj;
>>
>
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 14/16] qom: Introduce type_get_instance_size()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (12 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 13/16] qom: Pass available size to object_initialize() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-24 0:00 ` [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming Andreas Färber
` (3 subsequent siblings)
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Andreas Färber, anthony
Helper to obtain the instance_size for a type.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
include/qom/object.h | 8 ++++++++
qom/object.c | 7 +++++++
2 files changed, 15 insertions(+)
diff --git a/include/qom/object.h b/include/qom/object.h
index 1a7b71a..96b9ab4 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -659,6 +659,14 @@ const char *object_get_typename(Object *obj);
Type type_register_static(const TypeInfo *info);
/**
+ * type_get_instance_size:
+ * @typename: The name of the #Type to obtain the object size for.
+ *
+ * Returns: The instance size of an object of type @typename.
+ */
+size_t type_get_instance_size(const char *typename);
+
+/**
* type_register:
* @info: The #TypeInfo of the new type
*
diff --git a/qom/object.c b/qom/object.c
index e90e382..71322c3 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -337,6 +337,13 @@ void object_initialize(void *data, size_t size, const char *typename)
object_initialize_with_type(data, size, type);
}
+size_t type_get_instance_size(const char *typename)
+{
+ TypeImpl *type = type_get_by_name(typename);
+
+ return type->instance_size;
+}
+
static inline bool object_property_is_child(ObjectProperty *prop)
{
return strstart(prop->type, "child<", NULL);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (13 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 14/16] qom: Introduce type_get_instance_size() Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-26 7:52 ` Wenchao Xia
2013-08-24 0:00 ` [Qemu-devel] [PATCH 16/16] qdev-monitor: Avoid aborting on out-of-memory in qdev_device_add() Andreas Färber
` (2 subsequent siblings)
17 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Andreas Färber, anthony
Avoid confusion between object and object class.
Tidy DeviceClass variable while at it.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
qdev-monitor.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 410cdcb..51bfec0 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -444,8 +444,8 @@ static BusState *qbus_find(const char *path)
DeviceState *qdev_device_add(QemuOpts *opts)
{
- ObjectClass *obj;
- DeviceClass *k;
+ ObjectClass *oc;
+ DeviceClass *dc;
const char *driver, *path, *id;
DeviceState *qdev;
BusState *bus = NULL;
@@ -457,22 +457,22 @@ DeviceState *qdev_device_add(QemuOpts *opts)
}
/* find driver */
- obj = object_class_by_name(driver);
- if (!obj) {
+ oc = object_class_by_name(driver);
+ if (!oc) {
const char *typename = find_typename_by_alias(driver);
if (typename) {
driver = typename;
- obj = object_class_by_name(driver);
+ oc = object_class_by_name(driver);
}
}
- if (!obj) {
+ if (!oc) {
qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", "device type");
return NULL;
}
- k = DEVICE_CLASS(obj);
+ dc = DEVICE_CLASS(oc);
/* find bus */
path = qemu_opt_get(opts, "bus");
@@ -481,16 +481,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
if (!bus) {
return NULL;
}
- if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) {
+ if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
qerror_report(QERR_BAD_BUS_FOR_DEVICE,
driver, object_get_typename(OBJECT(bus)));
return NULL;
}
- } else if (k->bus_type != NULL) {
- bus = qbus_find_recursive(sysbus_get_default(), NULL, k->bus_type);
+ } else if (dc->bus_type != NULL) {
+ bus = qbus_find_recursive(sysbus_get_default(), NULL, dc->bus_type);
if (!bus) {
qerror_report(QERR_NO_BUS_FOR_DEVICE,
- k->bus_type, driver);
+ dc->bus_type, driver);
return NULL;
}
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming
2013-08-24 0:00 ` [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming Andreas Färber
@ 2013-08-26 7:52 ` Wenchao Xia
2013-08-30 17:19 ` Andreas Färber
0 siblings, 1 reply; 32+ messages in thread
From: Wenchao Xia @ 2013-08-26 7:52 UTC (permalink / raw)
To: Andreas Färber; +Cc: peter.maydell, qemu-devel, anthony
于 2013-8-24 8:00, Andreas Färber 写道:
> Avoid confusion between object and object class.
between object class and device class?
> Tidy DeviceClass variable while at it.
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> qdev-monitor.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 410cdcb..51bfec0 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -444,8 +444,8 @@ static BusState *qbus_find(const char *path)
>
> DeviceState *qdev_device_add(QemuOpts *opts)
> {
> - ObjectClass *obj;
> - DeviceClass *k;
> + ObjectClass *oc;
> + DeviceClass *dc;
> const char *driver, *path, *id;
> DeviceState *qdev;
> BusState *bus = NULL;
> @@ -457,22 +457,22 @@ DeviceState *qdev_device_add(QemuOpts *opts)
> }
>
> /* find driver */
> - obj = object_class_by_name(driver);
> - if (!obj) {
> + oc = object_class_by_name(driver);
> + if (!oc) {
> const char *typename = find_typename_by_alias(driver);
>
> if (typename) {
> driver = typename;
> - obj = object_class_by_name(driver);
> + oc = object_class_by_name(driver);
> }
> }
>
> - if (!obj) {
> + if (!oc) {
> qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", "device type");
> return NULL;
> }
>
> - k = DEVICE_CLASS(obj);
> + dc = DEVICE_CLASS(oc);
>
> /* find bus */
> path = qemu_opt_get(opts, "bus");
> @@ -481,16 +481,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
> if (!bus) {
> return NULL;
> }
> - if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) {
> + if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
> qerror_report(QERR_BAD_BUS_FOR_DEVICE,
> driver, object_get_typename(OBJECT(bus)));
> return NULL;
> }
> - } else if (k->bus_type != NULL) {
> - bus = qbus_find_recursive(sysbus_get_default(), NULL, k->bus_type);
> + } else if (dc->bus_type != NULL) {
> + bus = qbus_find_recursive(sysbus_get_default(), NULL, dc->bus_type);
> if (!bus) {
> qerror_report(QERR_NO_BUS_FOR_DEVICE,
> - k->bus_type, driver);
> + dc->bus_type, driver);
> return NULL;
> }
> }
>
--
Best Regards
Wenchao Xia
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming
2013-08-26 7:52 ` Wenchao Xia
@ 2013-08-30 17:19 ` Andreas Färber
2013-09-12 14:40 ` Andreas Färber
0 siblings, 1 reply; 32+ messages in thread
From: Andreas Färber @ 2013-08-30 17:19 UTC (permalink / raw)
To: Wenchao Xia; +Cc: peter.maydell, qemu-devel, anthony
Am 26.08.2013 09:52, schrieb Wenchao Xia:
> 于 2013-8-24 8:00, Andreas Färber 写道:
>> Avoid confusion between object and object class.
> between object class and device class?
No the issue is that by convention we usually use
Object *obj;
ObjectClass *oc; /* previously: klass or k */
rather than
ObjectClass *obj;
That makes the code more difficult to read.
This part of the series is not so important yet, so we can give it some
more review and thought.
Regards,
Andreas
>
>> Tidy DeviceClass variable while at it.
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>> qdev-monitor.c | 22 +++++++++++-----------
>> 1 file changed, 11 insertions(+), 11 deletions(-)
>>
>> diff --git a/qdev-monitor.c b/qdev-monitor.c
>> index 410cdcb..51bfec0 100644
>> --- a/qdev-monitor.c
>> +++ b/qdev-monitor.c
>> @@ -444,8 +444,8 @@ static BusState *qbus_find(const char *path)
>>
>> DeviceState *qdev_device_add(QemuOpts *opts)
>> {
>> - ObjectClass *obj;
>> - DeviceClass *k;
>> + ObjectClass *oc;
>> + DeviceClass *dc;
>> const char *driver, *path, *id;
>> DeviceState *qdev;
>> BusState *bus = NULL;
>> @@ -457,22 +457,22 @@ DeviceState *qdev_device_add(QemuOpts *opts)
>> }
>>
>> /* find driver */
>> - obj = object_class_by_name(driver);
>> - if (!obj) {
>> + oc = object_class_by_name(driver);
>> + if (!oc) {
>> const char *typename = find_typename_by_alias(driver);
>>
>> if (typename) {
>> driver = typename;
>> - obj = object_class_by_name(driver);
>> + oc = object_class_by_name(driver);
>> }
>> }
>>
>> - if (!obj) {
>> + if (!oc) {
>> qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver",
>> "device type");
>> return NULL;
>> }
>>
>> - k = DEVICE_CLASS(obj);
>> + dc = DEVICE_CLASS(oc);
>>
>> /* find bus */
>> path = qemu_opt_get(opts, "bus");
>> @@ -481,16 +481,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
>> if (!bus) {
>> return NULL;
>> }
>> - if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) {
>> + if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
>> qerror_report(QERR_BAD_BUS_FOR_DEVICE,
>> driver, object_get_typename(OBJECT(bus)));
>> return NULL;
>> }
>> - } else if (k->bus_type != NULL) {
>> - bus = qbus_find_recursive(sysbus_get_default(), NULL,
>> k->bus_type);
>> + } else if (dc->bus_type != NULL) {
>> + bus = qbus_find_recursive(sysbus_get_default(), NULL,
>> dc->bus_type);
>> if (!bus) {
>> qerror_report(QERR_NO_BUS_FOR_DEVICE,
>> - k->bus_type, driver);
>> + dc->bus_type, driver);
>> return NULL;
>> }
>> }
>>
>
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming
2013-08-30 17:19 ` Andreas Färber
@ 2013-09-12 14:40 ` Andreas Färber
0 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-09-12 14:40 UTC (permalink / raw)
To: Wenchao Xia; +Cc: peter.maydell, Stefan Hajnoczi, qemu-devel, anthony
Am 30.08.2013 19:19, schrieb Andreas Färber:
> Am 26.08.2013 09:52, schrieb Wenchao Xia:
>> 于 2013-8-24 8:00, Andreas Färber 写道:
>>> Avoid confusion between object and object class.
>> between object class and device class?
>
> No the issue is that by convention we usually use
>
> Object *obj;
> ObjectClass *oc; /* previously: klass or k */
>
> rather than
>
> ObjectClass *obj;
>
> That makes the code more difficult to read.
Clarified the commit message and applied to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
>
> This part of the series is not so important yet, so we can give it some
> more review and thought.
>
> Regards,
> Andreas
>
>>
>>> Tidy DeviceClass variable while at it.
>>>
>>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>>> ---
>>> qdev-monitor.c | 22 +++++++++++-----------
>>> 1 file changed, 11 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/qdev-monitor.c b/qdev-monitor.c
>>> index 410cdcb..51bfec0 100644
>>> --- a/qdev-monitor.c
>>> +++ b/qdev-monitor.c
>>> @@ -444,8 +444,8 @@ static BusState *qbus_find(const char *path)
>>>
>>> DeviceState *qdev_device_add(QemuOpts *opts)
>>> {
>>> - ObjectClass *obj;
>>> - DeviceClass *k;
>>> + ObjectClass *oc;
>>> + DeviceClass *dc;
>>> const char *driver, *path, *id;
>>> DeviceState *qdev;
>>> BusState *bus = NULL;
>>> @@ -457,22 +457,22 @@ DeviceState *qdev_device_add(QemuOpts *opts)
>>> }
>>>
>>> /* find driver */
>>> - obj = object_class_by_name(driver);
>>> - if (!obj) {
>>> + oc = object_class_by_name(driver);
>>> + if (!oc) {
>>> const char *typename = find_typename_by_alias(driver);
>>>
>>> if (typename) {
>>> driver = typename;
>>> - obj = object_class_by_name(driver);
>>> + oc = object_class_by_name(driver);
>>> }
>>> }
>>>
>>> - if (!obj) {
>>> + if (!oc) {
>>> qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver",
>>> "device type");
>>> return NULL;
>>> }
>>>
>>> - k = DEVICE_CLASS(obj);
>>> + dc = DEVICE_CLASS(oc);
>>>
>>> /* find bus */
>>> path = qemu_opt_get(opts, "bus");
>>> @@ -481,16 +481,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
>>> if (!bus) {
>>> return NULL;
>>> }
>>> - if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) {
>>> + if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
>>> qerror_report(QERR_BAD_BUS_FOR_DEVICE,
>>> driver, object_get_typename(OBJECT(bus)));
>>> return NULL;
>>> }
>>> - } else if (k->bus_type != NULL) {
>>> - bus = qbus_find_recursive(sysbus_get_default(), NULL,
>>> k->bus_type);
>>> + } else if (dc->bus_type != NULL) {
>>> + bus = qbus_find_recursive(sysbus_get_default(), NULL,
>>> dc->bus_type);
>>> if (!bus) {
>>> qerror_report(QERR_NO_BUS_FOR_DEVICE,
>>> - k->bus_type, driver);
>>> + dc->bus_type, driver);
>>> return NULL;
>>> }
>>> }
>>>
>>
>>
>
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread
* [Qemu-devel] [PATCH 16/16] qdev-monitor: Avoid aborting on out-of-memory in qdev_device_add()
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (14 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 15/16] qdev-monitor: Clean up qdev_device_add() variable naming Andreas Färber
@ 2013-08-24 0:00 ` Andreas Färber
2013-08-26 8:12 ` [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Wenchao Xia
2013-08-30 19:37 ` Andreas Färber
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-24 0:00 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Andreas Färber, anthony
Use g_try_malloc0() and object_initialize() instead of object_new() to
try letting large hot-add attempts fail without killing a running guest.
This requires obtaining the allocation size with type_get_instance_size().
Aborts can still occur whenever devices use object_new() to create child
devices rather than using object_initialize() on embedded structs. When
allocating dynamic properties fails, chances are there's not enough
memory left to emit Errors either.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
qdev-monitor.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 51bfec0..c5f504f 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -447,6 +447,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
ObjectClass *oc;
DeviceClass *dc;
const char *driver, *path, *id;
+ size_t size;
DeviceState *qdev;
BusState *bus = NULL;
@@ -500,7 +501,12 @@ DeviceState *qdev_device_add(QemuOpts *opts)
}
/* create device, set properties */
- qdev = DEVICE(object_new(driver));
+ size = type_get_instance_size(driver);
+ qdev = g_try_malloc0(size);
+ if (qdev == NULL) {
+ return NULL;
+ }
+ object_initialize(qdev, size, driver);
if (bus) {
qdev_set_parent_bus(qdev, bus);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (15 preceding siblings ...)
2013-08-24 0:00 ` [Qemu-devel] [PATCH 16/16] qdev-monitor: Avoid aborting on out-of-memory in qdev_device_add() Andreas Färber
@ 2013-08-26 8:12 ` Wenchao Xia
2013-08-30 19:37 ` Andreas Färber
17 siblings, 0 replies; 32+ messages in thread
From: Wenchao Xia @ 2013-08-26 8:12 UTC (permalink / raw)
To: Andreas Färber; +Cc: peter.maydell, qemu-devel, anthony
I have not looked deep into QOM, so only reviewed the code in this
series, and have some minor comments for patch 12, 13, and 15. For
other part,
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> Hello,
>
> Peter remarked that object_initialize() on a GICState struct field would not
> check whether the TypeInfo::instance_size for its typename argument exceeds
> the length of the field we're initializing. This series therefore updates
> all callers to explicitly pass the size available for the object.
>
> While we don't have that many object_initialize() users yet, quite a few
> devices are using qbus_create_inplace() or bus-specific functions based on it.
> Still I consider this the safest solution in pushing the responsability for
> supplying the length to the caller and thereby checking not only field type
> lengths but also allocation lengths.
>
> The series goes on to showcase an object_initialize() usage where we don't
> know the instance_size in advance and need a QOM API to obtain it.
>
> Based on Peter's OBJECT() elimination patch, which I have queued on qom-next.
> This series conflicts with my *mpcore, virtio and ipack series among others.
>
> Regards,
> Andreas
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Anthony Liguori <anthony@codemonkey.ws>
>
> Andreas Färber (16):
> qom: Fix object_initialize_with_type() argument name in documentation
> intel-hda: Pass size to hda_codec_bus_init()
> ipack: Pass size to ipack_bus_new_inplace()
> ide: Pass size to ide_bus_new()
> pci: Pass size to pci_bus_new_inplace()
> scsi: Pass size to scsi_bus_new()
> usb: Pass size to usb_bus_new()
> virtio-pci: Pass size to virtio_pci_bus_new()
> s390-virtio-bus: Pass size to virtio_s390_bus_new()
> virtio-ccw: Pass size to virtio_ccw_bus_new()
> virtio-mmio: Pass size to virtio_mmio_bus_new()
> qdev: Pass size to qbus_create_inplace()
> qom: Pass available size to object_initialize()
> qom: Introduce type_get_instance_size()
> qdev-monitor: Clean up qdev_device_add() variable naming
> qdev-monitor: Avoid aborting on out-of-memory in qdev_device_add()
>
> hw/audio/intel-hda.c | 6 +++---
> hw/audio/intel-hda.h | 2 +-
> hw/char/ipack.c | 5 +++--
> hw/char/ipack.h | 3 ++-
> hw/char/tpci200.c | 2 +-
> hw/char/virtio-serial-bus.c | 4 ++--
> hw/core/qdev.c | 4 ++--
> hw/core/sysbus.c | 4 ++--
> hw/cpu/icc_bus.c | 3 ++-
> hw/dma/xilinx_axidma.c | 6 ++++--
> hw/ide/ahci.c | 2 +-
> hw/ide/cmd646.c | 2 +-
> hw/ide/internal.h | 3 ++-
> hw/ide/isa.c | 2 +-
> hw/ide/macio.c | 2 +-
> hw/ide/mmio.c | 2 +-
> hw/ide/piix.c | 2 +-
> hw/ide/qdev.c | 5 +++--
> hw/ide/via.c | 2 +-
> hw/intc/xics.c | 2 +-
> hw/misc/macio/cuda.c | 4 ++--
> hw/misc/macio/macio.c | 13 +++++++------
> hw/net/xilinx_axienet.c | 6 ++++--
> hw/pci-host/prep.c | 4 ++--
> hw/pci-host/q35.c | 2 +-
> hw/pci-host/versatile.c | 4 ++--
> hw/pci/pci.c | 4 ++--
> hw/pci/pci_bridge.c | 3 ++-
> hw/s390x/event-facility.c | 4 ++--
> hw/s390x/s390-virtio-bus.c | 24 +++++++++++++-----------
> hw/s390x/virtio-ccw.c | 26 ++++++++++++++------------
> hw/scsi/esp-pci.c | 2 +-
> hw/scsi/esp.c | 2 +-
> hw/scsi/lsi53c895a.c | 2 +-
> hw/scsi/megasas.c | 3 ++-
> hw/scsi/scsi-bus.c | 6 +++---
> hw/scsi/spapr_vscsi.c | 3 ++-
> hw/scsi/virtio-scsi.c | 3 ++-
> hw/scsi/vmw_pvscsi.c | 3 ++-
> hw/usb/bus.c | 5 +++--
> hw/usb/dev-smartcard-reader.c | 3 ++-
> hw/usb/dev-storage.c | 6 ++++--
> hw/usb/dev-uas.c | 3 ++-
> hw/usb/hcd-ehci.c | 2 +-
> hw/usb/hcd-musb.c | 2 +-
> hw/usb/hcd-ohci.c | 2 +-
> hw/usb/hcd-uhci.c | 2 +-
> hw/usb/hcd-xhci.c | 2 +-
> hw/virtio/virtio-mmio.c | 10 ++++++----
> hw/virtio/virtio-pci.c | 26 ++++++++++++++------------
> include/hw/pci/pci.h | 2 +-
> include/hw/qdev-core.h | 2 +-
> include/hw/scsi/scsi.h | 4 ++--
> include/hw/usb.h | 3 ++-
> include/qom/object.h | 16 +++++++++++++---
> qdev-monitor.c | 30 ++++++++++++++++++------------
> qom/object.c | 16 ++++++++++++----
> 57 files changed, 185 insertions(+), 132 deletions(-)
>
--
Best Regards
Wenchao Xia
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size
2013-08-24 0:00 [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Andreas Färber
` (16 preceding siblings ...)
2013-08-26 8:12 ` [Qemu-devel] [PATCH 00/16] qom: Assert sufficient object instance size Wenchao Xia
@ 2013-08-30 19:37 ` Andreas Färber
17 siblings, 0 replies; 32+ messages in thread
From: Andreas Färber @ 2013-08-30 19:37 UTC (permalink / raw)
To: qemu-devel
Cc: Cornelia Huck, peter.maydell, Wenchao Xia, anthony, Paolo Bonzini
Am 24.08.2013 02:00, schrieb Andreas Färber:
> Andreas Färber (16):
> qom: Fix object_initialize_with_type() argument name in documentation
> intel-hda: Pass size to hda_codec_bus_init()
> ipack: Pass size to ipack_bus_new_inplace()
> ide: Pass size to ide_bus_new()
> pci: Pass size to pci_bus_new_inplace()
> scsi: Pass size to scsi_bus_new()
> usb: Pass size to usb_bus_new()
> virtio-pci: Pass size to virtio_pci_bus_new()
> s390-virtio-bus: Pass size to virtio_s390_bus_new()
> virtio-ccw: Pass size to virtio_ccw_bus_new()
> virtio-mmio: Pass size to virtio_mmio_bus_new()
> qdev: Pass size to qbus_create_inplace()
> qom: Pass available size to object_initialize()
Applied these to qom-next with the requested changes - dropping two more
(BusState *) casts and splitting the final patch in two.
https://github.com/afaerber/qemu-cpu/commits/qom-next
> qom: Introduce type_get_instance_size()
> qdev-monitor: Clean up qdev_device_add() variable naming
> qdev-monitor: Avoid aborting on out-of-memory in qdev_device_add()
This part only piggy-backed upon the modified object_initialize() but is
otherwise unrelated and not urgent, so waiting for review on the new QOM
API from Anthony and others.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 32+ messages in thread