[PATCH] vmx: Generate correct disk target device ID for superwide SCSI

Martin Kletzander via Devel posted 1 patch 3 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/50bdeaab517e38348ed29f7a2938486f893f59fb.1776714986.git.mkletzan@redhat.com
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(-)
[PATCH] vmx: Generate correct disk target device ID for superwide SCSI
Posted by Martin Kletzander via Devel 3 weeks, 1 day ago
From: Martin Kletzander <mkletzan@redhat.com>

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 <mkletzan@redhat.com>
---
 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
Re: [PATCH] vmx: Generate correct disk target device ID for superwide SCSI
Posted by Daniel P. Berrangé via Devel 3 weeks, 1 day ago
On Mon, Apr 20, 2026 at 09:56:26PM +0200, Martin Kletzander via Devel wrote:
> From: Martin Kletzander <mkletzan@redhat.com>
> 
> 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 <mkletzan@redhat.com>
> ---
>  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(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|