Skip to content

Commit e6e39c0

Browse files
committed
Added constant for s390-ccw-virtio and made related updates.
1 parent 00962c6 commit e6e39c0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.cloud.host.Host.HOST_INSTANCE_CONVERSION;
2020
import static com.cloud.host.Host.HOST_VOLUME_ENCRYPTION;
21+
import static org.apache.cloudstack.utils.linux.KVMHostInfo.isHostS390x;
2122

2223
import java.io.BufferedReader;
2324
import java.io.File;
@@ -244,11 +245,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
244245
private static final String LEGACY = "legacy";
245246
private static final String SECURE = "secure";
246247

248+
/**
249+
* Machine type for s390x architecture
250+
*/
251+
private static final String S390X_VIRTIO_DEVICE = "s390-ccw-virtio";
252+
247253
/**
248254
* Machine type.
249255
*/
250-
private static final String PC = ("s390x".equals(System.getProperty("os.arch"))) ? "s390-ccw-virtio" : "pc";
251-
private static final String VIRT = ("s390x".equals(System.getProperty("os.arch"))) ? "s390-ccw-virtio" : "virt";
256+
private static final String PC = isHostS390x() ? S390X_VIRTIO_DEVICE : "pc";
257+
private static final String VIRT = isHostS390x() ? S390X_VIRTIO_DEVICE : "virt";
252258

253259
/**
254260
* Possible devices to add to VM.
@@ -2762,7 +2768,7 @@ protected FeaturesDef createFeaturesDef(Map<String, String> customParams, boolea
27622768
FeaturesDef features = new FeaturesDef();
27632769
features.addFeatures(PAE);
27642770
features.addFeatures(APIC);
2765-
if (!isGuestS390x()) {
2771+
if (!isHostS390x()) {
27662772
features.addFeatures(ACPI);
27672773
}
27682774
if (isUefiEnabled && isSecureBoot) {

plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public String getCpuArch() {
111111
return cpuArch;
112112
}
113113

114+
public static boolean isHostS390x() {
115+
return "s390x".equals(System.getProperty("os.arch"));
116+
}
117+
114118
protected static long getCpuSpeed(final String cpabilities, final NodeInfo nodeInfo) {
115119
long speed = 0L;
116120
speed = getCpuSpeedFromCommandLscpu();
@@ -137,7 +141,7 @@ private static long getCpuSpeedFromCommandLscpu() {
137141
try {
138142
LOGGER.info("Fetching CPU speed from command \"lscpu\".");
139143
String command = "lscpu | grep -i 'Model name' | head -n 1 | egrep -o '[[:digit:]].[[:digit:]]+GHz' | sed 's/GHz//g'";
140-
if("s390x".equals(System.getProperty("os.arch"))) {
144+
if(isHostS390x()) {
141145
command = "lscpu | grep 'CPU dynamic MHz' | cut -d ':' -f 2 | tr -d ' ' | awk '{printf \"%.1f\\n\", $1 / 1000}'";
142146
}
143147
String result = Script.runSimpleBashScript(command);

0 commit comments

Comments
 (0)