Roy Golan has uploaded a new change for review. Change subject: core: osinfo - add unsupported list of CPUs ......................................................................
core: osinfo - add unsupported list of CPUs adding a comma separated list of unsupported CPUs to osinfo and 2 verbs to query it: public Map<Pair<Integer, Version>, Set<String>> getUnsupportedCpus(); public boolean isCpuSupported(int osId, Version version, String cpuId); Change-Id: I339b87de7646b813aa634102c26f710b9d5f6f75 Bug-Url: https://bugzilla.redhat.com/1096851 Signed-off-by: Roy Golan <rgo...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java M backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java M packaging/conf/osinfo-defaults.properties 4 files changed, 89 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/33229/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java index f8a951c..83e18cd 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java @@ -262,4 +262,30 @@ * @return an boolean */ public boolean isHypervEnabled(int osId, Version version); + + /** + * Some Operating Systems don't support certain CPUs. As a result of working + * with one,the guest OS might stop working, blue-screen, oops, or other well known red lights. + * @param osId + * @param version + * @return unsupported cpus mapping of {osId, version}->{set of cpu ids} ; cpu id is lower-case + */ + public Map<Pair<Integer, Version>, Set<String>> getUnsupportedCpus(); + + /** + * Stripped version of getUnsupportedCpus. + * @param osId + * @param version + * @return + */ + public Set<String> getUnsupportedCpus(int osId, Version version); + /** + * Some Operating Systems don't support certain CPUs. As a result of working + * with one,the guest OS might stop working, blue-screen, oops, or other well known red lights. + * @param osId + * @param version + * @param cpuId cpu id as being specified in vdc_options, <bold>case insensitive</bold> + * @return true if the cpu supported otherwise false + */ + public boolean isCpuSupported(int osId, Version version, String cpuId); } diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java index 093ede8..ee91e66 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java @@ -413,6 +413,29 @@ } @Override + public Map<Pair<Integer, Version>, Set<String>> getUnsupportedCpus() { + Set<Version> versionsWithNull = new HashSet<Version>(Version.ALL); + versionsWithNull.add(null); + + HashMap<Pair<Integer, Version>, Set<String>> unsupportedCpus = new HashMap<>(); + + for (int osId : getOsIds()) { + for (Version version : versionsWithNull) { + unsupportedCpus.put( + new Pair<>(osId, version), + getUnsupportedCpus(osId, version) + ); + } + } + return unsupportedCpus; + } + + @Override + public boolean isCpuSupported(int osId, Version version, String cpuId) { + return !getUnsupportedCpus(osId, version).contains(cpuId.toLowerCase()); + } + + @Override public int getOsIdByUniqueName(String uniqueOsName) { for (Map.Entry<Integer, String> entry : getUniqueOsNames().entrySet()) { if (entry.getValue().equals(uniqueOsName)) { @@ -427,6 +450,16 @@ return 0; } + @Override + public Set<String> getUnsupportedCpus(int osId, Version version) { + return new HashSet<>(trimElements( + getValueByVersion( + idToUnameLookup.get(osId), + "cpu.unsupported", + version) + .toLowerCase().split(","))); + } + private boolean getBoolean(String value, boolean defaultValue) { return value == null ? defaultValue : Boolean.parseBoolean(value); } diff --git a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java index 8d16db7..47a2720 100644 --- a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java +++ b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java @@ -16,6 +16,7 @@ import org.junit.Test; import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.osinfo.MapBackedPreferences; +import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.compat.Version; public class OsRepositoryImplTest { @@ -59,6 +60,7 @@ preferences.node("/os/windows_8/id").put("value", "20"); preferences.node("/backwardCompatibility").put("Windows8", "20"); preferences.node("/os/windows_7/devices/hyperv/enabled").put("value", "true"); + preferences.node("/os/windows_8/cpu/unsupported").put("value", "conroe, opteron_g1"); OsRepositoryImpl.INSTANCE.init(preferences); } @@ -244,4 +246,25 @@ public void testHyperVWindows() throws Exception { assertTrue(OsRepositoryImpl.INSTANCE.isHypervEnabled(OsRepositoryImpl.INSTANCE.getOsIdByUniqueName("windows_7"), Version.v3_5)); } + + @Test + public void testUnsupportedCpus() { + assertFalse( + OsRepositoryImpl.INSTANCE.isCpuSupported( + OsRepositoryImpl.INSTANCE.getOsIdByUniqueName("windows_8"), + Version.getLast(), + "OpTeRon_g1")); + assertTrue( + OsRepositoryImpl.INSTANCE.isCpuSupported( + OsRepositoryImpl.INSTANCE.getOsIdByUniqueName("windows_8"), + Version.getLast(), + "OpTeRon_g2")); + assertFalse( + OsRepositoryImpl.INSTANCE.getUnsupportedCpus() + .get(new Pair<>(20, Version.getLast())).contains("Penrin".toLowerCase())); + assertTrue( + OsRepositoryImpl.INSTANCE.getUnsupportedCpus() + .get(new Pair<>(20, Version.getLast())).contains("Conroe".toLowerCase())); + } + } diff --git a/packaging/conf/osinfo-defaults.properties b/packaging/conf/osinfo-defaults.properties index a594e1d..7d11946 100644 --- a/packaging/conf/osinfo-defaults.properties +++ b/packaging/conf/osinfo-defaults.properties @@ -74,6 +74,10 @@ # IDE, Agent, ACPI) os.other.devices.maxPciDevices.value = 26 +# comma separated list of unsupported CPUs by this guest operating system +# corresponds to the value in vdc_config:ServerCPUList +os.other.cpu.unsupported.value = + # otherLinux(5, OsType.Linux, false), os.other_linux.id.value = 5 os.other_linux.name.value = Linux @@ -240,6 +244,7 @@ os.windows_8.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.w8 os.windows_8.productKey.value = os.windows_8.devices.display.protocols.value = vnc/cirrus +os.windows_8.cpu.unsupported.value = conroe, opteron_g1 # Windows8x64(21, OsType.Windows, true), os.windows_8x64.id.value = 21 @@ -250,6 +255,7 @@ os.windows_8x64.productKey.value = os.windows_8x64.devices.display.protocols.value = vnc/cirrus os.windows_8x64.resources.maximum.ram.value = 524288 +os.windows_8x64.cpu.unsupported.value = conroe, opteron_g1 # Windows2012x64(23, OsType.Windows, true); os.windows_2012x64.id.value = 23 @@ -259,6 +265,7 @@ os.windows_2012x64.productKey.value = os.windows_2012x64.devices.display.protocols.value = vnc/cirrus os.windows_2012x64.resources.maximum.ram.value = 4194304 +os.windows_2012x64.cpu.unsupported.value = conroe, opteron_g1 #Suse os.sles_11.id.value = 1193 -- To view, visit http://gerrit.ovirt.org/33229 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I339b87de7646b813aa634102c26f710b9d5f6f75 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Roy Golan <rgo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches