render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
d759b5
From dfc8270c27d1eaad36b85d6eab8f912b5bd7e334 Mon Sep 17 00:00:00 2001
d759b5
Message-Id: <dfc8270c27d1eaad36b85d6eab8f912b5bd7e334@dist-git>
e00e43
From: Michal Privoznik <mprivozn@redhat.com>
d759b5
Date: Thu, 24 Oct 2019 08:45:50 +0200
e00e43
Subject: [PATCH] domain_conf: Relax SCSI addr used check
e00e43
MIME-Version: 1.0
e00e43
Content-Type: text/plain; charset=UTF-8
e00e43
Content-Transfer-Encoding: 8bit
e00e43
e00e43
In domain_conf.c we have virDomainSCSIDriveAddressIsUsed()
e00e43
function which returns true or false if given drive address is
e00e43
already in use for given domain config or not. However, it also
e00e43
takes a shortcut and returns true (meaning address in use) if the
e00e43
unit number equals 7. This is because for some controllers this
e00e43
is reserved address. The limitation comes mostly from vmware and
e00e43
applies to lsilogic, buslogic, spapr-vscsi and vmpvscsi models.
e00e43
On the other hand, we were not checking for the maximum unit
e00e43
number (aka LUN number) which is also relevant and differs from
e00e43
model to model.
e00e43
e00e43
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
e00e43
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
e00e43
(cherry picked from commit c8007fdc5d2ce43fec2753cda60fb4963f55abd5)
e00e43
d759b5
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1741782
e00e43
e00e43
I had to drop
e00e43
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL and
e00e43
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL from
e00e43
virDomainSCSIDriveAddressIsUsed() because those don't exist in
d759b5
RHEL-7.8 branch.
e00e43
e00e43
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
d759b5
Message-Id: <9e70aa28937fa3ea1bbeb792f848b2be2a6ae2e7.1571899509.git.mprivozn@redhat.com>
e00e43
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
e00e43
---
e00e43
 src/conf/domain_conf.c | 49 +++++++++++++++++++++++++++++++++++++-----
e00e43
 1 file changed, 44 insertions(+), 5 deletions(-)
e00e43
e00e43
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
d759b5
index 333d9836c1..8bd527cfa1 100644
e00e43
--- a/src/conf/domain_conf.c
e00e43
+++ b/src/conf/domain_conf.c
e00e43
@@ -4407,11 +4407,50 @@ bool
e00e43
 virDomainSCSIDriveAddressIsUsed(const virDomainDef *def,
e00e43
                                 const virDomainDeviceDriveAddress *addr)
e00e43
 {
e00e43
-    /* In current implementation, the maximum unit number of a controller
e00e43
-     * is either 16 or 7 (narrow SCSI bus), and if the maximum unit number
e00e43
-     * is 16, the controller itself is on unit 7 */
e00e43
-    if (addr->unit == 7)
e00e43
-        return true;
e00e43
+    const virDomainControllerDef *cont;
e00e43
+
e00e43
+    cont = virDomainDeviceFindSCSIController(def, addr);
e00e43
+    if (cont) {
e00e43
+        int max = -1;
e00e43
+        int reserved = -1;
e00e43
+
e00e43
+        /* Different controllers have different limits. These limits here are
e00e43
+         * taken from QEMU source code, but nevertheless they should apply to
e00e43
+         * other hypervisors too. */
e00e43
+        switch ((virDomainControllerModelSCSI) cont->model) {
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI:
e00e43
+            max = 16383;
e00e43
+            break;
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI:
e00e43
+            max = 31;
e00e43
+            reserved = 7;
e00e43
+            break;
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068:
e00e43
+            max = 1;
e00e43
+            break;
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1078:
e00e43
+            max = 255;
e00e43
+            break;
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC:
e00e43
+            reserved = 7;
e00e43
+            break;
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI:
e00e43
+            reserved = 7;
e00e43
+            break;
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC:
e00e43
+            reserved = 7;
e00e43
+            break;
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO:
e00e43
+        case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
e00e43
+            break;
e00e43
+        }
e00e43
+
e00e43
+        if (max != -1 && addr->unit >= max)
e00e43
+            return true;
e00e43
+        if (reserved != -1 && addr->unit == reserved)
e00e43
+            return true;
e00e43
+    }
e00e43
 
e00e43
     if (virDomainDriveAddressIsUsedByDisk(def, VIR_DOMAIN_DISK_BUS_SCSI,
e00e43
                                           addr) ||
e00e43
-- 
e00e43
2.23.0
e00e43