Skip to content

Commit fe509e9

Browse files
weizhouapachesureshanaparti
authored andcommitted
kvm: consider Debian same as Ubuntu (apache#10917)
Co-authored-by: Suresh Kumar Anaparti <[email protected]>
1 parent 7b3af54 commit fe509e9

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3889,7 +3889,7 @@ private boolean isIoUringEnabled() {
38893889
if (!meetRequirements) {
38903890
return false;
38913891
}
3892-
return isUbuntuHost() || isIoUringSupportedByQemu();
3892+
return isUbuntuOrDebianHost() || isIoUringSupportedByQemu();
38933893
}
38943894

38953895
/**
@@ -3902,13 +3902,14 @@ public boolean isQemuDiscardBugFree(DiskDef.DiskBus diskBus) {
39023902
return diskBus != DiskDef.DiskBus.IDE || getHypervisorQemuVersion() >= HYPERVISOR_QEMU_VERSION_IDE_DISCARD_FIXED;
39033903
}
39043904

3905-
public boolean isUbuntuHost() {
3905+
public boolean isUbuntuOrDebianHost() {
39063906
Map<String, String> versionString = getVersionStrings();
39073907
String hostKey = "Host.OS";
39083908
if (MapUtils.isEmpty(versionString) || !versionString.containsKey(hostKey) || versionString.get(hostKey) == null) {
39093909
return false;
39103910
}
3911-
return versionString.get(hostKey).equalsIgnoreCase("ubuntu");
3911+
return versionString.get(hostKey).equalsIgnoreCase("ubuntu")
3912+
|| versionString.get(hostKey).toLowerCase().startsWith("debian");
39123913
}
39133914

39143915
private KVMPhysicalDisk getPhysicalDiskFromNfsStore(String dataStoreUrl, DataTO data) {
@@ -6308,14 +6309,14 @@ public boolean isSecureMode(String bootMode) {
63086309

63096310
public boolean hostSupportsInstanceConversion() {
63106311
int exitValue = Script.runSimpleBashScriptForExitValue(INSTANCE_CONVERSION_SUPPORTED_CHECK_CMD);
6311-
if (isUbuntuHost() && exitValue == 0) {
6312+
if (isUbuntuOrDebianHost() && exitValue == 0) {
63126313
exitValue = Script.runSimpleBashScriptForExitValue(UBUNTU_NBDKIT_PKG_CHECK_CMD);
63136314
}
63146315
return exitValue == 0;
63156316
}
63166317

63176318
public boolean hostSupportsWindowsGuestConversion() {
6318-
if (isUbuntuHost()) {
6319+
if (isUbuntuOrDebianHost()) {
63196320
int exitValue = Script.runSimpleBashScriptForExitValue(UBUNTU_WINDOWS_GUEST_CONVERSION_SUPPORTED_CHECK_CMD);
63206321
return exitValue == 0;
63216322
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class LibvirtCheckConvertInstanceCommandWrapper extends CommandWrapper<Ch
3232
public Answer execute(CheckConvertInstanceCommand cmd, LibvirtComputingResource serverResource) {
3333
if (!serverResource.hostSupportsInstanceConversion()) {
3434
String msg = String.format("Cannot convert the instance from VMware as the virt-v2v binary is not found on host %s. " +
35-
"Please install virt-v2v%s on the host before attempting the instance conversion.", serverResource.getPrivateIp(), serverResource.isUbuntuHost()? ", nbdkit" : "");
35+
"Please install virt-v2v%s on the host before attempting the instance conversion.", serverResource.getPrivateIp(), serverResource.isUbuntuOrDebianHost()? ", nbdkit" : "");
3636
logger.info(msg);
3737
return new CheckConvertInstanceAnswer(cmd, false, msg);
3838
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public Answer execute(ConvertInstanceCommand cmd, LibvirtComputingResource serve
6060

6161
if (cmd.getCheckConversionSupport() && !serverResource.hostSupportsInstanceConversion()) {
6262
String msg = String.format("Cannot convert the instance %s from VMware as the virt-v2v binary is not found. " +
63-
"Please install virt-v2v%s on the host before attempting the instance conversion.", sourceInstanceName, serverResource.isUbuntuHost()? ", nbdkit" : "");
63+
"Please install virt-v2v%s on the host before attempting the instance conversion.", sourceInstanceName, serverResource.isUbuntuOrDebianHost()? ", nbdkit" : "");
6464
logger.info(msg);
6565
return new Answer(cmd, false, msg);
6666
}

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

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

46-
if (hostSupportsUefi(libvirtComputingResource.isUbuntuHost()) && libvirtComputingResource.isUefiPropertiesFileLoaded()) {
46+
if (hostSupportsUefi(libvirtComputingResource.isUbuntuOrDebianHost()) && libvirtComputingResource.isUefiPropertiesFileLoaded()) {
4747
hostDetails.put(Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString());
4848
}
4949

@@ -58,10 +58,10 @@ public Answer execute(final ReadyCommand command, final LibvirtComputingResource
5858
return new ReadyAnswer(command, hostDetails);
5959
}
6060

61-
private boolean hostSupportsUefi(boolean isUbuntuHost) {
61+
private boolean hostSupportsUefi(boolean isUbuntuOrDebianHost) {
6262
int timeout = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.AGENT_SCRIPT_TIMEOUT) * 1000; // Get property value & convert to milliseconds
6363
int result;
64-
if (isUbuntuHost) {
64+
if (isUbuntuOrDebianHost) {
6565
logger.debug("Running command : [dpkg -l ovmf] with timeout : " + timeout + " ms");
6666
result = Script.executeCommandForExitValue(timeout, Script.getExecutableAbsolutePath("dpkg"), "-l", "ovmf");
6767
} else {

0 commit comments

Comments
 (0)