提交 e6f53e7a 编写于 作者: J John Ferlan

storage: Fix build issue with MOUNT and VGCHANGE commands

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: NJohn Ferlan <jferlan@redhat.com>
上级 fe2bd021
...@@ -328,7 +328,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) ...@@ -328,7 +328,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
if (!(src = virStorageBackendFileSystemGetPoolSource(pool))) if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
return -1; return -1;
cmd = virStorageBackendFileSystemMountCmd(def, src); cmd = virStorageBackendFileSystemMountCmd(MOUNT, def, src);
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
goto cleanup; goto cleanup;
......
...@@ -50,7 +50,7 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool, ...@@ -50,7 +50,7 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool,
{ {
int ret; int ret;
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool); virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virCommandPtr cmd = virStorageBackendLogicalChangeCmd(def, on); virCommandPtr cmd = virStorageBackendLogicalChangeCmd(VGCHANGE, def, on);
ret = virCommandRun(cmd, NULL); ret = virCommandRun(cmd, NULL);
virCommandFree(cmd); virCommandFree(cmd);
......
...@@ -4312,7 +4312,8 @@ virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd, ...@@ -4312,7 +4312,8 @@ virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
virCommandPtr virCommandPtr
virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, virStorageBackendFileSystemMountCmd(const char *cmdstr,
virStoragePoolDefPtr def,
const char *src) const char *src)
{ {
/* 'mount -t auto' doesn't seem to auto determine nfs (or cifs), /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
...@@ -4326,7 +4327,7 @@ virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, ...@@ -4326,7 +4327,7 @@ virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
def->source.format == VIR_STORAGE_POOL_NETFS_CIFS); def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
cmd = virCommandNew(MOUNT); cmd = virCommandNew(cmdstr);
if (netauto) if (netauto)
virStorageBackendFileSystemMountNFSArgs(cmd, src, def); virStorageBackendFileSystemMountNFSArgs(cmd, src, def);
else if (glusterfs) else if (glusterfs)
...@@ -4340,10 +4341,11 @@ virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, ...@@ -4340,10 +4341,11 @@ virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
virCommandPtr virCommandPtr
virStorageBackendLogicalChangeCmd(virStoragePoolDefPtr def, virStorageBackendLogicalChangeCmd(const char *cmdstr,
virStoragePoolDefPtr def,
bool on) bool on)
{ {
return virCommandNewArgList(VGCHANGE, return virCommandNewArgList(cmdstr,
on ? "-aly" : "-aln", on ? "-aly" : "-aln",
def->source.name, def->source.name,
NULL); NULL);
......
...@@ -181,11 +181,13 @@ char * ...@@ -181,11 +181,13 @@ char *
virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool); virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool);
virCommandPtr virCommandPtr
virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, virStorageBackendFileSystemMountCmd(const char *cmdstr,
virStoragePoolDefPtr def,
const char *src); const char *src);
virCommandPtr virCommandPtr
virStorageBackendLogicalChangeCmd(virStoragePoolDefPtr def, virStorageBackendLogicalChangeCmd(const char *cmdstr,
virStoragePoolDefPtr def,
bool on); bool on);
#endif /* __VIR_STORAGE_UTIL_H__ */ #endif /* __VIR_STORAGE_UTIL_H__ */
...@@ -9,6 +9,13 @@ ...@@ -9,6 +9,13 @@
#define VIR_FROM_THIS VIR_FROM_NONE #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 static int
testCompareXMLToArgvFiles(bool shouldFail, testCompareXMLToArgvFiles(bool shouldFail,
...@@ -40,11 +47,11 @@ testCompareXMLToArgvFiles(bool shouldFail, ...@@ -40,11 +47,11 @@ testCompareXMLToArgvFiles(bool shouldFail,
goto cleanup; goto cleanup;
} }
cmd = virStorageBackendFileSystemMountCmd(def, src); cmd = virStorageBackendFileSystemMountCmd(MOUNT, def, src);
break; break;
case VIR_STORAGE_POOL_LOGICAL: case VIR_STORAGE_POOL_LOGICAL:
cmd = virStorageBackendLogicalChangeCmd(def, true); cmd = virStorageBackendLogicalChangeCmd(VGCHANGE, def, true);
break; break;
case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_DIR:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册