diff --git a/debian/parse-cpu-flags.pl b/debian/parse-cpu-flags.pl new file mode 100755 index 0000000..1847b3e --- /dev/null +++ b/debian/parse-cpu-flags.pl @@ -0,0 +1,23 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +my @flags = (); +my $got_flags_section; + +while () { + 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"; diff --git a/debian/rules b/debian/rules index 8f428c7..dad78dd 100755 --- a/debian/rules +++ b/debian/rules @@ -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.