Skip to content

Commit 09a845d

Browse files
shwstpprLocharla, Sandeep
authored andcommitted
kvm: allow skip forcing disk controller (apache#11750)
1 parent d611dcf commit 09a845d

File tree

3 files changed

+44
-9
lines changed

3 files changed

+44
-9
lines changed

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public interface VmDetailConstants {
5555
String NIC_MULTIQUEUE_NUMBER = "nic.multiqueue.number";
5656
String NIC_PACKED_VIRTQUEUES_ENABLED = "nic.packed.virtqueues.enabled";
5757

58+
// KVM specific, disk controllers
59+
String KVM_SKIP_FORCE_DISK_CONTROLLER = "skip.force.disk.controller";
60+
5861
// Mac OSX guest specific (internal)
5962
String SMC_PRESENT = "smc.present";
6063
String FIRMWARE = "firmware";

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

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,6 +3493,44 @@ public static DiskDef.DiskType getDiskType(KVMPhysicalDisk physicalDisk) {
34933493
return useBLOCKDiskType(physicalDisk) ? DiskDef.DiskType.BLOCK : DiskDef.DiskType.FILE;
34943494
}
34953495

3496+
/**
3497+
* Defines the disk configuration for the default pool type based on the provided parameters.
3498+
* It determines the appropriate disk settings depending on whether the disk is a data disk, whether
3499+
* it's a Windows template, whether UEFI is enabled, and whether secure boot is active.
3500+
*
3501+
* @param disk The disk definition object that will be configured with the disk settings.
3502+
* @param volume The volume (disk) object, containing information about the type of disk.
3503+
* @param isWindowsTemplate Flag indicating whether the template is a Windows template.
3504+
* @param isUefiEnabled Flag indicating whether UEFI is enabled.
3505+
* @param isSecureBoot Flag indicating whether secure boot is enabled.
3506+
* @param physicalDisk The physical disk object that contains the path to the disk.
3507+
* @param devId The device ID for the disk.
3508+
* @param diskBusType The disk bus type to use if not skipping force disk controller.
3509+
* @param diskBusTypeData The disk bus type to use for data disks, if applicable.
3510+
* @param details A map of VM details containing additional configuration values, such as whether to skip force
3511+
* disk controller.
3512+
*/
3513+
protected void defineDiskForDefaultPoolType(DiskDef disk, DiskTO volume, boolean isWindowsTemplate,
3514+
boolean isUefiEnabled, boolean isSecureBoot, KVMPhysicalDisk physicalDisk, int devId,
3515+
DiskDef.DiskBus diskBusType, DiskDef.DiskBus diskBusTypeData, Map<String, String> details) {
3516+
boolean skipForceDiskController = MapUtils.getBoolean(details, VmDetailConstants.KVM_SKIP_FORCE_DISK_CONTROLLER,
3517+
false);
3518+
if (skipForceDiskController) {
3519+
disk.defFileBasedDisk(physicalDisk.getPath(), devId, Volume.Type.DATADISK.equals(volume.getType()) ?
3520+
diskBusTypeData : diskBusType, DiskDef.DiskFmtType.QCOW2);
3521+
return;
3522+
}
3523+
if (volume.getType() == Volume.Type.DATADISK && !(isWindowsTemplate && isUefiEnabled)) {
3524+
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusTypeData, DiskDef.DiskFmtType.QCOW2);
3525+
} else {
3526+
if (isSecureBoot) {
3527+
disk.defFileBasedDisk(physicalDisk.getPath(), devId, DiskDef.DiskFmtType.QCOW2, isWindowsTemplate);
3528+
} else {
3529+
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusType, DiskDef.DiskFmtType.QCOW2);
3530+
}
3531+
}
3532+
}
3533+
34963534
public void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException {
34973535
final Map<String, String> details = vmSpec.getDetails();
34983536
final List<DiskTO> disks = Arrays.asList(vmSpec.getDisks());
@@ -3654,15 +3692,8 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
36543692
disk.setDiscard(DiscardType.UNMAP);
36553693
}
36563694
} else {
3657-
if (volume.getType() == Volume.Type.DATADISK && !(isWindowsTemplate && isUefiEnabled)) {
3658-
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusTypeData, DiskDef.DiskFmtType.QCOW2);
3659-
} else {
3660-
if (isSecureBoot) {
3661-
disk.defFileBasedDisk(physicalDisk.getPath(), devId, DiskDef.DiskFmtType.QCOW2, isWindowsTemplate);
3662-
} else {
3663-
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusType, DiskDef.DiskFmtType.QCOW2);
3664-
}
3665-
}
3695+
defineDiskForDefaultPoolType(disk, volume, isWindowsTemplate, isUefiEnabled, isSecureBoot,
3696+
physicalDisk, devId, diskBusType, diskBusTypeData, details);
36663697
}
36673698
pool.customizeLibvirtDiskDef(disk);
36683699
}

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5390,6 +5390,7 @@ private void fillVMOrTemplateDetailOptions(final Map<String, List<String>> optio
53905390
options.put(VmDetailConstants.VIRTUAL_TPM_VERSION, Arrays.asList("1.2", "2.0"));
53915391
options.put(VmDetailConstants.GUEST_CPU_MODE, Arrays.asList("custom", "host-model", "host-passthrough"));
53925392
options.put(VmDetailConstants.GUEST_CPU_MODEL, Collections.emptyList());
5393+
options.put(VmDetailConstants.KVM_SKIP_FORCE_DISK_CONTROLLER, Arrays.asList("true", "false"));
53935394
}
53945395

53955396
if (HypervisorType.VMware.equals(hypervisorType)) {

0 commit comments

Comments
 (0)