]> git.proxmox.com Git - pve-qemu.git/commitdiff
Write recognized CPUID flags into static file
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Oct 2019 11:37:02 +0000 (13:37 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Oct 2019 11:39:21 +0000 (13:39 +0200)
located at /usr/share/kvm/recognized-CPUID-flags-x86_64

It's a simple one flag per line list of all flags the build of QEMU
can understand for x86_64 CPUs.

It will be used in qemu-server for the custom CPU model feature.

For now, only x86_64 is implemented, since aarch64 doesn't print any flags when
called this way.

Co-developed-by: Stefan Reiter <s.reiter@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
debian/parse-cpu-flags.pl [new file with mode: 0755]
debian/rules

diff --git a/debian/parse-cpu-flags.pl b/debian/parse-cpu-flags.pl
new file mode 100755 (executable)
index 0000000..1847b3e
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+my @flags = ();
+my $got_flags_section;
+
+while (<STDIN>) {
+    if (/^\s*Recognized CPUID flags:/) {
+       $got_flags_section = 1;
+       next;
+    }
+    next if !$got_flags_section;
+
+    s/^\s+//;
+
+    push @flags, split(/\s+/);
+}
+
+die "no QEMU/KVM CPU flags detected from STDIN input" if scalar (@flags) <= 0;
+
+print join("\n", @flags) or die "$!\n";
index 8f428c77704b4a2240b6b11859c189c6e95373f6..dad78ddb8dd42f73fb17855c020647bd34cbfc01 100755 (executable)
@@ -21,6 +21,8 @@ ARCH ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
 PACKAGE=pve-qemu-kvm
 destdir := $(CURDIR)/debian/$(PACKAGE)
 
+flagfile := $(destdir)/usr/share/kvm/recognized-CPUID-flags-x86_64
+
 CFLAGS = -Wall
 
 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
@@ -128,6 +130,9 @@ install: build
        rm -Rf $(destdir)/usr/include
        rm -Rf $(destdir)/usr/lib*
 
+       # CPU flags are static for QEMU version, allows avoiding more costly checks
+       $(destdir)/usr/bin/qemu-system-x86_64 -cpu help | ./debian/parse-cpu-flags.pl > $(flagfile)
+
 # Build architecture-independent files here.
 binary-indep: build install
 # We have nothing to do by default.