mirror of https://gitee.com/openkylin/libvirt.git
storage: Rework virStorageBackendFileSystemMountCmd
Let's create helpers for each style of command line created. This primarily is easier on the eyes rather than the large multi line if-then-else-else clause used, but may also be useful if in the future any particular pool needs to add to the command line based on pool xml format. Signed-off-by: John Ferlan <jferlan@redhat.com> ACKed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
515aa0c184
commit
b663d4329c
|
@ -4261,6 +4261,56 @@ virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd,
|
||||||
|
const char *src,
|
||||||
|
virStoragePoolDefPtr def)
|
||||||
|
{
|
||||||
|
virCommandAddArgList(cmd, src, def->target.path, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
virStorageBackendFileSystemMountGlusterArgs(virCommandPtr cmd,
|
||||||
|
const char *src,
|
||||||
|
virStoragePoolDefPtr def)
|
||||||
|
{
|
||||||
|
const char *fmt;
|
||||||
|
|
||||||
|
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
|
||||||
|
virCommandAddArgList(cmd, "-t", fmt, src, "-o", "direct-io-mode=1",
|
||||||
|
def->target.path, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
virStorageBackendFileSystemMountCIFSArgs(virCommandPtr cmd,
|
||||||
|
const char *src,
|
||||||
|
virStoragePoolDefPtr def)
|
||||||
|
{
|
||||||
|
const char *fmt;
|
||||||
|
|
||||||
|
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
|
||||||
|
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path,
|
||||||
|
"-o", "guest", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd,
|
||||||
|
const char *src,
|
||||||
|
virStoragePoolDefPtr def)
|
||||||
|
{
|
||||||
|
const char *fmt;
|
||||||
|
|
||||||
|
if (def->type == VIR_STORAGE_POOL_FS)
|
||||||
|
fmt = virStoragePoolFormatFileSystemTypeToString(def->source.format);
|
||||||
|
else
|
||||||
|
fmt = virStoragePoolFormatFileSystemNetTypeToString(def->source.format);
|
||||||
|
virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virCommandPtr
|
virCommandPtr
|
||||||
virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
|
virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def,
|
||||||
const char *src)
|
const char *src)
|
||||||
|
@ -4276,38 +4326,14 @@ 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);
|
||||||
if (netauto)
|
if (netauto)
|
||||||
cmd = virCommandNewArgList(MOUNT,
|
virStorageBackendFileSystemMountNFSArgs(cmd, src, def);
|
||||||
src,
|
|
||||||
def->target.path,
|
|
||||||
NULL);
|
|
||||||
else if (glusterfs)
|
else if (glusterfs)
|
||||||
cmd = virCommandNewArgList(MOUNT,
|
virStorageBackendFileSystemMountGlusterArgs(cmd, src, def);
|
||||||
"-t",
|
|
||||||
virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
|
|
||||||
src,
|
|
||||||
"-o",
|
|
||||||
"direct-io-mode=1",
|
|
||||||
def->target.path,
|
|
||||||
NULL);
|
|
||||||
else if (cifsfs)
|
else if (cifsfs)
|
||||||
cmd = virCommandNewArgList(MOUNT,
|
virStorageBackendFileSystemMountCIFSArgs(cmd, src, def);
|
||||||
"-t",
|
|
||||||
virStoragePoolFormatFileSystemNetTypeToString(def->source.format),
|
|
||||||
src,
|
|
||||||
def->target.path,
|
|
||||||
"-o",
|
|
||||||
"guest",
|
|
||||||
NULL);
|
|
||||||
else
|
else
|
||||||
cmd = virCommandNewArgList(MOUNT,
|
virStorageBackendFileSystemMountDefaultArgs(cmd, src, def);
|
||||||
"-t",
|
|
||||||
(def->type == VIR_STORAGE_POOL_FS ?
|
|
||||||
virStoragePoolFormatFileSystemTypeToString(def->source.format) :
|
|
||||||
virStoragePoolFormatFileSystemNetTypeToString(def->source.format)),
|
|
||||||
src,
|
|
||||||
def->target.path,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue