-
Notifications
You must be signed in to change notification settings - Fork 1.2k
kvm: fix disk controller for secure boot vm #10213
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,6 @@ | |
import org.xml.sax.InputSource; | ||
import org.xml.sax.SAXException; | ||
|
||
|
||
import com.cloud.agent.api.Answer; | ||
import com.cloud.agent.api.Command; | ||
import com.cloud.agent.api.HostVmStateReportEntry; | ||
|
@@ -180,8 +179,8 @@ | |
import com.cloud.network.Networks.RouterPrivateIpStrategy; | ||
import com.cloud.network.Networks.TrafficType; | ||
import com.cloud.resource.AgentStatusUpdater; | ||
import com.cloud.resource.ResourceStatusUpdater; | ||
import com.cloud.resource.RequestWrapper; | ||
import com.cloud.resource.ResourceStatusUpdater; | ||
import com.cloud.resource.ServerResource; | ||
import com.cloud.resource.ServerResourceBase; | ||
import com.cloud.storage.JavaStorageLayer; | ||
|
@@ -3010,6 +3009,42 @@ | |
return useBLOCKDiskType(physicalDisk) ? DiskDef.DiskType.BLOCK : DiskDef.DiskType.FILE; | ||
} | ||
|
||
/** | ||
* Defines the disk configuration for the default pool type based on the provided parameters. | ||
* It determines the appropriate disk settings depending on whether the disk is a data disk, whether | ||
* it's a Windows template, whether UEFI is enabled, and whether secure boot is active. | ||
* | ||
* @param disk The disk definition object that will be configured with the disk settings. | ||
* @param volume The volume (disk) object, containing information about the type of disk. | ||
* @param isWindowsTemplate Flag indicating whether the template is a Windows template. | ||
* @param isUefiEnabled Flag indicating whether UEFI is enabled. | ||
* @param isSecureBoot Flag indicating whether secure boot is enabled. | ||
* @param physicalDisk The physical disk object that contains the path to the disk. | ||
* @param devId The device ID for the disk. | ||
* @param diskBusType The disk bus type to use if not skipping force disk controller. | ||
* @param diskBusTypeData The disk bus type to use for data disks, if applicable. | ||
* @param details A map of VM details containing additional configuration values, such as whether to skip force | ||
* disk controller. | ||
*/ | ||
protected void defineDiskForDefaultPoolType(DiskDef disk, DiskTO volume, boolean isWindowsTemplate, | ||
boolean isUefiEnabled, boolean isSecureBoot, KVMPhysicalDisk physicalDisk, int devId, | ||
DiskDef.DiskBus diskBusType, DiskDef.DiskBus diskBusTypeData, Map<String, String> details) { | ||
boolean skipForceDiskController = BooleanUtils.toBoolean(details.get( | ||
VmDetailConstants.KVM_WIN_SKIP_FORCE_DISK_CONTROLLER)); | ||
boolean isDataDiskWithoutForceController = volume.getType() == Volume.Type.DATADISK && | ||
(!(isWindowsTemplate && isUefiEnabled) || skipForceDiskController); | ||
|
||
if (isDataDiskWithoutForceController) { | ||
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusTypeData, DiskDef.DiskFmtType.QCOW2); | ||
} else { | ||
if (isSecureBoot) { | ||
disk.defFileBasedDisk(physicalDisk.getPath(), devId, DiskDef.DiskFmtType.QCOW2, isWindowsTemplate); | ||
} else { | ||
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusType, DiskDef.DiskFmtType.QCOW2); | ||
} | ||
} | ||
} | ||
|
||
public void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException { | ||
final Map<String, String> details = vmSpec.getDetails(); | ||
final List<DiskTO> disks = Arrays.asList(vmSpec.getDisks()); | ||
|
@@ -3161,18 +3196,9 @@ | |
disk.setDiscard(DiscardType.UNMAP); | ||
} | ||
} else { | ||
if (volume.getType() == Volume.Type.DATADISK && !(isWindowsTemplate && isUefiEnabled)) { | ||
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusTypeData, DiskDef.DiskFmtType.QCOW2); | ||
} else { | ||
if (isSecureBoot) { | ||
disk.defFileBasedDisk(physicalDisk.getPath(), devId, DiskDef.DiskFmtType.QCOW2, isWindowsTemplate); | ||
} else { | ||
disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusType, DiskDef.DiskFmtType.QCOW2); | ||
} | ||
} | ||
|
||
defineDiskForDefaultPoolType(disk, volume, isWindowsTemplate, isUefiEnabled, isSecureBoot, | ||
Check warning on line 3199 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shwstppr If a user forces the disk type with this template flag, will Secure Boot still work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavanaravapalli probably not for all guest OSes, but should work for newer ones, as #9460 reports VM works fine with virtio. Also, as this is optional, it is up to the operator to check and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shwstppr Thanks for the response. We should mention potential UEFI workflow issues in the flag description since guest OS support varies. |
||
physicalDisk,devId, diskBusType, diskBusTypeData, details); | ||
} | ||
|
||
} | ||
|
||
if (data instanceof VolumeObjectTO) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, the root disk and data disk controller should not be changed when vm is stopped and started, in regardless of the vm settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weizhouapache In my test they are not really changed. Even at the deployment time, Windows VM with secure boot was always getting
sata
while other (Linux, etc) VMs were gettingvirtio