18
18
19
19
import static com .cloud .host .Host .HOST_INSTANCE_CONVERSION ;
20
20
import static com .cloud .host .Host .HOST_VOLUME_ENCRYPTION ;
21
+ import static org .apache .cloudstack .utils .linux .KVMHostInfo .isHostS390x ;
21
22
22
23
import java .io .BufferedReader ;
23
24
import java .io .File ;
@@ -244,11 +245,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
244
245
private static final String LEGACY = "legacy" ;
245
246
private static final String SECURE = "secure" ;
246
247
248
+ /**
249
+ * Machine type for s390x architecture
250
+ */
251
+ private static final String S390X_VIRTIO_DEVICE = "s390-ccw-virtio" ;
252
+
247
253
/**
248
254
* Machine type.
249
255
*/
250
- private static final String PC = "pc" ;
251
- private static final String VIRT = "virt" ;
256
+ private static final String PC = isHostS390x () ? S390X_VIRTIO_DEVICE : "pc" ;
257
+ private static final String VIRT = isHostS390x () ? S390X_VIRTIO_DEVICE : "virt" ;
252
258
253
259
/**
254
260
* Possible devices to add to VM.
@@ -305,6 +311,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
305
311
* Constant that defines ARM64 (aarch64) guest architectures.
306
312
*/
307
313
private static final String AARCH64 = "aarch64" ;
314
+ /**
315
+ * Constant that defines IBM Z Arch (s390x) guest architectures.
316
+ */
317
+ private static final String S390X = "s390x" ;
308
318
309
319
public static final String RESIZE_NOTIFY_ONLY = "NOTIFYONLY" ;
310
320
public static final String BASEPATH = "/usr/share/cloudstack-common/vms/" ;
@@ -1796,7 +1806,8 @@ private String matchPifFileInDirectory(final String bridgeName) {
1796
1806
"^dummy" ,
1797
1807
"^lo" ,
1798
1808
"^p\\ d+p\\ d+" ,
1799
- "^vni"
1809
+ "^vni" ,
1810
+ "^enc"
1800
1811
};
1801
1812
1802
1813
/**
@@ -2642,12 +2653,15 @@ protected DevicesDef createDevicesDef(VirtualMachineTO vmTO, GuestDef guest, int
2642
2653
}
2643
2654
2644
2655
devices .addDevice (createChannelDef (vmTO ));
2645
- devices .addDevice (createWatchDogDef ());
2656
+ if (!isGuestS390x ()) {
2657
+ devices .addDevice (createWatchDogDef ());
2658
+ }
2646
2659
devices .addDevice (createVideoDef (vmTO ));
2647
2660
devices .addDevice (createConsoleDef ());
2648
2661
devices .addDevice (createGraphicDef (vmTO ));
2649
- devices .addDevice (createTabletInputDef ());
2650
-
2662
+ if (!isGuestS390x ()) {
2663
+ devices .addDevice (createTabletInputDef ());
2664
+ }
2651
2665
if (isGuestAarch64 ()) {
2652
2666
createArm64UsbDef (devices );
2653
2667
}
@@ -2765,7 +2779,9 @@ protected FeaturesDef createFeaturesDef(Map<String, String> customParams, boolea
2765
2779
FeaturesDef features = new FeaturesDef ();
2766
2780
features .addFeatures (PAE );
2767
2781
features .addFeatures (APIC );
2768
- features .addFeatures (ACPI );
2782
+ if (!isHostS390x ()) {
2783
+ features .addFeatures (ACPI );
2784
+ }
2769
2785
if (isUefiEnabled && isSecureBoot ) {
2770
2786
features .addFeatures (SMM );
2771
2787
}
@@ -2857,6 +2873,10 @@ private boolean isGuestAarch64() {
2857
2873
return AARCH64 .equals (guestCpuArch );
2858
2874
}
2859
2875
2876
+ private boolean isGuestS390x () {
2877
+ return S390X .equals (guestCpuArch );
2878
+ }
2879
+
2860
2880
/**
2861
2881
* Creates a guest definition from a VM specification.
2862
2882
*/
@@ -2867,7 +2887,7 @@ protected GuestDef createGuestFromSpec(VirtualMachineTO vmTO, LibvirtVMDef vm, S
2867
2887
guest .setManufacturer (vmTO .getMetadataManufacturer ());
2868
2888
guest .setProduct (vmTO .getMetadataProductName ());
2869
2889
guest .setGuestArch (guestCpuArch != null ? guestCpuArch : vmTO .getArch ());
2870
- guest .setMachineType (isGuestAarch64 () ? VIRT : PC );
2890
+ guest .setMachineType (( isGuestAarch64 () || isGuestS390x () ) ? VIRT : PC );
2871
2891
guest .setBootType (GuestDef .BootType .BIOS );
2872
2892
if (MapUtils .isNotEmpty (customParams )) {
2873
2893
if (customParams .containsKey (GuestDef .BootType .UEFI .toString ())) {
@@ -2881,7 +2901,9 @@ protected GuestDef createGuestFromSpec(VirtualMachineTO vmTO, LibvirtVMDef vm, S
2881
2901
guest .setIothreads (customParams .containsKey (VmDetailConstants .IOTHREADS ));
2882
2902
}
2883
2903
guest .setUuid (uuid );
2884
- guest .setBootOrder (GuestDef .BootOrder .CDROM );
2904
+ if (!isGuestS390x ()) {
2905
+ guest .setBootOrder (GuestDef .BootOrder .CDROM );
2906
+ }
2885
2907
guest .setBootOrder (GuestDef .BootOrder .HARDISK );
2886
2908
return guest ;
2887
2909
}
@@ -3122,7 +3144,7 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
3122
3144
final DiskDef .DiskType diskType = getDiskType (physicalDisk );
3123
3145
disk .defISODisk (volPath , devId , isUefiEnabled , diskType );
3124
3146
3125
- if (guestCpuArch != null && guestCpuArch .equals ("aarch64" )) {
3147
+ if (guestCpuArch != null && ( guestCpuArch .equals ("aarch64" ) || guestCpuArch . equals ( "s390x" ) )) {
3126
3148
disk .setBusType (DiskDef .DiskBus .SCSI );
3127
3149
}
3128
3150
} else {
@@ -3220,7 +3242,7 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
3220
3242
if (vmSpec .getType () != VirtualMachine .Type .User ) {
3221
3243
final DiskDef iso = new DiskDef ();
3222
3244
iso .defISODisk (sysvmISOPath , DiskDef .DiskType .FILE );
3223
- if (guestCpuArch != null && guestCpuArch .equals ("aarch64" )) {
3245
+ if (guestCpuArch != null && ( guestCpuArch .equals ("aarch64" ) || guestCpuArch . equals ( "s390x" ) )) {
3224
3246
iso .setBusType (DiskDef .DiskBus .SCSI );
3225
3247
}
3226
3248
vm .getDevices ().addDevice (iso );
@@ -4294,7 +4316,7 @@ private DiskDef.DiskBus getGuestDiskModel(final String platformEmulator, boolean
4294
4316
return DiskDef .DiskBus .VIRTIO ;
4295
4317
} else if (isUefiEnabled && StringUtils .startsWithAny (platformEmulator , "Windows" , "Other" )) {
4296
4318
return DiskDef .DiskBus .SATA ;
4297
- } else if (guestCpuArch != null && guestCpuArch .equals ("aarch64" )) {
4319
+ } else if (guestCpuArch != null && ( guestCpuArch .equals ("aarch64" ) || guestCpuArch . equals ( "s390x" ) )) {
4298
4320
return DiskDef .DiskBus .SCSI ;
4299
4321
} else {
4300
4322
return DiskDef .DiskBus .IDE ;
0 commit comments