From: Daniel P. Berrangé <berrange(a)redhat.com>
Change the mesonm rules to always enable the LVM driver if on a
Linux host, unless the meson options say not to.
The virCommand APIs will return suitable runtime errors if the
tools are not installed.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
meson.build | 30 +++++----------------------
src/locking/lock_driver_lockd.c | 4 ++--
src/storage/storage_backend_logical.c | 24 ++++++++++-----------
3 files changed, 19 insertions(+), 39 deletions(-)
diff --git a/meson.build b/meson.build
index 68b955a02c..e23777819d 100644
--- a/meson.build
+++ b/meson.build
@@ -1826,32 +1826,12 @@ if conf.has('WITH_LIBVIRTD')
error('Need libiscsi for iscsi-direct storage driver')
endif
- if not get_option('storage_lvm').disabled()
+ if not get_option('storage_lvm').disabled() and host_machine.system() ==
'linux'
lvm_enable = true
- lvm_progs = [
- 'pvcreate', 'vgcreate', 'lvcreate',
- 'pvremove', 'vgremove', 'lvremove',
- 'lvchange', 'vgchange', 'vgscan',
- 'pvs', 'vgs', 'lvs',
- ]
- foreach name : lvm_progs
- set_variable(
- '@0(a)_prog'.format(name),
- find_program(name, required: get_option('storage_lvm'), dirs:
libvirt_sbin_path)
- )
- if not get_variable('@0(a)_prog'.format(name)).found()
- lvm_enable = false
- endif
- endforeach
-
- if lvm_enable
- use_storage = true
- conf.set('WITH_STORAGE_LVM', 1)
-
- foreach name : lvm_progs
- conf.set_quoted(name.to_upper(),
get_variable('@0(a)_prog'.format(name)).full_path())
- endforeach
- endif
+ use_storage = true
+ conf.set('WITH_STORAGE_LVM', 1)
+ elif get_option('storage_lvm').enabled()
+ error('Linux host needed for LVM storage driver')
endif
if not get_option('storage_mpath').disabled() and host_machine.system() ==
'linux' and devmapper_dep.found()
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index 0b6c720477..a3bb285eec 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -433,7 +433,7 @@ static int virLockManagerLockDaemonNew(virLockManager *lock,
}
-#ifdef LVS
+#ifdef __linux__
static int
virLockManagerGetLVMKey(const char *path,
char **key)
@@ -446,7 +446,7 @@ virLockManagerGetLVMKey(const char *path,
int ret = -1;
g_autoptr(virCommand) cmd = NULL;
- cmd = virCommandNewArgList(LVS, "--noheadings",
+ cmd = virCommandNewArgList("lvs", "--noheadings",
"--unbuffered", "--nosuffix",
"--options", "uuid", path,
NULL
diff --git a/src/storage/storage_backend_logical.c
b/src/storage/storage_backend_logical.c
index 6acbc37f18..51e9337820 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -49,7 +49,7 @@ virStorageBackendLogicalSetActive(virStoragePoolObj *pool,
g_autoptr(virCommand) cmd = NULL;
int ret;
- cmd = virStorageBackendLogicalChangeCmd(VGCHANGE, def, on);
+ cmd = virStorageBackendLogicalChangeCmd("vgchange", def, on);
virObjectUnlock(pool);
ret = virCommandRun(cmd, NULL);
@@ -70,7 +70,7 @@ virStorageBackendLogicalRemoveDevice(const char *path)
{
g_autoptr(virCommand) cmd = NULL;
- cmd = virCommandNewArgList(PVREMOVE, path, NULL);
+ cmd = virCommandNewArgList("pvremove", path, NULL);
if (virCommandRun(cmd, NULL) < 0)
VIR_INFO("Failed to pvremove logical device '%s'", path);
}
@@ -100,7 +100,7 @@ virStorageBackendLogicalInitializeDevice(const char *path)
* Initialize the physical volume because vgcreate is not
* clever enough todo this for us :-(
*/
- pvcmd = virCommandNewArgList(PVCREATE, path, NULL);
+ pvcmd = virCommandNewArgList("pvcreate", path, NULL);
return virCommandRun(pvcmd, NULL);
}
@@ -380,7 +380,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObj *pool,
};
g_autoptr(virCommand) cmd = NULL;
- cmd = virCommandNewArgList(LVS,
+ cmd = virCommandNewArgList("lvs",
"--separator", "#",
"--noheadings",
"--units", "b",
@@ -483,11 +483,11 @@ virStorageBackendLogicalGetPoolSources(virStoragePoolSourceList
*sourceList)
* that might be hanging around, so if this fails for some reason, the
* worst that happens is that scanning doesn't pick everything up
*/
- vgcmd = virCommandNew(VGSCAN);
+ vgcmd = virCommandNew("vgscan");
if (virCommandRun(vgcmd, NULL) < 0)
VIR_WARN("Failure when running vgscan to refresh physical volumes");
- pvcmd = virCommandNewArgList(PVS,
+ pvcmd = virCommandNewArgList("pvs",
"--noheadings",
"-o", "pv_name,vg_name",
NULL, NULL);
@@ -658,7 +658,7 @@ virStorageBackendLogicalBuildPool(virStoragePoolObj *pool,
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE,
cleanup);
- vgcmd = virCommandNewArgList(VGCREATE, def->source.name, NULL);
+ vgcmd = virCommandNewArgList("vgcreate", def->source.name, NULL);
for (i = 0; i < def->source.ndevice; i++) {
const char *path = def->source.devices[i].path;
@@ -720,7 +720,7 @@ virStorageBackendLogicalRefreshPool(virStoragePoolObj *pool)
if (virStorageBackendLogicalFindLVs(pool, NULL) < 0)
return -1;
- cmd = virCommandNewArgList(VGS,
+ cmd = virCommandNewArgList("vgs",
"--separator", ":",
"--noheadings",
"--units", "b",
@@ -769,7 +769,7 @@ virStorageBackendLogicalDeletePool(virStoragePoolObj *pool,
virCheckFlags(0, -1);
/* first remove the volume group */
- cmd = virCommandNewArgList(VGREMOVE,
+ cmd = virCommandNewArgList("vgremove",
"-f", def->source.name,
NULL);
if (virCommandRun(cmd, NULL) < 0)
@@ -795,8 +795,8 @@ virStorageBackendLogicalDeleteVol(virStoragePoolObj *pool
G_GNUC_UNUSED,
virWaitForDevices();
- lvchange_cmd = virCommandNewArgList(LVCHANGE, "-aln", vol->target.path,
NULL);
- lvremove_cmd = virCommandNewArgList(LVREMOVE, "-f", vol->target.path,
NULL);
+ lvchange_cmd = virCommandNewArgList("lvchange", "-aln",
vol->target.path, NULL);
+ lvremove_cmd = virCommandNewArgList("lvremove", "-f",
vol->target.path, NULL);
if (virCommandRun(lvremove_cmd, NULL) < 0) {
if (virCommandRun(lvchange_cmd, NULL) < 0) {
@@ -825,7 +825,7 @@ virStorageBackendLogicalLVCreate(virStorageVolDef *vol,
return -1;
}
- cmd = virCommandNewArgList(LVCREATE,
+ cmd = virCommandNewArgList("lvcreate",
"--name", vol->name,
NULL);
virCommandAddArg(cmd, "-L");
--
2.49.0