commit
8110c07286
@ -0,0 +1,2 @@
|
||||
SOURCES/libguestfs-1.52.2.tar.gz
|
||||
SOURCES/libguestfs.keyring
|
@ -0,0 +1,2 @@
|
||||
83f002eeda4a818c0e90f444c7b48ccf4a7428cc SOURCES/libguestfs-1.52.2.tar.gz
|
||||
1bbc40f501a7fef9eef2a39b701a71aee2fea7c4 SOURCES/libguestfs.keyring
|
@ -0,0 +1,657 @@
|
||||
From 1638cd9e58161147bd2f440b6e28bf7365fc5688 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Fri, 10 May 2024 13:27:22 +0100
|
||||
Subject: [PATCH] daemon: Reimplement partition GPT functions using sfdisk
|
||||
|
||||
sfdisk can now do everything with GPT that sgdisk was needed for
|
||||
before. In particular we are able to reimplement the following
|
||||
functions using sfdisk:
|
||||
|
||||
- part_set_disk_guid (replace with sfdisk --disk-id)
|
||||
- part_get_disk_guid
|
||||
- part_set_disk_guid_random
|
||||
- part_set_gpt_attributes (sfdisk --part-attrs)
|
||||
- part_get_gpt_attributes
|
||||
- part_set_gpt_guid (sfdisk --part-uuid)
|
||||
- part_get_gpt_guid
|
||||
- part_set_gpt_type (sfdisk --part-type)
|
||||
- part_get_gpt_type
|
||||
|
||||
This allows us to drop the requirement for gdisk in many cases.
|
||||
|
||||
There is only one API remaining which requires gdisk, part_expand_gpt,
|
||||
which we do not use in our tools. In a prior commit I already moved
|
||||
this solitary function to a new source file (daemon/gdisk.c).
|
||||
|
||||
Fixes: https://issues.redhat.com/browse/RHEL-35998
|
||||
(cherry picked from commit c6c266a85d76dc2db90460202415790c585ac625)
|
||||
---
|
||||
.gitignore | 1 +
|
||||
daemon/Makefile.am | 3 +
|
||||
daemon/inspect_fs_windows.ml | 2 +-
|
||||
daemon/listfs.ml | 2 +-
|
||||
daemon/parted.c | 144 -----------------------------
|
||||
daemon/parted.ml | 92 +------------------
|
||||
daemon/sfdisk.ml | 172 +++++++++++++++++++++++++++++++++++
|
||||
generator/actions_core.ml | 24 ++---
|
||||
8 files changed, 189 insertions(+), 251 deletions(-)
|
||||
create mode 100644 daemon/sfdisk.ml
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 00e59fb37..2fc52e843 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -108,6 +108,7 @@ Makefile.in
|
||||
/daemon/parted.mli
|
||||
/daemon/realpath.mli
|
||||
/daemon/rpm.mli
|
||||
+/daemon/sfdisk.mli
|
||||
/daemon/stamp-guestfsd.pod
|
||||
/daemon/statvfs.mli
|
||||
/daemon/structs-cleanups.c
|
||||
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
|
||||
index 04370b7cd..bc74b6ef7 100644
|
||||
--- a/daemon/Makefile.am
|
||||
+++ b/daemon/Makefile.am
|
||||
@@ -59,6 +59,7 @@ generator_built = \
|
||||
parted.mli \
|
||||
realpath.mli \
|
||||
rpm.mli \
|
||||
+ sfdisk.mli \
|
||||
statvfs.mli \
|
||||
structs.ml \
|
||||
structs.mli
|
||||
@@ -306,6 +307,7 @@ SOURCES_MLI = \
|
||||
parted.mli \
|
||||
realpath.mli \
|
||||
rpm.mli \
|
||||
+ sfdisk.mli \
|
||||
statvfs.mli \
|
||||
structs.mli \
|
||||
sysroot.mli \
|
||||
@@ -337,6 +339,7 @@ SOURCES_ML = \
|
||||
md.ml \
|
||||
mount.ml \
|
||||
mount_utils.ml \
|
||||
+ sfdisk.ml \
|
||||
parted.ml \
|
||||
listfs.ml \
|
||||
realpath.ml \
|
||||
diff --git a/daemon/inspect_fs_windows.ml b/daemon/inspect_fs_windows.ml
|
||||
index 5d29c3a46..6537481e1 100644
|
||||
--- a/daemon/inspect_fs_windows.ml
|
||||
+++ b/daemon/inspect_fs_windows.ml
|
||||
@@ -419,7 +419,7 @@ and map_registry_disk_blob_gpt partitions blob =
|
||||
let typ = Parted.part_get_parttype device in
|
||||
if typ <> "gpt" then false
|
||||
else (
|
||||
- let guid = Parted.part_get_gpt_guid device partnum in
|
||||
+ let guid = Sfdisk.part_get_gpt_guid device partnum in
|
||||
String.lowercase_ascii guid = blob_guid
|
||||
)
|
||||
) partitions in
|
||||
diff --git a/daemon/listfs.ml b/daemon/listfs.ml
|
||||
index 4cc3c437a..93c1e7145 100644
|
||||
--- a/daemon/listfs.ml
|
||||
+++ b/daemon/listfs.ml
|
||||
@@ -114,7 +114,7 @@ and is_partition_can_hold_filesystem partition =
|
||||
else if is_mbr then
|
||||
true
|
||||
else (
|
||||
- let gpt_type = Parted.part_get_gpt_type device partnum in
|
||||
+ 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"
|
||||
diff --git a/daemon/parted.c b/daemon/parted.c
|
||||
index 9af5556c9..0f19baae5 100644
|
||||
--- a/daemon/parted.c
|
||||
+++ b/daemon/parted.c
|
||||
@@ -456,58 +456,6 @@ do_part_set_mbr_id (const char *device, int partnum, int idbyte)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int
|
||||
-do_part_set_gpt_type (const char *device, int partnum, const char *guid)
|
||||
-{
|
||||
- if (partnum <= 0) {
|
||||
- reply_with_error ("partition number must be >= 1");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- CLEANUP_FREE char *typecode = NULL;
|
||||
- if (asprintf (&typecode, "%i:%s", partnum, guid) == -1) {
|
||||
- reply_with_perror ("asprintf");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- CLEANUP_FREE char *err = NULL;
|
||||
- int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
|
||||
- "sgdisk", device, "-t", typecode, NULL);
|
||||
-
|
||||
- if (r == -1) {
|
||||
- reply_with_error ("%s %s -t %s: %s", "sgdisk", device, typecode, err);
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-int
|
||||
-do_part_set_gpt_guid (const char *device, int partnum, const char *guid)
|
||||
-{
|
||||
- if (partnum <= 0) {
|
||||
- reply_with_error ("partition number must be >= 1");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- CLEANUP_FREE char *typecode = NULL;
|
||||
- if (asprintf (&typecode, "%i:%s", partnum, guid) == -1) {
|
||||
- reply_with_perror ("asprintf");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- CLEANUP_FREE char *err = NULL;
|
||||
- int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
|
||||
- "sgdisk", device, "-u", typecode, NULL);
|
||||
-
|
||||
- if (r == -1) {
|
||||
- reply_with_error ("%s %s -u %s: %s", "sgdisk", device, typecode, err);
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
char *
|
||||
do_part_get_name (const char *device, int partnum)
|
||||
{
|
||||
@@ -564,95 +512,3 @@ do_part_get_name (const char *device, int partnum)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
-
|
||||
-static char *
|
||||
-extract_uuid (const char *value)
|
||||
-{
|
||||
- /* The value contains only valid GUID characters */
|
||||
- const size_t value_len = strspn (value, "-0123456789ABCDEF");
|
||||
-
|
||||
- char *ret = malloc (value_len + 1);
|
||||
- if (ret == NULL) {
|
||||
- reply_with_perror ("malloc");
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- memcpy (ret, value, value_len);
|
||||
- ret[value_len] = '\0';
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-char *
|
||||
-do_part_get_disk_guid (const char *device)
|
||||
-{
|
||||
- const char *pattern = "Disk identifier (GUID):";
|
||||
- size_t i;
|
||||
-
|
||||
- CLEANUP_FREE char *err = NULL;
|
||||
- int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
|
||||
- "sgdisk", device, "-p", NULL);
|
||||
- if (r == -1) {
|
||||
- reply_with_error ("%s %s -p: %s", "sgdisk", device, err);
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- CLEANUP_FREE_STRING_LIST char **lines = split_lines (err);
|
||||
- if (lines == NULL) {
|
||||
- reply_with_error ("'%s %s -p' returned no output",
|
||||
- "sgdisk", device);
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- for (i = 0; lines[i] != NULL; ++i) {
|
||||
- if (STRPREFIX (lines[i], pattern)) {
|
||||
- char *value = lines[i] + strlen (pattern);
|
||||
-
|
||||
- /* Skip any leading whitespace */
|
||||
- value += strspn (value, " \t");
|
||||
-
|
||||
- /* Extract the actual information from the field. */
|
||||
- char *ret = extract_uuid (value);
|
||||
- if (ret == NULL) {
|
||||
- /* The extraction function already sends the error. */
|
||||
- return NULL;
|
||||
- }
|
||||
-
|
||||
- return ret;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /* If we got here it means we didn't find the field */
|
||||
- reply_with_error ("sgdisk output did not contain disk GUID. "
|
||||
- "See LIBGUESTFS_DEBUG output for more details");
|
||||
- return NULL;
|
||||
-}
|
||||
-
|
||||
-int
|
||||
-do_part_set_disk_guid (const char *device, const char *guid)
|
||||
-{
|
||||
- CLEANUP_FREE char *err = NULL;
|
||||
- int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
|
||||
- "sgdisk", device, "-U", guid, NULL);
|
||||
-
|
||||
- if (r == -1) {
|
||||
- reply_with_error ("%s %s -U %s: %s", "sgdisk", device, guid, err);
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-int
|
||||
-do_part_set_disk_guid_random (const char *device)
|
||||
-{
|
||||
- CLEANUP_FREE char *err = NULL;
|
||||
- int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
|
||||
- "sgdisk", device, "-U", "R", NULL);
|
||||
-
|
||||
- if (r == -1) {
|
||||
- reply_with_error ("%s %s -U R: %s", "sgdisk", device, err);
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
diff --git a/daemon/parted.ml b/daemon/parted.ml
|
||||
index c9e55890b..f8f142bc5 100644
|
||||
--- a/daemon/parted.ml
|
||||
+++ b/daemon/parted.ml
|
||||
@@ -25,18 +25,6 @@ open Utils
|
||||
|
||||
include Structs
|
||||
|
||||
-let part_get_mbr_id device partnum =
|
||||
- if partnum <= 0 then
|
||||
- failwith "partition number must be >= 1";
|
||||
-
|
||||
- udev_settle ();
|
||||
- let out =
|
||||
- command "sfdisk" ["--part-type"; device; string_of_int partnum] in
|
||||
- udev_settle ();
|
||||
-
|
||||
- (* It's printed in hex, possibly with a leading space. *)
|
||||
- sscanf out " %x" identity
|
||||
-
|
||||
(* This is almost equivalent to print_partition_table in the C code. The
|
||||
* difference is that here we enforce the "BYT;" header internally.
|
||||
*)
|
||||
@@ -110,7 +98,7 @@ let part_get_parttype device =
|
||||
|
||||
let part_get_mbr_part_type device partnum =
|
||||
let parttype = part_get_parttype device in
|
||||
- let mbr_id = part_get_mbr_id device partnum in
|
||||
+ let mbr_id = Sfdisk.part_get_mbr_id device partnum in
|
||||
|
||||
(* 0x05 - extended partition.
|
||||
* 0x0f - extended partition using BIOS INT 13h extensions.
|
||||
@@ -120,81 +108,3 @@ let part_get_mbr_part_type device partnum =
|
||||
| "msdos", (1|2|3|4), _ -> "primary"
|
||||
| "msdos", _, _ -> "logical"
|
||||
| _, _, _ -> "primary"
|
||||
-
|
||||
-let part_set_gpt_attributes device partnum attributes =
|
||||
- if partnum <= 0 then failwith "partition number must be >= 1";
|
||||
-
|
||||
- udev_settle ();
|
||||
-
|
||||
- let arg = sprintf "%d:=:%LX" partnum attributes in
|
||||
- let r, _, err =
|
||||
- commandr ~fold_stdout_on_stderr:true
|
||||
- "sgdisk" [ device; "-A"; arg ] in
|
||||
- if r <> 0 then
|
||||
- failwithf "sgdisk: %s" err;
|
||||
-
|
||||
- udev_settle ()
|
||||
-
|
||||
-let extract_guid value =
|
||||
- (* The value contains only valid GUID characters. *)
|
||||
- String.sub value 0 (String.span value "-0123456789ABCDEF")
|
||||
-
|
||||
-let extract_hex value =
|
||||
- (* The value contains only valid numeric characters. *)
|
||||
- let str = String.sub value 0 (String.span value "0123456789ABCDEF") in
|
||||
- Int64.of_string ("0x" ^ str)
|
||||
-
|
||||
-let sgdisk_info_extract_field device partnum field extractor =
|
||||
- if partnum <= 0 then failwith "partition number must be >= 1";
|
||||
-
|
||||
- udev_settle ();
|
||||
-
|
||||
- let r, _, err =
|
||||
- commandr ~fold_stdout_on_stderr:true
|
||||
- "sgdisk" [ device; "-i"; string_of_int partnum ] in
|
||||
- if r <> 0 then
|
||||
- failwithf "getting %S: sgdisk: %s" field err;
|
||||
-
|
||||
- udev_settle ();
|
||||
-
|
||||
- let err = String.trim err in
|
||||
- let lines = String.nsplit "\n" err in
|
||||
-
|
||||
- (* Parse the output of sgdisk -i:
|
||||
- * Partition GUID code: 21686148-6449-6E6F-744E-656564454649 (BIOS boot partition)
|
||||
- * Partition unique GUID: 19AEC5FE-D63A-4A15-9D37-6FCBFB873DC0
|
||||
- * First sector: 2048 (at 1024.0 KiB)
|
||||
- * Last sector: 411647 (at 201.0 MiB)
|
||||
- * Partition size: 409600 sectors (200.0 MiB)
|
||||
- * Attribute flags: 0000000000000000
|
||||
- * Partition name: 'EFI System Partition'
|
||||
- *)
|
||||
- let field_len = String.length field in
|
||||
- let rec loop = function
|
||||
- | [] ->
|
||||
- failwithf "%s: sgdisk output did not contain '%s'" device field
|
||||
- | line :: _ when String.is_prefix line field &&
|
||||
- String.length line >= field_len + 2 &&
|
||||
- line.[field_len] = ':' ->
|
||||
- let value =
|
||||
- String.sub line (field_len+1) (String.length line - field_len - 1) in
|
||||
-
|
||||
- (* Skip any whitespace after the colon. *)
|
||||
- let value = String.triml value in
|
||||
-
|
||||
- (* Extract the value. *)
|
||||
- extractor value
|
||||
-
|
||||
- | _ :: lines -> loop lines
|
||||
- in
|
||||
- loop lines
|
||||
-
|
||||
-let rec part_get_gpt_type device partnum =
|
||||
- sgdisk_info_extract_field device partnum "Partition GUID code"
|
||||
- extract_guid
|
||||
-and part_get_gpt_guid device partnum =
|
||||
- sgdisk_info_extract_field device partnum "Partition unique GUID"
|
||||
- extract_guid
|
||||
-and part_get_gpt_attributes device partnum =
|
||||
- sgdisk_info_extract_field device partnum "Attribute flags"
|
||||
- extract_hex
|
||||
diff --git a/daemon/sfdisk.ml b/daemon/sfdisk.ml
|
||||
new file mode 100644
|
||||
index 000000000..2aea399aa
|
||||
--- /dev/null
|
||||
+++ b/daemon/sfdisk.ml
|
||||
@@ -0,0 +1,172 @@
|
||||
+(* guestfs-inspection
|
||||
+ * Copyright (C) 2009-2023 Red Hat Inc.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License along
|
||||
+ * with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
+ *)
|
||||
+
|
||||
+open Scanf
|
||||
+open Printf
|
||||
+
|
||||
+open Std_utils
|
||||
+
|
||||
+open Utils
|
||||
+
|
||||
+include Structs
|
||||
+
|
||||
+let part_get_mbr_id device partnum =
|
||||
+ if partnum <= 0 then
|
||||
+ failwith "partition number must be >= 1";
|
||||
+
|
||||
+ udev_settle ();
|
||||
+ let out =
|
||||
+ command "sfdisk" ["--part-type"; device; string_of_int partnum] in
|
||||
+ udev_settle ();
|
||||
+
|
||||
+ (* It's printed in hex, possibly with a leading space. *)
|
||||
+ sscanf out " %x" identity
|
||||
+
|
||||
+let part_get_gpt_type device partnum =
|
||||
+ if partnum <= 0 then
|
||||
+ failwith "partition number must be >= 1";
|
||||
+
|
||||
+ udev_settle ();
|
||||
+ let out =
|
||||
+ command "sfdisk" ["--part-type"; device; string_of_int partnum] in
|
||||
+ udev_settle ();
|
||||
+
|
||||
+ String.trimr out
|
||||
+
|
||||
+let part_set_gpt_type device partnum typ =
|
||||
+ if partnum <= 0 then
|
||||
+ failwith "partition number must be >= 1";
|
||||
+
|
||||
+ udev_settle ();
|
||||
+ let cmd =
|
||||
+ sprintf "sfdisk --part-type %s %d %s"
|
||||
+ (quote device) partnum (quote typ) in
|
||||
+ if verbose () then eprintf "%s\n%!" cmd;
|
||||
+ if Sys.command cmd <> 0 then failwith "sfdisk --part-type failed";
|
||||
+ udev_settle ()
|
||||
+
|
||||
+let part_get_gpt_guid device partnum =
|
||||
+ if partnum <= 0 then
|
||||
+ failwith "partition number must be >= 1";
|
||||
+
|
||||
+ udev_settle ();
|
||||
+ let out =
|
||||
+ command "sfdisk" ["--part-uuid"; device; string_of_int partnum] in
|
||||
+ udev_settle ();
|
||||
+
|
||||
+ String.trimr out
|
||||
+
|
||||
+let part_set_gpt_guid device partnum guid =
|
||||
+ if partnum <= 0 then
|
||||
+ failwith "partition number must be >= 1";
|
||||
+
|
||||
+ udev_settle ();
|
||||
+ let cmd =
|
||||
+ sprintf "sfdisk --part-uuid %s %d %s"
|
||||
+ (quote device) partnum (quote guid) in
|
||||
+ if verbose () then eprintf "%s\n%!" cmd;
|
||||
+ if Sys.command cmd <> 0 then failwith "sfdisk --part-uuid failed";
|
||||
+ udev_settle ()
|
||||
+
|
||||
+let part_get_disk_guid device =
|
||||
+ udev_settle ();
|
||||
+ let out =
|
||||
+ command "sfdisk" ["--disk-id"; device] in
|
||||
+ udev_settle ();
|
||||
+
|
||||
+ String.trimr out
|
||||
+
|
||||
+let part_set_disk_guid device guid =
|
||||
+ udev_settle ();
|
||||
+ let cmd =
|
||||
+ sprintf "sfdisk --disk-id %s %s"
|
||||
+ (quote device) (quote guid) in
|
||||
+ if verbose () then eprintf "%s\n%!" cmd;
|
||||
+ if Sys.command cmd <> 0 then failwith "sfdisk --disk-id failed";
|
||||
+ udev_settle ()
|
||||
+
|
||||
+let part_set_disk_guid_random device =
|
||||
+ let random_uuid = Utils.get_random_uuid () in
|
||||
+ let random_uuid = String.trimr random_uuid in
|
||||
+ part_set_disk_guid device random_uuid
|
||||
+
|
||||
+let part_get_gpt_attributes device partnum =
|
||||
+ if partnum <= 0 then
|
||||
+ failwith "partition number must be >= 1";
|
||||
+
|
||||
+ udev_settle ();
|
||||
+ let out =
|
||||
+ command "sfdisk" ["--part-attrs"; device; string_of_int partnum] in
|
||||
+ udev_settle ();
|
||||
+
|
||||
+ (* The output is a whitespace-separated list of:
|
||||
+ * "RequiredPartition" (equivalent to bit 0)
|
||||
+ * "NoBlockIOProtocol" (equivalent to bit 1)
|
||||
+ * "LegacyBIOSBootable" (equivalent to bit 2)
|
||||
+ * "48", "49", ..., "63"
|
||||
+ *)
|
||||
+ let out = String.trimr out in
|
||||
+ let attrs = String.nsplit " " out in
|
||||
+ List.fold_left (
|
||||
+ fun bits attr ->
|
||||
+ let bit =
|
||||
+ match attr with
|
||||
+ | "" -> -1
|
||||
+ | "RequiredPartition" -> 0
|
||||
+ | "NoBlockIOProtocol" -> 1
|
||||
+ | "LegacyBIOSBootable" -> 2
|
||||
+ | n -> int_of_string n in
|
||||
+ if bit >= 0 then
|
||||
+ Int64.logor bits (Int64.shift_left 1_L bit)
|
||||
+ else
|
||||
+ bits
|
||||
+ ) 0_L attrs
|
||||
+
|
||||
+let part_set_gpt_attributes device partnum attrs =
|
||||
+ if partnum <= 0 then
|
||||
+ failwith "partition number must be >= 1";
|
||||
+
|
||||
+ (* The input to sfdisk --part-attrs is a comma-separated list of
|
||||
+ * attribute names or bit positions. Note you have to use the
|
||||
+ * names, you can't use "0", "1" or "2".
|
||||
+ *)
|
||||
+ let s = ref [] in
|
||||
+ let rec loop i =
|
||||
+ let b = Int64.logand attrs (Int64.shift_left 1_L i) <> Int64.zero in
|
||||
+ (match i with
|
||||
+ | 0 -> if b then List.push_front "RequiredPartition" s
|
||||
+ | 1 -> if b then List.push_front "NoBlockIOProtocol" s
|
||||
+ | 2 -> if b then List.push_front "LegacyBIOSBootable" s
|
||||
+ | i when i >= 3 && i <= 47 ->
|
||||
+ if b then
|
||||
+ failwith "bits 3..47 are reserved and cannot be set"
|
||||
+ | i when i >= 48 && i <= 63 ->
|
||||
+ if b then List.push_front (string_of_int i) s
|
||||
+ | _ -> assert false
|
||||
+ );
|
||||
+ if i < 63 then loop (i+1)
|
||||
+ in
|
||||
+ loop 0;
|
||||
+
|
||||
+ udev_settle ();
|
||||
+ let cmd =
|
||||
+ sprintf "sfdisk --part-attrs %s %d %s"
|
||||
+ (quote device) partnum (quote (String.concat "," !s)) in
|
||||
+ if verbose () then eprintf "%s\n%!" cmd;
|
||||
+ if Sys.command cmd <> 0 then failwith "sfdisk --part-attrs failed";
|
||||
+ udev_settle ()
|
||||
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
|
||||
index 68627078f..46ef1422f 100644
|
||||
--- a/generator/actions_core.ml
|
||||
+++ b/generator/actions_core.ml
|
||||
@@ -5302,7 +5302,7 @@ See also C<guestfs_part_set_bootable>." };
|
||||
{ defaults with
|
||||
name = "part_get_mbr_id"; added = (1, 3, 2);
|
||||
style = RInt "idbyte", [String (Device, "device"); Int "partnum"], [];
|
||||
- impl = OCaml "Parted.part_get_mbr_id";
|
||||
+ impl = OCaml "Sfdisk.part_get_mbr_id";
|
||||
fish_output = Some FishOutputHexadecimal;
|
||||
tests = [
|
||||
InitEmpty, Always, TestResult (
|
||||
@@ -8128,7 +8128,7 @@ group with GUID C<diskgroup>." };
|
||||
{ defaults with
|
||||
name = "part_set_gpt_type"; added = (1, 21, 1);
|
||||
style = RErr, [String (Device, "device"); Int "partnum"; String (GUID, "guid")], [];
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_set_gpt_type";
|
||||
tests = [
|
||||
InitGPT, Always, TestLastFail (
|
||||
[["part_set_gpt_type"; "/dev/sda"; "1"; "f"]]), [];
|
||||
@@ -8150,8 +8150,7 @@ for a useful list of type GUIDs." };
|
||||
{ defaults with
|
||||
name = "part_get_gpt_type"; added = (1, 21, 1);
|
||||
style = RString (RPlainString, "guid"), [String (Device, "device"); Int "partnum"], [];
|
||||
- impl = OCaml "Parted.part_get_gpt_type";
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_get_gpt_type";
|
||||
tests = [
|
||||
InitGPT, Always, TestResultString (
|
||||
[["part_set_gpt_type"; "/dev/sda"; "1";
|
||||
@@ -8166,8 +8165,7 @@ Return the type GUID of numbered GPT partition C<partnum>." };
|
||||
{ defaults with
|
||||
name = "part_set_gpt_attributes"; added = (1, 21, 1);
|
||||
style = RErr, [String (Device, "device"); Int "partnum"; Int64 "attributes"], [];
|
||||
- impl = OCaml "Parted.part_set_gpt_attributes";
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_set_gpt_attributes";
|
||||
tests = [
|
||||
InitGPT, Always, TestResult (
|
||||
[["part_set_gpt_attributes"; "/dev/sda"; "1";
|
||||
@@ -8186,8 +8184,7 @@ for a useful list of partition attributes." };
|
||||
{ defaults with
|
||||
name = "part_get_gpt_attributes"; added = (1, 21, 1);
|
||||
style = RInt64 "attributes", [String (Device, "device"); Int "partnum"], [];
|
||||
- impl = OCaml "Parted.part_get_gpt_attributes";
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_get_gpt_attributes";
|
||||
tests = [
|
||||
InitGPT, Always, TestResult (
|
||||
[["part_set_gpt_attributes"; "/dev/sda"; "1";
|
||||
@@ -8987,7 +8984,7 @@ Recover bad superblocks from good copies." };
|
||||
{ defaults with
|
||||
name = "part_set_gpt_guid"; added = (1, 29, 25);
|
||||
style = RErr, [String (Device, "device"); Int "partnum"; String (GUID, "guid")], [];
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_set_gpt_guid";
|
||||
tests = [
|
||||
InitGPT, Always, TestLastFail (
|
||||
[["part_set_gpt_guid"; "/dev/sda"; "1"; "f"]]), [];
|
||||
@@ -9006,8 +9003,7 @@ valid GUID." };
|
||||
{ defaults with
|
||||
name = "part_get_gpt_guid"; added = (1, 29, 25);
|
||||
style = RString (RPlainString, "guid"), [String (Device, "device"); Int "partnum"], [];
|
||||
- impl = OCaml "Parted.part_get_gpt_guid";
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_get_gpt_guid";
|
||||
tests = [
|
||||
InitGPT, Always, TestResultString (
|
||||
[["part_set_gpt_guid"; "/dev/sda"; "1";
|
||||
@@ -9206,7 +9202,7 @@ This is the internal call which implements C<guestfs_feature_available>." };
|
||||
{ defaults with
|
||||
name = "part_set_disk_guid"; added = (1, 33, 2);
|
||||
style = RErr, [String (Device, "device"); String (GUID, "guid")], [];
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_set_disk_guid";
|
||||
tests = [
|
||||
InitGPT, Always, TestLastFail (
|
||||
[["part_set_disk_guid"; "/dev/sda"; "f"]]), [];
|
||||
@@ -9225,7 +9221,7 @@ or if C<guid> is not a valid GUID." };
|
||||
{ defaults with
|
||||
name = "part_get_disk_guid"; added = (1, 33, 2);
|
||||
style = RString (RPlainString, "guid"), [String (Device, "device")], [];
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_get_disk_guid";
|
||||
tests = [
|
||||
InitGPT, Always, TestResultString (
|
||||
[["part_set_disk_guid"; "/dev/sda";
|
||||
@@ -9241,7 +9237,7 @@ Behaviour is undefined for other partition types." };
|
||||
{ defaults with
|
||||
name = "part_set_disk_guid_random"; added = (1, 33, 2);
|
||||
style = RErr, [String (Device, "device")], [];
|
||||
- optional = Some "gdisk";
|
||||
+ impl = OCaml "Sfdisk.part_set_disk_guid_random";
|
||||
tests = [
|
||||
InitGPT, Always, TestRun (
|
||||
[["part_set_disk_guid_random"; "/dev/sda"]]), [];
|
||||
--
|
||||
2.43.0
|
||||
|
@ -0,0 +1,134 @@
|
||||
From 8539b763639cbe80e4b248455c0c28bd8ced9cbe Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Fri, 28 Jun 2024 09:42:20 +0100
|
||||
Subject: [PATCH] daemon: Fix parsing in part_get_gpt_attributes
|
||||
|
||||
The actual output of sfdisk --part-attrs is bizarre and doesn't match
|
||||
the documentation. After looking at the source from util-linux, fix
|
||||
the parsing to match what sfdisk produces.
|
||||
|
||||
Reported-by: Yongkui Guo
|
||||
Fixes: commit c6c266a85d76dc2db90460202415790c585ac625
|
||||
Fixes: https://issues.redhat.com/browse/RHEL-35998
|
||||
(cherry picked from commit 24c1f7b03aab6343e6c826250269e98a6060d762)
|
||||
---
|
||||
daemon/sfdisk.ml | 80 +++++++++++++++++++++++++++++++--------
|
||||
generator/actions_core.ml | 4 +-
|
||||
2 files changed, 66 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/daemon/sfdisk.ml b/daemon/sfdisk.ml
|
||||
index 2aea399aa..8c8ed2305 100644
|
||||
--- a/daemon/sfdisk.ml
|
||||
+++ b/daemon/sfdisk.ml
|
||||
@@ -114,28 +114,76 @@ let part_get_gpt_attributes device partnum =
|
||||
command "sfdisk" ["--part-attrs"; device; string_of_int partnum] in
|
||||
udev_settle ();
|
||||
|
||||
+ let out = String.trimr out in
|
||||
+
|
||||
(* The output is a whitespace-separated list of:
|
||||
+ *
|
||||
* "RequiredPartition" (equivalent to bit 0)
|
||||
* "NoBlockIOProtocol" (equivalent to bit 1)
|
||||
* "LegacyBIOSBootable" (equivalent to bit 2)
|
||||
- * "48", "49", ..., "63"
|
||||
+ * "GUID:" followed by a comma-separated list of bit numbers
|
||||
+ *
|
||||
+ * eg: "LegacyBIOSBootable RequiredPartition GUID:48,49"
|
||||
+ *
|
||||
+ * So this is a massive PITA to parse.
|
||||
*)
|
||||
- let out = String.trimr out in
|
||||
- let attrs = String.nsplit " " out in
|
||||
- List.fold_left (
|
||||
- fun bits attr ->
|
||||
+ let rec loop out acc =
|
||||
+ let len = String.length out in
|
||||
+ eprintf "part_get_gpt_attributes: %S [%s]\n%!"
|
||||
+ out (String.concat "," (List.map string_of_int acc));
|
||||
+ if len = 0 then (
|
||||
+ acc
|
||||
+ )
|
||||
+ else if Char.isspace out.[0] then (
|
||||
+ let out = String.triml out in
|
||||
+ loop out acc
|
||||
+ )
|
||||
+ else if out.[0] = ',' then (
|
||||
+ let out = String.sub out 1 (len-1) in
|
||||
+ loop out acc
|
||||
+ )
|
||||
+ else if String.is_prefix out "RequiredPartition" then (
|
||||
+ let acc = 0 :: acc in
|
||||
+ let out = String.sub out 17 (len-17) in
|
||||
+ loop out acc
|
||||
+ )
|
||||
+ else if String.is_prefix out "NoBlockIOProtocol" then (
|
||||
+ let acc = 1 :: acc in
|
||||
+ let out = String.sub out 17 (len-17) in
|
||||
+ loop out acc
|
||||
+ )
|
||||
+ else if String.is_prefix out "LegacyBIOSBootable" then (
|
||||
+ let acc = 2 :: acc in
|
||||
+ let out = String.sub out 18 (len-18) in
|
||||
+ loop out acc
|
||||
+ )
|
||||
+ else if String.is_prefix out "GUID:" then (
|
||||
+ let out = String.sub out 5 (len-5) in
|
||||
+ loop out acc
|
||||
+ )
|
||||
+ else if Char.isdigit out.[0] then (
|
||||
+ let n = String.span out "0123456789" in
|
||||
+ let num, out = String.break n out in
|
||||
let bit =
|
||||
- match attr with
|
||||
- | "" -> -1
|
||||
- | "RequiredPartition" -> 0
|
||||
- | "NoBlockIOProtocol" -> 1
|
||||
- | "LegacyBIOSBootable" -> 2
|
||||
- | n -> int_of_string n in
|
||||
- if bit >= 0 then
|
||||
- Int64.logor bits (Int64.shift_left 1_L bit)
|
||||
- else
|
||||
- bits
|
||||
- ) 0_L attrs
|
||||
+ try int_of_string num
|
||||
+ with Failure _ ->
|
||||
+ failwithf "part_get_gpt_attributes: cannot parse number %S" num in
|
||||
+ let acc = bit :: acc in
|
||||
+ loop out acc
|
||||
+ )
|
||||
+ else (
|
||||
+ failwithf "part_get_gpt_attributes: cannot parse %S" out
|
||||
+ )
|
||||
+ in
|
||||
+ let attrs = loop out [] in
|
||||
+
|
||||
+ let bits =
|
||||
+ List.fold_left (
|
||||
+ fun bits bit -> Int64.logor bits (Int64.shift_left 1_L bit)
|
||||
+ ) 0_L attrs in
|
||||
+ eprintf "part_get_gpt_attributes: [%s] -> %Ld\n%!"
|
||||
+ (String.concat "," (List.map string_of_int attrs)) bits;
|
||||
+ bits
|
||||
|
||||
let part_set_gpt_attributes device partnum attrs =
|
||||
if partnum <= 0 then
|
||||
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
|
||||
index 46ef1422f..ef9096772 100644
|
||||
--- a/generator/actions_core.ml
|
||||
+++ b/generator/actions_core.ml
|
||||
@@ -8188,9 +8188,9 @@ for a useful list of partition attributes." };
|
||||
tests = [
|
||||
InitGPT, Always, TestResult (
|
||||
[["part_set_gpt_attributes"; "/dev/sda"; "1";
|
||||
- "0"];
|
||||
+ (* bits 0, 2, 48 and 49 set *) "844424930131973"];
|
||||
["part_get_gpt_attributes"; "/dev/sda"; "1"]],
|
||||
- "ret == 0"), [];
|
||||
+ "ret == 844424930131973"), [];
|
||||
];
|
||||
shortdesc = "get the attribute flags of a GPT partition";
|
||||
longdesc = "\
|
||||
--
|
||||
2.43.0
|
||||
|
@ -0,0 +1,71 @@
|
||||
From 25ff96e2c465766960cbc5ca3918026442dfcc32 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Tue, 7 Jul 2015 09:28:03 -0400
|
||||
Subject: [PATCH] RHEL: Reject use of libguestfs-winsupport features except for
|
||||
virt-* tools (RHBZ#1240276).
|
||||
|
||||
Fix the tests: it doesn't let us use guestfish for arbitrary Windows
|
||||
edits.
|
||||
|
||||
(cherry picked from commit b875668bfa9f596aba2e84999c7c9921f8dcb55e)
|
||||
---
|
||||
generator/c.ml | 16 ++++++++++++++++
|
||||
test-data/phony-guests/make-windows-img.sh | 1 +
|
||||
tests/charsets/test-charset-fidelity.c | 2 ++
|
||||
3 files changed, 19 insertions(+)
|
||||
|
||||
diff --git a/generator/c.ml b/generator/c.ml
|
||||
index 447059b8a..0391dd3dd 100644
|
||||
--- a/generator/c.ml
|
||||
+++ b/generator/c.ml
|
||||
@@ -1846,6 +1846,22 @@ and generate_client_actions actions () =
|
||||
check_args_validity c_name style;
|
||||
trace_call name c_name style;
|
||||
|
||||
+ (* RHEL 8 *)
|
||||
+ if name = "mount" || name = "mount_ro" || name = "mount_options" ||
|
||||
+ name = "mount_vfs" then (
|
||||
+ pr " if (g->program && !STRPREFIX (g->program, \"virt-\")) {\n";
|
||||
+ pr " CLEANUP_FREE char *vfs_type = guestfs_vfs_type (g, mountable);\n";
|
||||
+ pr " if (vfs_type && STREQ (vfs_type, \"ntfs\")) {\n";
|
||||
+ pr " error (g, \"mount: unsupported filesystem type\");\n";
|
||||
+ pr " if (trace_flag)\n";
|
||||
+ pr " guestfs_int_trace (g, \"%%s = %%s (error)\",\n";
|
||||
+ pr " \"%s\", \"-1\");\n" name;
|
||||
+ pr " return %s;\n" (string_of_errcode errcode);
|
||||
+ pr " }\n";
|
||||
+ pr " }\n";
|
||||
+ pr "\n";
|
||||
+ );
|
||||
+
|
||||
(* Calculate the total size of all FileIn arguments to pass
|
||||
* as a progress bar hint.
|
||||
*)
|
||||
diff --git a/test-data/phony-guests/make-windows-img.sh b/test-data/phony-guests/make-windows-img.sh
|
||||
index 16debd129..1c13ddac3 100755
|
||||
--- a/test-data/phony-guests/make-windows-img.sh
|
||||
+++ b/test-data/phony-guests/make-windows-img.sh
|
||||
@@ -37,6 +37,7 @@ fi
|
||||
|
||||
# Create a disk image.
|
||||
guestfish <<EOF
|
||||
+set-program virt-testing
|
||||
sparse windows.img-t 512M
|
||||
run
|
||||
|
||||
diff --git a/tests/charsets/test-charset-fidelity.c b/tests/charsets/test-charset-fidelity.c
|
||||
index 105291dc3..5ca4f3b6d 100644
|
||||
--- a/tests/charsets/test-charset-fidelity.c
|
||||
+++ b/tests/charsets/test-charset-fidelity.c
|
||||
@@ -96,6 +96,8 @@ main (int argc, char *argv[])
|
||||
if (g == NULL)
|
||||
error (EXIT_FAILURE, 0, "failed to create handle");
|
||||
|
||||
+ guestfs_set_program (g, "virt-testing");
|
||||
+
|
||||
if (guestfs_add_drive_scratch (g, 1024*1024*1024, -1) == -1)
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
@ -0,0 +1,90 @@
|
||||
From 8aa0958faabcf6d1755a8dcda3bcbb3bc63f6c1f Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Mon, 8 Jul 2024 14:37:22 +0100
|
||||
Subject: [PATCH] New APIs: findfs_partuuid and findfs_partlabel
|
||||
|
||||
These search for partitions by UUID or label (name). They only work
|
||||
for GPT.
|
||||
|
||||
(cherry picked from commit 1816651f3c138600ad2e5ba0d6437b4753333818)
|
||||
(cherry picked from commit 04a45af93d21880e54a386386313100a04b91ca7)
|
||||
---
|
||||
daemon/findfs.ml | 4 ++++
|
||||
generator/actions_core.ml | 24 ++++++++++++++++++++++++
|
||||
generator/proc_nr.ml | 2 ++
|
||||
lib/MAX_PROC_NR | 2 +-
|
||||
4 files changed, 31 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/daemon/findfs.ml b/daemon/findfs.ml
|
||||
index cf2ba4a84..a94e0ce7b 100644
|
||||
--- a/daemon/findfs.ml
|
||||
+++ b/daemon/findfs.ml
|
||||
@@ -27,6 +27,10 @@ let rec findfs_uuid uuid =
|
||||
findfs "UUID" uuid
|
||||
and findfs_label label =
|
||||
findfs "LABEL" label
|
||||
+and findfs_partuuid uuid =
|
||||
+ findfs "PARTUUID" uuid
|
||||
+and findfs_partlabel label =
|
||||
+ findfs "PARTLABEL" label
|
||||
|
||||
and findfs tag str =
|
||||
(* Kill the cache file, forcing blkid to reread values from the
|
||||
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
|
||||
index 4a4a8e4c9..15cdd09ff 100644
|
||||
--- a/generator/actions_core.ml
|
||||
+++ b/generator/actions_core.ml
|
||||
@@ -5688,6 +5688,30 @@ filesystem can be found.
|
||||
|
||||
To find the label of a filesystem, use C<guestfs_vfs_label>." };
|
||||
|
||||
+ { defaults with
|
||||
+ name = "findfs_partuuid"; added = (1, 5, 3);
|
||||
+ style = RString (RDevice, "device"), [String (PlainString, "uuid")], [];
|
||||
+ impl = OCaml "Findfs.findfs_partuuid";
|
||||
+ shortdesc = "find a partition by UUID";
|
||||
+ longdesc = "\
|
||||
+This command searches the partitions and returns the one
|
||||
+which has the given partition UUID. An error is returned if no such
|
||||
+partition can be found.
|
||||
+
|
||||
+To find the UUID of a partition, use C<guestfs_blkid> (C<PART_ENTRY_UUID>)." };
|
||||
+
|
||||
+ { defaults with
|
||||
+ name = "findfs_partlabel"; added = (1, 5, 3);
|
||||
+ style = RString (RDevice, "device"), [String (PlainString, "label")], [];
|
||||
+ impl = OCaml "Findfs.findfs_partlabel";
|
||||
+ shortdesc = "find a partition by label";
|
||||
+ longdesc = "\
|
||||
+This command searches the partitions and returns the one
|
||||
+which has the given label. An error is returned if no such
|
||||
+partition can be found.
|
||||
+
|
||||
+To find the label of a partition, use C<guestfs_blkid> (C<PART_ENTRY_NAME>)." };
|
||||
+
|
||||
{ defaults with
|
||||
name = "is_chardev"; added = (1, 5, 10);
|
||||
style = RBool "flag", [String (Pathname, "path")], [OBool "followsymlinks"];
|
||||
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
|
||||
index f71a849c9..56cd97a9f 100644
|
||||
--- a/generator/proc_nr.ml
|
||||
+++ b/generator/proc_nr.ml
|
||||
@@ -516,6 +516,8 @@ let proc_nr = [
|
||||
511, "internal_readdir";
|
||||
512, "clevis_luks_unlock";
|
||||
513, "inspect_get_build_id";
|
||||
+514, "findfs_partuuid";
|
||||
+515, "findfs_partlabel";
|
||||
]
|
||||
|
||||
(* End of list. If adding a new entry, add it at the end of the list
|
||||
diff --git a/lib/MAX_PROC_NR b/lib/MAX_PROC_NR
|
||||
index 31cf34b8d..3cda32fc2 100644
|
||||
--- a/lib/MAX_PROC_NR
|
||||
+++ b/lib/MAX_PROC_NR
|
||||
@@ -1 +1 @@
|
||||
-513
|
||||
+515
|
||||
--
|
||||
2.43.0
|
||||
|
@ -0,0 +1,45 @@
|
||||
From 5733e5268fe0b7a99f20b23ea30ab13632cc9d95 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Mon, 8 Jul 2024 14:39:16 +0100
|
||||
Subject: [PATCH] inspection: Resolve PARTUUID= and PARTLABEL= in /etc/fstab
|
||||
|
||||
Fixes: https://issues.redhat.com/browse/RHEL-46596
|
||||
(cherry picked from commit e616c8f286ddacf401d7c356724ae874ed883262)
|
||||
(cherry picked from commit ebce03824a3ce75823037003ca2311d7b8d61565)
|
||||
---
|
||||
daemon/inspect_fs_unix_fstab.ml | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
diff --git a/daemon/inspect_fs_unix_fstab.ml b/daemon/inspect_fs_unix_fstab.ml
|
||||
index 837c8c620..f5817a318 100644
|
||||
--- a/daemon/inspect_fs_unix_fstab.ml
|
||||
+++ b/daemon/inspect_fs_unix_fstab.ml
|
||||
@@ -131,6 +131,25 @@ and check_fstab_entry md_map root_mountable os_type aug entry =
|
||||
with
|
||||
Failure _ -> return None
|
||||
)
|
||||
+ (* EFI partition UUIDs and labels. *)
|
||||
+ else if String.is_prefix spec "PARTUUID=" then (
|
||||
+ let uuid = String.sub spec 9 (String.length spec - 9) in
|
||||
+ let uuid = shell_unquote uuid in
|
||||
+ (* Just ignore the device if the UUID cannot be resolved. *)
|
||||
+ try
|
||||
+ Mountable.of_device (Findfs.findfs_partuuid uuid)
|
||||
+ with
|
||||
+ Failure _ -> return None
|
||||
+ )
|
||||
+ else if String.is_prefix spec "PARTLABEL=" then (
|
||||
+ let label = String.sub spec 10 (String.length spec - 10) in
|
||||
+ let label = shell_unquote label in
|
||||
+ (* Just ignore the device if the label cannot be resolved. *)
|
||||
+ try
|
||||
+ Mountable.of_device (Findfs.findfs_partlabel label)
|
||||
+ with
|
||||
+ Failure _ -> return None
|
||||
+ )
|
||||
(* Resolve /dev/root to the current device.
|
||||
* Do the same for the / partition of the *BSD
|
||||
* systems, since the BSD -> Linux device
|
||||
--
|
||||
2.43.0
|
||||
|
@ -0,0 +1,109 @@
|
||||
From 533d39a6862638f587b231ecf541ab1f5c8e85f9 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Fri, 16 Aug 2024 08:26:34 +0100
|
||||
Subject: [PATCH] appliance/init: Don't set impossible "noop" disk scheduler
|
||||
|
||||
Since RHEL 7.4, the noop scheduler is no longer a thing. Trying to
|
||||
set it results in the error:
|
||||
|
||||
+ echo noop
|
||||
/init: line 108: echo: write error: Invalid argument
|
||||
|
||||
The current recommendation (https://access.redhat.com/solutions/5427)
|
||||
is to use mq-deadline, but that's also the default so we don't have to
|
||||
do anything.
|
||||
|
||||
A bigger reason to remove these lines is that kernel 6.11.0 has
|
||||
introduced a hang where -- rarely -- the ext4 filesystem hangs if you
|
||||
try to change the scheduler while handing a page fault, even if you're
|
||||
setting a scheduler that doesn't exist. I couldn't get much detail
|
||||
except for a couple of stack traces from different VMs:
|
||||
|
||||
crash> set 234
|
||||
PID: 234
|
||||
COMMAND: "modprobe"
|
||||
TASK: ffff9f5ec3a22f40 [THREAD_INFO: ffff9f5ec3a22f40]
|
||||
CPU: 0
|
||||
STATE: TASK_UNINTERRUPTIBLE
|
||||
crash> bt
|
||||
PID: 234 TASK: ffff9f5ec3a22f40 CPU: 0 COMMAND: "modprobe"
|
||||
#0 [ffffb21e002e7840] __schedule at ffffffffa718f6d0
|
||||
#1 [ffffb21e002e78f8] schedule at ffffffffa7190a27
|
||||
#2 [ffffb21e002e7908] __bio_queue_enter at ffffffffa67e121c
|
||||
#3 [ffffb21e002e7968] blk_mq_submit_bio at ffffffffa67f358c
|
||||
#4 [ffffb21e002e79f0] __submit_bio at ffffffffa67e1e3c
|
||||
#5 [ffffb21e002e7a58] submit_bio_noacct_nocheck at ffffffffa67e2326
|
||||
#6 [ffffb21e002e7ac0] ext4_mpage_readpages at ffffffffa65ceafc
|
||||
#7 [ffffb21e002e7be0] read_pages at ffffffffa6381d17
|
||||
#8 [ffffb21e002e7c40] page_cache_ra_unbounded at ffffffffa6381ff5
|
||||
#9 [ffffb21e002e7ca8] filemap_fault at ffffffffa63761b5
|
||||
#10 [ffffb21e002e7d48] __do_fault at ffffffffa63d1892
|
||||
#11 [ffffb21e002e7d70] do_fault at ffffffffa63d2425
|
||||
#12 [ffffb21e002e7da0] __handle_mm_fault at ffffffffa63d8c6b
|
||||
#13 [ffffb21e002e7e88] handle_mm_fault at ffffffffa63d95c2
|
||||
#14 [ffffb21e002e7ec8] do_user_addr_fault at ffffffffa60b34ea
|
||||
#15 [ffffb21e002e7f28] exc_page_fault at ffffffffa7186e4e
|
||||
#16 [ffffb21e002e7f50] asm_exc_page_fault at ffffffffa72012a6
|
||||
RIP: 000055d16159f8d8 RSP: 00007ffdd4c1f340 RFLAGS: 00010206
|
||||
RAX: 00000000000bec82 RBX: 00007ff2fd00dc82 RCX: 000055d1615b492a
|
||||
RDX: 00007ffdd4c216b0 RSI: 00000000200bec82 RDI: 000055d185725960
|
||||
RBP: 00007ffdd4c1f5a0 R8: 0000000000000000 R9: 0000000000000000
|
||||
R10: 0000000000000000 R11: 0000000000000202 R12: 00000000200bec82
|
||||
R13: 000055d185725960 R14: 00007ffdd4c216b0 R15: 000055d1615b9708
|
||||
ORIG_RAX: ffffffffffffffff CS: 0033 SS: 002b
|
||||
|
||||
crash> set 230
|
||||
PID: 230
|
||||
COMMAND: "modprobe"
|
||||
TASK: ffff98ce03ca3040 [THREAD_INFO: ffff98ce03ca3040]
|
||||
CPU: 0
|
||||
STATE: TASK_UNINTERRUPTIBLE
|
||||
crash> bt
|
||||
PID: 230 TASK: ffff98ce03ca3040 CPU: 0 COMMAND: "modprobe"
|
||||
#0 [ffffaf9940307840] __schedule at ffffffff9618f6d0
|
||||
#1 [ffffaf99403078f8] schedule at ffffffff96190a27
|
||||
#2 [ffffaf9940307908] __bio_queue_enter at ffffffff957e121c
|
||||
#3 [ffffaf9940307968] blk_mq_submit_bio at ffffffff957f358c
|
||||
#4 [ffffaf99403079f0] __submit_bio at ffffffff957e1e3c
|
||||
#5 [ffffaf9940307a58] submit_bio_noacct_nocheck at ffffffff957e2326
|
||||
#6 [ffffaf9940307ac0] ext4_mpage_readpages at ffffffff955ceafc
|
||||
#7 [ffffaf9940307be0] read_pages at ffffffff95381d1a
|
||||
#8 [ffffaf9940307c40] page_cache_ra_unbounded at ffffffff95381ff5
|
||||
#9 [ffffaf9940307ca8] filemap_fault at ffffffff953761b5
|
||||
#10 [ffffaf9940307d48] __do_fault at ffffffff953d1895
|
||||
#11 [ffffaf9940307d70] do_fault at ffffffff953d2425
|
||||
#12 [ffffaf9940307da0] __handle_mm_fault at ffffffff953d8c6b
|
||||
#13 [ffffaf9940307e88] handle_mm_fault at ffffffff953d95c2
|
||||
#14 [ffffaf9940307ec8] do_user_addr_fault at ffffffff950b34ea
|
||||
#15 [ffffaf9940307f28] exc_page_fault at ffffffff96186e4e
|
||||
#16 [ffffaf9940307f50] asm_exc_page_fault at ffffffff962012a6
|
||||
RIP: 0000556b7a7468d8 RSP: 00007ffde2ffb560 RFLAGS: 00000206
|
||||
RAX: 00000000000bec82 RBX: 00007f5331a0dc82 RCX: 0000556b7a75b92a
|
||||
RDX: 00007ffde2ffd8d0 RSI: 00000000200bec82 RDI: 0000556ba8edf960
|
||||
RBP: 00007ffde2ffb7c0 R8: 0000000000000000 R9: 0000000000000000
|
||||
R10: 0000000000000000 R11: 0000000000000202 R12: 00000000200bec82
|
||||
R13: 0000556ba8edf960 R14: 00007ffde2ffd8d0 R15: 0000556b7a760708
|
||||
ORIG_RAX: ffffffffffffffff CS: 0033 SS: 002b
|
||||
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2303267
|
||||
(cherry picked from commit b2d682a4730ead8b4ae07e5aaf6fa230c5eec305)
|
||||
---
|
||||
appliance/init | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/appliance/init b/appliance/init
|
||||
index 128a3c20e..dae06dbbe 100755
|
||||
--- a/appliance/init
|
||||
+++ b/appliance/init
|
||||
@@ -104,8 +104,6 @@ udevadm settle --timeout=600
|
||||
# Increase the SCSI timeout so we can read remote images.
|
||||
shopt -s nullglob
|
||||
for f in /sys/block/sd*/device/timeout; do echo 300 > $f; done
|
||||
-# https://access.redhat.com/site/solutions/5427
|
||||
-for f in /sys/block/{h,s,ub,v}d*/queue/scheduler; do echo noop > $f; done
|
||||
shopt -u nullglob
|
||||
|
||||
# Set up the network.
|
||||
--
|
||||
2.43.0
|
||||
|
@ -0,0 +1,37 @@
|
||||
Libguestfs is a set of tools and a library for accessing and modifying
|
||||
guest disk images. For more information see the home page:
|
||||
|
||||
http://libguestfs.org/
|
||||
|
||||
For discussion, development, patches, etc. please use the mailing
|
||||
list:
|
||||
|
||||
http://www.redhat.com/mailman/listinfo/libguestfs
|
||||
|
||||
This package comes with a lot of help and examples to get you started.
|
||||
|
||||
The first place to start are the manual pages. Type:
|
||||
|
||||
man guestfs
|
||||
man guestfs-faq
|
||||
man guestfs-release-notes
|
||||
man guestfish
|
||||
man virt-cat # and other virt-* tools
|
||||
|
||||
If you install the libguestfs-devel package, then in the
|
||||
/usr/share/doc/libguestfs-devel/ directory you will find other
|
||||
documentation including:
|
||||
|
||||
- BUGS: list of open bugs in this version
|
||||
|
||||
- ChangeLog.gz: the detailed list of changes in this version
|
||||
|
||||
- HACKING: how to extend libguestfs
|
||||
|
||||
- TODO: ideas for extending libguestfs
|
||||
|
||||
- *.c: example C programs using the API
|
||||
|
||||
- *.xml.gz: example virt-inspector output (compressed)
|
||||
|
||||
- virt-inspector.rng: virt-inspector RelaxNG schema
|
@ -0,0 +1,56 @@
|
||||
#!/bin/bash -
|
||||
|
||||
set -e
|
||||
|
||||
# Maintainer script to copy patches from the git repo to the current
|
||||
# directory. It's normally only used downstream (ie. in RHEL). Use
|
||||
# it like this:
|
||||
# ./copy-patches.sh
|
||||
|
||||
rhel_version=10.0
|
||||
|
||||
# Check we're in the right directory.
|
||||
if [ ! -f libguestfs.spec ]; then
|
||||
echo "$0: run this from the directory containing 'libguestfs.spec'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git_checkout=$HOME/d/libguestfs-rhel-$rhel_version
|
||||
if [ ! -d $git_checkout ]; then
|
||||
echo "$0: $git_checkout does not exist"
|
||||
echo "This script is only for use by the maintainer when preparing a"
|
||||
echo "libguestfs release on RHEL."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the base version of libguestfs.
|
||||
version=`grep '^Version:' libguestfs.spec | awk '{print $2}'`
|
||||
tag="v$version"
|
||||
|
||||
# Remove any existing patches.
|
||||
git rm -f [0-9]*.patch ||:
|
||||
rm -f [0-9]*.patch
|
||||
|
||||
# Get the patches.
|
||||
(cd $git_checkout; rm -f [0-9]*.patch; git format-patch -N --submodule=diff $tag)
|
||||
mv $git_checkout/[0-9]*.patch .
|
||||
|
||||
# Remove any not to be applied.
|
||||
rm -f *NOT-FOR-RPM*.patch
|
||||
|
||||
# Add the patches.
|
||||
git add [0-9]*.patch
|
||||
|
||||
# Print out the patch lines.
|
||||
echo
|
||||
echo "--- Copy the following text into libguestfs.spec file"
|
||||
echo
|
||||
|
||||
echo "# Patches."
|
||||
for f in [0-9]*.patch; do
|
||||
n=`echo $f | awk -F- '{print $1}'`
|
||||
echo "Patch$n: $f"
|
||||
done
|
||||
|
||||
echo
|
||||
echo "--- End of text"
|
@ -0,0 +1,6 @@
|
||||
# Guestfish colour prompts. See PROMPT in guestfish(1).
|
||||
GUESTFISH_PS1='\[\e[1;32m\]><fs>\[\e[0;31m\] '
|
||||
GUESTFISH_OUTPUT='\e[0m'
|
||||
GUESTFISH_RESTORE="$GUESTFISH_OUTPUT"
|
||||
GUESTFISH_INIT='\e[1;34m'
|
||||
export GUESTFISH_PS1 GUESTFISH_OUTPUT GUESTFISH_RESTORE GUESTFISH_INIT
|
@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAmaMBYQRHHJpY2hAYW5u
|
||||
ZXhpYS5vcmcACgkQkXOPc+G3aKCgAA//Y3vipD+s/fdnFSNPkCxE7lPkBW+HPHKM
|
||||
ESFfm4hMaR1m9IgNftcFfdQuiApLOsiKN5eGOqyINsrZCWPDkz7mww911GO4V7Oz
|
||||
mbC2bqvpfLu7OhpxZew+ZrX0NY/hyGngGfSdlc8R0iF4uB76I+ghxllxEfGG1brG
|
||||
mbvbzFbVIsTj7REPWe5HudQHXgqQFtiSxWmB65/uEQo85W/Wbc7BsPZPps99Uyxm
|
||||
Mjt6QsiMxHipA2IZWXVCC9UgOewj7dcnXpmgxmWZxRn8e1C/mPNTYZo7z9AeB1YT
|
||||
W6VX0RRg9TFppi4fCclsWaHyWtaFeasooPzpV9dXn6rezB8K5IzJXeV1Ial154mn
|
||||
w2ofL1qkhtl8wMabBTC7zP+zb1pNu8iajrKgCmY10/Bgia/wRArIK5qS7dIxGDT9
|
||||
jJ5gfP9h5zi01tnNIKbZaoRKSrU+r2+efxvad+8uvQt4JFn1OAL+EVjzePi47aOx
|
||||
h06kt2uktjtWsKBnLmY91FOwSDPL0aDd8zKp6Ddm84TIQ4tXy4caQ9vQCON7cuNy
|
||||
5NhvHHs3VNAFOVUW5/e/E9RdmYMnSJaYRpdvpKOuHNcWzPmYR32BMI4LjtYABtkz
|
||||
Cn0WKnCASUa2W3CzD7V5bHtdT4fnQNbZvcgPGouB/+SlIpABqyfyIQnUta8Tsn2u
|
||||
msgD9HFR9kk=
|
||||
=yVGZ
|
||||
-----END PGP SIGNATURE-----
|
@ -0,0 +1,17 @@
|
||||
[main]
|
||||
cachedir=@PWD@/cachedir
|
||||
debuglevel=1
|
||||
logfile=@PWD@/yum.log
|
||||
retries=20
|
||||
obsoletes=1
|
||||
gpgcheck=0
|
||||
assumeyes=1
|
||||
reposdir=/dev/null
|
||||
modulesdir=@PWD@/modules
|
||||
|
||||
[local]
|
||||
name=local
|
||||
baseurl=file://@PWD@/repo
|
||||
failovermethod=priority
|
||||
enabled=1
|
||||
gpgcheck=0
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue