Ignore blank disks in Windows drive mapping
resolves: RHEL-108803
This commit is contained in:
parent
74238a92e0
commit
ca8b41709b
@ -0,0 +1,74 @@
|
||||
From cbd75c201754ff1c27911e63c92a82e1bcd21661 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 14 Aug 2025 14:56:47 +0100
|
||||
Subject: [PATCH] daemon/inspect_fs_windows.ml: Add debugging for MBR drive
|
||||
mappings
|
||||
|
||||
The function 'map_registry_disk_blob_gpt' immediately below this one
|
||||
has a debugging statement. Add the equivalent to the function
|
||||
'map_registry_disk_blob_mbr'.
|
||||
|
||||
The output looks like:
|
||||
|
||||
map_registry_disk_blob_mbr: searching for MBR disk ID 31 32 33 34
|
||||
map_registry_disk_blob_mbr: searching for MBR partition offset 00 00 00 10 00 00 00 00
|
||||
|
||||
(cherry picked from commit e18bd72c8edce1f7227ea625031df1f36db1a793)
|
||||
---
|
||||
daemon/inspect_fs_windows.ml | 8 ++++++++
|
||||
daemon/utils.ml | 4 ++++
|
||||
daemon/utils.mli | 4 ++++
|
||||
3 files changed, 16 insertions(+)
|
||||
|
||||
diff --git a/daemon/inspect_fs_windows.ml b/daemon/inspect_fs_windows.ml
|
||||
index 6537481e..18893e86 100644
|
||||
--- a/daemon/inspect_fs_windows.ml
|
||||
+++ b/daemon/inspect_fs_windows.ml
|
||||
@@ -376,6 +376,10 @@ and map_registry_disk_blob_mbr devices blob =
|
||||
* disk with this disk ID.
|
||||
*)
|
||||
let diskid = String.sub blob 0 4 in
|
||||
+ if verbose () then
|
||||
+ eprintf "map_registry_disk_blob_mbr: searching for MBR disk ID %s\n%!"
|
||||
+ (hex_of_string diskid);
|
||||
+
|
||||
let device =
|
||||
List.find (
|
||||
fun dev ->
|
||||
@@ -388,6 +392,10 @@ and map_registry_disk_blob_mbr devices blob =
|
||||
* partition byte offset from Parted.part_list.
|
||||
*)
|
||||
let offset = String.sub blob 4 8 in
|
||||
+ if verbose () then
|
||||
+ eprintf "map_registry_disk_blob_mbr: searching for MBR partition offset \
|
||||
+ %s\n%!"
|
||||
+ (hex_of_string offset);
|
||||
let offset = int_of_le64 offset in
|
||||
let partitions = Parted.part_list device in
|
||||
let partition =
|
||||
diff --git a/daemon/utils.ml b/daemon/utils.ml
|
||||
index 3b5c957c..bfaab3b0 100644
|
||||
--- a/daemon/utils.ml
|
||||
+++ b/daemon/utils.ml
|
||||
@@ -296,3 +296,7 @@ let parse_key_value_strings ?unquote lines =
|
||||
match unquote with
|
||||
| None -> lines
|
||||
| Some f -> List.map (fun (k, v) -> (k, f v)) lines
|
||||
+
|
||||
+let hex_of_string s =
|
||||
+ let bytes = String.map_chars (fun c -> sprintf "%02x" (Char.code c)) s in
|
||||
+ String.concat " " bytes
|
||||
diff --git a/daemon/utils.mli b/daemon/utils.mli
|
||||
index e721f28f..250f2f81 100644
|
||||
--- a/daemon/utils.mli
|
||||
+++ b/daemon/utils.mli
|
||||
@@ -121,5 +121,9 @@ val parse_key_value_strings : ?unquote:(string -> string) -> string list -> (str
|
||||
it is applied on the values as unquote function. Empty lines,
|
||||
or that start with a comment character [#], are ignored. *)
|
||||
|
||||
+val hex_of_string : string -> string
|
||||
+(** Return a string as a list of hex bytes.
|
||||
+ Use this for debugging msgs only. *)
|
||||
+
|
||||
(**/**)
|
||||
val get_verbose_flag : unit -> bool
|
@ -0,0 +1,31 @@
|
||||
From 3720994fca930e5cd685e6380ac5cd3068081bb3 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 14 Aug 2025 14:57:45 +0100
|
||||
Subject: [PATCH] daemon/inspect_fs_windows.ml: Add debugging when we start
|
||||
registry analysis
|
||||
|
||||
Add some debugging when we begin the process of analyzing the Windows
|
||||
registry of a guest.
|
||||
|
||||
(cherry picked from commit 5c7e15cfae7c91bb2e5685d657695a2d87d88bcd)
|
||||
---
|
||||
daemon/inspect_fs_windows.ml | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/daemon/inspect_fs_windows.ml b/daemon/inspect_fs_windows.ml
|
||||
index 18893e86..f4e3b998 100644
|
||||
--- a/daemon/inspect_fs_windows.ml
|
||||
+++ b/daemon/inspect_fs_windows.ml
|
||||
@@ -207,6 +207,12 @@ and check_windows_registry systemroot data =
|
||||
if Is.is_file system_hive then Some system_hive else None in
|
||||
data.windows_system_hive <- system_hive;
|
||||
|
||||
+ if verbose () then
|
||||
+ eprintf "check_windows_registry: software hive: %s\n\
|
||||
+ check_windows_registry: system hive: %s\n%!"
|
||||
+ (Option.value ~default:"None" software_hive)
|
||||
+ (Option.value ~default:"None" system_hive);
|
||||
+
|
||||
match software_hive, system_hive with
|
||||
| None, _ | Some _, None -> ()
|
||||
| Some software_hive, Some system_hive ->
|
@ -0,0 +1,76 @@
|
||||
From 98d94d847f9041df79c446d5c149bca626545eb0 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 14 Aug 2025 15:17:59 +0100
|
||||
Subject: [PATCH] daemon/inspect_fs_windows.ml: Ignore blank disks in drive
|
||||
mapping
|
||||
|
||||
If HKLM\System\MountedDevices references a blank disk, then when we
|
||||
try to search for the actual backing device we will get an error from
|
||||
parted:
|
||||
|
||||
parted: /dev/sdb: parted exited with status 1: Error: /dev/sdb: unrecognised disk label: Invalid argument
|
||||
|
||||
Just ignore these errors instead of failing inspection.
|
||||
|
||||
Fixes: https://issues.redhat.com/browse/RHEL-108803
|
||||
Reported-by: Ameen Barakat
|
||||
Thanks: Ming Xie
|
||||
(cherry picked from commit 1c00248ac191ab167f54103197a33bb60c3da67d)
|
||||
---
|
||||
daemon/inspect_fs_windows.ml | 35 ++++++++++++++++++++++++++---------
|
||||
1 file changed, 26 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/daemon/inspect_fs_windows.ml b/daemon/inspect_fs_windows.ml
|
||||
index f4e3b998..5d92ca0f 100644
|
||||
--- a/daemon/inspect_fs_windows.ml
|
||||
+++ b/daemon/inspect_fs_windows.ml
|
||||
@@ -389,8 +389,18 @@ and map_registry_disk_blob_mbr devices blob =
|
||||
let device =
|
||||
List.find (
|
||||
fun dev ->
|
||||
- Parted.part_get_parttype dev = "msdos" &&
|
||||
+ try
|
||||
+ Parted.part_get_parttype dev = "msdos" &&
|
||||
pread dev 4 0x01b8 = diskid
|
||||
+ with Unix.Unix_error (EINVAL, "parted", msg) ->
|
||||
+ (* Errors can happen here if the disk is empty. Just ignore
|
||||
+ * them. It means the drive mapping might have missing
|
||||
+ * entries but that's not important. (RHEL-108803)
|
||||
+ *)
|
||||
+ if verbose () then
|
||||
+ eprintf "map_registry_disk_blob_mbr: parted returned: \
|
||||
+ %s (ignored)\n" msg;
|
||||
+ false
|
||||
) devices in
|
||||
|
||||
(* Next 8 bytes are the offset of the partition in bytes(!) given as
|
||||
@@ -428,14 +438,21 @@ and map_registry_disk_blob_gpt partitions blob =
|
||||
let partition =
|
||||
List.find (
|
||||
fun part ->
|
||||
- let partnum = Devsparts.part_to_partnum part in
|
||||
- let device = Devsparts.part_to_dev part in
|
||||
- let typ = Parted.part_get_parttype device in
|
||||
- if typ <> "gpt" then false
|
||||
- else (
|
||||
- let guid = Sfdisk.part_get_gpt_guid device partnum in
|
||||
- String.lowercase_ascii guid = blob_guid
|
||||
- )
|
||||
+ try
|
||||
+ let partnum = Devsparts.part_to_partnum part in
|
||||
+ let device = Devsparts.part_to_dev part in
|
||||
+ let typ = Parted.part_get_parttype device in
|
||||
+ if typ <> "gpt" then false
|
||||
+ else (
|
||||
+ let guid = Sfdisk.part_get_gpt_guid device partnum in
|
||||
+ String.lowercase_ascii guid = blob_guid
|
||||
+ )
|
||||
+ with Unix.Unix_error (EINVAL, "parted", msg) ->
|
||||
+ (* See comment in MBR code above (RHEL-108803) *)
|
||||
+ if verbose () then
|
||||
+ eprintf "map_registry_disk_blob_gpt: parted returned: \
|
||||
+ %s (ignored)\n" msg;
|
||||
+ false
|
||||
) partitions in
|
||||
Some partition
|
||||
with
|
@ -37,7 +37,7 @@ Summary: Access and modify virtual machine disk images
|
||||
Name: libguestfs
|
||||
Epoch: 1
|
||||
Version: 1.54.0
|
||||
Release: 10%{?dist}
|
||||
Release: 11%{?dist}
|
||||
License: LGPL-2.1-or-later
|
||||
|
||||
# Build only for architectures that have a kernel
|
||||
@ -108,6 +108,9 @@ Patch0030: 0030-daemon-inspect-Remove-duplicate-root-mountpoints-in-.patch
|
||||
Patch0031: 0031-lib-inspect-osinfo.c-Generate-new-osinfo-shortname-f.patch
|
||||
Patch0032: 0032-daemon-Add-contents-of-etc-fstab-to-verbose-log.patch
|
||||
Patch0033: 0033-appliance-init-Add-lsblk-and-blkid-output-to-verbose.patch
|
||||
Patch0034: 0034-daemon-inspect_fs_windows.ml-Add-debugging-for-MBR-d.patch
|
||||
Patch0035: 0035-daemon-inspect_fs_windows.ml-Add-debugging-when-we-s.patch
|
||||
Patch0036: 0036-daemon-inspect_fs_windows.ml-Ignore-blank-disks-in-d.patch
|
||||
|
||||
BuildRequires: autoconf, automake, libtool, gettext-devel
|
||||
|
||||
@ -1117,9 +1120,9 @@ rm ocaml/html/.gitignore
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Jul 30 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-10
|
||||
- Add /etc/fstab, lsblk and blkid to verbose output
|
||||
resolves: RHEL-106539
|
||||
* Thu Aug 14 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-11
|
||||
- Ignore blank disks in Windows drive mapping
|
||||
resolves: RHEL-108803
|
||||
|
||||
* Tue Jun 17 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-9
|
||||
- Generate correct osinfo for SLES >= 15
|
||||
|
Loading…
Reference in New Issue
Block a user