summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2012-11-25 16:49:15 +0100
committerDoug Goldstein <cardoe@cardoe.com>2012-12-13 15:32:00 -0600
commitdc4329b5b9145067eda6576a157495e1a12ed36d (patch)
treec6d6b5584f78752cb0f3eda189d1ad9d90622c36
parentqxl: reload memslots after migration, when qxl is in UNDEFINED mode (diff)
downloadqemu-kvm-dc4329b5b9145067eda6576a157495e1a12ed36d.tar.gz
qemu-kvm-dc4329b5b9145067eda6576a157495e1a12ed36d.tar.bz2
qemu-kvm-dc4329b5b9145067eda6576a157495e1a12ed36d.zip
usb: fail usbdevice_create() when there is no USB bus
Report an error instead of segfaulting when attaching a USB device to a machine with no USB busses: $ qemu-system-arm -machine vexpress-a9 \ -sd Fedora-17-armhfp-vexpress-mmcblk0.img \ -kernel vmlinuz-3.4.2-3.fc17.armv7hl \ -initrd initramfs-3.4.2-3.fc17.armv7hl.img \ -usbdevice disk:format=raw:test.img Note that the vexpress-a9 machine does not have a USB host controller. Reported-by: David Abdurachmanov <David.Abdurachmanov@cern.ch> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> (cherry picked from commit c128d6a6d785eb9235a4f6dbd52f405ab8c60bee) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> (cherry picked from commit cd00334f1ae587aee146517af295adbfd7ab702a)
-rw-r--r--hw/usb/bus.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index b649360dd..1f73a5216 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -585,6 +585,13 @@ USBDevice *usbdevice_create(const char *cmdline)
return NULL;
}
+ if (!bus) {
+ error_report("Error: no usb bus to attach usbdevice %s, "
+ "please try -machine usb=on and check that "
+ "the machine model supports USB", driver);
+ return NULL;
+ }
+
if (!f->usbdevice_init) {
if (*params) {
error_report("usbdevice %s accepts no params", driver);