Skip to content

Commit 3c39f45

Browse files
weizhouapacheDajeong-Park
authored andcommitted
kvm: add SCSI controllers based on the number of virtio-SCSI disks (apache#9823)
According to libvirt code, the units per scsi controller is set to 7 therefore, we need to create scsi controller every 7 disks (including CDROM). https://github.com/libvirt/libvirt/blob/50cc7a0d9d2b9df085ec073a6d60820a9642158a/src/conf/domain_conf.h#L3007-L3008 https://github.com/libvirt/libvirt/blob/50cc7a0d9d2b9df085ec073a6d60820a9642158a/src/conf/domain_conf.c#L6701-L6704
1 parent 4d73ae1 commit 3c39f45

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,9 +2916,7 @@ protected DevicesDef createDevicesDef(VirtualMachineTO vmTO, GuestDef guest, int
29162916

29172917
int socket = getCoresPerSocket(vcpus, details);
29182918
boolean isIothreadsEnabled = details != null && details.containsKey(VmDetailConstants.IOTHREADS);
2919-
for (int i = 0; i < socket; i++) {
2920-
devices.addDevice(createSCSIDef(i, i, vcpus, isIothreadsEnabled));
2921-
}
2919+
addSCSIControllers(devices, vcpus, vmTO.getDisks().length, isIothreadsEnabled);
29222920
}
29232921

29242922

@@ -2979,20 +2977,19 @@ protected ChannelDef createChannelDef(VirtualMachineTO vmTO) {
29792977
* Creates Virtio SCSI controller. <br>
29802978
* The respective Virtio SCSI XML definition is generated only if the VM's Disk Bus is of ISCSI.
29812979
*/
2982-
protected SCSIDef createSCSIDef(int index, int function ,int vcpus) {
2983-
return new SCSIDef((short)index, 0, 0, 9, function, vcpus);
2984-
}
2985-
2986-
protected SCSIDef createSCSIDef(int vcpus) {
2987-
return new SCSIDef((short)0, 0, 0, 9, 0, vcpus);
2980+
protected SCSIDef createSCSIDef(short index, int vcpus, boolean isIothreadsEnabled) {
2981+
return new SCSIDef(index, 0, 0, 9 + index, 0, vcpus, isIothreadsEnabled);
29882982
}
29892983

2990-
protected SCSIDef createSCSIDef(int index, int function, int vcpus, boolean isIothreadsEnabled) {
2991-
return new SCSIDef((short)index, 0, 0, 9, function, vcpus, isIothreadsEnabled);
2992-
}
29932984

2994-
protected SCSIDef createSCSIDef(int vcpus, boolean isIothreadsEnabled) {
2995-
return new SCSIDef((short)0, 0, 0, 9, 0, vcpus, isIothreadsEnabled);
2985+
private void addSCSIControllers(DevicesDef devices, int vcpus, int diskCount, boolean isIothreadsEnabled) {
2986+
int controllers = diskCount / 7;
2987+
if (diskCount % 7 != 0) {
2988+
controllers++;
2989+
}
2990+
for (int i = 0; i < controllers; i++) {
2991+
devices.addDevice(createSCSIDef((short)i, vcpus, isIothreadsEnabled));
2992+
}
29962993
}
29972994

29982995
protected ConsoleDef createConsoleDef() {

0 commit comments

Comments
 (0)