mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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
This commit is contained in:
committed by
rwmjones
parent
5c7e15cfae
commit
1c00248ac1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user