Skip to contentSkip to conversation

hw/usb/dev-storage: add vid/pid/other overrides

PATCH New ~kholia 1 participant 2 messages Jun 4

lore
Share & tools
lore

~kholia

author
#0 lore raw

cover hw/usb/dev-storage: add vid/pid/other overrides

This patch adds the ability to override the Vendor ID, Product ID, Manufacturer and Product strings for USB storage devices via properties.

This allows emulating specific USB storage devices more accurately. When vid or pid is specified, a per-instance USB descriptor is created to hold these values.

This helps with debugging and reversing of various VID+PID restricted applications (e.g. Samsung SecretZone, SanDisk SecureAccess and others).

Dhiru Kholia (1):
hw/usb/dev-storage: add vid/pid/manufacturer/product overrides

 hw/usb/dev-storage-bot.c     |  1 +
 hw/usb/dev-storage-classic.c |  1 +
 hw/usb/dev-storage.c         | 43 ++++++++++++++++++++++++++++++++++++
 include/hw/usb/msd.h         |  3 +++
 4 files changed, 48 insertions(+)
Signature · 1 line
2.49.1
author
#1 lore raw

PATCH 1/1 hw/usb/dev-storage: add vid/pid/manufacturer/product overrides

From: Dhiru Kholia <[email protected]>

This patch adds the ability to override the Vendor ID, Product ID, Manufacturer and Product strings for USB storage devices via properties.

This allows emulating specific USB storage devices more accurately. When vid or pid is specified, a per-instance USB descriptor is created to hold these values.

This helps with debugging and reversing of various VID+PID restricted applications (e.g. Samsung SecretZone, SanDisk SecureAccess and others).

Usage:

-drive file=hdd.img,format=qcow2,if=none,id=disk \
-device usb-storage,drive=disk,vid=0x1,pid=0x2,manufacturer=A,product=B

---
 hw/usb/dev-storage-bot.c     |  1 +
 hw/usb/dev-storage-classic.c |  1 +
 hw/usb/dev-storage.c         | 43 ++++++++++++++++++++++++++++++++++++
 include/hw/usb/msd.h         |  3 +++
 4 files changed, 48 insertions(+)
hw/usb/dev-storage-bot.c +1 -0
index a7f8d80c17..9b8d12958c 100644
@@ -30,6 +30,7 @@ static void usb_msd_bot_realize(USBDevice *dev, Error **errp)
     DeviceState *d = DEVICE(dev);
 
     usb_desc_create_serial(dev);
+    usb_msd_init_desc(dev);
     usb_desc_init(dev);
     dev->flags |= (1 << USB_DEV_FLAG_IS_SCSI_STORAGE);
     if (d->hotplugged) {
hw/usb/dev-storage-classic.c +1 -0
index 977151c4a0..92cf125c8e 100644
@@ -53,6 +53,7 @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
     s->conf.blk = NULL;
 
     usb_desc_create_serial(dev);
+    usb_msd_init_desc(dev);
     usb_desc_init(dev);
     dev->flags |= (1 << USB_DEV_FLAG_IS_SCSI_STORAGE);
     scsi_bus_init(&s->bus, sizeof(s->bus), DEVICE(dev),
hw/usb/dev-storage.c +43 -0

58 lines not on this page · raw message

include/hw/usb/msd.h +3 -0
index 125d2c218f..1920938a20 100644
@@ -41,6 +41,8 @@ struct MSDState {
     bool commandlog;
     SCSIDevice *scsi_dev;
     bool needs_reset;
+    uint16_t vid, pid;
+    char *manufacturer, *product;
 };
 
 typedef struct MSDState MSDState;
@@ -53,3 +55,4 @@ void usb_msd_command_complete(SCSIRequest *req, size_t resid);
 void usb_msd_request_cancelled(SCSIRequest *req);
 void *usb_msd_load_request(QEMUFile *f, SCSIRequest *req);
 void usb_msd_handle_reset(USBDevice *dev);
+void usb_msd_init_desc(USBDevice *dev);
Signature · 1 line
2.49.1