qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] usb: fail usbdevice_create() when there is no USB bus
@ 2012-11-25 15:49 Stefan Hajnoczi
  2012-11-27 13:11 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2012-11-25 15:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Gerd Hoffmann, Stefan Hajnoczi

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>
---
 hw/usb/bus.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 99aac7a..55d0edd 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -590,6 +590,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);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] usb: fail usbdevice_create() when there is no USB bus
  2012-11-25 15:49 [Qemu-devel] [PATCH] usb: fail usbdevice_create() when there is no USB bus Stefan Hajnoczi
@ 2012-11-27 13:11 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2012-11-27 13:11 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Peter Maydell, qemu-devel

On 11/25/12 16:49, Stefan Hajnoczi wrote:
> 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>

Patch added to usb patch queue.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-27 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-25 15:49 [Qemu-devel] [PATCH] usb: fail usbdevice_create() when there is no USB bus Stefan Hajnoczi
2012-11-27 13:11 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).