From: minkee.lee Date: Thu, 14 May 2015 13:39:27 +0000 (+0900) Subject: Processor: Fixed processor number option. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d57b52986971649adf7f30190945aa415dbda93;p=sdk%2Femulator%2Femulator-manager.git Processor: Fixed processor number option. - In CLI create, set processor number as max value.(under 4) Change-Id: Ia02c78b1799d88c624c3bd6307ea7b98c6db57f6 Signed-off-by: minkee.lee --- diff --git a/src/org/tizen/emulator/manager/vms/CPU.java b/src/org/tizen/emulator/manager/vms/CPU.java index e9090ed..d19cf39 100644 --- a/src/org/tizen/emulator/manager/vms/CPU.java +++ b/src/org/tizen/emulator/manager/vms/CPU.java @@ -60,6 +60,14 @@ public class CPU { } } + public static int getMaxCpuNum() { + if (list == null) { + return 1; + } + + return list.get(list.size()-1).getValue(); + } + public static ArrayList values() { return list; diff --git a/src/org/tizen/emulator/manager/vms/Creator.java b/src/org/tizen/emulator/manager/vms/Creator.java index 798a9ea..19a19e6 100644 --- a/src/org/tizen/emulator/manager/vms/Creator.java +++ b/src/org/tizen/emulator/manager/vms/Creator.java @@ -347,13 +347,15 @@ public class Creator { } ////// CPU ////// - if (newVM.cpu != 0) { - ec.getDevice().setCPU(factory.createCpuType()); - - ec.getDevice().getCPU().setValue(factory.createCpuTypeValue()); - ec.getDevice().getCPU().getValue().setUnit("cpu"); - ec.getDevice().getCPU().getValue().setValue(newVM.cpu); + ec.getDevice().setCPU(factory.createCpuType()); + ec.getDevice().getCPU().setValue(factory.createCpuTypeValue()); + ec.getDevice().getCPU().getValue().setUnit("cpu"); + if (newVM.cpu == 0) { + int max = CPU.getMaxCpuNum(); + newVM.cpu = max > 4 ? 4 : max; } + ec.getDevice().getCPU().getValue().setValue(newVM.cpu); + ec.getDevice().setRAM(factory.createRamType()); ec.getDevice().getRAM().setSize(factory.createRamTypeSize()); diff --git a/src/org/tizen/emulator/manager/vms/Modifier.java b/src/org/tizen/emulator/manager/vms/Modifier.java index 1d442f4..7719356 100644 --- a/src/org/tizen/emulator/manager/vms/Modifier.java +++ b/src/org/tizen/emulator/manager/vms/Modifier.java @@ -87,7 +87,7 @@ public class Modifier { } if (newVM.cpu != oldVM.cpu) { - property.getConfiguration().getDevice().getCPU().getValue().setValue(newVM.cpu); + property.setCPU(newVM.cpu, true); } if (newVM.ramSize != oldVM.ramSize) { diff --git a/src/org/tizen/emulator/manager/vms/VMProperty.java b/src/org/tizen/emulator/manager/vms/VMProperty.java index 7eab7cd..7ddf071 100644 --- a/src/org/tizen/emulator/manager/vms/VMProperty.java +++ b/src/org/tizen/emulator/manager/vms/VMProperty.java @@ -36,6 +36,7 @@ import org.tizen.emulator.manager.plugin.EMPlugin; import org.tizen.emulator.manager.plugin.ExtensionItem; import org.tizen.emulator.manager.plugin.PluginStringResources; import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration; +import org.tizen.emulator.manager.vms.xml.ObjectFactory; public class VMProperty { public static final int MAX_NAME_LEN = 20; @@ -230,6 +231,21 @@ public class VMProperty { this.isRunning = isRunning; } + public void setCPU(int cpu, boolean isCreateElement) { + if (configuration != null) { + if (isCreateElement && configuration.getDevice().getCPU() == null) { + ObjectFactory factory = EmulatorVMList.getInstance().getObjectFactory(); + configuration.getDevice().setCPU(factory.createCpuType()); + configuration.getDevice().getCPU().setValue(factory.createCpuTypeValue()); + configuration.getDevice().getCPU().getValue().setUnit("cpu"); + } + + if (configuration.getDevice().getCPU() != null) { + configuration.getDevice().getCPU().getValue().setValue(cpu); + } + } + } + public enum Architecture { x86("x86"), ARM("arm"); @@ -257,4 +273,5 @@ public class VMProperty { return type; } }; + } \ No newline at end of file