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 31fa712aa0)
(cherry picked from commit 19c4d1c8b9)
This commit is contained in:
Richard W.M. Jones
2025-03-10 18:52:08 +00:00
parent d8142f0dc4
commit 287213b446

View File

@@ -36,6 +36,7 @@
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <errno.h>
#include <assert.h>
#include <libintl.h>
@@ -92,6 +93,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, ""))
@@ -108,6 +110,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. */