mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
storage: stop hardcoding LVM tool paths
Change the meson 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. Reviewed-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
1 parent
68d17f641a
commit
4f8b9e731a
3 files changed
+19
-39
No files matched your search
+5
-25
@@ -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@_prog'.format(name),
|
||||
find_program(name, required: get_option('storage_lvm'), dirs: libvirt_sbin_path)
|
||||
)
|
||||
if not get_variable('@0@_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@_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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user