[libvirt] [PATCH] Fix pool-create for netfs format 'auto'

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

 



Trying to pool-create a netfs pool with the format type
'auto' (as in, to autodetect the format) runs the command

mount -t auto munged-source-path

'-t auto' seems to do its job for regular file systems, but
actually fails with nfs or cifs (I assume anything that required
an external mount program). Strangely though, the command

mount munged-source-path

will do the right thing.

The attached patch fixes the generated command to work in
the above case, fully removing the '-t type' piece if auto
is specified for a netfs pool.

I tested the intended case, as well as regular fs pools
format=auto, and netfs format=nfs, and all seemed to work
fine.

Thanks,
Cole
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
index 9926493..f195034 100644
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -487,7 +487,23 @@ static int
 virStorageBackendFileSystemMount(virConnectPtr conn,
                                  virStoragePoolObjPtr pool) {
     char *src;
-    const char *mntargv[] = {
+    const char **mntargv;
+
+    /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
+     *  while plain 'mount' does. We have to craft separate argvs to
+     *  accommodate this */
+    int netauto = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
+                   pool->def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
+    int source_index;
+
+    const char *netfs_auto_argv[] = {
+        MOUNT,
+        NULL, /* source path */
+        pool->def->target.path,
+        NULL,
+    };
+
+    const char *fs_argv[] =  {
         MOUNT,
         "-t",
         pool->def->type == VIR_STORAGE_POOL_FS ?
@@ -495,10 +511,20 @@ virStorageBackendFileSystemMount(virConnectPtr conn,
                                                       pool->def->source.format) :
         virStorageBackendFileSystemNetPoolFormatToString(conn,
                                                          pool->def->source.format),
-        NULL, /* Fill in shortly - careful not to add extra fields before this */
+        NULL, /* Fill in shortly - careful not to add extra fields
+                 before this */
         pool->def->target.path,
         NULL,
     };
+
+    if (netauto) {
+        mntargv = netfs_auto_argv;
+        source_index = 1;
+    } else {
+        mntargv = fs_argv;
+        source_index = 3;
+    }
+
     int ret;
 
     if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
@@ -543,7 +569,7 @@ virStorageBackendFileSystemMount(virConnectPtr conn,
             return -1;
         }
     }
-    mntargv[3] = src;
+    mntargv[source_index] = src;
 
     if (virRun(conn, (char**)mntargv, NULL) < 0) {
         VIR_FREE(src);
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]