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 <[email protected]> --- 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, 83 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/32923/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..39a24f3 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,23 @@ * @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(); + + /** + * 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..0259c98 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 @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -413,6 +414,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 +451,15 @@ return 0; } + private HashSet<String> getUnsupportedCpus(int osId, Version version) { + return new HashSet<>(trimElements( + getValueByVersion( + idToUnameLookup.get(osId), + "devices.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..2177d67 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,8 @@ 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.osinfo.OsRepository; +import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.compat.Version; public class OsRepositoryImplTest { @@ -59,6 +61,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/devices/cpu/unsupported").put("value", "conroe, opteron_g1"); OsRepositoryImpl.INSTANCE.init(preferences); } @@ -244,4 +247,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 47d9dc2..cf94587 100644 --- a/packaging/conf/osinfo-defaults.properties +++ b/packaging/conf/osinfo-defaults.properties @@ -73,6 +73,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.devices.cpu.unsupported.value = + # otherLinux(5, OsType.Linux, false), os.other_linux.id.value = 5 os.other_linux.name.value = Linux @@ -239,6 +243,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.devices.cpu.unsupported.value = conroe, opteron_g1 # Windows8x64(21, OsType.Windows, true), os.windows_8x64.id.value = 21 @@ -249,6 +254,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.devices.cpu.unsupported.value = conroe, opteron_g1 # Windows2012x64(23, OsType.Windows, true); os.windows_2012x64.id.value = 23 @@ -258,6 +264,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.devices.cpu.unsupported.value = #Suse os.sles_11.id.value = 1193 -- To view, visit http://gerrit.ovirt.org/32923 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I339b87de7646b813aa634102c26f710b9d5f6f75 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Roy Golan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
