Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvm: add SCSI controllers based on the number of virtio-SCSI disks #9823

Open
wants to merge 1 commit into
base: 4.18
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2585,7 +2585,13 @@ protected DevicesDef createDevicesDef(VirtualMachineTO vmTO, GuestDef guest, int
Map<String, String> details = vmTO.getDetails();

boolean isIothreadsEnabled = details != null && details.containsKey(VmDetailConstants.IOTHREADS);
devices.addDevice(createSCSIDef(vcpus, isIothreadsEnabled));
int controllers = vmTO.getDisks().length / 7;
if (vmTO.getDisks().length % 7 != 0) {
controllers++;
}
for (int i = 0; i < controllers; i++) {
devices.addDevice(createSCSIDef((short)i, vcpus, isIothreadsEnabled));
}
}
return devices;
}
Expand Down Expand Up @@ -2623,8 +2629,8 @@ protected ChannelDef createChannelDef(VirtualMachineTO vmTO) {
* Creates Virtio SCSI controller. <br>
* The respective Virtio SCSI XML definition is generated only if the VM's Disk Bus is of ISCSI.
*/
protected SCSIDef createSCSIDef(int vcpus, boolean isIothreadsEnabled) {
return new SCSIDef((short)0, 0, 0, 9, 0, vcpus, isIothreadsEnabled);
protected SCSIDef createSCSIDef(short index, int vcpus, boolean isIothreadsEnabled) {
return new SCSIDef(index, 0, 0, 9 + index, 0, vcpus, isIothreadsEnabled);
}

protected ConsoleDef createConsoleDef() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ public void testCreateDevicesWithSCSIDisk() {
to.setDetails(new HashMap<>());
to.setPlatformEmulator("Other PV Virtio-SCSI");

final DiskTO diskTO = Mockito.mock(DiskTO.class);
to.setDisks(new DiskTO[]{diskTO});

GuestDef guest = new GuestDef();
guest.setGuestType(GuestType.KVM);

Expand Down Expand Up @@ -646,7 +649,7 @@ public void testCreateChannelDef() {
public void testCreateSCSIDef() {
VirtualMachineTO to = createDefaultVM(false);

SCSIDef scsiDef = libvirtComputingResourceSpy.createSCSIDef(to.getCpus(), false);
SCSIDef scsiDef = libvirtComputingResourceSpy.createSCSIDef((short)0, to.getCpus(), false);
Document domainDoc = parse(scsiDef.toString());
verifyScsi(to, domainDoc, "");
}
Expand Down
Loading