qemu/hw
Markus Armbruster bd8b92d5c8 usb: Suppress bogus error when automatic usb-hub creation fails
USBDevice's realize method usb_qdev_realize() automatically creates a
usb-hub when only one port is left.  Creating devices in realize
methods is questionable, but works.

If usb-hub creation fails, an error is reported to stderr, but the
failure is otherwise ignored.  We then create the actual device using
the last port, which may well succeed.

Example:

    $ qemu -nodefaults -S -display none -machine usb=on -monitor stdio
    QEMU 2.2.50 monitor - type 'help' for more information
    (qemu) device_add usb-mouse
    [Repeat 36 times]
    (qemu) info usb
      Device 0.0, Port 1, Speed 12 Mb/s, Product QEMU USB Mouse
      Device 0.0, Port 2, Speed 12 Mb/s, Product QEMU USB Hub
      Device 0.0, Port 2.1, Speed 12 Mb/s, Product QEMU USB Mouse
    [More mice and hubs omitted...]
      Device 0.0, Port 2.8.8.8.8.7, Speed 12 Mb/s, Product QEMU USB Mouse
    (qemu) device_add usb-mouse
    usb hub chain too deep
    Failed to initialize USB device 'usb-hub'
    (qemu) info usb
    [...]
      Device 0.0, Port 2.8.8.8.8.7, Speed 12 Mb/s, Product QEMU USB Mouse
      Device 0.0, Port 2.8.8.8.8.8, Speed 12 Mb/s, Product QEMU USB Mouse

Despite the "Failed" message, the command actually succeeded.

In QMP, it's worse.  When adding the 37th mouse via QMP, the command
fails with

    {"error": {"class": "GenericError", "desc": "usb hub chain too deep"}}

Additionally, "Failed to initialize USB device 'usb-hub'" is reported
on stderr.  Despite the command failure, the device was created.  This
is wrong.

Fix by avoiding qdev_init() for usb-hub creation, so we can ignore
errors cleanly.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-02-18 10:53:10 +01:00
..
9pfs rcu: add rcu library 2015-02-02 16:55:10 +01:00
acpi pci, pc, virtio fixes and cleanups 2015-01-27 13:17:30 +00:00
alpha
arm target-arm: Add feature parsing to virt 2015-02-13 05:46:08 +00:00
audio sb16: fix interrupt acknowledgement 2015-01-22 11:04:18 +01:00
block onenand: g_malloc() can't fail, bury dead error handling 2015-02-10 09:27:20 +03:00
bt
char virtio: Fix warning caused by missing 'static' attribute 2015-02-10 10:26:05 +03:00
core fw_cfg: fix typos in comments: patch -> path 2015-02-10 09:27:19 +03:00
cpu icc_bus: fix typo ICC_BRIGDE -> ICC_BRIDGE 2014-11-03 19:51:56 +03:00
cris
display vga: Fix warning caused by missing 'static' attribute 2015-02-10 10:26:05 +03:00
dma vmstate: accept QEMUTimer in VMSTATE_TIMER*, add VMSTATE_TIMER_PTR* 2015-01-26 12:22:44 +01:00
gpio PPC: Add MPC8XXX gpio controller 2014-11-04 23:26:12 +01:00
i2c
i386 pci, pc, virtio fixes and cleanups 2015-01-27 13:17:30 +00:00
ide atapi migration: Throw recoverable error to avoid recovery 2015-02-06 17:24:20 +01:00
input Add trace to ps2.c. 2015-02-10 09:27:20 +03:00
intc apic: do not dereference pointer before it is checked for NULL 2015-01-26 12:27:05 +01:00
ipack
isa vmstate: accept QEMUTimer in VMSTATE_TIMER*, add VMSTATE_TIMER_PTR* 2015-01-26 12:22:44 +01:00
lm32 acpi-build: make ROMs RAM blocks resizeable 2015-01-08 13:17:55 +02:00
m68k
mem pc-dimm: Add Error argument to pc_existing_dimms_capacity 2015-01-27 14:46:18 +02:00
microblaze
mips mips_mipssim: fix use-after-free for filename 2014-11-17 11:41:03 +01:00
misc hw: misc, add educational driver 2015-01-26 12:26:55 +01:00
moxie
net rtl8139: g_malloc() can't fail, bury dead error handling 2015-02-10 09:27:20 +03:00
nvram fw_cfg: fix endianness in fw_cfg_data_mem_read() / _write() 2015-01-16 11:54:30 +00:00
openrisc
pci migration: Append JSON description of migration stream 2015-02-05 17:16:14 +01:00
pci-bridge
pci-host pci: Add generic PCIe host bridge 2015-02-13 05:46:07 +00:00
pcmcia
ppc spapr_vio: Pair g_malloc() with g_free(), not free() 2015-02-10 09:27:20 +03:00
s390x s390x/ipl: Improved code indentation in s390_ipl_init() 2015-02-03 13:42:40 +01:00
scsi migration: Append JSON description of migration stream 2015-02-05 17:16:14 +01:00
sd vmstate: accept QEMUTimer in VMSTATE_TIMER*, add VMSTATE_TIMER_PTR* 2015-01-26 12:22:44 +01:00
sh4
sparc fw_cfg: move boards to fw_cfg_init_io() / fw_cfg_init_mem() 2014-12-22 23:39:15 +00:00
sparc64 fw_cfg: move boards to fw_cfg_init_io() / fw_cfg_init_mem() 2014-12-22 23:39:15 +00:00
ssi
timer fix mc146818rtc wrong subsection name to avoid vmstate_subsection_load() fail 2015-02-05 17:16:14 +01:00
tpm Drop superfluous conditionals around g_strdup() 2014-12-10 11:30:55 +03:00
tricore
unicore32
usb usb: Suppress bogus error when automatic usb-hub creation fails 2015-02-18 10:53:10 +01:00
vfio vfio: Fix debug message compile error 2015-02-10 10:25:44 -07:00
virtio migration: Append JSON description of migration stream 2015-02-05 17:16:14 +01:00
watchdog vmstate: accept QEMUTimer in VMSTATE_TIMER*, add VMSTATE_TIMER_PTR* 2015-01-26 12:22:44 +01:00
xen xen-pt: Fix PCI devices re-attach failed 2015-01-13 11:49:46 +00:00
xenpv
xtensa
Makefile.objs vfio: move hw/misc/vfio.c to hw/vfio/pci.c Move vfio.h into include/hw/vfio 2014-12-19 15:24:06 -07:00