Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ protected void init() {
parameters.getVmStaticData().setBiosType(vmDevicesSource.getClusterId() == null ? getCluster().getBiosType() : vmDevicesSource.getBiosType());
}

// For aarch64, always use host cpu flags
if (getCluster().getArchitecture().getFamily() == ArchitectureType.aarch64) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not do it this way.
When adding the CPU in the ServerCPUList in packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql, I would for example there put no CPU flags.
If you then create a VM with a CPU without CPU flags, it should use auto-passtrough/host cpu flags.

This has the advantage that in the future we can just add new ARM CPU's without messing in the code again.

parameters.getVm().setUseHostCpuFlags(true);
parameters.getVmStaticData().setUseHostCpuFlags(true);
}

imageTypeId = parameters.getVmStaticData().getImageTypeId();
vmInterfacesSourceId = parameters.getVmStaticData().getVmtGuid();
vmDisksSource = getVmTemplate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ && isX86Architecture(cluster)) {
} else if (isVersionGreaterOrEquals(cluster, Version.v4_4)
&& isX86Architecture(cluster)) {
cluster.setBiosType(BiosType.Q35_SEA_BIOS);
} else if (isVersionGreaterOrEquals(cluster, Version.v4_7)
&& isAarch64Architecture(cluster)) {
cluster.setBiosType(BiosType.AMPERE_OVMF);
} else {
cluster.setBiosType(BiosType.I440FX_SEA_BIOS);
}
Expand All @@ -202,6 +205,11 @@ private boolean isX86Architecture(Cluster cluster) {
&& cluster.getArchitecture().getFamily() == ArchitectureType.x86;
}

private boolean isAarch64Architecture(Cluster cluster) {
return cluster.getArchitecture() != null
&& cluster.getArchitecture().getFamily() == ArchitectureType.aarch64;
}

