import libguestfs-1.48.4-4.el9

This commit is contained in:
CentOS Sources 2023-03-28 10:57:32 +00:00 committed by Stepan Oksanichenko
parent 7e122ae857
commit bbe240d476
4 changed files with 285 additions and 9 deletions

View File

@ -0,0 +1,184 @@
From 7dbcddd5bd5939493db74843593316f7101f8fde Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 1 Dec 2022 10:00:46 +0000
Subject: [PATCH] New API: inspect_get_build_id
Add an API to return the build ID of the guest. This to allow a
future change to be able to distinguish between Windows 10 and Windows 11
which can only be done using the build ID.
For Windows we can read the CurrentBuildNumber key from the registry.
For Linux there happens to be a BUILD_ID field in /etc/os-release.
I've never seen a Linux distro that actually uses this.
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit f3dd67affe3c657af64ee9f6d70a16e965309556)
---
daemon/inspect.ml | 6 ++++++
daemon/inspect_fs_unix.ml | 2 ++
daemon/inspect_fs_windows.ml | 14 ++++++++++++++
daemon/inspect_types.ml | 5 +++++
daemon/inspect_types.mli | 1 +
generator/actions_inspection.ml | 19 +++++++++++++++++++
generator/proc_nr.ml | 3 ++-
lib/MAX_PROC_NR | 2 +-
8 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/daemon/inspect.ml b/daemon/inspect.ml
index fb75b4a6c..20217c025 100644
--- a/daemon/inspect.ml
+++ b/daemon/inspect.ml
@@ -335,6 +335,12 @@ and inspect_get_hostname root =
| Some v -> v
| None -> "unknown"
+and inspect_get_build_id root =
+ let root = search_for_root root in
+ match root.inspection_data.build_id with
+ | Some v -> v
+ | None -> "unknown"
+
and inspect_get_windows_systemroot root =
let root = search_for_root root in
match root.inspection_data.windows_systemroot with
diff --git a/daemon/inspect_fs_unix.ml b/daemon/inspect_fs_unix.ml
index 63cb279d0..009195f80 100644
--- a/daemon/inspect_fs_unix.ml
+++ b/daemon/inspect_fs_unix.ml
@@ -96,6 +96,8 @@ let rec parse_os_release release_file data =
data.product_name <- Some value
else if key = "VERSION_ID" then
parse_os_release_version_id value data
+ else if key = "BUILD_ID" then
+ data.build_id <- Some value
) values;
(* If we haven't got all the fields, exit right away. *)
diff --git a/daemon/inspect_fs_windows.ml b/daemon/inspect_fs_windows.ml
index c4a05bc38..7bc5de7f7 100644
--- a/daemon/inspect_fs_windows.ml
+++ b/daemon/inspect_fs_windows.ml
@@ -263,6 +263,20 @@ and check_windows_software_registry software_hive data =
with
Not_found -> ()
);
+
+ (* CurrentBuildNumber (build_id).
+ *
+ * In modern Windows, the "CurrentBuild" and "CurrentBuildNumber"
+ * keys are the same. But in Windows XP, "CurrentBuild"
+ * contained something quite different. So always use
+ * "CurrentBuildNumber".
+ *)
+ (try
+ let v = List.assoc "CurrentBuildNumber" values in
+ data.build_id <- Some (Hivex.value_string h v)
+ with
+ Not_found -> ()
+ );
with
| Not_found ->
if verbose () then
diff --git a/daemon/inspect_types.ml b/daemon/inspect_types.ml
index 9395c51f9..328a2146b 100644
--- a/daemon/inspect_types.ml
+++ b/daemon/inspect_types.ml
@@ -48,6 +48,7 @@ and inspection_data = {
mutable version : version option;
mutable arch : string option;
mutable hostname : string option;
+ mutable build_id : string option;
mutable fstab : fstab_entry list;
mutable windows_systemroot : string option;
mutable windows_software_hive : string option;
@@ -167,6 +168,8 @@ and string_of_inspection_data data =
data.arch;
Option.may (fun v -> bpf " hostname: %s\n" v)
data.hostname;
+ Option.may (fun v -> bpf " build ID: %s\n" v)
+ data.build_id;
if data.fstab <> [] then (
let v = List.map (
fun (a, b) -> sprintf "(%s, %s)" (Mountable.to_string a) b
@@ -272,6 +275,7 @@ let null_inspection_data = {
version = None;
arch = None;
hostname = None;
+ build_id = None;
fstab = [];
windows_systemroot = None;
windows_software_hive = None;
@@ -294,6 +298,7 @@ let merge_inspection_data child parent =
parent.version <- merge child.version parent.version;
parent.arch <- merge child.arch parent.arch;
parent.hostname <- merge child.hostname parent.hostname;
+ parent.build_id <- merge child.build_id parent.build_id;
parent.fstab <- child.fstab @ parent.fstab;
parent.windows_systemroot <-
merge child.windows_systemroot parent.windows_systemroot;
diff --git a/daemon/inspect_types.mli b/daemon/inspect_types.mli
index 29c76e8ab..05a3ffd4e 100644
--- a/daemon/inspect_types.mli
+++ b/daemon/inspect_types.mli
@@ -51,6 +51,7 @@ and inspection_data = {
mutable version : version option;
mutable arch : string option;
mutable hostname : string option;
+ mutable build_id : string option;
mutable fstab : fstab_entry list;
mutable windows_systemroot : string option;
mutable windows_software_hive : string option;
diff --git a/generator/actions_inspection.ml b/generator/actions_inspection.ml
index f8b744993..70de22ec0 100644
--- a/generator/actions_inspection.ml
+++ b/generator/actions_inspection.ml
@@ -529,6 +529,25 @@ hive is a valid Windows Registry hive.
You can use C<guestfs_hivex_open> to read or write to the hive.
+Please read L<guestfs(3)/INSPECTION> for more details." };
+
+ { defaults with
+ name = "inspect_get_build_id"; added = (1, 49, 8);
+ style = RString (RPlainString, "buildid"), [String (Mountable, "root")], [];
+ impl = OCaml "Inspect.inspect_get_build_id";
+ shortdesc = "get the system build ID";
+ longdesc = "\
+This returns the build ID of the system, or the string
+C<\"unknown\"> if the system does not have a build ID.
+
+For Windows, this gets the build number. Although it is
+returned as a string, it is (so far) always a number. See
+L<https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions>
+for some possible values.
+
+For Linux, this returns the C<BUILD_ID> string from
+F</etc/os-release>, although this is not often used.
+
Please read L<guestfs(3)/INSPECTION> for more details." };
{ defaults with
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
index edd9bd99d..0f17b1c06 100644
--- a/generator/proc_nr.ml
+++ b/generator/proc_nr.ml
@@ -514,7 +514,8 @@ let proc_nr = [
509, "cryptsetup_close";
510, "internal_list_rpm_applications";
511, "internal_readdir";
-512, "clevis_luks_unlock"
+512, "clevis_luks_unlock";
+513, "inspect_get_build_id";
]
(* 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 4d0e90cbc..31cf34b8d 100644
--- a/lib/MAX_PROC_NR
+++ b/lib/MAX_PROC_NR
@@ -1 +1 @@
-512
+513
--
2.31.1

View File

@ -0,0 +1,82 @@
From 363bbb7e9bd39fc1683fb600c76266f67ad2063c Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 1 Dec 2022 10:14:43 +0000
Subject: [PATCH] lib: Return correct osinfo field for Windows 11
For Windows Client, we can only distinguish between Windows 10 and
Windows 11 using the build ID. The product name in both cases is
"Windows 10 <something>", apparently intentionally.
References:
https://learn.microsoft.com/en-us/answers/questions/586619/windows-11-build-ver-is-still-10022000194.html
https://github.com/cygwin/cygwin/blob/a263fe0b268580273c1adc4b1bad256147990222/winsup/cygwin/wincap.cc#L429
https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
After this fix, the output of virt-inspector changes to this, which is
a bit odd, but correct:
<name>windows</name>
<arch>x86_64</arch>
<distro>windows</distro>
<product_name>Windows 10 Pro</product_name>
<product_variant>Client</product_variant>
<major_version>10</major_version>
<minor_version>0</minor_version>
<windows_systemroot>/Windows</windows_systemroot>
<windows_current_control_set>ControlSet001</windows_current_control_set>
<osinfo>win11</osinfo>
Thanks: Yaakov Selkowitz
Reported-by: Yongkui Guo
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2012658
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 824c7457489366494f0f10fd3369dc30f3a3c360)
---
lib/inspect-osinfo.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/lib/inspect-osinfo.c b/lib/inspect-osinfo.c
index 90e57e6df..1c10ff469 100644
--- a/lib/inspect-osinfo.c
+++ b/lib/inspect-osinfo.c
@@ -86,6 +86,8 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root)
else if (STREQ (type, "windows")) {
CLEANUP_FREE char *product_name = NULL;
CLEANUP_FREE char *product_variant = NULL;
+ CLEANUP_FREE char *build_id_str = NULL;
+ int build_id;
product_name = guestfs_inspect_get_product_name (g, root);
if (!product_name)
@@ -142,8 +144,26 @@ guestfs_impl_inspect_get_osinfo (guestfs_h *g, const char *root)
return safe_strdup (g, "win2k19");
else
return safe_strdup (g, "win2k16");
- } else
- return safe_strdup (g, "win10");
+ }
+ else {
+ /* For Windows >= 10 Client we can only distinguish between
+ * versions by looking at the build ID. See:
+ * https://learn.microsoft.com/en-us/answers/questions/586619/windows-11-build-ver-is-still-10022000194.html
+ * https://github.com/cygwin/cygwin/blob/a263fe0b268580273c1adc4b1bad256147990222/winsup/cygwin/wincap.cc#L429
+ */
+ build_id_str = guestfs_inspect_get_build_id (g, root);
+ if (!build_id_str)
+ return NULL;
+
+ build_id = guestfs_int_parse_unsigned_int (g, build_id_str);
+ if (build_id == -1)
+ return NULL;
+
+ if (build_id >= 22000)
+ return safe_strdup (g, "win11");
+ else
+ return safe_strdup (g, "win10");
+ }
}
break;
}
--
2.31.1

View File

@ -8,7 +8,7 @@ set -e
# ./copy-patches.sh # ./copy-patches.sh
project=libguestfs project=libguestfs
rhel_version=9.1 rhel_version=9.2
# 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

@ -48,7 +48,7 @@ Summary: Access and modify virtual machine disk images
Name: libguestfs Name: libguestfs
Epoch: 1 Epoch: 1
Version: 1.48.4 Version: 1.48.4
Release: 2%{?dist} Release: 4%{?dist}
License: LGPLv2+ License: LGPLv2+
# Build only for architectures that have a kernel # Build only for architectures that have a kernel
@ -83,7 +83,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.1 # https://github.com/libguestfs/libguestfs/commits/rhel-9.2
# Patches. # Patches.
Patch0001: 0001-New-API-guestfs_device_name-returning-the-drive-name.patch Patch0001: 0001-New-API-guestfs_device_name-returning-the-drive-name.patch
@ -102,6 +102,8 @@ Patch0013: 0013-php-add-arginfo-to-php-bindings.patch
Patch0014: 0014-introduce-the-clevis_luks_unlock-API.patch Patch0014: 0014-introduce-the-clevis_luks_unlock-API.patch
Patch0015: 0015-guestfish-guestmount-enable-networking-for-key-ID-cl.patch Patch0015: 0015-guestfish-guestmount-enable-networking-for-key-ID-cl.patch
Patch0016: 0016-daemon-Add-zstd-support-to-guestfs_file_architecture.patch Patch0016: 0016-daemon-Add-zstd-support-to-guestfs_file_architecture.patch
Patch0017: 0017-New-API-inspect_get_build_id.patch
Patch0018: 0018-lib-Return-correct-osinfo-field-for-Windows-11.patch
%if 0%{patches_touch_autotools} %if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool, gettext-devel BuildRequires: autoconf, automake, libtool, gettext-devel
@ -341,6 +343,9 @@ Requires: coreutils
Requires: grep Requires: grep
Requires: tar Requires: tar
# libguestfs-make-fixed-appliance requires xz.
Requires: xz
# For qemu direct and libvirt backends. # For qemu direct and libvirt backends.
Requires: qemu-kvm-core Requires: qemu-kvm-core
%if !0%{?rhel} %if !0%{?rhel}
@ -440,10 +445,6 @@ Summary: Development tools and libraries for %{name}
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release} Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
Requires: pkgconfig Requires: pkgconfig
# libguestfs-make-fixed-appliance requires guestfish.
Requires: xz
Requires: %{name} = %{epoch}:%{version}-%{release}
%description devel %description devel
%{name}-devel contains development tools and libraries %{name}-devel contains development tools and libraries
@ -934,6 +935,7 @@ rm ocaml/html/.gitignore
%{_bindir}/virt-copy-out %{_bindir}/virt-copy-out
%{_bindir}/virt-tar-in %{_bindir}/virt-tar-in
%{_bindir}/virt-tar-out %{_bindir}/virt-tar-out
%{_sbindir}/libguestfs-make-fixed-appliance
%{_libdir}/libguestfs.so.* %{_libdir}/libguestfs.so.*
%{_mandir}/man1/guestfish.1* %{_mandir}/man1/guestfish.1*
%{_mandir}/man1/guestfs-faq.1* %{_mandir}/man1/guestfs-faq.1*
@ -944,6 +946,7 @@ rm ocaml/html/.gitignore
%{_mandir}/man1/guestfs-security.1* %{_mandir}/man1/guestfs-security.1*
%{_mandir}/man1/guestmount.1* %{_mandir}/man1/guestmount.1*
%{_mandir}/man1/guestunmount.1* %{_mandir}/man1/guestunmount.1*
%{_mandir}/man1/libguestfs-make-fixed-appliance.1*
%{_mandir}/man1/libguestfs-test-tool.1* %{_mandir}/man1/libguestfs-test-tool.1*
%{_mandir}/man1/virt-copy-in.1* %{_mandir}/man1/virt-copy-in.1*
%{_mandir}/man1/virt-copy-out.1* %{_mandir}/man1/virt-copy-out.1*
@ -963,12 +966,10 @@ rm ocaml/html/.gitignore
%doc AUTHORS HACKING TODO README %doc AUTHORS HACKING TODO README
%doc examples/*.c %doc examples/*.c
%{_libdir}/libguestfs.so %{_libdir}/libguestfs.so
%{_sbindir}/libguestfs-make-fixed-appliance
%{_mandir}/man1/guestfs-building.1* %{_mandir}/man1/guestfs-building.1*
%{_mandir}/man1/guestfs-hacking.1* %{_mandir}/man1/guestfs-hacking.1*
%{_mandir}/man1/guestfs-internals.1* %{_mandir}/man1/guestfs-internals.1*
%{_mandir}/man1/guestfs-testing.1* %{_mandir}/man1/guestfs-testing.1*
%{_mandir}/man1/libguestfs-make-fixed-appliance.1*
%{_mandir}/man3/guestfs.3* %{_mandir}/man3/guestfs.3*
%{_mandir}/man3/guestfs-examples.3* %{_mandir}/man3/guestfs-examples.3*
%{_mandir}/man3/libguestfs.3* %{_mandir}/man3/libguestfs.3*
@ -1139,6 +1140,15 @@ rm ocaml/html/.gitignore
%changelog %changelog
* Fri Dec 02 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.48.4-4
- New API: guestfs_inspect_get_build_id
- Add support for detecting Windows >= 10, returned through osinfo
resolves: rhbz#2012658
* Tue Nov 08 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.48.4-3
- Move libguestfs-make-fixed-appliance to main package
resolves: rhbz#2140695
* Wed Aug 10 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.48.4-2 * Wed Aug 10 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.48.4-2
- Rebase to new stable branch version 1.48.4 - Rebase to new stable branch version 1.48.4
resolves: rhbz#2059285 resolves: rhbz#2059285