From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60375 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgEjG-0000lQ-9E for qemu-devel@nongnu.org; Fri, 21 Jan 2011 06:00:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgEjD-0004CM-TT for qemu-devel@nongnu.org; Fri, 21 Jan 2011 06:00:30 -0500 Received: from mtagate4.uk.ibm.com ([194.196.100.164]:36354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgEjD-0004BY-Fl for qemu-devel@nongnu.org; Fri, 21 Jan 2011 06:00:27 -0500 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate4.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p0LB0Q4I029684 for ; Fri, 21 Jan 2011 11:00:26 GMT Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0LB0SDT1380386 for ; Fri, 21 Jan 2011 11:00:28 GMT Received: from d06av05.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0LB0Pqb031645 for ; Fri, 21 Jan 2011 04:00:25 -0700 From: Stefan Hajnoczi Date: Fri, 21 Jan 2011 11:00:08 +0000 Message-Id: <1295607609-21091-4-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1295607609-21091-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1295607609-21091-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v3 3/4] usb-msd: Propagate removable bit to SCSI device List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Christoph Hellwig , "Justin M. Forbes" , Stefan Hajnoczi USB Mass Storage Devices sometimes have the RMB (removable) bit set in the SCSI INQUIRY response. Thumbdrives tend to have the bit set whereas hard disks do not. Operating systems differentiate between removable devices and fixed devices. Under Linux, the anaconda installer looks for removable devices. Under Windows, only fixed devices may have more than one partition and AutoRun is also affected by the removable bit. For these reasons, allow USB Mass Storage Devices to override the removable bit: qemu -usb -drive if=none,file=test.img,cache=none,id=disk0 -device usb-storage,drive=disk0,removable=on The default is off. Signed-off-by: Stefan Hajnoczi --- hw/usb-msd.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index ee897b6..f1f150b 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -50,6 +50,7 @@ typedef struct { SCSIBus bus; BlockConf conf; SCSIDevice *scsi_dev; + uint32_t removable; int result; /* For async completion. */ USBPacket *packet; @@ -544,7 +545,7 @@ static int usb_msd_initfn(USBDevice *dev) s->dev.speed = USB_SPEED_FULL; scsi_bus_new(&s->bus, &s->dev.qdev, 0, 1, usb_msd_command_complete); - s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, false); + s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable); if (!s->scsi_dev) { return -1; } @@ -634,6 +635,7 @@ static struct USBDeviceInfo msd_info = { .usbdevice_init = usb_msd_init, .qdev.props = (Property[]) { DEFINE_BLOCK_PROPERTIES(MSDState, conf), + DEFINE_PROP_BIT("removable", MSDState, removable, 0, false), DEFINE_PROP_END_OF_LIST(), }, }; -- 1.7.2.3