]> git.proxmox.com Git - qemu-server.git/commitdiff
Simplify QEMU version check and require 3.0+
authorStefan Reiter <s.reiter@proxmox.com>
Wed, 12 Feb 2020 10:10:56 +0000 (11:10 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 12 Feb 2020 10:19:29 +0000 (11:19 +0100)
Some of the recent QMP changes require at least 2.8.0, but since the
oldest version we officially package for 6.x is 4.0.0 anyway, checking
for at least 3.0 should not break anyone's setup.

Note that this does not affect machine version checks, only the
installed QEMU binary version.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/QemuServer.pm
test/cfg2cmd/old-qemu.conf [new file with mode: 0644]
test/cfg2cmd/simple1.conf

index 27b9866551875f36cd278f7bbe55408dd96bf43c..23176dd098de4b6c86f5c84ef3df6e08ad97e0d8 100644 (file)
@@ -3415,7 +3415,6 @@ sub config_to_command {
     my $devices = [];
     my $pciaddr = '';
     my $bridges = {};
-    my $vernum = 0; # unknown
     my $ostype = $conf->{ostype};
     my $winversion = windows_version($ostype);
     my $kvm = $conf->{kvm};
@@ -3425,6 +3424,11 @@ sub config_to_command {
     my $kvm_binary = get_command_for_arch($arch);
     my $kvmver = kvm_user_version($kvm_binary);
 
+    if (!$kvmver || $kvmver !~ m/^(\d+)\.(\d+)/ || $1 < 3) {
+       $kvmver //= "undefined";
+       die "Detected old QEMU binary ('$kvmver', at least 3.0 is required)\n";
+    }
+
     my $add_pve_version = min_version($kvmver, 4, 1);
 
     my $machine_type = get_vm_machine($conf, $forcemachine, $arch, $add_pve_version);
@@ -3458,14 +3462,6 @@ sub config_to_command {
            if !defined kvm_version();
     }
 
-    if ($kvmver =~ m/^(\d+)\.(\d+)$/) {
-       $vernum = $1*1000000+$2*1000;
-    } elsif ($kvmver =~ m/^(\d+)\.(\d+)\.(\d+)$/) {
-       $vernum = $1*1000000+$2*1000+$3;
-    }
-
-    die "detected old qemu-kvm binary ($kvmver)\n" if $vernum < 15000;
-
     my $q35 = PVE::QemuServer::Machine::machine_type_is_q35($conf);
     my $hotplug_features = parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
     my $use_old_bios_files = undef;
diff --git a/test/cfg2cmd/old-qemu.conf b/test/cfg2cmd/old-qemu.conf
new file mode 100644 (file)
index 0000000..08e852c
--- /dev/null
@@ -0,0 +1,4 @@
+# TEST: Test QEMU version detection and expect fail on old version
+# QEMU_VERSION: 2.12.1
+# EXPECT_ERROR: Detected old QEMU binary ('2.12.1', at least 3.0 is required)
+smbios1: uuid=7b10d7af-b932-4c66-b2c3-3996152ec465
index 10a4c315e52faa80aa2c106bb1e3db533e38b5e2..16a24023cd1f5da6e12dd18852d05220405f464e 100644 (file)
@@ -1,5 +1,5 @@
 # TEST: Simple test for a basic configuration with no special things
-# QEMU_VERSION: 2.12.1
+# QEMU_VERSION: 3.0
 bootdisk: scsi0
 cores: 3
 ide2: none,media=cdrom