From c2dd84b2635bb2d9f7fb0b4ecf1e0274bfd553b1 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 26 Sep 2022 08:50:47 +0100 Subject: [PATCH] daemon: Make vg_scan and lvm_scan no-ops if no LVM feature If the LVM ("lvm2") feature is not available, these calls would fail. Really they ought to be part of the "lvm2" optgroup which would cause the generator to call reply_with_unavailable_feature and generate the correct ENOTSUP error. When vgscan was originally added in 2010 it was not added to the optgroup, and when lvm_scan was later added in 2018 and deprecating vgscan, the same mistake was copied. Before this commit they will try to run the lvm pvscan command which will fail returning some other error (instead of ENOTSUP). Fix this by turning the calls into no-ops if the LVM feature is not available, since scanning for LVM objects when there is no LVM can be safely turned into a no-op. See also https://listman.redhat.com/archives/libguestfs/2022-September/thread.html#29908 Also this updates the common module to pick up a related fix: commit 4b4a5b84647b1496d034bcdff910930ca5f5c486 Author: Richard W.M. Jones Date: Fri Sep 23 15:18:43 2022 +0100 options: Don't attempt to scan LVs if "lvm2" feature is not available Reported-by: Laszlo Ersek Acked-by: Laszlo Ersek Fixes: 55dfcb2211 ("New API: lvm_scan, deprecate vgscan") Fixes: 9752039e52 ("New API: vgscan") --- common | 2 +- daemon/lvm.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/common b/common index 9d4059085..4b4a5b846 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 9d40590852e0755d4719adf97122758fa98e90f9 +Subproject commit 4b4a5b84647b1496d034bcdff910930ca5f5c486 diff --git a/daemon/lvm.c b/daemon/lvm.c index 72c59c3a1..c273946d3 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -651,6 +651,13 @@ do_lvm_scan (int activate) const char *argv[MAX_ARGS]; size_t i = 0; + /* Historically this call was never added to the "lvm2" optgroup. + * Rather than changing that and have the small risk of breaking + * callers, just make it into a no-op if LVM is not available. + */ + if (optgroup_lvm2_available () == 0) + return 0; + ADD_ARG (argv, i, "lvm"); ADD_ARG (argv, i, "pvscan"); ADD_ARG (argv, i, "--cache");