private ClusterPolicy getClusterPolicy(final Cluster cluster) {
ClusterPolicy clusterPolicy = null;
if (cluster == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,18 @@ private static class CpuFlagsManager {
private List<ServerCpu> amdCpuList;
private List<ServerCpu> ibmCpuList;
private List<ServerCpu> s390CpuList;
private List<ServerCpu> armCpuList;
private List<ServerCpu> allCpuList = new ArrayList<>();
private Map<String, ServerCpu> intelCpuByNameDictionary = new HashMap<>();
private Map<String, ServerCpu> amdCpuByNameDictionary = new HashMap<>();
private Map<String, ServerCpu> ibmCpuByNameDictionary = new HashMap<>();
private Map<String, ServerCpu> s390CpuByNameDictionary = new HashMap<>();
private Map<String, ServerCpu> armCpuByNameDictionary = new HashMap<>();
private Map<String, ServerCpu> intelCpuByVdsNameDictionary = new HashMap<>();
private Map<String, ServerCpu> amdCpuByVdsNameDictionary = new HashMap<>();
private Map<String, ServerCpu> ibmCpuByVdsNameDictionary = new HashMap<>();
private Map<String, ServerCpu> s390CpuByVdsNameDictionary = new HashMap<>();
private Map<String, ServerCpu> armCpuByVdsNameDictionary = new HashMap<>();

public CpuFlagsManager(Version ver) {
initDictionaries(ver);
Expand Down Expand Up @@ -200,6 +203,8 @@ public String getVendorByCpuName(String cpuName) {
result = CpuVendor.IBM.name();
} else if (s390CpuByNameDictionary.get(cpuName) != null) {
result = CpuVendor.IBMS390.name();
} else if (armCpuByNameDictionary.get(cpuName) != null) {
result = CpuVendor.ARM.name();
}
}
return result;
Expand All @@ -222,6 +227,10 @@ public ServerCpu getServerCpuByName(String cpuName) {
if (result == null) {
result = s390CpuByNameDictionary.get(cpuName);
}

if (result == null) {
result = armCpuByNameDictionary.get(cpuName);
}
}
return result;
}
Expand All @@ -233,6 +242,7 @@ public void initDictionaries(Version ver) {
amdCpuByNameDictionary.clear();
ibmCpuByNameDictionary.clear();
s390CpuByNameDictionary.clear();
armCpuByNameDictionary.clear();
allCpuList.clear();

String[] cpus = Config.<String> getValue(ConfigValues.ServerCPUList, ver.toString()).trim().split("[;]", -1);
Expand Down Expand Up @@ -271,6 +281,9 @@ public void initDictionaries(Version ver) {
} else if (sc.getFlags().contains(CpuVendor.IBMS390.getFlag())) {
s390CpuByNameDictionary.put(sc.getCpuName(), sc);
s390CpuByVdsNameDictionary.put(sc.getVdsVerbData(), sc);
} else if (sc.getFlags().contains(CpuVendor.ARM.getFlag())) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would name it AARCH64 instead of ARM

armCpuByNameDictionary.put(sc.getCpuName(), sc);
armCpuByVdsNameDictionary.put(sc.getVdsVerbData(), sc);
}

allCpuList.add(sc);
Expand All @@ -283,6 +296,7 @@ public void initDictionaries(Version ver) {
amdCpuList = new ArrayList<>(amdCpuByNameDictionary.values());
ibmCpuList = new ArrayList<>(ibmCpuByNameDictionary.values());
s390CpuList = new ArrayList<>(s390CpuByNameDictionary.values());
armCpuList = new ArrayList<>(armCpuByNameDictionary.values());

Comparator<ServerCpu> cpuComparator = Comparator.comparingInt(ServerCpu::getLevel);

Expand All @@ -292,6 +306,7 @@ public void initDictionaries(Version ver) {
Collections.sort(amdCpuList, cpuComparator);
Collections.sort(ibmCpuList, cpuComparator);
Collections.sort(s390CpuList, cpuComparator);
Collections.sort(armCpuList, cpuComparator);
}

public String getVDSVerbDataByCpuName(String name) {
Expand All @@ -301,7 +316,8 @@ public String getVDSVerbDataByCpuName(String name) {
if ((sc = intelCpuByNameDictionary.get(name)) != null
|| (sc = amdCpuByNameDictionary.get(name)) != null
|| (sc = ibmCpuByNameDictionary.get(name)) != null
|| (sc = s390CpuByNameDictionary.get(name)) != null) {
|| (sc = s390CpuByNameDictionary.get(name)) != null
|| (sc = armCpuByVdsNameDictionary.get(name)) != null) {
result = sc.getVdsVerbData();
}
}
Expand All @@ -315,7 +331,8 @@ public String getCpuNameByCpuId(String vdsName) {
if ((sc = intelCpuByVdsNameDictionary.get(vdsName)) != null
|| (sc = amdCpuByVdsNameDictionary.get(vdsName)) != null
|| (sc = ibmCpuByVdsNameDictionary.get(vdsName)) != null
|| (sc = s390CpuByVdsNameDictionary.get(vdsName)) != null) {
|| (sc = s390CpuByVdsNameDictionary.get(vdsName)) != null
|| (sc = armCpuByVdsNameDictionary.get(vdsName)) != null) {
result = sc.getCpuName();
}
}
Expand Down Expand Up @@ -346,6 +363,7 @@ public List<String> missingServerCpuFlags(String clusterCpuName, String serverFl
|| (clusterCpu = amdCpuByNameDictionary.get(clusterCpuName)) != null
|| (clusterCpu = ibmCpuByNameDictionary.get(clusterCpuName)) != null
|| (clusterCpu = s390CpuByNameDictionary.get(clusterCpuName)) != null
|| (clusterCpu = armCpuByNameDictionary.get(clusterCpuName)) != null
)) {
for (String flag : clusterCpu.getFlags()) {
if (!lstServerflags.contains(flag)) {
Expand Down Expand Up @@ -393,6 +411,10 @@ public boolean checkIfCpusSameManufacture(String cpuName1, String cpuName2) {
return s390CpuByNameDictionary.containsKey(cpuName2);
}

if (armCpuByNameDictionary.containsKey(cpuName1)) {
return armCpuByNameDictionary.containsKey(cpuName2);
}

return false;
}

Expand All @@ -401,7 +423,8 @@ public boolean checkIfCpusExist(String cpuName) {
&& (intelCpuByNameDictionary.containsKey(cpuName)
|| amdCpuByNameDictionary.containsKey(cpuName)
|| ibmCpuByNameDictionary.containsKey(cpuName)
|| s390CpuByNameDictionary.containsKey(cpuName));
|| s390CpuByNameDictionary.containsKey(cpuName)
|| armCpuByNameDictionary.containsKey(cpuName));
}

/**
Expand Down Expand Up @@ -441,6 +464,12 @@ public List<ServerCpu> findServerCpusByFlags(String flags) {
foundCpus.add(s390CpuList.get(i));
}
}
} else if (lstFlags.contains(CpuVendor.ARM.getFlag())) {
for (int i = armCpuList.size() - 1; i >= 0; i--) {
if (checkIfFlagsContainsCpuFlags(armCpuList.get(i), lstFlags)) {
foundCpus.add(armCpuList.get(i));
}
}
}
return foundCpus;
}
Expand Down Expand Up @@ -478,6 +507,12 @@ public List<ServerCpu> getSupportedServerCpuList(String maxCpuName) {
for (int i = 0; i <= selectedCpuIndex; i++) {
supportedCpus.add(s390CpuList.get(i));
}
} else if (armCpuByNameDictionary.containsKey(maxCpuName)) {
ServerCpu selected = armCpuByNameDictionary.get(maxCpuName);
int selectedCpuIndex = armCpuList.indexOf(selected);
for (int i = 0; i <= selectedCpuIndex; i++) {
supportedCpus.add(armCpuList.get(i));
}
}
return supportedCpus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ protected boolean getVdsToRunOn() {
if (getVm().isUsingCpuPassthrough()) {
getVm().setCpuName(getVds().getCpuFlags());
getVm().setUseHostCpuFlags(true);
} else if (getVm().getClusterArch().getFamily() == ArchitectureType.aarch64) {
getVm().setUseHostCpuFlags(true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as above. If no cpu flags -> usehostcpu

}

addNumaPinningForDedicated(getVdsId());
Expand Down Expand Up @@ -1146,6 +1148,7 @@ protected boolean validateImpl() {

if (FeatureSupported.isBiosTypeSupported(getCluster().getCompatibilityVersion())
&& getVm().getBiosType() != BiosType.I440FX_SEA_BIOS
&& getCluster().getArchitecture().getFamily() != ArchitectureType.aarch64
&& getCluster().getArchitecture().getFamily() != ArchitectureType.x86) {
return failValidation(EngineMessage.NON_DEFAULT_BIOS_TYPE_FOR_X86_ONLY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ private String getEmulatedMachineOfHostInCluster(VDS vds) {
List<String> available = Config.getValue(ConfigValues.ClusterEmulatedMachines, version.getValue());
return ClusterEmulatedMachines.build(
EmulatedMachineCommonUtils.getSupportedByChipset(ChipsetType.I440FX, supported, available),
EmulatedMachineCommonUtils.getSupportedByChipset(ChipsetType.Q35, supported, available));
EmulatedMachineCommonUtils.getSupportedByChipset(ChipsetType.Q35, supported, available),
EmulatedMachineCommonUtils.getSupportedByChipset(ChipsetType.VIRT, supported, available));
}

private void addOrUpdateAddtionalClusterFeatures() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ protected void init() {
if (getParameters().getVmStaticData().getBiosType() == null) {
getParameters().getVmStaticData().setBiosType(getVm().getBiosType());
}
if (!getParameters().getVm().isUseHostCpuFlags()
&& getVm().getClusterArch().getFamily() == ArchitectureType.aarch64) {
getParameters().getVm().setUseHostCpuFlags(true);
}
}

private VmPropertiesUtils getVmPropertiesUtils() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public void runForS390X() {
hasMaximum = VmCommand.MAX_VIRTIO_CCW_DISKS == countDisks(DiskInterface.VirtIO);
}

@Override
public void runForAARCH64() {
hasMaximum = VmCommand.MAX_IDE_SLOTS == countDisks(DiskInterface.IDE);
}

public boolean returnValue() {
return hasMaximum;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ public ValidationResult nonDefaultBiosType() {
.when(FeatureSupported.isBiosTypeSupported(eCluster.getCompatibilityVersion())
&& eCluster.getBiosType() != null
&& eCluster.getBiosType() != BiosType.I440FX_SEA_BIOS
&& eCluster.getBiosType() != BiosType.AMPERE
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should validate BiosType together with Architecture.
So that you don't select BiosType.AMPERE on X86 for example.

Next to that, name the BiosType VIRT/VIRT_AAVMF ?
This patch is not ampere-only...

&& eCluster.getBiosType() != BiosType.AMPERE_OVMF
&& architecture.getFamily() != ArchitectureType.x86);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ public ValidationResult canMigrate(boolean forceMigration) {
public static ValidationResult isBiosTypeSupported(VmBase vmBase, Cluster cluster, OsRepository osRepository) {
if (FeatureSupported.isBiosTypeSupported(cluster.getCompatibilityVersion())
&& vmBase.getBiosType() != BiosType.I440FX_SEA_BIOS
&& vmBase.getBiosType() != BiosType.AMPERE
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

&& vmBase.getBiosType() != BiosType.AMPERE_OVMF
&& cluster.getArchitecture() != ArchitectureType.undefined
&& cluster.getArchitecture().getFamily() != ArchitectureType.x86) {
return new ValidationResult(EngineMessage.NON_DEFAULT_BIOS_TYPE_FOR_X86_ONLY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.ovirt.engine.core.bll.interfaces.BackendInternal;
import org.ovirt.engine.core.bll.utils.VmDeviceUtils;
import org.ovirt.engine.core.common.action.CloneVmParameters;
import org.ovirt.engine.core.common.businessentities.ArchitectureType;
import org.ovirt.engine.core.common.businessentities.BiosType;
import org.ovirt.engine.core.common.businessentities.Cluster;
import org.ovirt.engine.core.common.businessentities.VM;
Expand Down Expand Up @@ -106,6 +107,7 @@ private void initializeCommand() {
when(vmDao.get(any())).thenReturn(vm);
Cluster cluster = new Cluster();
cluster.setCompatibilityVersion(Version.v4_4);
cluster.setArchitecture(ArchitectureType.x86);
when(clusterDao.get(any())).thenReturn(cluster);
VmTemplate vmTemplate = new VmTemplate();
when(vmTemplateDao.get(any())).thenReturn(vmTemplate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public enum ArchitectureType implements Identifiable {
ppc(3),
/* Host & Guest architecture */
s390x(7),
/* Host & Guest architecture */
aarch64(8),

// Specific architectures
/* Host & Guest architecture */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public enum BiosType implements Identifiable {
I440FX_SEA_BIOS(1, ChipsetType.I440FX, false),
Q35_SEA_BIOS(2, ChipsetType.Q35, false),
Q35_OVMF(3, ChipsetType.Q35, true),
Q35_SECURE_BOOT(4, ChipsetType.Q35, true);
Q35_SECURE_BOOT(4, ChipsetType.Q35, true),
AMPERE(5, ChipsetType.VIRT, false),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename those

AMPERE_OVMF(6, ChipsetType.VIRT, true);

private int value;
private ChipsetType chipsetType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
public enum ChipsetType {

I440FX("i440fx"),
Q35("q35");
Q35("q35"),
VIRT("virt");

private String chipsetName;

Expand All @@ -26,6 +27,9 @@ public static ChipsetType fromMachineType(String machineType) {
if (element.equalsIgnoreCase("pc")) {
defaultChipset = I440FX;
}
if (element.equalsIgnoreCase("virt")) {
defaultChipset = VIRT;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ public void setCustomCpuName(String customCpuName) {
}

public boolean isUseHostCpuFlags() {
return useHostCpuFlags;
return useHostCpuFlags = biosType == BiosType.AMPERE || biosType == BiosType.AMPERE_OVMF;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comments

}

public void setUseHostCpuFlags(boolean useHostCpuFlags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public interface OsRepository {
int DEFAULT_X86_OS = 0;
int DEFAULT_PPC_OS = 1001;
int DEFAULT_S390_OS = 2001;
int DEFAULT_AARCH64_OS = 3001;

/*
* This value is used to enable the auto selection of an appropriate OS when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,29 @@ public class ClusterEmulatedMachines {

private static final String I440FX_CHIPSET_NAME = ChipsetType.I440FX.getChipsetName();
private static final String Q35_CHIPSET_NAME = ChipsetType.Q35.getChipsetName();
private static final String VIRT_CHIPSET_NAME = ChipsetType.VIRT.getChipsetName();

private String i440fxType = "";
private String q35Type = "";
private String virtType = "";

private ClusterEmulatedMachines() {
}

private ClusterEmulatedMachines(String virtType) {
this.virtType = virtType;
}

private ClusterEmulatedMachines(String i440fxType, String q35Type) {
this.i440fxType = i440fxType;
this.q35Type = q35Type;
}

public static String build(String i440fxType, String q35Type) {
if (i440fxType == null) {
public static String build(String i440fxType, String q35Type, String virtType) {
if (i440fxType == null && q35Type != null) {
return q35Type;
} else if (q35Type == null && i440fxType == null && virtType != null) {
return virtType;
} else {
return q35Type == null ? i440fxType : i440fxType + ";" + q35Type;
}
Expand All @@ -44,6 +52,8 @@ public static ClusterEmulatedMachines parse(String emulatedMachine) {
ChipsetType chipsetType = ChipsetType.fromMachineType(emulatedMachine);
if (chipsetType == ChipsetType.Q35) {
return new ClusterEmulatedMachines(replaceChipset(emulatedMachine, ChipsetType.I440FX), emulatedMachine);
} else if (chipsetType == ChipsetType.VIRT) {
return new ClusterEmulatedMachines(replaceChipset(emulatedMachine, ChipsetType.VIRT));
} else {
return new ClusterEmulatedMachines(emulatedMachine, replaceChipset(emulatedMachine, ChipsetType.Q35));
}
Expand All @@ -68,6 +78,12 @@ protected static String replaceChipset(String emulatedMachine, ChipsetType chips
return emulatedMachine.replace(Q35_CHIPSET_NAME, I440FX_CHIPSET_NAME);
}
break;

case VIRT:
if (emulatedMachine.contains(VIRT_CHIPSET_NAME)) {
return emulatedMachine.replace(Q35_CHIPSET_NAME, VIRT_CHIPSET_NAME);
}
break;
}
return emulatedMachine;
}
Expand All @@ -80,8 +96,16 @@ public String getQ35Type() {
return q35Type;
}

public String getVirtType() {
return virtType;
}

public String getTypeByChipset(ChipsetType chipsetType) {
return chipsetType == ChipsetType.Q35 ? q35Type : i440fxType;
if (chipsetType == ChipsetType.VIRT) {
return virtType;
} else {
return chipsetType == ChipsetType.Q35 ? q35Type : i440fxType;
}
}

public static String forChipset(String emulatedMachine, ChipsetType chipsetType) {
Expand Down
Loading