}
////// 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());
}
if (newVM.cpu != oldVM.cpu) {
- property.getConfiguration().getDevice().getCPU().getValue().setValue(newVM.cpu);
+ property.setCPU(newVM.cpu, true);
}
if (newVM.ramSize != oldVM.ramSize) {
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;
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");
return type;
}
};
+
}
\ No newline at end of file