Skip to content
Merged
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,7 @@ 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));
addSCSIControllers(devices, vcpus, vmTO.getDisks().length, isIothreadsEnabled);
}
return devices;
}
Expand Down Expand Up @@ -2623,8 +2623,19 @@ 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);
}


private void addSCSIControllers(DevicesDef devices, int vcpus, int diskCount, boolean isIothreadsEnabled) {
int controllers = diskCount / 7;
if (diskCount % 7 != 0) {
controllers++;
}
for (int i = 0; i < controllers; i++) {
devices.addDevice(createSCSIDef((short)i, 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