Skip to content

Commit 2cf5f65

Browse files
committed
Improve SCSI controller mapping
Signed-off-by: Volker Theile <[email protected]>
1 parent c6c6592 commit 2cf5f65

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
@@ -496,22 +496,39 @@ func mapNetworkCards(networkCards []networkInfo, mapping []migration.NetworkMapp
496496
}
497497

498498
// detectBusType tries to identify the disk bus type from VMware to attempt and
499-
// set correct bus types in kubevirt.
499+
// set correct bus types in KubeVirt.
500500
// Examples:
501-
// .-----------------------------------------------.
502-
// | Bus | Device ID |
503-
// |------|----------------------------------------|
504-
// | SCSI | /vm-13010/ParaVirtualSCSIController0:0 |
505-
// | SATA | /vm-13767/VirtualAHCIController0:1 |
506-
// | IDE | /vm-5678/VirtualIDEController1:0 |
507-
// | NVMe | /vm-2468/VirtualNVMEController0:0 |
508-
// | USB | /vm-54321/VirtualUSBController0:0 |
509-
// '-----------------------------------------------'
501+
// .--------------------------------------------------.
502+
// | Bus | Device ID |
503+
// |------|-------------------------------------------|
504+
// | SCSI | /vm-13010/ParaVirtualSCSIController0:0 |
505+
// | SCSI | /vm-13011/VirtualBusLogicController0:0 |
506+
// | SCSI | /vm-13012/VirtualLsiLogicController0:0 |
507+
// | SCSI | /vm-13013/VirtualLsiLogicSASController0:0 |
508+
// | SATA | /vm-13767/VirtualAHCIController0:1 |
509+
// | IDE | /vm-5678/VirtualIDEController1:0 |
510+
// | NVMe | /vm-2468/VirtualNVMEController0:0 |
511+
// | USB | /vm-54321/VirtualUSBController0:0 |
512+
// '--------------------------------------------------'
513+
// References:
514+
// - https://github.com/vmware/pyvmomi/tree/master/pyVmomi/vim/vm/device
515+
// - https://vdc-download.vmware.com/vmwb-repository/dcr-public/d1902b0e-d479-46bf-8ac9-cee0e31e8ec0/07ce8dbd-db48-4261-9b8f-c6d3ad8ba472/vim.vm.device.VirtualSCSIController.html
516+
// - https://libvirt.org/formatdomain.html#controllers
517+
// - https://kubevirt.io/api-reference/v1.1.0/definitions.html#_v1_disktarget
510518
func detectBusType(deviceID string) kubevirt.DiskBus {
511519
deviceID = strings.ToLower(deviceID)
512-
// https://kubevirt.io/api-reference/v1.1.0/definitions.html#_v1_disktarget
513520
switch {
514-
case strings.Contains(deviceID, "scsi"):
521+
case strings.Contains(deviceID, "paravirtualscsi"):
522+
// The pvscsi (Paravirtual SCSI) controller cannot be mapped to
523+
// SCSI bus type because in KubeVirt it is not possible to specify
524+
// the exact model (pvscsi, lsilogic, ...) of the disk via the
525+
// VirtualMachine API. Attempting to map pvscsi to SCSI prevents
526+
// the VM from booting.
527+
// As a workaround, the SATA bus type is utilized in such case.
528+
// Note, VirtIO would be better, but it is not said that the
529+
// required drivers are installed in the VM.
530+
return kubevirt.DiskBusSATA
531+
case strings.Contains(deviceID, "scsi"), strings.Contains(deviceID, "buslogic"), strings.Contains(deviceID, "lsilogic"):
515532
return kubevirt.DiskBusSCSI
516533
case strings.Contains(deviceID, "ahci"), strings.Contains(deviceID, "sata"), strings.Contains(deviceID, "ide"):
517534
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)