[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/26] usb-storage: Fix how legacy init handles optio
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 01/26] usb-storage: Fix how legacy init handles option ID clash |
Date: |
Tue, 23 Sep 2014 14:13:12 +0200 |
From: Markus Armbruster <address@hidden>
usb_msd_init() calls qemu_opts_create() with a made-up ID and false
fail_if_exists. If the ID already exists, it happily messes up those
options, then fails drive_new(), because the BlockDriverState with
that ID already exists, too.
Reproducer: -drive if=none,id=usb0,format=raw -usbdevice disk:tmp.qcow2
Pass true fail_if_exists to qemu_opts_create(), and if it fails, try
the next made-up ID.
The reproducer now succeeds, and creates an usb-storage device with ID
usb1.
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb/dev-storage.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index ae4efcb..eb75f6a 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -666,8 +666,10 @@ static USBDevice *usb_msd_init(USBBus *bus, const char
*filename)
char fmt[32];
/* parse -usbdevice disk: syntax into drive opts */
- snprintf(id, sizeof(id), "usb%d", nr++);
- opts = qemu_opts_create(qemu_find_opts("drive"), id, 0, NULL);
+ do {
+ snprintf(id, sizeof(id), "usb%d", nr++);
+ opts = qemu_opts_create(qemu_find_opts("drive"), id, 1, NULL);
+ } while (!opts);
p1 = strchr(filename, ':');
if (p1++) {
--
1.8.3.1
- [Qemu-devel] [PULL 18/26] usb-audio: convert init to realize, (continued)
- [Qemu-devel] [PULL 18/26] usb-audio: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 13/26] dev-bluetooth: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 15/26] usb-ccid: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 14/26] dev-serial: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 16/26] dev-hid: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 20/26] usb-mtp: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 04/26] usb-bus: convert USBDeviceClass init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 17/26] dev-wacom: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 08/26] usb-hub: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 03/26] ohci: Convert fprint/DPRINTF/print to traces, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 01/26] usb-storage: Fix how legacy init handles option ID clash,
Gerd Hoffmann <=
- [Qemu-devel] [PULL 26/26] usb: tag standalone ehci as hotpluggable, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 11/26] dev-uas: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 02/26] usb-storage: fix possible memory leak and missing error message, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 06/26] libusb: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 09/26] dev-storage: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 10/26] dev-storage: usring error_report instead of fprintf/printf, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 05/26] usb-net: convert init to realize, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 24/26] usb: tag xhci as hotpluggable, Gerd Hoffmann, 2014/09/23
- [Qemu-devel] [PULL 25/26] usb: tag standalone uhci as hotpluggable, Gerd Hoffmann, 2014/09/23
- Re: [Qemu-devel] [PULL 00/26] usb patch queue, Peter Maydell, 2014/09/23