diff --git a/0001-appliance-Use-cpu-max.patch b/0001-appliance-Use-cpu-max.patch new file mode 100644 index 0000000..70b482a --- /dev/null +++ b/0001-appliance-Use-cpu-max.patch @@ -0,0 +1,80 @@ +From 282e2f74cf1209ecf6bb18655018b2000a5b36a1 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 28 Jan 2021 12:20:49 +0000 +Subject: [PATCH] appliance: Use -cpu max. + +QEMU has a newish feature (from about 2017 / qemu 2.9) called -cpu max +which is supposed to select the best CPU, ideal for libguestfs. + +After this change, on x86-64: + + KVM TCG + +Direct -cpu max -cpu max +(non-libvirt) + +Libvirt + + +--- + lib/appliance-cpu.c | 16 ++++++++-------- + lib/launch-libvirt.c | 9 +++++++++ + 2 files changed, 17 insertions(+), 8 deletions(-) + +diff --git a/lib/appliance-cpu.c b/lib/appliance-cpu.c +index 5ef9f5c72..54ac6e2e3 100644 +--- a/lib/appliance-cpu.c ++++ b/lib/appliance-cpu.c +@@ -38,6 +38,11 @@ + * + * The literal string C<"host"> means use C<-cpu host>. + * ++ * =item C<"max"> ++ * ++ * The literal string C<"max"> means use C<-cpu max> (the best ++ * possible). This requires awkward translation for libvirt. ++ * + * =item some string + * + * Some string such as C<"cortex-a57"> means use C<-cpu cortex-a57>. +@@ -80,14 +85,9 @@ guestfs_int_get_cpu_model (int kvm) + /* See discussion in https://bugzilla.redhat.com/show_bug.cgi?id=1605071 */ + return NULL; + #else +- /* On most architectures, it is faster to pass the CPU host model to +- * the appliance, allowing maximum speed for things like checksums +- * and encryption. Only do this with KVM. It is broken in subtle +- * ways on TCG, and fairly pointless when you're emulating anyway. ++ /* On most architectures we can use "max" to get the best possible CPU. ++ * For recent qemu this should work even on TCG. + */ +- if (kvm) +- return "host"; +- else +- return NULL; ++ return "max"; + #endif + } +diff --git a/lib/launch-libvirt.c b/lib/launch-libvirt.c +index 026dc6b26..eff1c8f7e 100644 +--- a/lib/launch-libvirt.c ++++ b/lib/launch-libvirt.c +@@ -1169,6 +1169,15 @@ construct_libvirt_xml_cpu (guestfs_h *g, + attribute ("fallback", "allow"); + } end_element (); + } ++ else if (STREQ (cpu_model, "max")) { ++ if (params->data->is_kvm) ++ attribute ("mode", "host-passthrough"); ++ else ++ attribute ("mode", "host-model"); ++ start_element ("model") { ++ attribute ("fallback", "allow"); ++ } end_element (); ++ } + else + single_element ("model", cpu_model); + } end_element (); +-- +2.29.0.rc2 + diff --git a/libguestfs.spec b/libguestfs.spec index b623156..9fc8f60 100644 --- a/libguestfs.spec +++ b/libguestfs.spec @@ -29,6 +29,7 @@ %else # RHEL 9 only: # x86-64: "/lib64/libc.so.6: CPU ISA level is lower than required" +# (RHBZ#1919389) %global test_arches NONE %endif @@ -55,7 +56,7 @@ Summary: Access and modify virtual machine disk images Name: libguestfs Epoch: 1 Version: 1.44.0 -Release: 4%{?dist} +Release: 5%{?dist} License: LGPLv2+ # Build only for architectures that have a kernel @@ -85,6 +86,9 @@ Source7: libguestfs.keyring # Maintainer script which helps with handling patches. Source8: copy-patches.sh +# Upstream patch to use -cpu max. +Patch1: 0001-appliance-Use-cpu-max.patch + %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool, gettext-devel %endif @@ -222,7 +226,9 @@ BuildRequires: findutils BuildRequires: gawk BuildRequires: gdisk BuildRequires: genisoimage +%if !0%{?rhel} BuildRequires: gfs2-utils +%endif BuildRequires: grep BuildRequires: gzip %if !0%{?rhel} @@ -385,9 +391,7 @@ For enhanced features, install: %if !0%{?rhel} libguestfs-forensics adds filesystem forensics support -%endif libguestfs-gfs2 adds Global Filesystem (GFS2) support -%if !0%{?rhel} libguestfs-hfsplus adds HFS+ (Mac filesystem) support %endif libguestfs-inspect-icons adds support for inspecting guest icons @@ -456,6 +460,7 @@ want to forensically analyze disk images using The Sleuth Kit. %endif +%if !0%{?rhel} %package gfs2 Summary: GFS2 support for %{name} License: LGPLv2+ @@ -464,6 +469,7 @@ Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release} %description gfs2 This adds GFS2 support to %{name}. Install it if you want to process disk images containing GFS2. +%endif %if !0%{?rhel} @@ -1039,9 +1045,7 @@ move_to qemu-img zz-packages-dib move_to which zz-packages-dib %if !0%{?rhel} move_to sleuthkit zz-packages-forensics -%endif move_to gfs2-utils zz-packages-gfs2 -%if !0%{?rhel} move_to hfsplus-tools zz-packages-hfsplus move_to jfsutils zz-packages-jfs move_to nilfs-utils zz-packages-nilfs @@ -1129,8 +1133,10 @@ rm ocaml/html/.gitignore %{_libdir}/guestfs/supermin.d/zz-packages-forensics %endif +%if !0%{?rhel} %files gfs2 %{_libdir}/guestfs/supermin.d/zz-packages-gfs2 +%endif %if !0%{?rhel} %ifnarch ppc @@ -1371,6 +1377,9 @@ rm ocaml/html/.gitignore %changelog +* Tue Feb 09 2021 Richard W.M. Jones - 1:1.44.0-5 +- Remove gfs2-utils dependency in RHEL 9. + * Thu Jan 28 2021 Richard W.M. Jones - 1:1.44.0-4 - ELN has full-fat qemu (not qemu-kvm).