Re: [Qemu-devel] [PATCH 11/14] qbus: move get_fw_dev_path to DeviceClass
Il 02/05/2012 00:36, Andreas Färber ha scritto: Sorry, I reviewed the patches in mail reception order. ;) I meant 08/14 (qdev: convert busses to QEMU object model) where macros for other bus types were introduced. Seemed like an oversight. A lot of these were missing, and furthermore they should be in a header file. Paolo
[Qemu-devel] [PATCH 11/14] qbus: move get_fw_dev_path to DeviceClass
It should have never been a bus method. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/ide/qdev.c | 33 + hw/isa-bus.c | 31 +++ hw/pci.c | 31 +++ hw/qdev.c | 10 +- hw/qdev.h |2 +- hw/scsi-bus.c | 33 - hw/sysbus.c | 39 +++ hw/usb/bus.c | 55 +++ 8 files changed, 107 insertions(+), 127 deletions(-) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 4a468f8..5044018 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -25,22 +25,13 @@ /* - */ -static char *idebus_get_fw_dev_path(DeviceState *dev); - #define TYPE_IDE_BUS IDE - -static void ide_bus_class_init(ObjectClass *klass, void *data) -{ -BusClass *k = BUS_CLASS(klass); - -k-get_fw_dev_path = idebus_get_fw_dev_path; -} +#define IDE_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS) static TypeInfo ide_bus_info = { .name = TYPE_IDE_BUS, .parent = TYPE_BUS, .instance_size = sizeof(IDEBus), -.class_init = ide_bus_class_init, }; void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id) @@ -49,16 +40,6 @@ void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id) idebus-bus_id = bus_id; } -static char *idebus_get_fw_dev_path(DeviceState *dev) -{ -char path[30]; - -snprintf(path, sizeof(path), %s@%d, qdev_fw_name(dev), - ((IDEBus*)dev-parent_bus)-bus_id); - -return strdup(path); -} - static int ide_qdev_init(DeviceState *qdev) { IDEDevice *dev = IDE_DEVICE(qdev); @@ -250,11 +231,23 @@ static TypeInfo ide_drive_info = { .class_init= ide_drive_class_init, }; +static char *ide_device_get_fw_dev_path(DeviceState *dev) +{ +IDEBus *parent_bus = IDE_BUS(dev-parent_bus); +char path[30]; + +snprintf(path, sizeof(path), %s@%d, qdev_fw_name(dev), + parent_bus-bus_id); + +return g_strdup(path); +} + static void ide_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k-init = ide_qdev_init; k-bus_type = TYPE_IDE_BUS; +k-get_fw_dev_path = ide_device_get_fw_dev_path; } static Property ide_bus_properties[] = { diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 2616f22..6141515 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -26,7 +26,6 @@ static ISABus *isabus; target_phys_addr_t isa_mem_base = 0; static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent); -static char *isabus_get_fw_dev_path(DeviceState *dev); #define TYPE_ISA_BUS ISA @@ -35,7 +34,6 @@ static void isa_bus_class_init(ObjectClass *klass, void *data) BusClass *k = BUS_CLASS(klass); k-print_dev = isabus_dev_print; -k-get_fw_dev_path = isabus_get_fw_dev_path; } static TypeInfo isa_bus_info = { @@ -204,11 +202,26 @@ static TypeInfo isabus_bridge_info = { .class_init= isabus_bridge_class_init, }; +static char *isa_device_get_fw_dev_path(DeviceState *dev) +{ +ISADevice *d = (ISADevice*)dev; +char path[40]; +int off; + +off = snprintf(path, sizeof(path), %s, qdev_fw_name(dev)); +if (d-ioport_id) { +snprintf(path + off, sizeof(path) - off, @%04x, d-ioport_id); +} + +return strdup(path); +} + static void isa_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k-init = isa_qdev_init; k-bus_type = TYPE_ISA_BUS; +k-get_fw_dev_path = isa_device_get_fw_dev_path; } static TypeInfo isa_device_type_info = { @@ -227,20 +240,6 @@ static void isabus_register_types(void) type_register_static(isa_device_type_info); } -static char *isabus_get_fw_dev_path(DeviceState *dev) -{ -ISADevice *d = (ISADevice*)dev; -char path[40]; -int off; - -off = snprintf(path, sizeof(path), %s, qdev_fw_name(dev)); -if (d-ioport_id) { -snprintf(path + off, sizeof(path) - off, @%04x, d-ioport_id); -} - -return strdup(path); -} - MemoryRegion *isa_address_space(ISADevice *dev) { return get_system_memory(); diff --git a/hw/pci.c b/hw/pci.c index 291181e..425ceaa 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -40,7 +40,6 @@ #endif static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent); -static char *pcibus_get_fw_dev_path(DeviceState *dev); static int pcibus_reset(BusState *qbus); static void pci_bus_class_init(ObjectClass *klass, void *data) @@ -48,7 +47,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) BusClass *k = BUS_CLASS(klass); k-print_dev = pcibus_dev_print; -k-get_fw_dev_path = pcibus_get_fw_dev_path; k-reset = pcibus_reset; } @@ -1883,20 +1881,6 @@ static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len) return buf; } -static char *pcibus_get_fw_dev_path(DeviceState *dev) -{ -PCIDevice
Re: [Qemu-devel] [PATCH 11/14] qbus: move get_fw_dev_path to DeviceClass
Am 01.05.2012 20:18, schrieb Anthony Liguori: It should have never been a bus method. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- [...] diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 4a468f8..5044018 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -25,22 +25,13 @@ /* - */ -static char *idebus_get_fw_dev_path(DeviceState *dev); - #define TYPE_IDE_BUS IDE - -static void ide_bus_class_init(ObjectClass *klass, void *data) -{ -BusClass *k = BUS_CLASS(klass); - -k-get_fw_dev_path = idebus_get_fw_dev_path; -} +#define IDE_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS) Move macro to preceding patch? Otherwise looks good. /-F -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 11/14] qbus: move get_fw_dev_path to DeviceClass
On 05/01/2012 02:34 PM, Andreas Färber wrote: Am 01.05.2012 20:18, schrieb Anthony Liguori: It should have never been a bus method. Signed-off-by: Anthony Liguorialigu...@us.ibm.com --- [...] diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 4a468f8..5044018 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -25,22 +25,13 @@ /* - */ -static char *idebus_get_fw_dev_path(DeviceState *dev); - #define TYPE_IDE_BUS IDE - -static void ide_bus_class_init(ObjectClass *klass, void *data) -{ -BusClass *k = BUS_CLASS(klass); - -k-get_fw_dev_path = idebus_get_fw_dev_path; -} +#define IDE_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS) Move macro to preceding patch? Otherwise looks good. Do you mean an independent patch? Regards, Anthony Liguori /-F
Re: [Qemu-devel] [PATCH 11/14] qbus: move get_fw_dev_path to DeviceClass
Am 02.05.2012 00:24, schrieb Anthony Liguori: On 05/01/2012 02:34 PM, Andreas Färber wrote: Am 01.05.2012 20:18, schrieb Anthony Liguori: +#define IDE_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS) Move macro to preceding patch? Do you mean an independent patch? Sorry, I reviewed the patches in mail reception order. ;) I meant 08/14 (qdev: convert busses to QEMU object model) where macros for other bus types were introduced. Seemed like an oversight. Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
[Qemu-devel] [PATCH 11/14] qbus: move get_fw_dev_path to DeviceClass
It should have never been a bus method. Signed-off-by: Anthony Liguori aligu...@us.ibm.com --- hw/ide/qdev.c | 33 + hw/isa-bus.c | 31 +++ hw/pci.c | 31 +++ hw/qdev.c | 10 +- hw/qdev.h |2 +- hw/scsi-bus.c | 33 - hw/sysbus.c | 39 +++ hw/usb/bus.c | 55 +++ 8 files changed, 107 insertions(+), 127 deletions(-) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 4a468f8..5044018 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -25,22 +25,13 @@ /* - */ -static char *idebus_get_fw_dev_path(DeviceState *dev); - #define TYPE_IDE_BUS IDE - -static void ide_bus_class_init(ObjectClass *klass, void *data) -{ -BusClass *k = BUS_CLASS(klass); - -k-get_fw_dev_path = idebus_get_fw_dev_path; -} +#define IDE_BUS(obj) OBJECT_CHECK(IDEBus, (obj), TYPE_IDE_BUS) static TypeInfo ide_bus_info = { .name = TYPE_IDE_BUS, .parent = TYPE_BUS, .instance_size = sizeof(IDEBus), -.class_init = ide_bus_class_init, }; void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id) @@ -49,16 +40,6 @@ void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id) idebus-bus_id = bus_id; } -static char *idebus_get_fw_dev_path(DeviceState *dev) -{ -char path[30]; - -snprintf(path, sizeof(path), %s@%d, qdev_fw_name(dev), - ((IDEBus*)dev-parent_bus)-bus_id); - -return strdup(path); -} - static int ide_qdev_init(DeviceState *qdev) { IDEDevice *dev = IDE_DEVICE(qdev); @@ -250,11 +231,23 @@ static TypeInfo ide_drive_info = { .class_init= ide_drive_class_init, }; +static char *ide_device_get_fw_dev_path(DeviceState *dev) +{ +IDEBus *parent_bus = IDE_BUS(dev-parent_bus); +char path[30]; + +snprintf(path, sizeof(path), %s@%d, qdev_fw_name(dev), + parent_bus-bus_id); + +return g_strdup(path); +} + static void ide_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k-init = ide_qdev_init; k-bus_type = TYPE_IDE_BUS; +k-get_fw_dev_path = ide_device_get_fw_dev_path; } static Property ide_bus_properties[] = { diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 2616f22..6141515 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -26,7 +26,6 @@ static ISABus *isabus; target_phys_addr_t isa_mem_base = 0; static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent); -static char *isabus_get_fw_dev_path(DeviceState *dev); #define TYPE_ISA_BUS ISA @@ -35,7 +34,6 @@ static void isa_bus_class_init(ObjectClass *klass, void *data) BusClass *k = BUS_CLASS(klass); k-print_dev = isabus_dev_print; -k-get_fw_dev_path = isabus_get_fw_dev_path; } static TypeInfo isa_bus_info = { @@ -204,11 +202,26 @@ static TypeInfo isabus_bridge_info = { .class_init= isabus_bridge_class_init, }; +static char *isa_device_get_fw_dev_path(DeviceState *dev) +{ +ISADevice *d = (ISADevice*)dev; +char path[40]; +int off; + +off = snprintf(path, sizeof(path), %s, qdev_fw_name(dev)); +if (d-ioport_id) { +snprintf(path + off, sizeof(path) - off, @%04x, d-ioport_id); +} + +return strdup(path); +} + static void isa_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k-init = isa_qdev_init; k-bus_type = TYPE_ISA_BUS; +k-get_fw_dev_path = isa_device_get_fw_dev_path; } static TypeInfo isa_device_type_info = { @@ -227,20 +240,6 @@ static void isabus_register_types(void) type_register_static(isa_device_type_info); } -static char *isabus_get_fw_dev_path(DeviceState *dev) -{ -ISADevice *d = (ISADevice*)dev; -char path[40]; -int off; - -off = snprintf(path, sizeof(path), %s, qdev_fw_name(dev)); -if (d-ioport_id) { -snprintf(path + off, sizeof(path) - off, @%04x, d-ioport_id); -} - -return strdup(path); -} - MemoryRegion *isa_address_space(ISADevice *dev) { return get_system_memory(); diff --git a/hw/pci.c b/hw/pci.c index 291181e..425ceaa 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -40,7 +40,6 @@ #endif static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent); -static char *pcibus_get_fw_dev_path(DeviceState *dev); static int pcibus_reset(BusState *qbus); static void pci_bus_class_init(ObjectClass *klass, void *data) @@ -48,7 +47,6 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) BusClass *k = BUS_CLASS(klass); k-print_dev = pcibus_dev_print; -k-get_fw_dev_path = pcibus_get_fw_dev_path; k-reset = pcibus_reset; } @@ -1883,20 +1881,6 @@ static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len) return buf; } -static char *pcibus_get_fw_dev_path(DeviceState *dev) -{ -PCIDevice