[pve-devel] [PATCH qemu-server 2/2] fix #2566: increase scsi limit to 31

Dominik Csapak d.csapak at proxmox.com
Fri Jan 31 15:41:22 CET 2020


to achieve this we have to add 3 new scsihw addresses since lsi
controllers can only hold 7 scsi drives

we go up to 31, since this is the limit for virtio-scsi-single devices
we have reserved (we can increase this in the future)

to make it more future proof, we add a new pci bridge under pci
bridge 1, so we have to adapt the bridge adding code (we did not
need this for q35 previously)

impact on live migration:
since on older versions of qemu-server we do not have those config
settings, there is no problem from old -> new

new->old is not supported anyway and this breaks so that
the vm crashes and loses the configs for scsi15-30
(same behaviour as e.g. with audio0 and migration from new->old)

tested with 31 scsi disk on
i440fx + virtio-scsi
i440fx + lsi
q35 + virtio-scsi
q35 + lsi
with ovmf + seabios

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
altough i tried to test it with many config combinations,
please also test with some, e.g. i only tested a little with
hotplugging + live migration etc.

 PVE/QemuServer.pm     | 19 +++++++++++++++----
 PVE/QemuServer/PCI.pm |  4 ++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index d365e27..c4c3524 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -697,7 +697,7 @@ while (my ($k, $v) = each %$confdesc) {
 }
 
 my $MAX_IDE_DISKS = 4;
-my $MAX_SCSI_DISKS = 14;
+my $MAX_SCSI_DISKS = 31;
 my $MAX_VIRTIO_DISKS = 16;
 my $MAX_SATA_DISKS = 6;
 my $MAX_USB_DEVICES = 5;
@@ -3979,6 +3979,9 @@ sub config_to_command {
 	push @$devices, '-object', "memory-backend-file,id=ivshmem,share=on,mem-path=$path,size=$ivshmem->{size}M";
     }
 
+    # pci.4 is nested in pci.1
+    $bridges->{1} = 1 if $bridges->{4};
+
     if (!$q35) {
 	# add pci bridges
         if (min_version($machine_version, 2, 3)) {
@@ -3988,9 +3991,17 @@ sub config_to_command {
 
 	$bridges->{3} = 1 if $scsihw =~ m/^virtio-scsi-single/;
 
-	for my $k (sort {$b cmp $a} keys %$bridges) {
-	    $pciaddr = print_pci_addr("pci.$k", undef, $arch, $machine_type);
-	    unshift @$devices, '-device', "pci-bridge,id=pci.$k,chassis_nr=$k$pciaddr" if $k > 0;
+    }
+
+    for my $k (sort {$b cmp $a} keys %$bridges) {
+	next if $q35 && $k < 4; # q35.cfg already includes bridges up to 3
+	$pciaddr = print_pci_addr("pci.$k", undef, $arch, $machine_type);
+	my $devstr = "pci-bridge,id=pci.$k,chassis_nr=$k$pciaddr";
+	if ($q35) {
+	    # add after -readconfig pve-q35.cfg
+	    splice @$devices, 2, 0, '-device', $devstr;
+	} else {
+	    unshift @$devices, '-device', $devstr if $k > 0;
 	}
     }
 
diff --git a/PVE/QemuServer/PCI.pm b/PVE/QemuServer/PCI.pm
index e0bc1a2..c3b4716 100644
--- a/PVE/QemuServer/PCI.pm
+++ b/PVE/QemuServer/PCI.pm
@@ -71,6 +71,7 @@ sub get_pci_addr_map {
 	'net30' => { bus => 1, addr => 25 },
 	'net31' => { bus => 1, addr => 26 },
 	'xhci' => { bus => 1, addr => 27 },
+	'pci.4' => { bus => 1, addr => 28 },
 	'virtio6' => { bus => 2, addr => 1 },
 	'virtio7' => { bus => 2, addr => 2 },
 	'virtio8' => { bus => 2, addr => 3 },
@@ -126,6 +127,9 @@ sub get_pci_addr_map {
 	'virtioscsi28' => { bus => 3, addr => 29 },
 	'virtioscsi29' => { bus => 3, addr => 30 },
 	'virtioscsi30' => { bus => 3, addr => 31 },
+	'scsihw2' => { bus => 4, addr => 1 },
+	'scsihw3' => { bus => 4, addr => 2 },
+	'scsihw4' => { bus => 4, addr => 3 },
     } if !defined($pci_addr_map);
     return $pci_addr_map;
 }
-- 
2.20.1





More information about the pve-devel mailing list