QOM devices patch queue 2015-02-24
Hello Peter,
This is my QOM (devices) patch queue. Please pull.
Regards,
Andreas
The following changes since commit cd2d5541271f1934345d8ca42f5fafff1744eee7:
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20150212' into staging (2015-02-13 11:44:50 +0000)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-peter
for you to fetch changes up to 4bc6a3e54e06c47b8e23bfa3d873fa2f42dfec02:
parallel: parallel_hds_isa_init() shouldn't fail (2015-02-24 00:19:06 +0100)
----------------------------------------------------------------
QOM infrastructure fixes and device conversions
* Assertion fix for device_add with non-device types
* Documentation fix
* qdev_init() error reporting cleanups
----------------------------------------------------------------
Jun Li (1):
qdev: Avoid type assertion in qdev_build_hotpluggable_device_list()
Markus Armbruster (8):
qdev: Improve qdev_init_nofail()'s error reporting ide/isa: Replace unchecked qdev_init() by qdev_init_nofail()
leon3: Replace unchecked qdev_init() by qdev_init_nofail()
etsec: Replace qdev_init() by qdev_init_nofail()
serial: Factor out common serial_hds_isa_init()
serial: serial_hds_isa_init() shouldn't fail
parallel: Factor out common parallel_hds_isa_init()
parallel: parallel_hds_isa_init() shouldn't fail
Zhoujian (1):
qom: Fix typo, 'my_class_init' -> 'derived_class_init'
hw/alpha/dp264.c | 6 +----- hw/char/parallel.c | 25 +++++++++++++++++++++++++ hw/char/serial-isa.c | 23 +++++++++++++++-------- hw/core/qdev.c | 18 ++++++++++++++---- hw/i386/pc.c | 13 ++----------- hw/ide/isa.c | 4 +--- hw/mips/mips_fulong2e.c | 12 ++---------- hw/mips/mips_malta.c | 7 +++---- hw/mips/mips_r4k.c | 6 +----- hw/net/fsl_etsec/etsec.c | 5 +---- hw/sparc64/sun4u.c | 12 ++---------- include/hw/char/serial.h | 2 +- include/hw/i386/pc.h | 17 +---------------- include/hw/sparc/grlib.h | 12 +++--------- include/qom/object.h | 2 +- 15 files changed, 73 insertions(+), 91 deletions(-)
[Qemu-devel] [PULL 08/10] serial: serial_hds_isa_init() shouldn't fail
From: Markus Armbruster <[email protected]>
It shouldn't fail, and no caller checks for failure. Make failure fatal.
Maintainers of affected machines cc'ed.
--- hw/char/serial-isa.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
hw/char/serial-isa.c +3 -9
@@ -119,22 +119,16 @@ static void serial_register_types(void)type_init (serial_register_types) -static bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr) +static void serial_isa_init(ISABus *bus, int index, CharDriverState *chr) {DeviceState *dev;ISADevice *isadev; - isadev =isa_try_create (bus,TYPE_ISA_SERIAL ); -if (!isadev) { -return false; - } + isadev =isa_create (bus,TYPE_ISA_SERIAL ); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"index" , index);qdev_prop_set_chr (dev,"chardev" , chr); -if (qdev_init (dev) <0 ) { -return false; - } -return true; +qdev_init_nofail (dev); }void serial_hds_isa_init (ISABus *bus,int n)
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 07/10] serial: Factor out common serial_hds_isa_init()
In reply to Andreas FärberFrom: Markus Armbruster <[email protected]>
It's the same old loop copied five times, plus another instance where it's clipped to two iterations and unrolled.
No external users of serial_isa_init() are left, so give it internal linkage.
Maintainers of affected machines cc'ed.
--- hw/alpha/dp264.c | 6 +----- hw/char/serial-isa.c | 15 ++++++++++++++- hw/i386/pc.c | 6 +----- hw/mips/mips_fulong2e.c | 7 +------ hw/mips/mips_malta.c | 3 +-- hw/mips/mips_r4k.c | 6 +----- hw/sparc64/sun4u.c | 7 ++----- include/hw/char/serial.h | 2 +- 8 files changed, 22 insertions(+), 30 deletions(-)
hw/alpha/dp264.c +1 -5
@@ -83,11 +83,7 @@ static void clipper_init(MachineState *machine)pci_vga_init (pci_bus);/* Serial code setup. */ -for (i =0 ; i <MAX_SERIAL_PORTS ; ++i) { -if (serial_hds[i]) { -serial_isa_init (isa_bus, i, serial_hds[i]); - } - } +serial_hds_isa_init (isa_bus,MAX_SERIAL_PORTS );/* Network setup. e1000 is good enough, failing Tulip support. */ for (i =0 ; i < nb_nics; i++) {
hw/char/serial-isa.c +14 -1
@@ -119,7 +119,7 @@ static void serial_register_types(void)type_init (serial_register_types) -bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr) +static bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr) {DeviceState *dev;ISADevice *isadev;
@@ -136,3 +136,16 @@ bool serial_isa_init(ISABus *bus, int index, CharDriverState *chr) }return true; } + +void serial_hds_isa_init (ISABus *bus,int n) +{ +int i; + +assert (n <=MAX_SERIAL_PORTS ); + +for (i =0 ; i < n; ++i) { +if (serial_hds[i]) { +serial_isa_init (bus, i, serial_hds[i]); + } + } +}
hw/i386/pc.c +1 -5
@@ -1419,11 +1419,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,pcspk_init (isa_bus, pit); } -for (i =0 ; i <MAX_SERIAL_PORTS ; i++) { -if (serial_hds[i]) { -serial_isa_init (isa_bus, i, serial_hds[i]); - } - } +serial_hds_isa_init (isa_bus,MAX_SERIAL_PORTS );for (i =0 ; i <MAX_PARALLEL_PORTS ; i++) {if (parallel_hds[i]) {
hw/mips/mips_fulong2e.c +1 -6
@@ -277,7 +277,6 @@ static void mips_fulong2e_init(MachineState *machine)PCIBus *pci_bus;ISABus *isa_bus;I2CBus *smbus; -int i;DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];MIPSCPU *cpu;CPUMIPSState *env;
@@ -384,11 +383,7 @@ static void mips_fulong2e_init(MachineState *machine)rtc_init (isa_bus,2000 ,NULL ); -for (i =0 ; i <MAX_SERIAL_PORTS ; i++) { -if (serial_hds[i]) { -serial_isa_init (isa_bus, i, serial_hds[i]); - } - } +serial_hds_isa_init (isa_bus,MAX_SERIAL_PORTS );if (parallel_hds[0 ]) {parallel_init (isa_bus,0 , parallel_hds[0 ]);
hw/mips/mips_malta.c +1 -2
@@ -1172,8 +1172,7 @@ void mips_malta_init(MachineState *machine)isa_create_simple (isa_bus,"i8042" );rtc_init (isa_bus,2000 ,NULL ); -serial_isa_init (isa_bus,0 , serial_hds[0 ]); -serial_isa_init (isa_bus,1 , serial_hds[1 ]); +serial_hds_isa_init (isa_bus,2 );if (parallel_hds[0 ])parallel_init (isa_bus,0 , parallel_hds[0 ]);for (i =0 ; i <MAX_FD ; i++) {
hw/mips/mips_r4k.c +1 -5
@@ -283,11 +283,7 @@ void mips_r4k_init(MachineState *machine) pit =pit_init (isa_bus,0x40 ,0 ,NULL ); -for (i =0 ; i <MAX_SERIAL_PORTS ; i++) { -if (serial_hds[i]) { -serial_isa_init (isa_bus, i, serial_hds[i]); - } - } +serial_hds_isa_init (isa_bus,MAX_SERIAL_PORTS );isa_vga_init (isa_bus);
hw/sparc64/sun4u.c +2 -5
@@ -849,11 +849,8 @@ static void sun4uv_init(MemoryRegion *address_space_mem, NULL, 115200, serial_hds[i], DEVICE_BIG_ENDIAN); i++; } -for (; i <MAX_SERIAL_PORTS ; i++) { -if (serial_hds[i]) { -serial_isa_init (isa_bus, i, serial_hds[i]); - } - } + +serial_hds_isa_init (isa_bus,MAX_SERIAL_PORTS );for (i =0 ; i <MAX_PARALLEL_PORTS ; i++) {if (parallel_hds[i]) {
include/hw/char/serial.h +1 -1
@@ -92,6 +92,6 @@ SerialState *serial_mm_init(MemoryRegion *address_space,/* serial-isa.c */ #define TYPE_ISA_SERIAL "isa-serial" -bool serial_isa_init (ISABus *bus,int index,CharDriverState *chr); +void serial_hds_isa_init (ISABus *bus,int n);#endif
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 01/10] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list()
In reply to Andreas FärberFrom: Jun Li <[email protected]>
Currently when *obj is not a TYPE_DEVICE, QEMU will abort. This patch fixes it. When *obj is not a TYPE_DEVICE, just do not add it to hotpluggable device list.
This patch also fixes the following issue:
1. boot QEMU using cli:
$ /opt/qemu-git-arm/bin/qemu-system-x86_64 -monitor stdio -enable-kvm \ -device virtio-scsi-pci,id=scsi0
2. device_del scsi0 via hmp using tab key(first input device_del, then press "Tab" key).
(qemu) device_del
After step 2, QEMU will abort.
(qemu) device_del hw/core/qdev.c:930:qdev_build_hotpluggable_device_list:
Object 0x5555563a2460 is not an instance of type device
--- hw/core/qdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
hw/core/qdev.c +6 -1
@@ -988,7 +988,12 @@ void qdev_alias_all_properties(DeviceState *target, Object *source)static int qdev_add_hotpluggable_device (Object *obj,void *opaque) {GSList **list = opaque; -DeviceState *dev =DEVICE (obj); +DeviceState *dev = (DeviceState *)object_dynamic_cast (OBJECT (obj), +TYPE_DEVICE ); + +if (dev ==NULL ) { +return 0 ; + }if (dev->realized &&object_property_get_bool (obj,"hotpluggable" ,NULL )) { *list =g_slist_append (*list, dev);
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 02/10] qom: Fix typo, 'my_class_init' -> 'derived_class_init'
In reply to Andreas FärberFrom: Zhoujian <[email protected]>
--- include/qom/object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/qom/object.h +1 -1
@@ -273,7 +273,7 @@ typedef struct InterfaceInfo InterfaceInfo;* .name = TYPE_DERIVED, * .parent = TYPE_MY, * .class_size = sizeof(DerivedClass), -* .class_init = my_class_init, +* .class_init = derived_class_init, * }; * </programlisting> * </example>
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 09/10] parallel: Factor out common parallel_hds_isa_init()
In reply to Andreas FärberFrom: Markus Armbruster <[email protected]>
Maintainers of affected machines cc'ed.
--- hw/char/parallel.c | 31 +++++++++++++++++++++++++++++++ hw/i386/pc.c | 7 +------ hw/mips/mips_fulong2e.c | 5 +---- hw/mips/mips_malta.c | 4 ++-- hw/sparc64/sun4u.c | 7 +------ include/hw/i386/pc.h | 17 +---------------- 6 files changed, 37 insertions(+), 34 deletions(-)
hw/char/parallel.c +31 -0
@@ -641,3 +641,34 @@ static void parallel_register_types(void) }type_init (parallel_register_types) + +static bool parallel_init(ISABus *bus, int index, CharDriverState *chr) +{ +DeviceState *dev; +ISADevice *isadev; + + isadev =isa_try_create (bus,"isa-parallel" ); +if (!isadev) { +return false; + } + dev =DEVICE (isadev); +qdev_prop_set_uint32 (dev,"index" , index); +qdev_prop_set_chr (dev,"chardev" , chr); +if (qdev_init (dev) <0 ) { +return false; + } +return true; +} + +void parallel_hds_isa_init (ISABus *bus,int n) +{ +int i; + +assert (n <=MAX_PARALLEL_PORTS ); + +for (i =0 ; i < n; i++) { +if (parallel_hds[i]) { +parallel_init (bus, i, parallel_hds[i]); + } + } +}
hw/i386/pc.c +1 -6
@@ -1420,12 +1420,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, }serial_hds_isa_init (isa_bus,MAX_SERIAL_PORTS ); - -for (i =0 ; i <MAX_PARALLEL_PORTS ; i++) { -if (parallel_hds[i]) { -parallel_init (isa_bus, i, parallel_hds[i]); - } - } +parallel_hds_isa_init (isa_bus,MAX_PARALLEL_PORTS ); a20_line =qemu_allocate_irqs (handle_a20_line_change, first_cpu,2 ); i8042 =isa_create_simple (isa_bus,"i8042" );
hw/mips/mips_fulong2e.c +1 -4
@@ -384,10 +384,7 @@ static void mips_fulong2e_init(MachineState *machine)rtc_init (isa_bus,2000 ,NULL );serial_hds_isa_init (isa_bus,MAX_SERIAL_PORTS ); - -if (parallel_hds[0 ]) { -parallel_init (isa_bus,0 , parallel_hds[0 ]); - } +parallel_hds_isa_init (isa_bus,1 );/* Sound card */ audio_init (pci_bus);
hw/mips/mips_malta.c +2 -2
@@ -1173,8 +1173,8 @@ void mips_malta_init(MachineState *machine)rtc_init (isa_bus,2000 ,NULL );serial_hds_isa_init (isa_bus,2 ); -if (parallel_hds[0 ]) -parallel_init (isa_bus,0 , parallel_hds[0 ]); +parallel_hds_isa_init (isa_bus,1 ); +for (i =0 ; i <MAX_FD ; i++) { fd[i] =drive_get (IF_FLOPPY ,0 , i); }
hw/sparc64/sun4u.c +1 -6
@@ -851,12 +851,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, }serial_hds_isa_init (isa_bus,MAX_SERIAL_PORTS ); - -for (i =0 ; i <MAX_PARALLEL_PORTS ; i++) { -if (parallel_hds[i]) { -parallel_init (isa_bus, i, parallel_hds[i]); - } - } +parallel_hds_isa_init (isa_bus,MAX_PARALLEL_PORTS );for (i =0 ; i < nb_nics; i++)pci_nic_init_nofail (&nd_table[i], pci_bus,"ne2k_pci" ,NULL );
include/hw/i386/pc.h +1 -16
@@ -107,23 +107,8 @@ struct PcGuestInfo { };/* parallel.c */ -static inline bool parallel_init (ISABus *bus,int index,CharDriverState *chr) -{ -DeviceState *dev; -ISADevice *isadev; - isadev =isa_try_create (bus,"isa-parallel" ); -if (!isadev) { -return false; - } - dev =DEVICE (isadev); -qdev_prop_set_uint32 (dev,"index" , index); -qdev_prop_set_chr (dev,"chardev" , chr); -if (qdev_init (dev) <0 ) { -return false; - } -return true; -} +void parallel_hds_isa_init (ISABus *bus,int n); bool parallel_mm_init(MemoryRegion *address_space, hwaddr base, int it_shift, qemu_irq irq,
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 05/10] leon3: Replace unchecked qdev_init() by qdev_init_nofail()
In reply to Andreas FärberFrom: Markus Armbruster <[email protected]>
grlib_irqmp_create(), grlib_gptimer_create() and grlib_apbuart_create() are helpers to create and realize GRLIB devices. Their only caller leon3_generic_hw_init() doesn't check for failure. Only the first can actually fail, and only when the caller fails to set up a pointer property, which is a programming error.
Replace qdev_init() by qdev_init_nofail().
--- include/hw/sparc/grlib.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
include/hw/sparc/grlib.h +3 -9
@@ -55,9 +55,7 @@ DeviceState *grlib_irqmp_create(hwaddr base,qdev_prop_set_ptr (dev,"set_pil_in" , set_pil_in);qdev_prop_set_ptr (dev,"set_pil_in_opaque" , env); -if (qdev_init (dev)) { -return NULL ; - } +qdev_init_nofail (dev); env->irq_manager = dev;
@@ -87,9 +85,7 @@ DeviceState *grlib_gptimer_create(hwaddr base,qdev_prop_set_uint32 (dev,"frequency" , freq);qdev_prop_set_uint32 (dev,"irq-line" , base_irq); -if (qdev_init (dev)) { -return NULL ; - } +qdev_init_nofail (dev);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , base);
@@ -112,9 +108,7 @@ DeviceState *grlib_apbuart_create(hwaddr base, dev =qdev_create (NULL ,"grlib,apbuart" );qdev_prop_set_chr (dev,"chrdev" , serial); -if (qdev_init (dev)) { -return NULL ; - } +qdev_init_nofail (dev);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , base);
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 06/10] etsec: Replace qdev_init() by qdev_init_nofail()
In reply to Andreas FärberFrom: Markus Armbruster <[email protected]>
etsec_create() is a helper to create and realize the eTSEC. It's currently unused. Similar helpers for other NICs use qdev_init_nofail(). Match that.
--- hw/net/fsl_etsec/etsec.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/net/fsl_etsec/etsec.c +1 -4
@@ -443,10 +443,7 @@ DeviceState *etsec_create(hwaddr base, dev =qdev_create (NULL ,"eTSEC" );qdev_set_nic_properties (dev, nd); - -if (qdev_init (dev)) { -return NULL ; - } +qdev_init_nofail (dev);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , tx_irq);sysbus_connect_irq (SYS_BUS_DEVICE (dev),1 , rx_irq);
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 03/10] qdev: Improve qdev_init_nofail()'s error reporting
In reply to Andreas FärberFrom: Markus Armbruster <[email protected]>
We get two error messages: a specific one from qdev_init(), and a generic one from qdev_init_nofail(). The specific one gets suppressed in QMP context. qdev_init_nofail() failing there is a bug, though.
Cut out the qdev_init() middle-man: realize the device, and on error exit with a single error message.
--- hw/core/qdev.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
hw/core/qdev.c +8 -3
@@ -373,10 +373,15 @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,way is somewhat unclean, and best avoided. */ void qdev_init_nofail (DeviceState *dev) { -const char *typename =object_get_typename (OBJECT (dev)); +Error *err =NULL ; + +assert (!dev->realized); -if (qdev_init (dev) <0 ) { -error_report ("Initialization of device %s failed" , typename); +object_property_set_bool (OBJECT (dev), true,"realized" , &err); +if (err) { +error_report ("Initialization of device %s failed: %s" , +object_get_typename (OBJECT (dev)), +error_get_pretty (err));exit (1 ); } }
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 04/10] ide/isa: Replace unchecked qdev_init() by qdev_init_nofail()
In reply to Andreas FärberFrom: Markus Armbruster <[email protected]>
isa_ide_init()'s callers don't check for failure. isa_ide_init() looks like it could fail, but since isa_ide_realizefn() can't fail, it actually can't. Replace its qdev_init() by qdev_init_nofail() to make it obvious.
--- hw/ide/isa.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/ide/isa.c +1 -3
@@ -88,9 +88,7 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int isairq,qdev_prop_set_uint32 (dev,"iobase" , iobase);qdev_prop_set_uint32 (dev,"iobase2" , iobase2);qdev_prop_set_uint32 (dev,"irq" , isairq); -if (qdev_init (dev) <0 ) { -return NULL ; - } +qdev_init_nofail (dev); s =ISA_IDE (dev);if (hd0) {
Signature · 1 line
2.1.4
[Qemu-devel] [PULL 10/10] parallel: parallel_hds_isa_init() shouldn't fail
In reply to Andreas FärberFrom: Markus Armbruster <[email protected]>
It shouldn't fail, and no caller checks for failure. Make failure fatal.
Maintainers of affected machines cc'ed.
--- hw/char/parallel.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
hw/char/parallel.c +3 -9
@@ -642,22 +642,16 @@ static void parallel_register_types(void)type_init (parallel_register_types) -static bool parallel_init(ISABus *bus, int index, CharDriverState *chr) +static void parallel_init(ISABus *bus, int index, CharDriverState *chr) {DeviceState *dev;ISADevice *isadev; - isadev =isa_try_create (bus,"isa-parallel" ); -if (!isadev) { -return false; - } + isadev =isa_create (bus,"isa-parallel" ); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"index" , index);qdev_prop_set_chr (dev,"chardev" , chr); -if (qdev_init (dev) <0 ) { -return false; - } -return true; +qdev_init_nofail (dev); }void parallel_hds_isa_init (ISABus *bus,int n)
Signature · 1 line
2.1.4
Quoted 6 lines · Andreas Färber
Hello Peter,
This is my QOM (devices) patch queue. Please pull.
Regards,
Andreas
Hi Andreas,
Are you able to take the m48t59 QOM patch below via your tree:
http://lists.gnu.org/archive/html/qemu-devel/2015-01/msg02294.html
Or should it be routed via your PReP tree instead? The reason for asking is that my qemu-sparc pull request for 2.3 is dependent upon this patchset.
ATB,
Mark.
Peter Maydell
AppliedQuoted 23 lines · Andreas Färber
Hello Peter,
This is my QOM (devices) patch queue. Please pull.
Regards,
AndreasCc Peter Maydell <[email protected]>Cc Markus Armbruster <[email protected]>The following changes since commit
cd2d5541271f1934345d8ca42f5fafff1744eee7:Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20150212' into staging (2015-02-13 11:44:50 +0000)
are available in the git repository at:
git://github.com/afaerber/qemu-cpu.gittags/qom-devices-for-peterfor you to fetch changes up to
4bc6a3e54e06c47b8e23bfa3d873fa2f42dfec02:parallel:
parallel_hds_isa_init()shouldn't fail (2015-02-24 00:19:06 +0100)
Quoted 8 lines
----------------------------------------------------------------
QOM infrastructure fixes and device conversions* Assertion fix for
device_addwith non-device types
* Documentation fix
*qdev_init()error reporting cleanups----------------------------------------------------------------
Applied, thanks.
-- PMM