[libvirt] [PATCH] storage: Fix build issue with MOUNT and VGCHANGE commands

John Ferlan posted 1 patch 5 years, 3 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20181213161740.31041-1-jferlan@redhat.com
src/storage/storage_backend_fs.c      |  2 +-
src/storage/storage_backend_logical.c |  2 +-
src/storage/storage_util.c            | 10 ++++++----
src/storage/storage_util.h            |  6 ++++--
tests/storagepoolxml2argvtest.c       | 11 +++++++++--
5 files changed, 21 insertions(+), 10 deletions(-)
[libvirt] [PATCH] storage: Fix build issue with MOUNT and VGCHANGE commands
Posted by John Ferlan 5 years, 3 months ago
Turns out there some build platforms that must not define MOUNT
or VGCHANGE in config.h... So moving the commands from the storage
backend specific module into a common storage_util module causes
issues for those platforms.

So instead of assuming they are there, let's just pass the command
string to the storage util API's from the storage backend specific
code (as would have been successful before).  Also modify the test
to determine whether the MOUNT and/or VGCHANGE doesn't exist and
just define it to (for example) what Fedora has for the path. Could
have just used "mount" and "vgchange" in the call, but that defeats
the purpose of adding the call to virTestClearCommandPath.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---

 Although it is a build breaker I figured I'd wait before pushing to ensure
 no one had heartburn over my selected solution of just restoring the onus
 of the MOUNT and VGCHANGE back to the storage backend specific module as
 opposed to trying to use #ifdef's in the common module and of course the
 testing code.  This just seemed to be the path of least resistance.

 src/storage/storage_backend_fs.c      |  2 +-
 src/storage/storage_backend_logical.c |  2 +-
 src/storage/storage_util.c            | 10 ++++++----
 src/storage/storage_util.h            |  6 ++++--
 tests/storagepoolxml2argvtest.c       | 11 +++++++++--
 5 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index c5e75627b5..37feff79d1 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -330,7 +330,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
     if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
         return -1;
 
-    cmd = virStorageBackendFileSystemMountCmd(def, src);
+    cmd = virStorageBackendFileSystemMountCmd(MOUNT, def, src);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index 12fff651e8..0059e24308 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -52,7 +52,7 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool,
 {
     int ret;
     virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
-    virCommandPtr cmd = virStorageBackendLogicalChangeCmd(def, on);
+    virCommandPtr cmd = virStorageBackendLogicalChangeCmd(VGCHANGE, def, on);
 
     ret = virCommandRun(cmd, NULL);
     virCommandFree(cmd);
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 01f3c93008..a84ee5b600 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -4312,7 +4312,8 @@ virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
 
 
 virCommandPtr
-virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
+virStorageBackendFileSystemMountCmd(const char *cmdstr,
+                                    virStoragePoolDefPtr def,
                                     const char *src)
 {
     /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
@@ -4326,7 +4327,7 @@ virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
                    def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
     virCommandPtr cmd = NULL;
 
-    cmd = virCommandNew(MOUNT);
+    cmd = virCommandNew(cmdstr);
     if (netauto)
         virStorageBackendFileSystemMountNFSArgs(cmd, src, def);
     else if (glusterfs)
@@ -4340,10 +4341,11 @@ virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
 
 
 virCommandPtr
-virStorageBackendLogicalChangeCmd(virStoragePoolDefPtr def,
+virStorageBackendLogicalChangeCmd(const char *cmdstr,
+                                  virStoragePoolDefPtr def,
                                   bool on)
 {
-    return virCommandNewArgList(VGCHANGE,
+    return virCommandNewArgList(cmdstr,
                                 on ? "-aly" : "-aln",
                                 def->source.name,
                                 NULL);
diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h
index a2ef2ac07d..d0cb5d9884 100644
--- a/src/storage/storage_util.h
+++ b/src/storage/storage_util.h
@@ -181,11 +181,13 @@ char *
 virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool);
 
 virCommandPtr
-virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
+virStorageBackendFileSystemMountCmd(const char *cmdstr,
+                                    virStoragePoolDefPtr def,
                                     const char *src);
 
 virCommandPtr
-virStorageBackendLogicalChangeCmd(virStoragePoolDefPtr def,
+virStorageBackendLogicalChangeCmd(const char *cmdstr,
+                                  virStoragePoolDefPtr def,
                                   bool on);
 
 #endif /* __VIR_STORAGE_UTIL_H__ */
diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtest.c
index 534cb21144..196989cb6d 100644
--- a/tests/storagepoolxml2argvtest.c
+++ b/tests/storagepoolxml2argvtest.c
@@ -9,6 +9,13 @@
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
+#ifndef MOUNT
+# define MOUNT "/usr/bin/mount"
+#endif
+
+#ifndef VGCHANGE
+# define VGCHANGE "/usr/sbin/vgchange"
+#endif
 
 static int
 testCompareXMLToArgvFiles(bool shouldFail,
@@ -40,11 +47,11 @@ testCompareXMLToArgvFiles(bool shouldFail,
             goto cleanup;
         }
 
-        cmd = virStorageBackendFileSystemMountCmd(def, src);
+        cmd = virStorageBackendFileSystemMountCmd(MOUNT, def, src);
         break;
 
     case VIR_STORAGE_POOL_LOGICAL:
-        cmd = virStorageBackendLogicalChangeCmd(def, true);
+        cmd = virStorageBackendLogicalChangeCmd(VGCHANGE, def, true);
         break;
 
     case VIR_STORAGE_POOL_DIR:
-- 
2.17.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list