[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH libvirt 4/6] qemu: add support for MTP filesystem



Generate the qemu command line option:

-device 'usb-mtp,root=$SRC,desc=$TARGET'

from the definition XML:

    <filesystem type='mtp'>
      <source dir='$SRC'/>
      <target name='$TARGET'/>
    </filesystem>

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1121781

Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>
---
 src/qemu/qemu_command.c | 53 ++++++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 716be0a..ad5b318 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3955,12 +3955,6 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
     const char *driver = qemuDomainFSDriverTypeToString(fs->fsdriver);
     const char *wrpolicy = virDomainFSWrpolicyTypeToString(fs->wrpolicy);
 
-    if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("only supports mount filesystem type"));
-        goto error;
-    }
-
     if (!driver) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Filesystem driver type not supported"));
@@ -4029,22 +4023,26 @@ qemuBuildFSDevStr(virDomainDefPtr def,
 {
     virBuffer opt = VIR_BUFFER_INITIALIZER;
 
-    if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("can only passthrough directories"));
-        goto error;
-    }
+    if (fs->type == VIR_DOMAIN_FS_TYPE_MOUNT) {
+        virBufferAddLit(&opt, "virtio-9p-pci");
+        virBufferAsprintf(&opt, ",id=%s", fs->info.alias);
+        virBufferAsprintf(&opt, ",fsdev=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
+        virBufferAsprintf(&opt, ",mount_tag=%s", fs->dst);
 
-    virBufferAddLit(&opt, "virtio-9p-pci");
-    virBufferAsprintf(&opt, ",id=%s", fs->info.alias);
-    virBufferAsprintf(&opt, ",fsdev=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
-    virBufferAsprintf(&opt, ",mount_tag=%s", fs->dst);
-
-    if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
-        goto error;
+        if (qemuBuildDeviceAddressStr(&opt, def, &fs->info, qemuCaps) < 0)
+            goto error;
 
-    if (virBufferCheckError(&opt) < 0)
+        if (virBufferCheckError(&opt) < 0)
+            goto error;
+    }
+    else if (fs->type == VIR_DOMAIN_FS_TYPE_MTP) {
+        virBufferAddLit(&opt, "usb-mtp");
+        virBufferAsprintf(&opt, ",root=%s,desc=%s", fs->src, fs->dst);
+    } else {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("unsupported filesystem type"));
         goto error;
+    }
 
     return virBufferContentAndReset(&opt);
 
@@ -8310,11 +8308,20 @@ qemuBuildCommandLine(virConnectPtr conn,
             char *optstr;
             virDomainFSDefPtr fs = def->fss[i];
 
-            virCommandAddArg(cmd, "-fsdev");
-            if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
+            if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT &&
+                fs->type != VIR_DOMAIN_FS_TYPE_MTP) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("only supports mount or mtp filesystem type"));
                 goto error;
-            virCommandAddArg(cmd, optstr);
-            VIR_FREE(optstr);
+            }
+
+            if (fs->type == VIR_DOMAIN_FS_TYPE_MOUNT) {
+                virCommandAddArg(cmd, "-fsdev");
+                if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
+                    goto error;
+                virCommandAddArg(cmd, optstr);
+                VIR_FREE(optstr);
+            }
 
             virCommandAddArg(cmd, "-device");
             if (!(optstr = qemuBuildFSDevStr(def, fs, qemuCaps)))
-- 
1.9.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]