mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix UEFI detection on KVM and prevent deployments on non UEFI enabled hosts (#6423)
* Do not allow UEFI deployments on non UEFI enabled hosts * Fix UEFI detection on KVM * Refactor * Improvement
This commit is contained in:
parent
81b7e6e750
commit
82e0d5d679
@ -1414,9 +1414,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
s_logger.debug("agent.hooks.libvirt_vm_on_stop.method is " + _agentHooksVmOnStopMethod);
|
||||
}
|
||||
|
||||
public boolean isUefiPropertiesFileLoaded() {
|
||||
return !_uefiProperties.isEmpty();
|
||||
}
|
||||
|
||||
private void loadUefiProperties() throws FileNotFoundException {
|
||||
|
||||
if (_uefiProperties != null && _uefiProperties.getProperty("guest.loader.legacy") != null) {
|
||||
if (isUefiPropertiesFileLoaded()) {
|
||||
return;
|
||||
}
|
||||
final File file = PropertiesUtil.findConfigFile("uefi.properties");
|
||||
|
||||
@ -42,7 +42,7 @@ public final class LibvirtReadyCommandWrapper extends CommandWrapper<ReadyComman
|
||||
public Answer execute(final ReadyCommand command, final LibvirtComputingResource libvirtComputingResource) {
|
||||
Map<String, String> hostDetails = new HashMap<String, String>();
|
||||
|
||||
if (hostSupportsUefi()) {
|
||||
if (hostSupportsUefi() && libvirtComputingResource.isUefiPropertiesFileLoaded()) {
|
||||
hostDetails.put(Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,6 @@ import com.cloud.utils.fsm.StateMachine2;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.framework.config.Configurable;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
|
||||
@ -301,8 +300,8 @@ StateListener<State, VirtualMachine.Event, VirtualMachine>, Configurable {
|
||||
}
|
||||
HostVO host = _hostDao.findById(hostIdSpecified);
|
||||
if (host != null && StringUtils.isNotBlank(uefiFlag) && "yes".equalsIgnoreCase(uefiFlag)) {
|
||||
_hostDao.loadDetails(host);
|
||||
if (MapUtils.isNotEmpty(host.getDetails()) && host.getDetails().containsKey(Host.HOST_UEFI_ENABLE) && "false".equalsIgnoreCase(host.getDetails().get(Host.HOST_UEFI_ENABLE))) {
|
||||
DetailVO uefiHostDetail = _hostDetailsDao.findDetail(host.getId(), Host.HOST_UEFI_ENABLE);
|
||||
if (uefiHostDetail == null || "false".equalsIgnoreCase(uefiHostDetail.getValue())) {
|
||||
s_logger.debug("Cannot deploy to specified host as host does n't support uefi vm deployment, returning.");
|
||||
return null;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user