[pve-devel] [PATCH pve-qemu 1/7] add static supported machines file

Stefan Reiter s.reiter at proxmox.com
Thu Mar 4 13:52:03 CET 2021


Same rationale as the CPU flags file, avoids calling QEMU binary just to
query machine types.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 debian/parse-machines.pl | 21 +++++++++++++++++++++
 debian/rules             |  4 +++-
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100755 debian/parse-machines.pl

diff --git a/debian/parse-machines.pl b/debian/parse-machines.pl
new file mode 100755
index 0000000..8ad335d
--- /dev/null
+++ b/debian/parse-machines.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+my @machines = ();
+
+while (<STDIN>) {
+    if (/^\s*Supported machines are:/) {
+	next;
+    }
+
+    s/^\s+//;
+    my @machine = split(/\s+/);
+    next if $machine[0] !~ m/^pc-(i440fx|q35)/;
+    push @machines, $machine[0];
+}
+
+die "no QEMU machine types detected from STDIN input" if scalar (@machines) <= 0;
+
+print join("\n", @machines) or die "$!\n";
diff --git a/debian/rules b/debian/rules
index 4a6b472..386ac4b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -22,6 +22,7 @@ PACKAGE=pve-qemu-kvm
 destdir := $(CURDIR)/debian/$(PACKAGE)
 
 flagfile := $(destdir)/usr/share/kvm/recognized-CPUID-flags-x86_64
+machinefile := $(destdir)/usr/share/kvm/machine-versions-x86_64
 
 # default QEMU out-of-tree build directory is ./build
 BUILDDIR=build
@@ -124,7 +125,7 @@ install: build
 	rm $(destdir)/usr/share/kvm/qemu_vga.ndrv
 	rm $(destdir)/usr/share/kvm/slof.bin
 	rm $(destdir)/usr/share/kvm/u-boot.e500
-	# remove Aplha files
+	# remove Alpha files
 	rm $(destdir)/usr/share/kvm/palcode-clipper
 	# remove RISC-V files
 	rm $(destdir)/usr/share/kvm/opensbi-riscv32-generic-fw_dynamic.elf
@@ -138,6 +139,7 @@ install: build
 
 	# 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)
+	$(destdir)/usr/bin/qemu-system-x86_64 -machine help | ./debian/parse-machines.pl > $(machinefile)
 
 # Build architecture-independent files here.
 binary-indep: build install
-- 
2.20.1






More information about the pve-devel mailing list