Capture and raise qemu-img stderr
resolves: RHEL-92239 Ignore btrfs snapshots of roots resolves: RHEL-93109
This commit is contained in:
parent
1dc8960b91
commit
f1a7701278
@ -0,0 +1,56 @@
|
|||||||
|
From 406588d4a00a42b49278669e34643a9ecfa7ecd3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Cole Robinson <crobinso@redhat.com>
|
||||||
|
Date: Tue, 20 May 2025 13:33:26 -0400
|
||||||
|
Subject: [PATCH] lib: flatten `extra` output when external command fails
|
||||||
|
|
||||||
|
Otherwise string output looks quite awkward
|
||||||
|
|
||||||
|
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
||||||
|
---
|
||||||
|
lib/errors.c | 15 +++++++++++----
|
||||||
|
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/errors.c b/lib/errors.c
|
||||||
|
index 148d8da27..c391a6d84 100644
|
||||||
|
--- a/lib/errors.c
|
||||||
|
+++ b/lib/errors.c
|
||||||
|
@@ -536,18 +536,25 @@ guestfs_int_external_command_failed (guestfs_h *g, int status,
|
||||||
|
{
|
||||||
|
const size_t len = 80 + strlen (cmd_name);
|
||||||
|
CLEANUP_FREE char *status_string = safe_malloc (g, len);
|
||||||
|
+ CLEANUP_FREE char *extra_clean = NULL;
|
||||||
|
|
||||||
|
guestfs_int_exit_status_to_string (status, cmd_name, status_string, len);
|
||||||
|
|
||||||
|
+ if (extra) {
|
||||||
|
+ extra_clean = guestfs_int_replace_string(extra, "\n", " ");
|
||||||
|
+ if (!extra_clean)
|
||||||
|
+ g->abort_cb ();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (g->verbose) {
|
||||||
|
- if (!extra)
|
||||||
|
+ if (!extra_clean)
|
||||||
|
error (g, _("%s, see debug messages above"), status_string);
|
||||||
|
else
|
||||||
|
error (g, _("%s: %s: %s, see debug messages above"),
|
||||||
|
- cmd_name, extra, status_string);
|
||||||
|
+ cmd_name, extra_clean, status_string);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
- if (!extra)
|
||||||
|
+ if (!extra_clean)
|
||||||
|
error (g, _("%s.\n"
|
||||||
|
"To see full error messages you may need to enable debugging.\n"
|
||||||
|
DEBUG_ADVICE),
|
||||||
|
@@ -556,6 +563,6 @@ guestfs_int_external_command_failed (guestfs_h *g, int status,
|
||||||
|
error (g, _("%s: %s: %s.\n"
|
||||||
|
"To see full error messages you may need to enable debugging.\n"
|
||||||
|
DEBUG_ADVICE),
|
||||||
|
- cmd_name, extra, status_string);
|
||||||
|
+ cmd_name, extra_clean, status_string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.47.1
|
||||||
|
|
67
0002-lib-create.c-Capture-and-raise-qemu-img-stderr.patch
Normal file
67
0002-lib-create.c-Capture-and-raise-qemu-img-stderr.patch
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
From 606aa1d1822260905a5dd8a47f29a66652168f22 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Cole Robinson <crobinso@redhat.com>
|
||||||
|
Date: Mon, 19 May 2025 13:42:12 -0400
|
||||||
|
Subject: [PATCH] lib/create.c: Capture and raise qemu-img stderr
|
||||||
|
|
||||||
|
https://issues.redhat.com/browse/RHEL-92239
|
||||||
|
|
||||||
|
After this, output looks like
|
||||||
|
|
||||||
|
$ ./run guestfish --ro --format=qcow2 -a test.img
|
||||||
|
libguestfs: error: qemu-img: qemu-img: /home/crobinso/src/libguestfs/tmp/libguestfsFlxnb0/overlay1.qcow2: Image is not in qcow2 format Could not open backing image. : qemu-img exited with error status 1.
|
||||||
|
To see full error messages you may need to enable debugging.
|
||||||
|
...
|
||||||
|
|
||||||
|
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
||||||
|
---
|
||||||
|
lib/create.c | 17 ++++++++++++++++-
|
||||||
|
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/lib/create.c b/lib/create.c
|
||||||
|
index b660d11e5..72b4632c8 100644
|
||||||
|
--- a/lib/create.c
|
||||||
|
+++ b/lib/create.c
|
||||||
|
@@ -241,6 +241,14 @@ is_power_of_2 (unsigned v)
|
||||||
|
return v && ((v & (v - 1)) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void
|
||||||
|
+read_all (guestfs_h *g, void *retv, const char *buf, size_t len)
|
||||||
|
+{
|
||||||
|
+ char **ret = retv;
|
||||||
|
+
|
||||||
|
+ *ret = safe_strndup (g, buf, len);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Check for valid backing format. Allow any C<^[[:alnum]]+$>
|
||||||
|
* (in C locale), but limit the length to something reasonable.
|
||||||
|
@@ -256,6 +264,7 @@ disk_create_qcow2 (guestfs_h *g, const char *filename, int64_t size,
|
||||||
|
{
|
||||||
|
const char *backingformat = NULL;
|
||||||
|
CLEANUP_FREE char *backingformat_free = NULL;
|
||||||
|
+ CLEANUP_FREE char *cmd_stdout = NULL;
|
||||||
|
const char *preallocation = NULL;
|
||||||
|
const char *compat = NULL;
|
||||||
|
int clustersize = -1;
|
||||||
|
@@ -351,10 +360,16 @@ disk_create_qcow2 (guestfs_h *g, const char *filename, int64_t size,
|
||||||
|
if (size >= 0)
|
||||||
|
guestfs_int_cmd_add_arg_format (cmd, "%" PRIi64, size);
|
||||||
|
|
||||||
|
+ guestfs_int_cmd_clear_capture_errors (cmd);
|
||||||
|
+ guestfs_int_cmd_set_stderr_to_stdout (cmd);
|
||||||
|
+ guestfs_int_cmd_set_stdout_callback (cmd, read_all, &cmd_stdout,
|
||||||
|
+ CMD_STDOUT_FLAG_WHOLE_BUFFER);
|
||||||
|
r = guestfs_int_cmd_run (cmd);
|
||||||
|
if (!WIFEXITED (r) || WEXITSTATUS (r) != 0) {
|
||||||
|
- guestfs_int_external_command_failed (g, r, "qemu-img", filename);
|
||||||
|
+ guestfs_int_external_command_failed (g, r, "qemu-img", cmd_stdout);
|
||||||
|
return -1;
|
||||||
|
+ } else {
|
||||||
|
+ debug (g, cmd_stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
--
|
||||||
|
2.47.1
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
From 833e5e63b3d03c9500727e167f5d7287dfeafbd2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 22 May 2025 09:48:14 +0100
|
||||||
|
Subject: [PATCH] lib/create.c: Fix string passed to printf-like function
|
||||||
|
|
||||||
|
create.c: In function 'disk_create_qcow2':
|
||||||
|
create.c:372:5: error: format not a string literal and no format arguments [-Werror=format-security]
|
||||||
|
372 | debug (g, cmd_stdout);
|
||||||
|
| ^~~~~
|
||||||
|
|
||||||
|
Fixes: commit 606aa1d1822260905a5dd8a47f29a66652168f22
|
||||||
|
---
|
||||||
|
lib/create.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/lib/create.c b/lib/create.c
|
||||||
|
index 72b4632c8..67631132f 100644
|
||||||
|
--- a/lib/create.c
|
||||||
|
+++ b/lib/create.c
|
||||||
|
@@ -369,7 +369,7 @@ disk_create_qcow2 (guestfs_h *g, const char *filename, int64_t size,
|
||||||
|
guestfs_int_external_command_failed (g, r, "qemu-img", cmd_stdout);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
- debug (g, cmd_stdout);
|
||||||
|
+ debug (g, "%s", cmd_stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
--
|
||||||
|
2.47.1
|
||||||
|
|
138
0004-daemon-listfs.ml-Add-more-debugging-to-list_filesyst.patch
Normal file
138
0004-daemon-listfs.ml-Add-more-debugging-to-list_filesyst.patch
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
From 7ac190ed20e7a2f8e664a4994e5508f050ed12e8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 22 May 2025 10:03:32 +0100
|
||||||
|
Subject: [PATCH] daemon/listfs.ml: Add more debugging to list_filesystems
|
||||||
|
|
||||||
|
This function is used from other parts of the daemon, especially for
|
||||||
|
example with inspection. However it was difficult to follow exactly
|
||||||
|
what filesystems it was returning because of insufficient debugging
|
||||||
|
information.
|
||||||
|
---
|
||||||
|
daemon/listfs.ml | 49 ++++++++++++++++++++++++++++++++++++++++--------
|
||||||
|
1 file changed, 41 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/daemon/listfs.ml b/daemon/listfs.ml
|
||||||
|
index 0139e927d..4c90796ef 100644
|
||||||
|
--- a/daemon/listfs.ml
|
||||||
|
+++ b/daemon/listfs.ml
|
||||||
|
@@ -25,12 +25,17 @@ open Std_utils
|
||||||
|
* contain filesystems, so we filter them out.
|
||||||
|
*)
|
||||||
|
let rec list_filesystems () =
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: start\n";
|
||||||
|
+
|
||||||
|
let has_lvm2 = Optgroups.lvm2_available () in
|
||||||
|
let has_ldm = Optgroups.ldm_available () in
|
||||||
|
|
||||||
|
- let ret = ref [] in
|
||||||
|
+ let ret : (Mountable.t * string) list ref = ref [] in
|
||||||
|
|
||||||
|
(* Devices. *)
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: checking for whole devices\n";
|
||||||
|
let devices = Devsparts.list_devices () in
|
||||||
|
let devices = List.filter is_not_partitioned_device devices in
|
||||||
|
List.iter (check_with_vfs_type ret) devices;
|
||||||
|
@@ -39,32 +44,44 @@ let rec list_filesystems () =
|
||||||
|
* We include these in case any encrypted devices contain
|
||||||
|
* direct filesystems.
|
||||||
|
*)
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: checking for device-mapper devices\n";
|
||||||
|
let devices = Lvm_dm.list_dm_devices () in
|
||||||
|
let devices = List.filter is_not_partitioned_device devices in
|
||||||
|
List.iter (check_with_vfs_type ret) devices;
|
||||||
|
|
||||||
|
(* Partitions. *)
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: checking for partitions\n";
|
||||||
|
let partitions = Devsparts.list_partitions () in
|
||||||
|
let partitions = List.filter is_partition_can_hold_filesystem partitions in
|
||||||
|
List.iter (check_with_vfs_type ret) partitions;
|
||||||
|
|
||||||
|
(* MD. *)
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: checking for MD devices\n";
|
||||||
|
let mds = Md.list_md_devices () in
|
||||||
|
let mds = List.filter is_not_partitioned_device mds in
|
||||||
|
List.iter (check_with_vfs_type ret) mds;
|
||||||
|
|
||||||
|
(* LVM. *)
|
||||||
|
if has_lvm2 then (
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: checking for logical volumes\n";
|
||||||
|
let lvs = Lvm.lvs () in
|
||||||
|
List.iter (check_with_vfs_type ret) lvs
|
||||||
|
);
|
||||||
|
|
||||||
|
(* LDM. *)
|
||||||
|
if has_ldm then (
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: checking for LDM volumes\n";
|
||||||
|
let ldmvols = Ldm.list_ldm_volumes () in
|
||||||
|
List.iter (check_with_vfs_type ret) ldmvols
|
||||||
|
);
|
||||||
|
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: finished\n%!";
|
||||||
|
!ret
|
||||||
|
|
||||||
|
(* Look to see if device can directly contain filesystem (RHBZ#590167).
|
||||||
|
@@ -146,12 +163,15 @@ and check_with_vfs_type ret device =
|
||||||
|
try Blkid.vfs_type mountable
|
||||||
|
with exn ->
|
||||||
|
if verbose () then
|
||||||
|
- eprintf "check_with_vfs_type: %s: %s\n"
|
||||||
|
+ eprintf "list_filesystems: check_with_vfs_type: %s: %s\n"
|
||||||
|
device (Printexc.to_string exn);
|
||||||
|
"" in
|
||||||
|
|
||||||
|
- if vfs_type = "" then
|
||||||
|
- List.push_back ret (mountable, "unknown")
|
||||||
|
+ if vfs_type = "" then (
|
||||||
|
+ let fs = mountable, "unknown" in
|
||||||
|
+ debug_one_fs fs;
|
||||||
|
+ List.push_back ret fs
|
||||||
|
+ )
|
||||||
|
|
||||||
|
(* Ignore all "*_member" strings. In libblkid these are returned
|
||||||
|
* for things which are members of some RAID or LVM set, most
|
||||||
|
@@ -179,17 +199,30 @@ and check_with_vfs_type ret device =
|
||||||
|
) vols in
|
||||||
|
|
||||||
|
(* whole device = default volume *)
|
||||||
|
- List.push_back ret (mountable, vfs_type);
|
||||||
|
+ let fs = mountable, vfs_type in
|
||||||
|
+ debug_one_fs fs;
|
||||||
|
+ List.push_back ret fs;
|
||||||
|
|
||||||
|
(* subvolumes *)
|
||||||
|
List.push_back_list ret (
|
||||||
|
List.map (
|
||||||
|
fun { Structs.btrfssubvolume_path = path } ->
|
||||||
|
let mountable = Mountable.of_btrfsvol device path in
|
||||||
|
- (mountable, "btrfs")
|
||||||
|
+ let fs = mountable, "btrfs" in
|
||||||
|
+ debug_one_fs fs;
|
||||||
|
+ fs
|
||||||
|
) vols
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
- else
|
||||||
|
- List.push_back ret (mountable, vfs_type)
|
||||||
|
+ (* Otherwise it's some other VFS type. *)
|
||||||
|
+ else (
|
||||||
|
+ let fs = mountable, vfs_type in
|
||||||
|
+ debug_one_fs fs;
|
||||||
|
+ List.push_back ret fs
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+and debug_one_fs (mountable, vfs_type) =
|
||||||
|
+ if verbose () then
|
||||||
|
+ eprintf "list_filesystems: adding %S, %S\n"
|
||||||
|
+ (Mountable.to_string mountable) vfs_type
|
||||||
|
--
|
||||||
|
2.47.1
|
||||||
|
|
129
0005-daemon-inspect.ml-Pipeline-style-when-mapping-and-fi.patch
Normal file
129
0005-daemon-inspect.ml-Pipeline-style-when-mapping-and-fi.patch
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
From b2ec671abd026fbe9fff94d48f51282df555b71d Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Sun, 25 May 2025 09:29:18 +0100
|
||||||
|
Subject: [PATCH] daemon/inspect.ml: Pipeline style when mapping and filtering
|
||||||
|
filesystems
|
||||||
|
|
||||||
|
No actual change in the functionality, just make it clear that this is
|
||||||
|
a pipeline of transformations on the list of filesystems.
|
||||||
|
---
|
||||||
|
daemon/inspect.ml | 69 +++++++++++++++++++++++++++++------------------
|
||||||
|
1 file changed, 43 insertions(+), 26 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/daemon/inspect.ml b/daemon/inspect.ml
|
||||||
|
index 2c027b7c5..03174ef23 100644
|
||||||
|
--- a/daemon/inspect.ml
|
||||||
|
+++ b/daemon/inspect.ml
|
||||||
|
@@ -29,40 +29,43 @@ let re_primary_partition = PCRE.compile "^/dev/(?:h|s|v)d.[1234]$"
|
||||||
|
let rec inspect_os () =
|
||||||
|
Mount_utils.umount_all ();
|
||||||
|
|
||||||
|
- (* Iterate over all detected filesystems. Inspect each one in turn. *)
|
||||||
|
- let fses = Listfs.list_filesystems () in
|
||||||
|
+ (* Start with the full list of filesystems, and inspect each one
|
||||||
|
+ * in turn to determine its possible role (root, /usr, homedir, etc.)
|
||||||
|
+ * Then we filter out duplicates and merge some filesystems into
|
||||||
|
+ * others.
|
||||||
|
+ *)
|
||||||
|
|
||||||
|
let fses =
|
||||||
|
+ Listfs.list_filesystems () |>
|
||||||
|
+
|
||||||
|
+ (* Filter out those filesystems which are mountable, and inspect
|
||||||
|
+ * each one to find its possible role. Converts the list to
|
||||||
|
+ * type: {!Inspect_types.fs} list.
|
||||||
|
+ *)
|
||||||
|
List.filter_map (
|
||||||
|
fun (mountable, vfs_type) ->
|
||||||
|
Inspect_fs.check_for_filesystem_on mountable vfs_type
|
||||||
|
- ) fses in
|
||||||
|
- if verbose () then (
|
||||||
|
- eprintf "inspect_os: fses:\n";
|
||||||
|
- List.iter (fun fs -> eprintf "%s" (string_of_fs fs)) fses;
|
||||||
|
- flush stderr
|
||||||
|
- );
|
||||||
|
+ ) |>
|
||||||
|
|
||||||
|
- (* The OS inspection information for CoreOS are gathered by inspecting
|
||||||
|
- * multiple filesystems. Gather all the inspected information in the
|
||||||
|
- * inspect_fs struct of the root filesystem.
|
||||||
|
- *)
|
||||||
|
- eprintf "inspect_os: collect_coreos_inspection_info\n%!";
|
||||||
|
- let fses = collect_coreos_inspection_info fses in
|
||||||
|
+ debug_list_of_filesystems |>
|
||||||
|
|
||||||
|
- (* Check if the same filesystem was listed twice as root in fses.
|
||||||
|
- * This may happen for the *BSD root partition where an MBR partition
|
||||||
|
- * is a shadow of the real root partition probably /dev/sda5
|
||||||
|
- *)
|
||||||
|
- eprintf "inspect_os: check_for_duplicated_bsd_root\n%!";
|
||||||
|
- let fses = check_for_duplicated_bsd_root fses in
|
||||||
|
+ (* The OS inspection information for CoreOS are gathered by inspecting
|
||||||
|
+ * multiple filesystems. Gather all the inspected information in the
|
||||||
|
+ * inspect_fs struct of the root filesystem.
|
||||||
|
+ *)
|
||||||
|
+ collect_coreos_inspection_info |>
|
||||||
|
|
||||||
|
- (* For Linux guests with a separate /usr filesystem, merge some of the
|
||||||
|
- * inspected information in that partition to the inspect_fs struct
|
||||||
|
- * of the root filesystem.
|
||||||
|
- *)
|
||||||
|
- eprintf "inspect_os: collect_linux_inspection_info\n%!";
|
||||||
|
- let fses = collect_linux_inspection_info fses in
|
||||||
|
+ (* Check if the same filesystem was listed twice as root in fses.
|
||||||
|
+ * This may happen for the *BSD root partition where an MBR partition
|
||||||
|
+ * is a shadow of the real root partition probably /dev/sda5
|
||||||
|
+ *)
|
||||||
|
+ check_for_duplicated_bsd_root |>
|
||||||
|
+
|
||||||
|
+ (* For Linux guests with a separate /usr filesystem, merge some of the
|
||||||
|
+ * inspected information in that partition to the inspect_fs struct
|
||||||
|
+ * of the root filesystem.
|
||||||
|
+ *)
|
||||||
|
+ collect_linux_inspection_info in
|
||||||
|
|
||||||
|
(* Save what we found in a global variable. *)
|
||||||
|
Inspect_types.inspect_fses := fses;
|
||||||
|
@@ -75,11 +78,21 @@ let rec inspect_os () =
|
||||||
|
*)
|
||||||
|
inspect_get_roots ()
|
||||||
|
|
||||||
|
+and debug_list_of_filesystems fses =
|
||||||
|
+ if verbose () then (
|
||||||
|
+ eprintf "inspect_os: fses:\n";
|
||||||
|
+ List.iter (fun fs -> eprintf "%s" (string_of_fs fs)) fses;
|
||||||
|
+ flush stderr
|
||||||
|
+ );
|
||||||
|
+ fses
|
||||||
|
+
|
||||||
|
(* Traverse through the filesystem list and find out if it contains
|
||||||
|
* the [/] and [/usr] filesystems of a CoreOS image. If this is the
|
||||||
|
* case, sum up all the collected information on the root fs.
|
||||||
|
*)
|
||||||
|
and collect_coreos_inspection_info fses =
|
||||||
|
+ eprintf "inspect_os: collect_coreos_inspection_info\n%!";
|
||||||
|
+
|
||||||
|
(* Split the list into CoreOS root(s), CoreOS usr(s), and
|
||||||
|
* everything else.
|
||||||
|
*)
|
||||||
|
@@ -137,6 +150,8 @@ and collect_coreos_inspection_info fses =
|
||||||
|
* [http://www.freebsd.org/doc/handbook/disk-organization.html])
|
||||||
|
*)
|
||||||
|
and check_for_duplicated_bsd_root fses =
|
||||||
|
+ eprintf "inspect_os: check_for_duplicated_bsd_root\n%!";
|
||||||
|
+
|
||||||
|
try
|
||||||
|
let is_primary_partition = function
|
||||||
|
| { m_type = (MountablePath | MountableBtrfsVol _) } -> false
|
||||||
|
@@ -183,6 +198,8 @@ and check_for_duplicated_bsd_root fses =
|
||||||
|
* root fs from the respective [/usr] filesystems.
|
||||||
|
*)
|
||||||
|
and collect_linux_inspection_info fses =
|
||||||
|
+ eprintf "inspect_os: collect_linux_inspection_info\n%!";
|
||||||
|
+
|
||||||
|
List.map (
|
||||||
|
function
|
||||||
|
| { role = RoleRoot { distro = Some DISTRO_COREOS } } as root -> root
|
||||||
|
--
|
||||||
|
2.47.1
|
||||||
|
|
33
0006-daemon-inspect.ml-Fix-comment.patch
Normal file
33
0006-daemon-inspect.ml-Fix-comment.patch
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
From ebaba4322191ae65e5cd49f274291e63f8f46bef Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Sun, 25 May 2025 09:43:43 +0100
|
||||||
|
Subject: [PATCH] daemon/inspect.ml: Fix comment
|
||||||
|
|
||||||
|
Back in commit 8289aa1ad6 ("New APIs for guest inspection.", 2010)
|
||||||
|
when inspection was first added, we did inspection in the library, so
|
||||||
|
it was accurate to say that inspection information was stored "in the
|
||||||
|
handle". Much later, in commit 394d11be49 and commit 3a00c4d179
|
||||||
|
(2017) we moved inspection to the daemon, but left the comment the
|
||||||
|
same.
|
||||||
|
|
||||||
|
Fixes: commit 3a00c4d179554f8c1299368a02b43370b6aa7af3
|
||||||
|
---
|
||||||
|
daemon/inspect.ml | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/daemon/inspect.ml b/daemon/inspect.ml
|
||||||
|
index 03174ef23..5c6be3193 100644
|
||||||
|
--- a/daemon/inspect.ml
|
||||||
|
+++ b/daemon/inspect.ml
|
||||||
|
@@ -70,7 +70,7 @@ let rec inspect_os () =
|
||||||
|
(* Save what we found in a global variable. *)
|
||||||
|
Inspect_types.inspect_fses := fses;
|
||||||
|
|
||||||
|
- (* At this point we have, in the handle, a list of all filesystems
|
||||||
|
+ (* At this point we have (in a global variable) a list of all filesystems
|
||||||
|
* found and data about each one. Now we assemble the list of
|
||||||
|
* filesystems which are root devices.
|
||||||
|
*
|
||||||
|
--
|
||||||
|
2.47.1
|
||||||
|
|
98
0007-inspection-Ignore-btrfs-snapshots-of-roots.patch
Normal file
98
0007-inspection-Ignore-btrfs-snapshots-of-roots.patch
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
From 8f5e4f07ba92d42506072520260d96ce77d58e21 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Thu, 22 May 2025 11:32:11 +0100
|
||||||
|
Subject: [PATCH] inspection: Ignore btrfs snapshots of roots
|
||||||
|
|
||||||
|
In SLES guests in particular, btrfs snapshots seem to be used to allow
|
||||||
|
rollback of changes made to the filesystem. Dozens of snapshots may
|
||||||
|
be present. Technically therefore these are multi-boot guests. The
|
||||||
|
libguestfs concept of "root" of an operating system does not map well
|
||||||
|
to this, causing problems in virt-inspector and virt-v2v.
|
||||||
|
|
||||||
|
In this commit we ignore these duplicates. The test is quite narrow
|
||||||
|
to avoid false positives: We only remove a duplicate if it is a member
|
||||||
|
of a parent device, both are btrfs, both the snapshot and parent have
|
||||||
|
a root role, and the roles are otherwise very similar.
|
||||||
|
|
||||||
|
There may be a case for reporting this information separately in
|
||||||
|
future, although it's also easy to find this out now. For example,
|
||||||
|
when you see a btrfs root device returned by inspect_os, you could
|
||||||
|
call btrfs_subvolume_list on the root device to list the snapshots.
|
||||||
|
|
||||||
|
Fixes: https://issues.redhat.com/browse/RHEL-93109
|
||||||
|
---
|
||||||
|
daemon/inspect.ml | 51 +++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 51 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/daemon/inspect.ml b/daemon/inspect.ml
|
||||||
|
index 5c6be3193..84571f582 100644
|
||||||
|
--- a/daemon/inspect.ml
|
||||||
|
+++ b/daemon/inspect.ml
|
||||||
|
@@ -61,6 +61,11 @@ let rec inspect_os () =
|
||||||
|
*)
|
||||||
|
check_for_duplicated_bsd_root |>
|
||||||
|
|
||||||
|
+ (* Check if the root filesystems are duplicated by btrfs snapshots.
|
||||||
|
+ * This happens especially for SLES guests.
|
||||||
|
+ *)
|
||||||
|
+ check_for_duplicated_btrfs_snapshots_of_root |>
|
||||||
|
+
|
||||||
|
(* For Linux guests with a separate /usr filesystem, merge some of the
|
||||||
|
* inspected information in that partition to the inspect_fs struct
|
||||||
|
* of the root filesystem.
|
||||||
|
@@ -190,6 +195,52 @@ and check_for_duplicated_bsd_root fses =
|
||||||
|
with
|
||||||
|
Not_found -> fses
|
||||||
|
|
||||||
|
+(* Check for the case where the root filesystem gets duplicated by
|
||||||
|
+ * btrfs snapshots. Ignore the snapshots in this case (RHEL-93109).
|
||||||
|
+ *)
|
||||||
|
+and check_for_duplicated_btrfs_snapshots_of_root fses =
|
||||||
|
+ eprintf "inspect_os: check_for_duplicated_btrfs_snapshots_of_root\n%!";
|
||||||
|
+
|
||||||
|
+ let fs_is_btrfs_snapshot_of_root = function
|
||||||
|
+ (* Is this filesystem a btrfs snapshot of root? *)
|
||||||
|
+ | { fs_location =
|
||||||
|
+ { mountable = { m_type = MountableBtrfsVol _; m_device = dev1 };
|
||||||
|
+ vfs_type = "btrfs" };
|
||||||
|
+ role = RoleRoot inspection_data1 } as fs1 ->
|
||||||
|
+ (* Return true if it duplicates the parent device which has
|
||||||
|
+ * a root role.
|
||||||
|
+ *)
|
||||||
|
+ List.exists (function
|
||||||
|
+ | { fs_location =
|
||||||
|
+ { mountable = { m_type = MountableDevice; m_device = dev2 };
|
||||||
|
+ vfs_type = "btrfs" };
|
||||||
|
+ role = RoleRoot inspection_data2 }
|
||||||
|
+ when dev1 = dev2 ->
|
||||||
|
+ (* Check the roles are similar enough. In my test I saw
|
||||||
|
+ * that /etc/fstab was slightly different in the parent
|
||||||
|
+ * and snapshot. It's possible this is because the snapshot
|
||||||
|
+ * was created during installation, but it's not clear.
|
||||||
|
+ *)
|
||||||
|
+ let similar =
|
||||||
|
+ inspection_data1.os_type = inspection_data2.os_type &&
|
||||||
|
+ inspection_data1.distro = inspection_data2.distro &&
|
||||||
|
+ inspection_data1.product_name = inspection_data2.product_name &&
|
||||||
|
+ inspection_data1.version = inspection_data2.version in
|
||||||
|
+ if verbose () && similar then
|
||||||
|
+ eprintf "check_for_duplicated_btrfs_snapshots_of_root: \
|
||||||
|
+ dropping duplicate btrfs snapshot:\n%s\n"
|
||||||
|
+ (string_of_fs fs1);
|
||||||
|
+ similar
|
||||||
|
+ | _ -> false
|
||||||
|
+ ) fses
|
||||||
|
+
|
||||||
|
+ (* Anything else is not a snapshot. *)
|
||||||
|
+ | _ -> false
|
||||||
|
+ in
|
||||||
|
+
|
||||||
|
+ (* Filter out the duplicates. *)
|
||||||
|
+ List.filter (Fun.negate fs_is_btrfs_snapshot_of_root) fses
|
||||||
|
+
|
||||||
|
(* Traverse through the filesystem list and find out if it contains
|
||||||
|
* the [/] and [/usr] filesystems of a Linux image (but not CoreOS,
|
||||||
|
* for which there is a separate [collect_coreos_inspection_info]).
|
||||||
|
--
|
||||||
|
2.47.1
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
From b0fc7db87d8df6116e720e3b1b1b46959c33b5e5 Mon Sep 17 00:00:00 2001
|
From 891abf8771e740a55c73bd6a8c33560ae33424ba Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Mon, 29 Jul 2013 14:47:56 +0100
|
Date: Mon, 29 Jul 2013 14:47:56 +0100
|
||||||
Subject: [PATCH] RHEL: Disable unsupported remote drive protocols
|
Subject: [PATCH] RHEL: Disable unsupported remote drive protocols
|
@ -1,4 +1,4 @@
|
|||||||
From dbda58cdce4de84e125131b7bbcfc4da76809e24 Mon Sep 17 00:00:00 2001
|
From 0e8418540d94edada4356e9a7e8ec8d0508211ae Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Tue, 7 Jul 2015 09:28:03 -0400
|
Date: Tue, 7 Jul 2015 09:28:03 -0400
|
||||||
Subject: [PATCH] RHEL: Reject use of libguestfs-winsupport features except for
|
Subject: [PATCH] RHEL: Reject use of libguestfs-winsupport features except for
|
@ -1,4 +1,4 @@
|
|||||||
From d03f04787725666f2589a135b46cdcc1bcaf4ab5 Mon Sep 17 00:00:00 2001
|
From 0bdd0f7b652560f7ff82feb730324adf0c4cccfd Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Tue, 13 May 2025 17:28:25 +0100
|
Date: Tue, 13 May 2025 17:28:25 +0100
|
||||||
Subject: [PATCH] RHEL: appliance/init: Run depmod -a to rebuild kernel module
|
Subject: [PATCH] RHEL: appliance/init: Run depmod -a to rebuild kernel module
|
@ -42,7 +42,7 @@ Summary: Access and modify virtual machine disk images
|
|||||||
Name: libguestfs
|
Name: libguestfs
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Version: 1.55.13
|
Version: 1.55.13
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: LGPL-2.1-or-later
|
License: LGPL-2.1-or-later
|
||||||
|
|
||||||
# Build only for architectures that have a kernel
|
# Build only for architectures that have a kernel
|
||||||
@ -80,9 +80,16 @@ Source8: copy-patches.sh
|
|||||||
# https://github.com/libguestfs/libguestfs/commits/rhel-10.1
|
# https://github.com/libguestfs/libguestfs/commits/rhel-10.1
|
||||||
|
|
||||||
# Patches.
|
# Patches.
|
||||||
Patch0001: 0001-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch
|
Patch0001: 0001-lib-flatten-extra-output-when-external-command-fails.patch
|
||||||
Patch0002: 0002-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
|
Patch0002: 0002-lib-create.c-Capture-and-raise-qemu-img-stderr.patch
|
||||||
Patch0003: 0003-RHEL-appliance-init-Run-depmod-a-to-rebuild-kernel-m.patch
|
Patch0003: 0003-lib-create.c-Fix-string-passed-to-printf-like-functi.patch
|
||||||
|
Patch0004: 0004-daemon-listfs.ml-Add-more-debugging-to-list_filesyst.patch
|
||||||
|
Patch0005: 0005-daemon-inspect.ml-Pipeline-style-when-mapping-and-fi.patch
|
||||||
|
Patch0006: 0006-daemon-inspect.ml-Fix-comment.patch
|
||||||
|
Patch0007: 0007-inspection-Ignore-btrfs-snapshots-of-roots.patch
|
||||||
|
Patch0008: 0008-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch
|
||||||
|
Patch0009: 0009-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
|
||||||
|
Patch0010: 0010-RHEL-appliance-init-Run-depmod-a-to-rebuild-kernel-m.patch
|
||||||
|
|
||||||
BuildRequires: autoconf, automake, libtool, gettext-devel
|
BuildRequires: autoconf, automake, libtool, gettext-devel
|
||||||
|
|
||||||
@ -1070,7 +1077,7 @@ rm ocaml/html/.gitignore
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Tue May 20 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.55.13-1
|
* Tue May 27 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.55.13-2
|
||||||
- Rebase to libguestfs 1.55.12
|
- Rebase to libguestfs 1.55.12
|
||||||
resolves: RHEL-81733
|
resolves: RHEL-81733
|
||||||
- Include host kernel information in libguestfs debugging output
|
- Include host kernel information in libguestfs debugging output
|
||||||
@ -1086,6 +1093,10 @@ rm ocaml/html/.gitignore
|
|||||||
resolves: RHEL-91936
|
resolves: RHEL-91936
|
||||||
- Add e2fsck forceno flag
|
- Add e2fsck forceno flag
|
||||||
resolves: RHEL-92599
|
resolves: RHEL-92599
|
||||||
|
- Capture and raise qemu-img stderr
|
||||||
|
resolves: RHEL-92239
|
||||||
|
- Ignore btrfs snapshots of roots
|
||||||
|
resolves: RHEL-93109
|
||||||
|
|
||||||
* Tue Nov 26 2024 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-5
|
* Tue Nov 26 2024 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-5
|
||||||
- Rebase to libguestfs 1.54.0
|
- Rebase to libguestfs 1.54.0
|
||||||
|
Loading…
Reference in New Issue
Block a user