kvm: make UEFI host check to support both Ubuntu and EL (#7084)

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2023-01-16 18:42:53 +05:30 committed by GitHub
parent 52c321a0c6
commit 55d2d26449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -3072,10 +3072,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
} }
return enableIoUringConfig != null ? return enableIoUringConfig != null ?
enableIoUringConfig: enableIoUringConfig:
(isBaseOsUbuntu() || isIoUringSupportedByQemu()); (isUbuntuHost() || isIoUringSupportedByQemu());
} }
private boolean isBaseOsUbuntu() { public boolean isUbuntuHost() {
Map<String, String> versionString = getVersionStrings(); Map<String, String> versionString = getVersionStrings();
String hostKey = "Host.OS"; String hostKey = "Host.OS";
if (MapUtils.isEmpty(versionString) || !versionString.containsKey(hostKey) || versionString.get(hostKey) == null) { if (MapUtils.isEmpty(versionString) || !versionString.containsKey(hostKey) || versionString.get(hostKey) == null) {

View File

@ -42,18 +42,21 @@ public final class LibvirtReadyCommandWrapper extends CommandWrapper<ReadyComman
public Answer execute(final ReadyCommand command, final LibvirtComputingResource libvirtComputingResource) { public Answer execute(final ReadyCommand command, final LibvirtComputingResource libvirtComputingResource) {
Map<String, String> hostDetails = new HashMap<String, String>(); Map<String, String> hostDetails = new HashMap<String, String>();
if (hostSupportsUefi() && libvirtComputingResource.isUefiPropertiesFileLoaded()) { if (hostSupportsUefi(libvirtComputingResource.isUbuntuHost()) && libvirtComputingResource.isUefiPropertiesFileLoaded()) {
hostDetails.put(Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString()); hostDetails.put(Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString());
} }
return new ReadyAnswer(command, hostDetails); return new ReadyAnswer(command, hostDetails);
} }
private boolean hostSupportsUefi() { private boolean hostSupportsUefi(boolean isUbuntuHost) {
String cmd = "rpm -qa | grep -i ovmf"; String cmd = "rpm -qa | grep -i ovmf";
if (isUbuntuHost) {
cmd = "dpkg -l ovmf";
}
s_logger.debug("Running command : " + cmd); s_logger.debug("Running command : " + cmd);
int result = Script.runSimpleBashScriptForExitValue(cmd); int result = Script.runSimpleBashScriptForExitValue(cmd);
s_logger.debug("Got result : " + result); s_logger.debug("Got result : " + result);
return result == 0; return result == 0;
} }
} }