[pve-devel] [PATCH qemu-server 2/2] version_guard scsi drive count

Stefan Reiter s.reiter at proxmox.com
Mon Feb 10 16:05:36 CET 2020


Live-migrating a VM with more than 14 SCSI disks to a node that doesn't
support it yet is broken. Use a bumped pve-version to represent that and
give the user a nice error message instead.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---

This is more for correctness, since older versions (i.e. ones that don't support
this feature) do not include the code to die with a useful message. It does,
however, give a nice example of how $version_guard is supposed to be used.


 PVE/QemuServer.pm         | 3 +++
 PVE/QemuServer/Machine.pm | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 37ffc86..27b9866 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3931,6 +3931,9 @@ sub config_to_command {
 
 	    my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
 
+	    die "scsi$drive->{index}: machine version 4.1~pve2 or higher is required to use more than 14 SCSI disks\n"
+		if $drive->{index} > 13 && !&$version_guard(4, 1, 2);
+
 	    $pciaddr = print_pci_addr("$controller_prefix$controller", $bridges, $arch, $machine_type);
 	    my $scsihw_type = $scsihw =~ m/^virtio-scsi-single/ ? "virtio-scsi-pci" : $scsihw;
 
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index 9fbe9a8..0817d2a 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -9,7 +9,7 @@ use PVE::QemuServer::Monitor;
 # Bump this for VM HW layout changes during a release (where the QEMU machine
 # version stays the same)
 our $PVE_MACHINE_VERSION = {
-    '4.1' => 1,
+    '4.1' => 2,
 };
 
 sub machine_type_is_q35 {
-- 
2.20.1





More information about the pve-devel mailing list