Fix CHS geometry error for Veritas/Sun partitions
resolves: RHEL-165220
This commit is contained in:
parent
cbbf973cbd
commit
5f59f6e0eb
@ -0,0 +1,87 @@
|
||||
From 6a27009836aa3ae0883144cc662559fd1bcdcb66 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 16 Apr 2026 08:06:50 +0100
|
||||
Subject: [PATCH] daemon/listfs.ml: Refactor is_partition_can_hold_filesystem
|
||||
|
||||
Refactor and simplify the function.
|
||||
|
||||
This is just code motion, there is no functional change.
|
||||
|
||||
(cherry picked from commit 88bd07f350407619d4f5fe406c5594b50cf541dd)
|
||||
---
|
||||
daemon/listfs.ml | 53 ++++++++++++++++++++----------------------------
|
||||
1 file changed, 22 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/daemon/listfs.ml b/daemon/listfs.ml
|
||||
index 4c90796ef..067314c47 100644
|
||||
--- a/daemon/listfs.ml
|
||||
+++ b/daemon/listfs.ml
|
||||
@@ -115,43 +115,34 @@ and is_not_partitioned_device device =
|
||||
* Windows Snapshot Partition as well as MBR extended partitions.
|
||||
*)
|
||||
and is_partition_can_hold_filesystem partition =
|
||||
- let device = Devsparts.part_to_dev partition in
|
||||
- let partnum = Devsparts.part_to_partnum partition in
|
||||
- let parttype = Parted.part_get_parttype device in
|
||||
+ let device = Devsparts.part_to_dev partition
|
||||
+ and partnum = Devsparts.part_to_partnum partition in
|
||||
|
||||
- let is_gpt = parttype = "gpt" in
|
||||
- let is_mbr = parttype = "msdos" in
|
||||
- let is_gpt_or_mbr = is_gpt || is_mbr in
|
||||
+ match Parted.part_get_parttype device with
|
||||
+ | "msdos" ->
|
||||
+ if Parted.part_get_mbr_part_type device partnum = "extended" then
|
||||
+ false
|
||||
+ else if partnum = 1 && Utils.has_bogus_mbr device then
|
||||
+ true
|
||||
+ else
|
||||
+ true
|
||||
|
||||
- if is_gpt_or_mbr then (
|
||||
- if is_mbr_extended parttype device partnum then
|
||||
- false
|
||||
- else if is_mbr_bogus parttype device partnum then
|
||||
- true
|
||||
- else if is_mbr then
|
||||
- true
|
||||
- else (
|
||||
- let gpt_type = Sfdisk.part_get_gpt_type device partnum in
|
||||
- match gpt_type with
|
||||
+ | "gpt" ->
|
||||
+ let gpt_type = Sfdisk.part_get_gpt_type device partnum in
|
||||
+ (match gpt_type with
|
||||
(* Windows Logical Disk Manager metadata partition. *)
|
||||
| "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3"
|
||||
- (* Windows Logical Disk Manager data partition. *)
|
||||
- | "AF9B60A0-1431-4F62-BC68-3311714A69AD"
|
||||
- (* Microsoft Reserved Partition. *)
|
||||
- | "E3C9E316-0B5C-4DB8-817D-F92DF00215AE"
|
||||
- (* Windows Snapshot Partition. *)
|
||||
- | "CADDEBF1-4400-4DE8-B103-12117DCF3CCF" -> false
|
||||
+ (* Windows Logical Disk Manager data partition. *)
|
||||
+ | "AF9B60A0-1431-4F62-BC68-3311714A69AD"
|
||||
+ (* Microsoft Reserved Partition. *)
|
||||
+ | "E3C9E316-0B5C-4DB8-817D-F92DF00215AE"
|
||||
+ (* Windows Snapshot Partition. *)
|
||||
+ | "CADDEBF1-4400-4DE8-B103-12117DCF3CCF" -> false
|
||||
| _ -> true
|
||||
- )
|
||||
- )
|
||||
- else true
|
||||
+ )
|
||||
|
||||
-and is_mbr_extended parttype device partnum =
|
||||
- parttype = "msdos" &&
|
||||
- Parted.part_get_mbr_part_type device partnum = "extended"
|
||||
-
|
||||
-and is_mbr_bogus parttype device partnum =
|
||||
- parttype = "msdos" && partnum = 1 && Utils.has_bogus_mbr device
|
||||
+ | _ -> (* unknown or other *)
|
||||
+ true
|
||||
|
||||
(* Use vfs-type to check for a filesystem of some sort of [device].
|
||||
* Appends (device, vfs_type) to the ret parameter (there may be
|
||||
--
|
||||
2.47.3
|
||||
|
||||
114
0006-daemon-listfs.ml-Ignore-CHS-geometry-error-from-part.patch
Normal file
114
0006-daemon-listfs.ml-Ignore-CHS-geometry-error-from-part.patch
Normal file
@ -0,0 +1,114 @@
|
||||
From 219211f090536a8f6aa1919930284a439880c815 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 16 Apr 2026 08:34:38 +0100
|
||||
Subject: [PATCH] daemon/listfs.ml: Ignore CHS geometry error from parted
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
parted has an annoying bug where it fails to parse Sun partition
|
||||
tables (still used by Veritas). It tries to check the CHS geometry
|
||||
stored in the header matches the physical CHS geometry, which is a
|
||||
meaningless test.
|
||||
|
||||
In function is_partition_can_hold_filesystem we are only interested in
|
||||
MBR and GPT partition types, so catch and ignore this specific parted
|
||||
error.
|
||||
|
||||
I tested this by adding a Sun disk as a second disk to a Fedora
|
||||
guest and doing inspection. Previously the operation would
|
||||
fail:
|
||||
|
||||
$ guestfish --ro -a /var/tmp/fedora-41.img -a /var/tmp/dump.img -i
|
||||
libguestfs: error: inspect_os: parted exited with status 1: Warning:
|
||||
The disk CHS geometry (205603,255,2) reported by the operating
|
||||
system does not match the geometry stored on the disk label
|
||||
(64887,16,101).
|
||||
|
||||
After this change it succeeds:
|
||||
|
||||
$ guestfish --ro -a /var/tmp/fedora-41.img -a /var/tmp/dump.img -i
|
||||
|
||||
Welcome to guestfish, the guest filesystem shell for
|
||||
editing virtual machine filesystems and disk images.
|
||||
|
||||
Type: ‘help’ for help on commands
|
||||
‘man’ to read the manual
|
||||
‘quit’ to quit the shell
|
||||
|
||||
Operating system: Fedora Linux 41 (Forty One)
|
||||
/dev/sda3 mounted on /
|
||||
/dev/sda2 mounted on /boot
|
||||
|
||||
Fixes: https://redhat.atlassian.net/browse/RHEL-165220
|
||||
(cherry picked from commit 8d83bf2bcf31c5206b6deaa5e993009a85ff174f)
|
||||
---
|
||||
daemon/listfs.ml | 44 ++++++++++++++++++++++++++++----------------
|
||||
1 file changed, 28 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/daemon/listfs.ml b/daemon/listfs.ml
|
||||
index 067314c47..8ca5ca8a8 100644
|
||||
--- a/daemon/listfs.ml
|
||||
+++ b/daemon/listfs.ml
|
||||
@@ -118,30 +118,42 @@ and is_partition_can_hold_filesystem partition =
|
||||
let device = Devsparts.part_to_dev partition
|
||||
and partnum = Devsparts.part_to_partnum partition in
|
||||
|
||||
- match Parted.part_get_parttype device with
|
||||
- | "msdos" ->
|
||||
- if Parted.part_get_mbr_part_type device partnum = "extended" then
|
||||
- false
|
||||
- else if partnum = 1 && Utils.has_bogus_mbr device then
|
||||
- true
|
||||
- else
|
||||
- true
|
||||
+ try
|
||||
+ match Parted.part_get_parttype device with
|
||||
+ | "msdos" ->
|
||||
+ if Parted.part_get_mbr_part_type device partnum = "extended" then
|
||||
+ false
|
||||
+ else if partnum = 1 && Utils.has_bogus_mbr device then
|
||||
+ true
|
||||
+ else
|
||||
+ true
|
||||
|
||||
- | "gpt" ->
|
||||
- let gpt_type = Sfdisk.part_get_gpt_type device partnum in
|
||||
- (match gpt_type with
|
||||
- (* Windows Logical Disk Manager metadata partition. *)
|
||||
- | "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3"
|
||||
+ | "gpt" ->
|
||||
+ let gpt_type = Sfdisk.part_get_gpt_type device partnum in
|
||||
+ (match gpt_type with
|
||||
+ (* Windows Logical Disk Manager metadata partition. *)
|
||||
+ | "5808C8AA-7E8F-42E0-85D2-E1E90434CFB3"
|
||||
(* Windows Logical Disk Manager data partition. *)
|
||||
| "AF9B60A0-1431-4F62-BC68-3311714A69AD"
|
||||
(* Microsoft Reserved Partition. *)
|
||||
| "E3C9E316-0B5C-4DB8-817D-F92DF00215AE"
|
||||
(* Windows Snapshot Partition. *)
|
||||
| "CADDEBF1-4400-4DE8-B103-12117DCF3CCF" -> false
|
||||
- | _ -> true
|
||||
- )
|
||||
+ | _ -> true
|
||||
+ )
|
||||
|
||||
- | _ -> (* unknown or other *)
|
||||
+ | _ -> (* unknown or other *)
|
||||
+ true
|
||||
+
|
||||
+ with
|
||||
+ | Failure msg when String.find msg "CHS geometry" >= 0 ->
|
||||
+ (* Parted has poor handling of "sun" partition types, always
|
||||
+ * issuing a warning because the CHS doesn't match the physical
|
||||
+ * geometry. Ignore this as we don't care about it in this
|
||||
+ * function (RHEL-165220).
|
||||
+ *)
|
||||
+ eprintf "is_partition_can_hold_filesystem: \
|
||||
+ ignoring warning from parted: %s\n%!" msg;
|
||||
true
|
||||
|
||||
(* Use vfs-type to check for a filesystem of some sort of [device].
|
||||
--
|
||||
2.47.3
|
||||
|
||||
@ -35,7 +35,7 @@ Summary: Access and modify virtual machine disk images
|
||||
Name: libguestfs
|
||||
Epoch: 1
|
||||
Version: 1.59.5
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: LGPL-2.1-or-later
|
||||
|
||||
# Build only for architectures that have a kernel
|
||||
@ -77,6 +77,8 @@ Patch0001: 0001-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch
|
||||
Patch0002: 0002-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
|
||||
Patch0003: 0003-RHEL-appliance-init-Run-depmod-a-to-rebuild-kernel-m.patch
|
||||
Patch0004: 0004-RHEL-Use-alternate-location-for-qemu-kvm-in-direct-b.patch
|
||||
Patch0005: 0005-daemon-listfs.ml-Refactor-is_partition_can_hold_file.patch
|
||||
Patch0006: 0006-daemon-listfs.ml-Ignore-CHS-geometry-error-from-part.patch
|
||||
|
||||
BuildRequires: autoconf, automake, libtool, gettext-devel
|
||||
|
||||
@ -1028,12 +1030,14 @@ rm ocaml/html/.gitignore
|
||||
|
||||
|
||||
%changelog
|
||||
* Thu Apr 02 2026 Richard W.M. Jones <rjones@redhat.com> - 1:1.59.5-1
|
||||
* Thu Apr 16 2026 Richard W.M. Jones <rjones@redhat.com> - 1:1.59.5-2
|
||||
- Rebase to libguestfs 1.59.5
|
||||
Synchronize spec file with Fedora
|
||||
resolves: RHEL-153358
|
||||
- Detect Windows Defender antivirus
|
||||
resolves: RHEL-129145
|
||||
- Fix CHS geometry error for Veritas/Sun partitions
|
||||
resolves: RHEL-165220
|
||||
|
||||
* Mon Jan 26 2026 Richard W.M. Jones <rjones@redhat.com> - 1:1.58.1-2
|
||||
- Rebase to libguestfs 1.58.1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user