Processor: Fixed processor number option.
authorminkee.lee <minkee.lee@samsung.com>
Thu, 14 May 2015 13:39:27 +0000 (22:39 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Thu, 14 May 2015 13:42:56 +0000 (22:42 +0900)
- In CLI create, set processor number as max value.(under 4)

Change-Id: Ia02c78b1799d88c624c3bd6307ea7b98c6db57f6
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
src/org/tizen/emulator/manager/vms/CPU.java
src/org/tizen/emulator/manager/vms/Creator.java
src/org/tizen/emulator/manager/vms/Modifier.java
src/org/tizen/emulator/manager/vms/VMProperty.java

index e9090ed..d19cf39 100644 (file)
@@ -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<CPU> values() {
 
                return list;
index 798a9ea..19a19e6 100644 (file)
@@ -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());
index 1d442f4..7719356 100644 (file)
@@ -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) {
index 7eab7cd..7ddf071 100644 (file)
@@ -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