From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=49317 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfBVZ-0006XM-7w for qemu-devel@nongnu.org; Tue, 18 Jan 2011 08:22:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfBVY-00011K-39 for qemu-devel@nongnu.org; Tue, 18 Jan 2011 08:22:01 -0500 Received: from mtagate6.uk.ibm.com ([194.196.100.166]:33263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfBVX-00010m-IQ for qemu-devel@nongnu.org; Tue, 18 Jan 2011 08:22:00 -0500 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate6.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p0IAB8ch025324 for ; Tue, 18 Jan 2011 10:11:08 GMT Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0IAB90l659602 for ; Tue, 18 Jan 2011 10:11:09 GMT Received: from d06av09.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0IAB6lE012300 for ; Tue, 18 Jan 2011 03:11:06 -0700 From: Stefan Hajnoczi Date: Tue, 18 Jan 2011 10:10:42 +0000 Message-Id: <1295345442-16218-4-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1295345442-16218-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1295345442-16218-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2 3/3] 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..f593c46 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, 1, false), DEFINE_PROP_END_OF_LIST(), }, }; -- 1.7.2.3