When guestfs_lvm_canonical_lv_name was called with a /dev/dm* or
/dev/mapper* name which was not an LV then a noisy error would be
printed. This would typically have happened with encrypted disks, and
now happens very noticably when inspecting Windows BitLocker-
encrypted guests.
Using the modified error behaviour of this API from the previous
commit we can now hide that error in that specific case. (Even in
this case the underlying error message still gets logged in debug
output).
---
lib/canonical-name.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/canonical-name.c b/lib/canonical-name.c
index 052bbf12c..e0c7918b4 100644
--- a/lib/canonical-name.c
+++ b/lib/canonical-name.c
@@ -46,9 +46,14 @@ guestfs_impl_canonical_device_name (guestfs_h *g, const char *device)
}
else if (STRPREFIX (device, "/dev/mapper/") ||
STRPREFIX (device, "/dev/dm-")) {
- /* XXX hide errors */
+ guestfs_push_error_handler (g, NULL, NULL);
ret = guestfs_lvm_canonical_lv_name (g, device);
- if (ret == NULL)
+ guestfs_pop_error_handler (g);
+ /* EINVAL is expected if the device is somelike a LUKS- or
+ * BitLocker-encrypted volume, so simply return the original
+ * name in that case.
+ */
+ if (ret == NULL && guestfs_last_errno (g) == EINVAL)
ret = safe_strdup (g, device);
}
else
--
2.27.0