From: Martin Kletzander <[email protected]>

Commit 32f7db0989e4 added support for superwide SCSI, but did not change
the disk ID calculation which resulted in a possible duplicate.  Change
it to calculate based on the (already decided) maximum of SCSI units per
bus and add a (well, modify existing) test case.

Fixes: 32f7db0989e4
Signed-off-by: Martin Kletzander <[email protected]>
---
 src/vmx/vmx.c                            | 2 +-
 tests/vmx2xmldata/esx-in-the-wild-11.vmx | 6 ++++++
 tests/vmx2xmldata/esx-in-the-wild-11.xml | 6 ++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 57dfd57cfc86..1da5a0fd8a31 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2244,7 +2244,7 @@ virVMXGenerateDiskTarget(virDomainDiskDef *def,
             return -1;
         }
 
-        idx = controllerOrBus * 15 + (unit < 7 ? unit : unit - 1);
+        idx = controllerOrBus * (vmdef->scsiBusMaxUnit - 1) + (unit < 7 ? unit 
: unit - 1);
         prefix = "sd";
         break;
 
diff --git a/tests/vmx2xmldata/esx-in-the-wild-11.vmx 
b/tests/vmx2xmldata/esx-in-the-wild-11.vmx
index ae1d146f9a44..e6b547d8ace5 100644
--- a/tests/vmx2xmldata/esx-in-the-wild-11.vmx
+++ b/tests/vmx2xmldata/esx-in-the-wild-11.vmx
@@ -89,3 +89,9 @@ sched.scsi0:16.shares = "normal"
 sched.scsi0:16.throughputCap = "off"
 scsi0:16.present = "TRUE"
 scsi0:16.redo = ""
+scsi1.virtualDev = "pvscsi"
+scsi1.present = "TRUE"
+scsi1:0.deviceType = "scsi-hardDisk"
+scsi1:0.fileName = "esx6.7-rhel7.7-x86_64_4.vmdk"
+sched.scsi1:0.shares = "normal"
+scsi1:0.present = "TRUE"
diff --git a/tests/vmx2xmldata/esx-in-the-wild-11.xml 
b/tests/vmx2xmldata/esx-in-the-wild-11.xml
index 8807a057d7ca..73befdeca0c6 100644
--- a/tests/vmx2xmldata/esx-in-the-wild-11.xml
+++ b/tests/vmx2xmldata/esx-in-the-wild-11.xml
@@ -25,7 +25,13 @@
       <target dev='sdp' bus='scsi'/>
       <address type='drive' controller='0' bus='0' target='0' unit='16'/>
     </disk>
+    <disk type='file' device='disk'>
+      <source file='[datastore] directory/esx6.7-rhel7.7-x86_64_4.vmdk'/>
+      <target dev='sdbl' bus='scsi'/>
+      <address type='drive' controller='1' bus='0' target='0' unit='0'/>
+    </disk>
     <controller type='scsi' index='0' model='vmpvscsi'/>
+    <controller type='scsi' index='1' model='vmpvscsi'/>
     <interface type='bridge'>
       <mac address='00:50:56:ac:3e:a1' type='generated'/>
       <source bridge='VM Network'/>
-- 
2.53.0

Reply via email to