From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=32800 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhTg9-0001Ll-8W for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:10:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhTg6-0007Zg-ML for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:10:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhTg6-0007Zb-FV for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:10:22 -0500 From: Kevin Wolf Date: Mon, 24 Jan 2011 22:10:51 +0100 Message-Id: <1295903452-18017-23-git-send-email-kwolf@redhat.com> In-Reply-To: <1295903452-18017-1-git-send-email-kwolf@redhat.com> References: <1295903452-18017-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 22/23] 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: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: 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 Signed-off-by: Kevin Wolf --- 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 ccdf8ff..11722c7 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -51,6 +51,7 @@ typedef struct { SCSIBus bus; BlockConf conf; SCSIDevice *scsi_dev; + uint32_t removable; int result; /* For async completion. */ USBPacket *packet; @@ -515,7 +516,7 @@ static int usb_msd_initfn(USBDevice *dev) usb_desc_init(dev); 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; } @@ -607,6 +608,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