Signed-off-by: Stefan Reiter <s.rei...@proxmox.com> --- Based on qemu refactor series[0], especially patch 6, can send a version for current master as well, but then the refactor has to be rebased because of qemu_machine_version_enabled -> Helpers::min_version.
Tested with snapshot create/restore between 3.0, 4.0.0-2, 4.0.0-7, 4.0.1-5 and the new 4.1.1, as well as migration from and to 4.0.0 <-> 4.0.1 <-> 4.1.1. @Wolfgang B.: Does the comment describe the situation correctly? Tried to make it somewhat understandable, but not sure if I got everything right... [0] https://pve.proxmox.com/pipermail/pve-devel/2019-November/040442.html PVE/QemuServer.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 74f7ca7..3f42b02 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -3899,7 +3899,21 @@ sub config_to_command { # enable balloon by default, unless explicitly disabled if (!defined($conf->{balloon}) || $conf->{balloon}) { $pciaddr = print_pci_addr("balloon0", $bridges, $arch, $machine_type); - push @$devices, '-device', "virtio-balloon-pci,id=balloon0$pciaddr"; + my $extra = ''; + + # QEMU versions between 4.0.0-3 and latest 4.0.1 trigger a bug that + # causes ballooning memory to be misaligned ('qemu-4-0-config-size' + # defaults to 'false', even though 4.0(.1) is clearly running). This + # makes snapshot restore and migration to newer versions (4.1.0+) fail, + # so set 'qemu-4-0-config-size' manually to false, to tell QEMU to + # expect the old misaligned memory even though it is running what is + # expected to be a patched 4.0(.1) machine type. + if ($machine_type =~ m/^pc-.*-4\.0/ + && PVE::QemuServer::Helpers::min_version($kvmver, 4, 1)) { + $extra .= ",qemu-4-0-config-size=false"; + } + + push @$devices, '-device', "virtio-balloon-pci,id=balloon0$pciaddr$extra"; } if ($conf->{watchdog}) { -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel