Skip to content

Commit 8fc9114

Browse files
committed
Improve SCSI controller mapping
Signed-off-by: Volker Theile <[email protected]>
1 parent 0173a3b commit 8fc9114

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

pkg/source/vmware/client.go

+29-12
Original file line numberDiff line numberDiff line change
@@ -505,22 +505,39 @@ func mapNetworkCards(networkCards []networkInfo, mapping []migration.NetworkMapp
505505
}
506506

507507
// detectBusType tries to identify the disk bus type from VMware to attempt and
508-
// set correct bus types in kubevirt.
508+
// set correct bus types in KubeVirt.
509509
// Examples:
510-
// .-----------------------------------------------.
511-
// | Bus | Device ID |
512-
// |------|----------------------------------------|
513-
// | SCSI | /vm-13010/ParaVirtualSCSIController0:0 |
514-
// | SATA | /vm-13767/VirtualAHCIController0:1 |
515-
// | IDE | /vm-5678/VirtualIDEController1:0 |
516-
// | NVMe | /vm-2468/VirtualNVMEController0:0 |
517-
// | USB | /vm-54321/VirtualUSBController0:0 |
518-
// '-----------------------------------------------'
510+
// .--------------------------------------------------.
511+
// | Bus | Device ID |
512+
// |------|-------------------------------------------|
513+
// | SCSI | /vm-13010/ParaVirtualSCSIController0:0 |
514+
// | SCSI | /vm-13011/VirtualBusLogicController0:0 |
515+
// | SCSI | /vm-13012/VirtualLsiLogicController0:0 |
516+
// | SCSI | /vm-13013/VirtualLsiLogicSASController0:0 |
517+
// | SATA | /vm-13767/VirtualAHCIController0:1 |
518+
// | IDE | /vm-5678/VirtualIDEController1:0 |
519+
// | NVMe | /vm-2468/VirtualNVMEController0:0 |
520+
// | USB | /vm-54321/VirtualUSBController0:0 |
521+
// '--------------------------------------------------'
522+
// References:
523+
// - https://github.com/vmware/pyvmomi/tree/master/pyVmomi/vim/vm/device
524+
// - https://vdc-download.vmware.com/vmwb-repository/dcr-public/d1902b0e-d479-46bf-8ac9-cee0e31e8ec0/07ce8dbd-db48-4261-9b8f-c6d3ad8ba472/vim.vm.device.VirtualSCSIController.html
525+
// - https://libvirt.org/formatdomain.html#controllers
526+
// - https://kubevirt.io/api-reference/v1.1.0/definitions.html#_v1_disktarget
519527
func detectBusType(deviceID string) kubevirt.DiskBus {
520528
deviceID = strings.ToLower(deviceID)
521-
// https://kubevirt.io/api-reference/v1.1.0/definitions.html#_v1_disktarget
522529
switch {
523-
case strings.Contains(deviceID, "scsi"):
530+
case strings.Contains(deviceID, "paravirtualscsi"):
531+
// The pvscsi (Paravirtual SCSI) controller cannot be mapped to
532+
// SCSI bus type because in KubeVirt it is not possible to specify
533+
// the exact model (pvscsi, lsilogic, ...) of the disk via the
534+
// VirtualMachine API. Attempting to map pvscsi to SCSI prevents
535+
// the VM from booting.
536+
// As a workaround, the SATA bus type is utilized in such case.
537+
// Note, VirtIO would be better, but it is not said that the
538+
// required drivers are installed in the VM.
539+
return kubevirt.DiskBusSATA
540+
case strings.Contains(deviceID, "scsi"), strings.Contains(deviceID, "buslogic"), strings.Contains(deviceID, "lsilogic"):
524541
return kubevirt.DiskBusSCSI
525542
case strings.Contains(deviceID, "ahci"), strings.Contains(deviceID, "sata"), strings.Contains(deviceID, "ide"):
526543
return kubevirt.DiskBusSATA

pkg/source/vmware/client_test.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,23 @@ func Test_adapterType(t *testing.T) {
314314
expected kubevirt.DiskBus
315315
}{
316316
{
317-
desc: "SCSI disk",
317+
desc: "SCSI disk - VMware Paravirtual",
318318
deviceID: "/vm-13010/ParaVirtualSCSIController0:0",
319+
expected: kubevirt.DiskBusSATA,
320+
},
321+
{
322+
desc: "SCSI disk - BusLogic Parallel",
323+
deviceID: "/vm-13011/VirtualBusLogicController0:0",
324+
expected: kubevirt.DiskBusSCSI,
325+
},
326+
{
327+
desc: "SCSI disk - LSI Logic Parallel",
328+
deviceID: "/vm-13012/VirtualLsiLogicController0:0",
329+
expected: kubevirt.DiskBusSCSI,
330+
},
331+
{
332+
desc: "SCSI disk - LSI Logic SAS",
333+
deviceID: "/vm-13013/VirtualLsiLogicSASController0:0",
319334
expected: kubevirt.DiskBusSCSI,
320335
},
321336
{

0 commit comments

Comments
 (0)