-
Notifications
You must be signed in to change notification settings - Fork 299
ARM support engine changes #1063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
|
@@ -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; | ||
|
|
@@ -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; | ||
| } | ||
|
|
@@ -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); | ||
|
|
@@ -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())) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
@@ -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); | ||
|
|
||
|
|
@@ -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) { | ||
|
|
@@ -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(); | ||
| } | ||
| } | ||
|
|
@@ -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(); | ||
| } | ||
| } | ||
|
|
@@ -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)) { | ||
|
|
@@ -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; | ||
| } | ||
|
|
||
|
|
@@ -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)); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -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; | ||
| } | ||
|
|
@@ -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; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here as above. If no cpu flags -> usehostcpu |
||
| } | ||
|
|
||
| addNumaPinningForDedicated(getVdsId()); | ||
|
|
@@ -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); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should validate BiosType together with Architecture. Next to that, name the BiosType VIRT/VIRT_AAVMF ? |
||
| && eCluster.getBiosType() != BiosType.AMPERE_OVMF | ||
| && architecture.getFamily() != ArchitectureType.x86); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1627,7 +1627,7 @@ public void setCustomCpuName(String customCpuName) { | |
| } | ||
|
|
||
| public boolean isUseHostCpuFlags() { | ||
| return useHostCpuFlags; | ||
| return useHostCpuFlags = biosType == BiosType.AMPERE || biosType == BiosType.AMPERE_OVMF; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See other comments |
||
| } | ||
|
|
||
| public void setUseHostCpuFlags(boolean useHostCpuFlags) { | ||
|
|
||
There was a problem hiding this comment.
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.