Include host kernel information in libguestfs debugging output

resolves: RHEL-83025
This commit is contained in:
Richard W.M. Jones 2025-03-11 13:03:34 +00:00
parent 1047a2ce7e
commit 029a7e6ce3
4 changed files with 83 additions and 3 deletions

View File

@ -0,0 +1,45 @@
From 19c4d1c8b9f278e054594660b5392d6c08a59d8f Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 10 Mar 2025 18:52:08 +0000
Subject: [PATCH] lib: Print kernel utsname in debug output
Useful for debugging problems caused by the host kernel. In
particular we were looking at a problem with passt creating a user
namespace but didn't know what exact kernel was being used.
(cherry picked from commit 31fa712aa07190f2c5ed789712b92b4be2d51488)
---
lib/launch.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/launch.c b/lib/launch.c
index b9b76e50..9c44612d 100644
--- a/lib/launch.c
+++ b/lib/launch.c
@@ -36,6 +36,7 @@
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/utsname.h>
#include <sys/wait.h>
#include <errno.h>
#include <assert.h>
@@ -93,6 +94,7 @@ guestfs_impl_launch (guestfs_h *g)
struct backend *b;
CLEANUP_FREE char *backend = guestfs_get_backend (g);
int mask;
+ struct utsname utsname;
debug (g, "launch: program=%s", g->program);
if (STRNEQ (g->identifier, ""))
@@ -109,6 +111,10 @@ guestfs_impl_launch (guestfs_h *g)
if (mask >= 0)
debug (g, "launch: umask=0%03o", (unsigned) mask);
debug (g, "launch: euid=%ju", (uintmax_t) geteuid ());
+ if (uname (&utsname) == 0)
+ debug (g, "launch: host: %s %s %s %s %s",
+ utsname.sysname, utsname.nodename, utsname.release,
+ utsname.version, utsname.machine);
}
/* Launch the appliance. */

View File

@ -0,0 +1,29 @@
From fa1c16528267c89de8a2ecebd44405cbd04fa0ee Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 11 Mar 2025 13:36:12 +0000
Subject: [PATCH] daemon: Fix loongarch64 detection on RHEL 9
$ rpm -q file
file-5.39-16.el9.x86_64
$ file ./test-data/binaries/bin-loongarch64-dynamic
./test-data/binaries/bin-loongarch64-dynamic: ELF 64-bit LSB pie executable, *unknown arch 0x102* version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-loongarch-lp64d.so.1, BuildID[sha1]=7622a1a70bf6e697851ac3790557e1ca686459b5, for GNU/Linux 5.19.0, stripped
Updates: commit 729d6d55ea84494f0398d02450bd29c39c55f0bd
(cherry picked from commit 4176b2043f6cf65f8f5f4f7d6fa39beb9c0a22c6)
---
daemon/filearch.ml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/daemon/filearch.ml b/daemon/filearch.ml
index 7dfc1cb7..e2bd5a2c 100644
--- a/daemon/filearch.ml
+++ b/daemon/filearch.ml
@@ -100,6 +100,8 @@ and canonical_elf_arch bits endianness elf_arch =
)
else if substr "LoongArch" then
sprintf "loongarch%s" bits
+ else if substr "*unknown arch 0x102*" then (* file command on RHEL 9 *)
+ sprintf "loongarch%s" bits
else
elf_arch

View File

@ -7,7 +7,7 @@ set -e
# ./copy-patches.sh # ./copy-patches.sh
project=libguestfs project=libguestfs
rhel_version=9.6 rhel_version=9.7
# Check we're in the right directory. # Check we're in the right directory.
if [ ! -f $project.spec ]; then if [ ! -f $project.spec ]; then

View File

@ -37,7 +37,7 @@ Summary: Access and modify virtual machine disk images
Name: libguestfs Name: libguestfs
Epoch: 1 Epoch: 1
Version: 1.54.0 Version: 1.54.0
Release: 4%{?dist} Release: 5%{?dist}
License: LGPL-2.1-or-later License: LGPL-2.1-or-later
# Build only for architectures that have a kernel # Build only for architectures that have a kernel
@ -72,7 +72,7 @@ Source7: libguestfs.keyring
Source8: copy-patches.sh Source8: copy-patches.sh
# Patches are maintained in the following repository: # Patches are maintained in the following repository:
# https://github.com/libguestfs/libguestfs/commits/rhel-9.6 # https://github.com/libguestfs/libguestfs/commits/rhel-9.7
# Patches. # Patches.
Patch0001: 0001-website-Add-links-for-1.54-and-1.55-download-locatio.patch Patch0001: 0001-website-Add-links-for-1.54-and-1.55-download-locatio.patch
@ -92,6 +92,8 @@ Patch0014: 0014-website-Fix-link-to-latest-development-version.patch
Patch0015: 0015-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch Patch0015: 0015-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch
Patch0016: 0016-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch Patch0016: 0016-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
Patch0017: 0017-daemon-New-command_out-and-sh_out-APIs.patch Patch0017: 0017-daemon-New-command_out-and-sh_out-APIs.patch
Patch0018: 0018-lib-Print-kernel-utsname-in-debug-output.patch
Patch0019: 0019-daemon-Fix-loongarch64-detection-on-RHEL-9.patch
BuildRequires: autoconf, automake, libtool, gettext-devel BuildRequires: autoconf, automake, libtool, gettext-devel
@ -1101,6 +1103,10 @@ rm ocaml/html/.gitignore
%changelog %changelog
* Tue Mar 11 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-5
- Include host kernel information in libguestfs debugging output
resolves: RHEL-83025
* Mon Feb 24 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-4 * Mon Feb 24 2025 Richard W.M. Jones <rjones@redhat.com> - 1:1.54.0-4
- Add new APIs to allow command output > 4MB - Add new APIs to allow command output > 4MB
resolves: RHEL-80159 resolves: RHEL-80159