Skip to content

Commit 82e0d5d

Browse files
authored
Fix UEFI detection on KVM and prevent deployments on non UEFI enabled hosts (apache#6423)
* Do not allow UEFI deployments on non UEFI enabled hosts * Fix UEFI detection on KVM * Refactor * Improvement
1 parent 81b7e6e commit 82e0d5d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,9 +1414,13 @@ private void configureAgentHooks(final Map<String, Object> params) {
14141414
s_logger.debug("agent.hooks.libvirt_vm_on_stop.method is " + _agentHooksVmOnStopMethod);
14151415
}
14161416

1417+
public boolean isUefiPropertiesFileLoaded() {
1418+
return !_uefiProperties.isEmpty();
1419+
}
1420+
14171421
private void loadUefiProperties() throws FileNotFoundException {
14181422

1419-
if (_uefiProperties != null && _uefiProperties.getProperty("guest.loader.legacy") != null) {
1423+
if (isUefiPropertiesFileLoaded()) {
14201424
return;
14211425
}
14221426
final File file = PropertiesUtil.findConfigFile("uefi.properties");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public final class LibvirtReadyCommandWrapper extends CommandWrapper<ReadyComman
4242
public Answer execute(final ReadyCommand command, final LibvirtComputingResource libvirtComputingResource) {
4343
Map<String, String> hostDetails = new HashMap<String, String>();
4444

45-
if (hostSupportsUefi()) {
45+
if (hostSupportsUefi() && libvirtComputingResource.isUefiPropertiesFileLoaded()) {
4646
hostDetails.put(Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString());
4747
}
4848

server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.apache.cloudstack.framework.config.ConfigKey;
4343
import org.apache.cloudstack.framework.config.Configurable;
4444
import org.apache.commons.collections.CollectionUtils;
45-
import org.apache.commons.collections.MapUtils;
4645
import org.apache.commons.lang3.StringUtils;
4746
import org.apache.log4j.Logger;
4847
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
@@ -301,8 +300,8 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile, Deploym
301300
}
302301
HostVO host = _hostDao.findById(hostIdSpecified);
303302
if (host != null && StringUtils.isNotBlank(uefiFlag) && "yes".equalsIgnoreCase(uefiFlag)) {
304-
_hostDao.loadDetails(host);
305-
if (MapUtils.isNotEmpty(host.getDetails()) && host.getDetails().containsKey(Host.HOST_UEFI_ENABLE) && "false".equalsIgnoreCase(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
303+
DetailVO uefiHostDetail = _hostDetailsDao.findDetail(host.getId(), Host.HOST_UEFI_ENABLE);
304+
if (uefiHostDetail == null || "false".equalsIgnoreCase(uefiHostDetail.getValue())) {
306305
s_logger.debug("Cannot deploy to specified host as host does n't support uefi vm deployment, returning.");
307306
return null;
308307

0 commit comments

Comments
 (0)