1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

storage: logical: use two cmd vars in GetPoolSources

Do not mix manual and automatic freeing.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2021-12-10 17:17:13 +01:00
parent 4c5bcaf027
commit 42823e67dc

View File

@ -477,23 +477,23 @@ virStorageBackendLogicalGetPoolSources(virStoragePoolSourceList *sourceList)
int vars[] = { int vars[] = {
2 2
}; };
g_autoptr(virCommand) cmd = NULL; g_autoptr(virCommand) vgcmd = NULL;
g_autoptr(virCommand) pvcmd = NULL;
/* /*
* NOTE: ignoring errors here; this is just to "touch" any logical volumes * NOTE: ignoring errors here; this is just to "touch" any logical volumes
* that might be hanging around, so if this fails for some reason, the * that might be hanging around, so if this fails for some reason, the
* worst that happens is that scanning doesn't pick everything up * worst that happens is that scanning doesn't pick everything up
*/ */
cmd = virCommandNew(VGSCAN); vgcmd = virCommandNew(VGSCAN);
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(vgcmd, NULL) < 0)
VIR_WARN("Failure when running vgscan to refresh physical volumes"); VIR_WARN("Failure when running vgscan to refresh physical volumes");
virCommandFree(cmd);
cmd = virCommandNewArgList(PVS, pvcmd = virCommandNewArgList(PVS,
"--noheadings", "--noheadings",
"-o", "pv_name,vg_name", "-o", "pv_name,vg_name",
NULL, NULL); NULL, NULL);
return virCommandRunRegex(cmd, 1, regexes, vars, return virCommandRunRegex(pvcmd, 1, regexes, vars,
virStorageBackendLogicalFindPoolSourcesFunc, virStorageBackendLogicalFindPoolSourcesFunc,
sourceList, "pvs", NULL); sourceList, "pvs", NULL);
} }