]> git.proxmox.com Git - qemu-server.git/commitdiff
always pin windows VMs to a machine version by default
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 5 Mar 2021 19:46:28 +0000 (20:46 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 5 Mar 2021 19:46:46 +0000 (20:46 +0100)
A fix for violating a important standard for booting[0] in recently
packaged QEMU 5.2 surfaced some issues with Windows based VMs in our
forum[1], which seem to be quite sensitive for such changes (it seems
they derive lots of their device assignment from ACPI).
User visible effects are loss of any network configuration due to
windows thinking it was swapped with a new one, and starts with a
fresh config - this is mostly problematic for setups with static
address assignment.

There may be lots of other, more subtle, effects and the PVE admin is
also not always the VM admin, so we really need to avoid such
negative effects. Do this by pinning the version of any windows based
VMs to either the minimum of (5.1, kvm-version) for existing VMs or
the kvm-version at time of VM creation for new ones.

There are patches in pve-manager for user to be able to change the
pinned version themself in the webinterface, so this can now also get
adapted more easily if there surface any other issues (with new or
old version) in the future.

0: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
1: https://forum.proxmox.com/threads/warning-latest-patch-just-broke-all-my-windows-vms-6-3-4-patch-inside.84915/page-2#post-373331

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Qemu.pm
PVE/QemuServer.pm
test/cfg2cmd/custom-cpu-model-host-phys-bits.conf.cmd
test/cfg2cmd/custom-cpu-model.conf.cmd
test/cfg2cmd/i440fx-win10-hostpci.conf.cmd
test/cfg2cmd/q35-win10-hostpci.conf.cmd
test/cfg2cmd/spice-win.conf.cmd

index feb9ea8b7e236f4f02d01bd77bce96b929838ee3..5015d82ca8e7240107285b90bfa0734d4bfa0e08 100644 (file)
@@ -670,6 +670,20 @@ __PACKAGE__->register_method({
                        $conf->{vmgenid} = PVE::QemuServer::generate_uuid();
                    }
 
+                   my $machine = $conf->{machine};
+                   if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
+                       # always pin Windows' machine version on create, they get to easily confused
+                       if (PVE::QemuServer::windows_version($conf->{ostype})) {
+                           my $pin_version = PVE::QemuServer::kvm_user_version();
+                           if (!$machine || $machine eq 'pc') {
+                               $machine = "pc-i440fx-$pin_version";
+                           } elsif ($machine eq 'q35') {
+                               $machine = "pc-q35-$pin_version";
+                           }
+                           $conf->{machine} = $machine;
+                       }
+                   }
+
                    PVE::QemuConfig->write_config($vmid, $conf);
 
                };
index 2ee79339dedc2f42b4a6c63ffe4b0ea77f79decd..0ac4fcfecd4d61b36329c50a1d62e6bf37d5051b 100644 (file)
@@ -2897,10 +2897,25 @@ sub get_vm_machine {
     my $machine = $forcemachine || $conf->{machine};
 
     if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
+       $kvmversion //= kvm_user_version();
+       # we must pin Windows VMs without a specific version to 5.1, as 5.2 fixed a bug in ACPI
+       # layout which confuses windows quite a bit and may result in various regressions..
+       # see: https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg08484.html
+       if (windows_version($conf->{ostype})) {
+           my $pin_version = '5.1';
+           if (!PVE::QemuServer::Machine::can_run_pve_machine_version($pin_version, $kvmversion)) {
+               $kvmversion =~ m/^(\d+\.\d+)/;
+               $pin_version = $1;
+           }
+           if (!$machine || $machine eq 'pc') {
+               $machine = "pc-i440fx-$pin_version";
+           } elsif ($machine eq 'q35') {
+               $machine = "pc-q35-$pin_version";
+           }
+       }
        $arch //= 'x86_64';
        $machine ||= $default_machines->{$arch};
        if ($add_pve_version) {
-           $kvmversion //= kvm_user_version();
            my $pvever = PVE::QemuServer::Machine::get_pve_version($kvmversion);
            $machine .= "+pve$pvever";
        }
index ea5dfc85a2a2a0814232a1a9bdb5d41a3324f21c..5492477ca0baed31455731712847df9f4dd87870 100644 (file)
@@ -24,5 +24,5 @@
   -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' \
   -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
   -rtc 'driftfix=slew,base=localtime' \
-  -machine 'type=pc+pve0' \
+  -machine 'type=pc-i440fx-5.1+pve0' \
   -global 'kvm-pit.lost_tick_policy=discard'
index 7ad2e9b9b515c7ec5e7cc0bc5a225128d94727d1..af27b65ed211558e5a03526ec289459145ef4c43 100644 (file)
@@ -24,5 +24,5 @@
   -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' \
   -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
   -rtc 'driftfix=slew,base=localtime' \
-  -machine 'type=pc+pve0' \
+  -machine 'type=pc-i440fx-5.1+pve0' \
   -global 'kvm-pit.lost_tick_policy=discard'
index a9c27209f791a748d23f4f4dd22b600c668fffd9..f926be00ec4af4fcfa4d1c075699b82e60004752 100644 (file)
@@ -34,5 +34,5 @@
   -netdev 'type=tap,id=net0,ifname=tap8006i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' \
   -device 'virtio-net-pci,mac=2E:01:68:F9:9C:87,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' \
   -rtc 'driftfix=slew,base=localtime' \
-  -machine 'type=pc+pve0' \
+  -machine 'type=pc-i440fx-5.1+pve0' \
   -global 'kvm-pit.lost_tick_policy=discard'
index 4572348fe8b43475155e3bcf46fe1877bb84cf0d..0ad8a3e0b40aa778f8ab83f56050df841dedafb7 100644 (file)
@@ -35,5 +35,5 @@
   -netdev 'type=tap,id=net0,ifname=tap8006i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' \
   -device 'virtio-net-pci,mac=2E:01:68:F9:9C:87,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' \
   -rtc 'driftfix=slew,base=localtime' \
-  -machine 'type=q35+pve0' \
+  -machine 'type=pc-q35-5.1+pve0' \
   -global 'kvm-pit.lost_tick_policy=discard'
index 78e3c5e5ae582a903fcb50e7721d5a96d030ecb8..47dbd707950ca3360ed9d2e53d2420fa7c471dac 100644 (file)
@@ -34,5 +34,5 @@
   -netdev 'type=tap,id=net0,ifname=tap8006i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' \
   -device 'virtio-net-pci,mac=A2:C0:43:77:08:A1,netdev=net0,bus=pci.0,addr=0x12,id=net0,bootindex=300' \
   -rtc 'driftfix=slew,base=localtime' \
-  -machine 'type=pc' \
+  -machine 'type=pc-i440fx-4.0' \
   -global 'kvm-pit.lost_tick_policy=discard'