aboutsummaryrefslogtreecommitdiff
path: root/hw/usb
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2021-06-24 12:38:33 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-07-09 18:21:33 +0200
commitb7b2a60b01036c6e7c21e7dc41829c7b5f6011b4 (patch)
treed5feef8607825f503e319186917f1d9d46abd6be /hw/usb
parentf0e48cbd791e88728fcea65366dbb6d9a63a16e5 (diff)
downloadqemu-b7b2a60b01036c6e7c21e7dc41829c7b5f6011b4.zip
qemu-b7b2a60b01036c6e7c21e7dc41829c7b5f6011b4.tar.gz
qemu-b7b2a60b01036c6e7c21e7dc41829c7b5f6011b4.tar.bz2
usb: drop usb_host_dev_is_scsi_storage hook
Introduce an usb device flag instead, set it when usb-host looks at the device descriptors anyway. Also set it for emulated storage devices, for consistency. Add an inline helper function to check the flag. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Jose R. Ziviani <jziviani@suse.de> Message-Id: <20210624103836.2382472-32-kraxel@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/usb')
-rw-r--r--hw/usb/dev-storage-bot.c1
-rw-r--r--hw/usb/dev-storage-classic.c1
-rw-r--r--hw/usb/dev-uas.c1
-rw-r--r--hw/usb/host-libusb.c36
-rw-r--r--hw/usb/host-stub.c5
5 files changed, 10 insertions, 34 deletions
diff --git a/hw/usb/dev-storage-bot.c b/hw/usb/dev-storage-bot.c
index 6aad026..68ebaca 100644
--- a/hw/usb/dev-storage-bot.c
+++ b/hw/usb/dev-storage-bot.c
@@ -32,6 +32,7 @@ static void usb_msd_bot_realize(USBDevice *dev, Error **errp)
usb_desc_create_serial(dev);
usb_desc_init(dev);
+ dev->flags |= (1 << USB_DEV_FLAG_IS_SCSI_STORAGE);
if (d->hotplugged) {
s->dev.auto_attach = 0;
}
diff --git a/hw/usb/dev-storage-classic.c b/hw/usb/dev-storage-classic.c
index 00cb34b..3d017a4 100644
--- a/hw/usb/dev-storage-classic.c
+++ b/hw/usb/dev-storage-classic.c
@@ -64,6 +64,7 @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
usb_desc_create_serial(dev);
usb_desc_init(dev);
+ dev->flags |= (1 << USB_DEV_FLAG_IS_SCSI_STORAGE);
scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(dev),
&usb_msd_scsi_info_storage, NULL);
scsi_dev = scsi_bus_legacy_add_drive(&s->bus, blk, 0, !!s->removable,
diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c
index d2bd85d..2630562 100644
--- a/hw/usb/dev-uas.c
+++ b/hw/usb/dev-uas.c
@@ -926,6 +926,7 @@ static void usb_uas_realize(USBDevice *dev, Error **errp)
QTAILQ_INIT(&uas->requests);
uas->status_bh = qemu_bh_new(usb_uas_send_status_bh, uas);
+ dev->flags |= (1 << USB_DEV_FLAG_IS_SCSI_STORAGE);
scsi_bus_new(&uas->bus, sizeof(uas->bus), DEVICE(dev),
&usb_uas_scsi_info, NULL);
}
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 2518306f..e6d21aa 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -770,6 +770,13 @@ static void usb_host_speed_compat(USBHostDevice *s)
for (i = 0; i < conf->bNumInterfaces; i++) {
for (a = 0; a < conf->interface[i].num_altsetting; a++) {
intf = &conf->interface[i].altsetting[a];
+
+ if (intf->bInterfaceClass == LIBUSB_CLASS_MASS_STORAGE &&
+ intf->bInterfaceSubClass == 6) { /* SCSI */
+ udev->flags |= (1 << USB_DEV_FLAG_IS_SCSI_STORAGE);
+ break;
+ }
+
for (e = 0; e < intf->bNumEndpoints; e++) {
endp = &intf->endpoint[e];
type = endp->bmAttributes & 0x3;
@@ -1893,35 +1900,6 @@ static void usb_host_auto_check(void *unused)
timer_mod(usb_auto_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 2000);
}
-/**
- * Check whether USB host device has a USB mass storage SCSI interface
- */
-bool usb_host_dev_is_scsi_storage(USBDevice *ud)
-{
- USBHostDevice *uhd = USB_HOST_DEVICE(ud);
- struct libusb_config_descriptor *conf;
- const struct libusb_interface_descriptor *intf;
- bool is_scsi_storage = false;
- int i;
-
- if (!uhd || libusb_get_active_config_descriptor(uhd->dev, &conf) != 0) {
- return false;
- }
-
- for (i = 0; i < conf->bNumInterfaces; i++) {
- intf = &conf->interface[i].altsetting[ud->altsetting[i]];
- if (intf->bInterfaceClass == LIBUSB_CLASS_MASS_STORAGE &&
- intf->bInterfaceSubClass == 6) { /* 6 means SCSI */
- is_scsi_storage = true;
- break;
- }
- }
-
- libusb_free_config_descriptor(conf);
-
- return is_scsi_storage;
-}
-
void hmp_info_usbhost(Monitor *mon, const QDict *qdict)
{
libusb_device **devs = NULL;
diff --git a/hw/usb/host-stub.c b/hw/usb/host-stub.c
index 80809ce..bbe69ba 100644
--- a/hw/usb/host-stub.c
+++ b/hw/usb/host-stub.c
@@ -38,8 +38,3 @@ void hmp_info_usbhost(Monitor *mon, const QDict *qdict)
{
monitor_printf(mon, "USB host devices not supported\n");
}
-
-bool usb_host_dev_is_scsi_storage(USBDevice *ud)
-{
- return false;
-}