Fix parsing in part_get_gpt_attributes
resolves: RHEL-45465
This commit is contained in:
parent
a72cbc21d8
commit
a2c4e63c73
@ -0,0 +1,34 @@
|
||||
From 0572a675c9ba5d2bb4e31bc5844fcfd9bc3538cf Mon Sep 17 00:00:00 2001
|
||||
From: Olaf Hering <olaf@aepfle.de>
|
||||
Date: Wed, 15 May 2024 09:11:49 +0200
|
||||
Subject: [PATCH] appliance: only wait for resolv.conf update if dhcpcd
|
||||
succeeded
|
||||
|
||||
In case network was requested, but the host lacks both dhclient and
|
||||
dhcpcd, skip the loop which waits for a resolv.conf update.
|
||||
|
||||
This reduces boot time by 10 seconds.
|
||||
|
||||
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
||||
(cherry picked from commit 4ef645778a563759406cee597b9ff37c99da33fe)
|
||||
---
|
||||
appliance/init | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/appliance/init b/appliance/init
|
||||
index cb200d5bf..128a3c20e 100755
|
||||
--- a/appliance/init
|
||||
+++ b/appliance/init
|
||||
@@ -119,8 +119,7 @@ if test "$guestfs_network" = 1; then
|
||||
rm -f /etc/dhcp/dhclient-enter-hooks.d/resolved
|
||||
if dhclient --version >/dev/null 2>&1; then
|
||||
dhclient $iface
|
||||
- else
|
||||
- dhcpcd $iface
|
||||
+ elif dhcpcd $iface; then
|
||||
# https://github.com/NetworkConfiguration/dhcpcd/issues/258
|
||||
for i in `seq 0 10`; do
|
||||
if grep nameserver /etc/resolv.conf; then break; fi
|
||||
--
|
||||
2.43.0
|
||||
|
40
0003-rust-Handle-null-pointer-when-creating-slice.patch
Normal file
40
0003-rust-Handle-null-pointer-when-creating-slice.patch
Normal file
@ -0,0 +1,40 @@
|
||||
From a5bc2980ec85d04ad1905d299b7b8c083c26965f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6tzel?= <juergen@archlinux.org>
|
||||
Date: Thu, 20 Jun 2024 13:27:51 +0100
|
||||
Subject: [PATCH] rust: Handle null pointer when creating slice
|
||||
|
||||
Starting with Rust 1.78 null assertions in the standard library are
|
||||
now checked when compiling in test/debug mode.
|
||||
|
||||
Fixes: https://github.com/libguestfs/libguestfs/issues/145
|
||||
(cherry picked from commit 43946911c7e4eda422b8d041e063689e7434b04e)
|
||||
---
|
||||
rust/src/event.rs | 12 ++++++++++--
|
||||
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/rust/src/event.rs b/rust/src/event.rs
|
||||
index 752e73610..72afd3cf6 100644
|
||||
--- a/rust/src/event.rs
|
||||
+++ b/rust/src/event.rs
|
||||
@@ -105,8 +105,16 @@ impl<'a> base::Handle<'a> {
|
||||
None => panic!("Failed to parse bitmask: {}", event),
|
||||
};
|
||||
let eh = EventHandle { eh: event_handle };
|
||||
- let buf = unsafe { slice::from_raw_parts(buf as *const u8, buf_len) };
|
||||
- let array = unsafe { slice::from_raw_parts(array, array_len) };
|
||||
+ let buf = if !buf.is_null() {
|
||||
+ unsafe { slice::from_raw_parts(buf as *const u8, buf_len) }
|
||||
+ } else {
|
||||
+ &[]
|
||||
+ };
|
||||
+ let array = if !array.is_null() {
|
||||
+ unsafe { slice::from_raw_parts(array, array_len) }
|
||||
+ } else {
|
||||
+ &[]
|
||||
+ };
|
||||
|
||||
let callback: &Box<dyn Fn(guestfs::Event, EventHandle, &[u8], &[u64])> =
|
||||
Box::leak(unsafe { Box::from_raw(opaque as *mut _) });
|
||||
--
|
||||
2.43.0
|
||||
|
@ -0,0 +1,34 @@
|
||||
From 3e749db4e291af9d0d49244d82bdb844735dedb1 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Fri, 28 Jun 2024 09:39:59 +0100
|
||||
Subject: [PATCH] generator/daemon: Don't truncate 64 bit results from OCaml
|
||||
functions
|
||||
|
||||
Commit d5b6f1df5f ("daemon: Allow parts of the daemon and APIs to be
|
||||
written in OCaml.", 2017) contained a bug where in any OCaml function
|
||||
that returns int64_t, the result was truncated to an int. This
|
||||
particularly affected part_get_gpt_attributes as that returns large 64
|
||||
bit numbers, but probably affects other functions too, undetected.
|
||||
|
||||
Fixes: commit d5b6f1df5ff2d387a5dfc89b8316c0dff67ce2c9
|
||||
(cherry picked from commit 882ef4d93a2f8b150a66fa89f87ef1c4dd42de2f)
|
||||
---
|
||||
generator/daemon.ml | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/generator/daemon.ml b/generator/daemon.ml
|
||||
index 5e2a78b91..78a2412d2 100644
|
||||
--- a/generator/daemon.ml
|
||||
+++ b/generator/daemon.ml
|
||||
@@ -835,7 +835,7 @@ let generate_daemon_caml_stubs () =
|
||||
| RInt _ ->
|
||||
pr " CAMLreturnT (int, Int_val (retv));\n"
|
||||
| RInt64 _ ->
|
||||
- pr " CAMLreturnT (int, Int64_val (retv));\n"
|
||||
+ pr " CAMLreturnT (int64_t, Int64_val (retv));\n"
|
||||
| RBool _ ->
|
||||
pr " CAMLreturnT (int, Bool_val (retv));\n"
|
||||
| RConstString _ -> assert false
|
||||
--
|
||||
2.43.0
|
||||
|
134
0005-daemon-Fix-parsing-in-part_get_gpt_attributes.patch
Normal file
134
0005-daemon-Fix-parsing-in-part_get_gpt_attributes.patch
Normal file
@ -0,0 +1,134 @@
|
||||
From 768d81c5f681e2fff922eb31ddc2318f9704de85 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
|
||||
|
@ -42,7 +42,7 @@ Summary: Access and modify virtual machine disk images
|
||||
Name: libguestfs
|
||||
Epoch: 1
|
||||
Version: 1.52.1
|
||||
Release: 5%{?dist}
|
||||
Release: 6%{?dist}
|
||||
License: LGPL-2.1-or-later
|
||||
|
||||
# Build only for architectures that have a kernel
|
||||
@ -81,6 +81,10 @@ Source8: copy-patches.sh
|
||||
|
||||
# Patches.
|
||||
Patch0001: 0001-daemon-Reimplement-partition-GPT-functions-using-sfd.patch
|
||||
Patch0002: 0002-appliance-only-wait-for-resolv.conf-update-if-dhcpcd.patch
|
||||
Patch0003: 0003-rust-Handle-null-pointer-when-creating-slice.patch
|
||||
Patch0004: 0004-generator-daemon-Don-t-truncate-64-bit-results-from-.patch
|
||||
Patch0005: 0005-daemon-Fix-parsing-in-part_get_gpt_attributes.patch
|
||||
|
||||
BuildRequires: autoconf, automake, libtool, gettext-devel
|
||||
|
||||
@ -1105,6 +1109,10 @@ rm ocaml/html/.gitignore
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Jun 28 2024 Richard W.M. Jones <rjones@redhat.com> - 1:1.52.1-6
|
||||
- Fix parsing in part_get_gpt_attributes
|
||||
resolves: RHEL-45465
|
||||
|
||||
* Tue Jun 25 2024 Troy Dawson <tdawson@redhat.com> - 1:1.52.1-5
|
||||
- Bump release for June 2024 mass rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user