Skip to contentSkip to conversation

usb: mtp filesharing

PATCH New Gerd Hoffmann 1 participant 3 messages Mar 19, 2014

lore
Share & tools
lore
#0 lore raw

cover usb: mtp filesharing

Hi,

Lingering in my git branch for ages. Now I've finally managed to nail the "burns lots of cpu time" issue, which makes this useful enouth that I think it should go in now, even though there are limitations.

cheers,
Gerd

Gerd Hoffmann (2):
usb: add CompatibleID support to msos
usb: mtp filesharing

 default-configs/usb.mak |    1 +
 hw/usb/Makefile.objs    |    4 +
 hw/usb/desc-msos.c      |    6 +-
 hw/usb/desc.h           |    1 +
 hw/usb/dev-mtp.c        | 1100 +++++++++++++++++++++++++++++++++++++++++++++++
 trace-events            |   21 +
 6 files changed, 1132 insertions(+), 1 deletion(-)
 create mode 100644 hw/usb/dev-mtp.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/2 usb: add CompatibleID support to msos

---
 hw/usb/desc-msos.c | 6 +++++-
 hw/usb/desc.h      | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)
hw/usb/desc-msos.c +5 -1
index ed8d62c..334d1ae 100644
@@ -44,7 +44,7 @@ typedef struct msos_compat_hdr {
 typedef struct msos_compat_func {
     uint8_t  bFirstInterfaceNumber;
     uint8_t  reserved_1;
-    uint8_t  compatibleId[8];
+    char     compatibleId[8];
     uint8_t  subCompatibleId[8];
     uint8_t  reserved_2[6];
 } QEMU_PACKED msos_compat_func;
@@ -59,6 +59,10 @@ static int usb_desc_msos_compat(const USBDesc *desc, uint8_t *dest)
     func = (void *)(dest + length);
     func->bFirstInterfaceNumber = 0;
     func->reserved_1 = 0x01;
+    if (desc->msos->CompatibleID) {
+        snprintf(func->compatibleId, sizeof(func->compatibleId),
+                 "%s", desc->msos->CompatibleID);
+    }
     length += sizeof(*func);
     count++;
 
hw/usb/desc.h +1 -0
index 2b4fcda..8e8db03 100644
@@ -184,6 +184,7 @@ struct USBDescOther {
 };
 
 struct USBDescMSOS {
+    const char                *CompatibleID;
     const wchar_t             *Label;
     bool                      SelectiveSuspendEnabled;
 };
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/2 usb: mtp filesharing

In reply to Gerd Hoffmann

Implementation of a USB Media Transfer Device device for easy filesharing. Read-only. No access control inside qemu, it will happily export any file it is able to open to the guest, i.e. standard unix access rights for the qemu process apply.

---
 default-configs/usb.mak |    1 +
 hw/usb/Makefile.objs    |    4 +
 hw/usb/dev-mtp.c        | 1100 +++++++++++++++++++++++++++++++++++++++++++++++
 trace-events            |   21 +
 4 files changed, 1126 insertions(+)
 create mode 100644 hw/usb/dev-mtp.c
default-configs/usb.mak +1 -0
index 1bf9075..73d8489 100644
@@ -1,6 +1,7 @@
 CONFIG_USB_TABLET_WACOM=y
 CONFIG_USB_STORAGE_BOT=y
 CONFIG_USB_STORAGE_UAS=y
+CONFIG_USB_STORAGE_MTP=y
 CONFIG_USB_SMARTCARD=y
 CONFIG_USB_AUDIO=y
 CONFIG_USB_SERIAL=y
hw/usb/Makefile.objs +4 -0
index 97b4575..654aaf5 100644
@@ -26,6 +26,10 @@ common-obj-y                          += ccid-card-passthru.o
 common-obj-$(CONFIG_SMARTCARD_NSS)    += ccid-card-emulated.o
 endif
 
+ifeq ($(CONFIG_LINUX),y)
+common-obj-$(CONFIG_USB_STORAGE_MTP)  += dev-mtp.o
+endif
+
 # usb redirection
 common-obj-$(CONFIG_USB_REDIR) += redirect.o quirks.o
 
hw/usb/dev-mtp.c new file +1100 -0

1,100 lines not on this page · raw message

trace-events +21 -0
index 002c260..439f6d5 100644
@@ -433,6 +433,27 @@ usb_uas_tmf_abort_task(int addr, uint16_t tag, uint16_t task_tag) "dev %d, tag 0
 usb_uas_tmf_logical_unit_reset(int addr, uint16_t tag, int lun) "dev %d, tag 0x%x, lun %d"
 usb_uas_tmf_unsupported(int addr, uint16_t tag, uint32_t function) "dev %d, tag 0x%x, function 0x%x"
 
+# hw/usb/dev-mtp.c
+usb_mtp_reset(int addr) "dev %d"
+usb_mtp_command(int dev, uint16_t code, uint32_t trans, uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4) "dev %d, code 0x%x, trans 0x%x, args 0x%x, 0x%x, 0x%x, 0x%x, 0x%x"
+usb_mtp_success(int dev, uint32_t trans, uint32_t arg0, uint32_t arg1) "dev %d, trans 0x%x, args 0x%x, 0x%x"
+usb_mtp_error(int dev, uint16_t code, uint32_t trans, uint32_t arg0, uint32_t arg1) "dev %d, code 0x%x, trans 0x%x, args 0x%x, 0x%x"
+usb_mtp_data_in(int dev, uint32_t trans, uint32_t len) "dev %d, trans 0x%x, len %d"
+usb_mtp_data_out(int dev, uint32_t trans, uint32_t len) "dev %d, trans 0x%x, len %d"
+usb_mtp_xfer(int dev, uint32_t ep, uint32_t dlen, uint32_t plen) "dev %d, ep %d, %d/%d"
+usb_mtp_nak(int dev, uint32_t ep) "dev %d, ep %d"
+usb_mtp_stall(int dev, const char *reason) "dev %d, reason: %s"
+usb_mtp_op_get_device_info(int dev) "dev %d"
+usb_mtp_op_open_session(int dev) "dev %d"
+usb_mtp_op_close_session(int dev) "dev %d"
+usb_mtp_op_get_storage_ids(int dev) "dev %d"
+usb_mtp_op_get_storage_info(int dev) "dev %d"
+usb_mtp_op_get_num_objects(int dev, uint32_t handle, const char *path) "dev %d, handle 0x%x, path %s"
+usb_mtp_op_get_object_handles(int dev, uint32_t handle, const char *path) "dev %d, handle 0x%x, path %s"
+usb_mtp_op_get_object_info(int dev, uint32_t handle, const char *path) "dev %d, handle 0x%x, path %s"
+usb_mtp_op_get_object(int dev, uint32_t handle, const char *path) "dev %d, handle 0x%x, path %s"
+usb_mtp_op_get_partial_object(int dev, uint32_t handle, const char *path, uint32_t offset, uint32_t length) "dev %d, handle 0x%x, path %s, off %d, len %d"
+
 # hw/usb/host-libusb.c
 usb_host_open_started(int bus, int addr) "dev %d:%d"
 usb_host_open_success(int bus, int addr) "dev %d:%d"
Signature · 1 line
1.8.3.1