Launcher: Applied new launcher as experimental feature.
authorminkee.lee <minkee.lee@samsung.com>
Thu, 2 Apr 2015 11:52:09 +0000 (20:52 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Wed, 6 May 2015 08:19:23 +0000 (17:19 +0900)
- Applied launch config file.
- Applied emulator log redirection.

Change-Id: Id0e7357684c53bdd77b1ec62e8288404ae265707
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
38 files changed:
common-project/src/org/tizen/emulator/manager/console/ConsoleProcessor.java
common-project/src/org/tizen/emulator/manager/platform/BaseImage.java
common-project/src/org/tizen/emulator/manager/platform/CustomBaseImage.java
common-project/src/org/tizen/emulator/manager/platform/CustomPlatform.java
common-project/src/org/tizen/emulator/manager/platform/Platform.java
common-project/src/org/tizen/emulator/manager/platform/PlatformList.java
common-project/src/org/tizen/emulator/manager/plugin/PluginStringResources.java
common-project/src/org/tizen/emulator/manager/resources/StringResources.java
common-project/src/org/tizen/emulator/manager/ui/detail/PInfoViewPage.java
common-project/src/org/tizen/emulator/manager/ui/detail/PModifyViewPage.java
common-project/src/org/tizen/emulator/manager/ui/detail/item/IItemListFactory.java
common-project/src/org/tizen/emulator/manager/ui/detail/item/ItemName.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/ui/widgets/CustomSpinner.java
common-project/src/org/tizen/emulator/manager/vms/Creator.java
common-project/src/org/tizen/emulator/manager/vms/Modifier.java
common-project/src/org/tizen/emulator/manager/vms/VMLauncher.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/VMProperty.java
common-project/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java
common-project/src/org/tizen/emulator/manager/vms/helper/CheckingRunningEmulator.java
common-project/src/org/tizen/emulator/manager/vms/helper/MonitoringEmulator.java
common-project/src/org/tizen/emulator/manager/vms/helper/VMLogUtil.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/BaseImageOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/CommonOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/DisplayOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/FileShareOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/HWSupportOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/IOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/IOptionFactory.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/LaunchConfig.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/NetProxyOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/NetworkOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/Option.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/ProcessorOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/RamSizeOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/RemoteOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/SuspendSupportOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/TouchPointOption.java [new file with mode: 0644]
common-project/src/org/tizen/emulator/manager/vms/option/VMNameOption.java [new file with mode: 0644]

index 0f77164..a352fdc 100644 (file)
@@ -35,6 +35,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
 
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.platform.BaseImage;
 import org.tizen.emulator.manager.platform.Platform;
@@ -48,6 +50,7 @@ import org.tizen.emulator.manager.vms.VMProperty;
 import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
 import org.tizen.emulator.manager.vms.helper.HelperClass;
 import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+import org.tizen.emulator.manager.vms.option.LaunchConfig;
 
 public class ConsoleProcessor {
        private EmulatorVMList vms = EmulatorVMList.getInstance();
@@ -210,43 +213,65 @@ public class ConsoleProcessor {
                        }
                }
 
-               List<String> cmd;
-               try {
-                       ILauncher launcher = prop.getWorker().getLauncher();
-                       if (launcher == null) {
-                               throw new VMWorkerException("Fail to get launcher");
-                       }
-                       cmd = launcher.getLaunchCommand(prop, path);
+               if (EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE) {
+                       if (!isTest) {
+                               try {
+                                       System.out.println("Arguments from vm_launch.conf...");
+                                       System.out.println();
+                                       for (String str : LaunchConfig.readLaunchConfig(prop.getName())) {
+                                               System.out.println(str);
+                                       }
+                                       System.out.println();
 
-               } catch (VMWorkerException e) {
-                       EMLogger.getLogger().log(Level.WARNING, "Failed to launch :" + e.getMessage());
-                       System.out.println("Error: " + "Failed to launch: " + e.getMessage());
-                       return false;
-               }
+                                       prop.getWorker().launchVM(true, path);
+                               } catch (VMWorkerException e) {
+                                       System.out.println("Error: Can not execute this VM."
+                                                       + StringResources.NEW_LINE
+                                                       + e.getMessage());
+                                       return false;
+                               }
 
-               if (isTest || EMLogger.getLogger().getLevel() == Level.WARNING) {
-                       System.out.println("Arguments of emulator : ");
-                       String temp = cmd.get(0) + " ";
-                       for (String s : cmd.subList(1, cmd.size())) {
-                               temp += ("\"" + s + "\" ");
+                               System.out.println("Success: To start emulator is completed.");
                        }
-                       System.out.println(temp);
-                       System.out.println();
-               }
 
-               if (!isTest) {
+               } else {
+                       List<String> cmd;
                        try {
-                               prop.getWorker().launchVM(true);
+                               ILauncher launcher = prop.getWorker().getLauncher();
+                               if (launcher == null) {
+                                       throw new VMWorkerException("Fail to get launcher");
+                               }
+                               cmd = launcher.getLaunchCommand(prop, path);
+
                        } catch (VMWorkerException e) {
-                               System.out.println("Error: Can not execute this VM."
-                                               + StringResources.NEW_LINE
-                                               + e.getMessage());
+                               EMLogger.getLogger().log(Level.WARNING, "Failed to launch :" + e.getMessage());
+                               System.out.println("Error: " + "Failed to launch: " + e.getMessage());
                                return false;
                        }
 
-                       System.out.println("Success: To start emulator is completed.");
-               }
+                       if (isTest || EMLogger.getLogger().getLevel() == Level.WARNING) {
+                               System.out.println("Arguments of emulator : ");
+                               String temp = cmd.get(0) + " ";
+                               for (String s : cmd.subList(1, cmd.size())) {
+                                       temp += ("\"" + s + "\" ");
+                               }
+                               System.out.println(temp);
+                               System.out.println();
+                       }
 
+                       if (!isTest) {
+                               try {
+                                       prop.getWorker().launchVM(true, null);
+                               } catch (VMWorkerException e) {
+                                       System.out.println("Error: Can not execute this VM."
+                                                       + StringResources.NEW_LINE
+                                                       + e.getMessage());
+                                       return false;
+                               }
+
+                               System.out.println("Success: To start emulator is completed.");
+                       }
+               }
                return true;
        }
 
index b276dba..169b72b 100644 (file)
@@ -33,6 +33,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 import java.util.logging.Level;
 
@@ -47,6 +48,8 @@ import org.tizen.emulator.manager.resources.FilePathResources;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.vms.EmulatorVMList;
 import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.option.IOption;
+import org.tizen.emulator.manager.vms.option.LaunchConfig;
 import org.tizen.emulator.manager.vms.xml.template.ItemList;
 
 public class BaseImage {
@@ -67,7 +70,10 @@ public class BaseImage {
        protected String lastCreatedPropertyPath;
 
        protected VMProperty defaultProperty;
-       private ItemList itemList;
+       protected ItemList itemList;
+
+       protected List<IOption> optionList;
+       private LaunchConfig launchTemplate; // TODO replace xDefaultOption.java
 
        public static JAXBContext templateContext = null;
 
@@ -90,6 +96,14 @@ public class BaseImage {
                loadTemplate();
        }
 
+       public List<IOption> getOptionList() {
+               return optionList;
+       }
+
+       public void setOptionList(List<IOption> optionList) {
+               this.optionList = optionList;
+       }
+
        public VMProperty getDefaultProperty() {
                return defaultProperty;
        }
index 8b3ccb8..829dfa5 100644 (file)
@@ -31,13 +31,26 @@ package org.tizen.emulator.manager.platform;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 import org.tizen.emulator.manager.resources.FilePathResources;
 import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.ui.detail.item.OptionType;
 import org.tizen.emulator.manager.vms.EmulatorVMList;
+import org.tizen.emulator.manager.vms.xml.template.DeviceList;
+import org.tizen.emulator.manager.vms.xml.template.Item;
+import org.tizen.emulator.manager.vms.xml.template.ItemList;
+import org.tizen.emulator.manager.vms.xml.template.ObjectFactory;
+import org.tizen.emulator.manager.vms.xml.template.Option;
+import org.tizen.emulator.manager.vms.xml.template.PropertyList;
 
 public class CustomBaseImage extends BaseImage {
 
+       public static ObjectFactory factory = new ObjectFactory();
+
        public CustomBaseImage(Platform platform, String name, String cpu, String profile) throws IOException {
                this.platform = platform;
 
@@ -49,6 +62,7 @@ public class CustomBaseImage extends BaseImage {
                this.binaryVersion = "";
                initLastCreatedPropertyPath();
                loadProperty();
+               createTemplate();
        }
 
        protected void initLastCreatedPropertyPath() {
@@ -60,6 +74,25 @@ public class CustomBaseImage extends BaseImage {
                lastCreatedPropertyPath = sb.toString();
        }
 
+       // Create template from standard platform's template.
+       private void createTemplate() {
+               if (PlatformList.getPlatformList() != null) {
+                       for (Platform p : PlatformList.getPlatformList()) {
+                               if (p.getProfile().equals(profile)) {
+                                       List<ItemList> templateList = new ArrayList<ItemList>();
+                                       for(BaseImage i : p.getImageList()) {
+                                               if (i.getItemList() != null) {
+                                                       templateList.add(i.getItemList());
+                                               }
+                                       }
+                                       itemList = createCustomTemplate(templateList);
+                               }
+                       }
+               }
+       }
+
+
+
        private void loadProperty() {
                // load default
                File propertyFile = new File(platform.platformPath + File.separator
@@ -102,4 +135,207 @@ public class CustomBaseImage extends BaseImage {
                        }
                }
        }
+
+       private ItemList createCustomTemplate(List<ItemList> templateList) {
+
+               if (templateList.size() == 0) {
+                       return null;
+
+               } else if (templateList.size() == 1) {
+                       ItemList template = cloneTemplate(templateList.get(0));
+                       template.setImage(null);
+                       return template;
+
+               } else { // Make union set
+                       ItemList base = cloneTemplate(templateList.get(0));
+                       for (int i=1 ; i < templateList.size() ; i++) {
+                               addToBase(base,templateList.get(i));
+                       }
+                       return base;
+               }
+       }
+
+       private void addToBase(ItemList base, ItemList newOne) {
+               // Property list add
+               PropertyList newPropertyList = newOne.getPropertyList();
+               PropertyList basePropertyList = base.getPropertyList();
+               if (newPropertyList != null) {
+                       if (basePropertyList == null) {
+                               basePropertyList = factory.createPropertyList();
+                               base.setPropertyList(basePropertyList);
+                       }
+                       for (Item newItem : newPropertyList.getItem()) {
+                               boolean itemExistInBase = false;
+                               for (Item baseItem : basePropertyList.getItem()) {
+                                       if (baseItem.getName().equals(newItem.getName())) {
+                                               itemExistInBase = true;
+                                               joinItem(baseItem, newItem);
+                                       }
+                               }
+                               if (!itemExistInBase) {
+                                       basePropertyList.getItem().add(cloneItem(newItem));
+                               }
+                       }
+               }
+
+               // Device list add
+               DeviceList newDeviceList = newOne.getDeviceList();
+               DeviceList baseDeviceList = base.getDeviceList();
+               if (newDeviceList != null) {
+                       if (baseDeviceList == null) {
+                               baseDeviceList = factory.createDeviceList();
+                               base.setDeviceList(baseDeviceList);
+                       }
+                       for (Item newItem : newDeviceList.getItem()) {
+                               boolean itemExistInBase = false;
+                               for (Item baseItem : baseDeviceList.getItem()) {
+                                       if (baseItem.getName().equals(newItem.getName())) {
+                                               itemExistInBase = true;
+                                               joinItem(baseItem, newItem);
+                                       }
+                               }
+                               if (!itemExistInBase) {
+                                       baseDeviceList.getItem().add(cloneItem(newItem));
+                               }
+                       }
+               }
+       }
+
+
+       private void joinItem(Item baseItem, Item newItem) {
+               // join sub items
+               for (Item newSub : newItem.getItem()) {
+                       boolean itemExistInBase = false;
+                       for (Item baseSub : baseItem.getItem()) {
+                               if (baseSub.getName().equals(newSub.getName())) {
+                                       itemExistInBase = true;
+                                       joinItem(baseSub, newSub);
+                               }
+                       }
+                       if (!itemExistInBase) {
+                               baseItem.getItem().add(cloneItem(newSub));
+                       }
+               }
+               // join options
+               for (Option newOption : newItem.getOption()) {
+                       boolean optionExistInBase = false;
+                       for (Option baseOption : baseItem.getOption()) {
+                               if (baseOption.getName().equals(newOption.getName())) {
+                                       optionExistInBase = true;
+                                       if (isListOption(baseOption, newOption)) {
+                                               joinOption(baseOption, newOption);
+                                       }
+                               }
+                       }
+
+                       if (!optionExistInBase) {
+                               baseItem.getOption().add(cloneOption(newOption));
+                       }
+               }
+
+       }
+
+       private void joinOption(Option baseOption, Option newOption) {
+               baseOption.setValue(joinCommaString(baseOption.getValue(), newOption.getValue()));
+       }
+
+
+       private String joinCommaString(String base, String newOne) {
+               List<String> optionList = new ArrayList<String>();
+               if (base != null) {
+                       String[] split = base.split(",");
+                       for (String str : split) {
+                               optionList.add(str.trim());
+                       }
+               }
+               if (newOne != null) {
+                       String[] split = newOne.split(",");
+                       for (String str : split) {
+                               optionList.add(str.trim());
+                       }
+               }
+
+               if (optionList.size() > 0) {
+                       Set<String> optionSet = new HashSet<String>();
+                       optionSet.addAll(optionList);
+                       optionList.clear();
+                       optionList.addAll(optionSet);
+//                     Collections.sort(optionList);
+                       StringBuilder sb = new StringBuilder();
+
+                       for (int i=0 ; i<optionList.size() ; i++) {
+                               sb.append(optionList.get(i));
+                               if (i < optionList.size()-1) {
+                                       sb.append(",");
+                               }
+                       }
+
+                       return sb.toString();
+               }
+
+               return null;
+       }
+
+       private ItemList cloneTemplate(ItemList template) {
+               ItemList newTemplate = factory.createItemList();
+               newTemplate.setProfile(template.getProfile());
+               newTemplate.setImage(template.getImage());
+
+               // clone property list
+               PropertyList propertyList = template.getPropertyList();
+               if (propertyList != null) {
+                       PropertyList newPropertyList = factory.createPropertyList();
+                       newTemplate.setPropertyList(newPropertyList);
+
+                       for (Item item : propertyList.getItem()) {
+                               newPropertyList.getItem().add(cloneItem(item));
+                       }
+               }
+
+               // clone device list.
+               DeviceList deviceList = template.getDeviceList();
+               if (deviceList != null) {
+                       DeviceList newDeviceList = factory.createDeviceList();
+                       newTemplate.setDeviceList(newDeviceList);
+
+                       for (Item item : deviceList.getItem()) {
+                               newDeviceList.getItem().add(cloneItem(item));
+                       }
+               }
+
+               return newTemplate;
+       }
+
+       private Item cloneItem(Item item) {
+               Item newItem = factory.createItem();
+               newItem.setType(item.getType());
+               newItem.setName(item.getName());
+               newItem.setTitle(item.getTitle());
+
+               for (Option option : item.getOption()) {
+                       newItem.getOption().add(cloneOption(option));
+               }
+
+               for (Item subItem : item.getItem()) {
+                       newItem.getItem().add(cloneItem(subItem));
+               }
+
+               return newItem;
+       }
+
+       private Option cloneOption(Option option) {
+               Option newOption = factory.createOption();
+               newOption.setName(option.getName());
+               newOption.setValue(option.getValue());
+               return newOption;
+       }
+
+       private boolean isListOption(Option baseOption, Option newOption) {
+               if (baseOption.getName().equals(OptionType.COMBO_LIST.getName())
+                               && newOption.getName().equals(OptionType.COMBO_LIST.getName())) {
+                       return true;
+               }
+
+               return false;
+       }
 }
index 3a004b7..6fa0f70 100644 (file)
@@ -57,6 +57,7 @@ public class CustomPlatform extends Platform {
                }
        }
 
+
        private void loadSkins() {
                Platform latest = null;
 
index f8fdf18..46fa3c5 100644 (file)
@@ -37,12 +37,15 @@ import java.util.ArrayList;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.plugin.EMPlugin;
 import org.tizen.emulator.manager.plugin.EMPluginLoader;
+import org.tizen.emulator.manager.plugin.ExtensionItem;
+import org.tizen.emulator.manager.plugin.PluginStringResources;
 import org.tizen.emulator.manager.resources.FilePathResources;
 import org.tizen.emulator.manager.resources.StringResources;
 import org.tizen.emulator.manager.tool.SettingInfoFile;
 import org.tizen.emulator.manager.vms.EmulatorVMList;
 import org.tizen.emulator.manager.vms.RESOLUTION;
 import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.option.IOptionFactory;
 
 public class Platform {
        // platform name = profile + version = profile-version
@@ -91,6 +94,19 @@ public class Platform {
                return "";
        }
 
+       // Load option list for each image.
+       public void loadOptionList() {
+               if (plugin != null) {
+                       ExtensionItem exItem = getPlugin().getExtensionItem(PluginStringResources.OptionFactory);
+                       IOptionFactory f = (IOptionFactory)(exItem.createClass());
+                       if (f != null) {
+                               for (BaseImage img : imageList) {
+                                       img.setOptionList(f.makeOptionList(img.getItemList()));
+                               }
+                       }
+               }
+       }
+
        private void loadProperties() {
                if (platformPath == null) {
                        return;
index 5b15143..5fe3171 100644 (file)
@@ -41,6 +41,7 @@ import org.tizen.emulator.manager.vms.EmulatorVMList;
 import org.tizen.emulator.manager.vms.VMProperty;
 import org.tizen.emulator.manager.vms.VMProperty.FSImageType;
 import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+import org.tizen.emulator.manager.vms.option.IOption;
 
 public class PlatformList {
        private static ArrayList<Platform> platformList = null;
@@ -65,12 +66,14 @@ public class PlatformList {
        private static void makeCustomPlatformList() {
                int profileCount = profileList.size();
                if (profileCount == 0) {
-                       customList.add(new CustomPlatform("custom", PlatformStringResources.MobileProfile));
+                       customList.add(new CustomPlatform("custom",
+                                       PlatformStringResources.MobileProfile));
                } else if (profileCount == 1) {
                        customList.add(new CustomPlatform("custom", profileList.get(0)));
-               } else if (profileCount >= 2){
+               } else if (profileCount >= 2) {
                        for (String profile : profileList) {
-                               customList.add(new CustomPlatform(profile+ "-custom", profile));
+                               customList
+                                               .add(new CustomPlatform(profile + "-custom", profile));
                        }
                }
        }
@@ -124,7 +127,6 @@ public class PlatformList {
                                                                        //addProfile(p.getProfile());
                                                                }
                                                        }
-
                                                }
                                        }
                                }
@@ -144,6 +146,18 @@ public class PlatformList {
 
                // Remove invalid last-created property file.
                checkLastCreatedPropertyFile();
+
+               // Load option list
+               loadOptionList();
+       }
+
+       private static void loadOptionList() {
+               for (Platform p : platformList) {
+                       p.loadOptionList();
+               }
+               for (Platform cp : customList) {
+                       cp.loadOptionList();
+               }
        }
 
        private static void addProfile(String profile) {
@@ -168,7 +182,7 @@ public class PlatformList {
                EmulatorVMList vms = EmulatorVMList.getInstance();
                vms.refreshProperties();
 
-               for(Platform p : getPlatformList()) {
+               for (Platform p : getPlatformList()) {
                        p.clearVMs();
                }
 
@@ -176,7 +190,7 @@ public class PlatformList {
                        p.clearVMs();
                }
 
-               for (VMProperty prop : (VMProperty[])vms.getProperties()) {
+               for (VMProperty prop : (VMProperty[]) vms.getProperties()) {
                        if (prop.getImageType() == FSImageType.custom) {
                                for (CustomPlatform p : getCustomPlatform()) {
                                        if (prop.getPropertyValue().profile.equals(p.getProfile())) {
@@ -186,8 +200,9 @@ public class PlatformList {
                        } else {
                                for (Platform p : getPlatformList()) {
                                        if (prop.getImageVersion().equals(p.getVersion())) {
-                                               if (p.isOldVersion() ||
-                                                               prop.getImageProfile().equals(p.getProfile())) {
+                                               if (p.isOldVersion()
+                                                               || prop.getImageProfile()
+                                                                               .equals(p.getProfile())) {
                                                        for (BaseImage b : p.getImageList()) {
                                                                if (prop.getBaseImageName().equals(b.getName())) {
                                                                        prop.getPropertyValue().baseImage = b;
@@ -209,21 +224,29 @@ public class PlatformList {
        private static void checkingBaseImageBinaryVersion() {
                settingVMPropertyList();
 
-               for (VMProperty prop : (VMProperty[])EmulatorVMList.getInstance().getProperties()) {
+               for (VMProperty prop : (VMProperty[]) EmulatorVMList.getInstance()
+                               .getProperties()) {
                        if (prop.getImageType() == FSImageType.standard) {
                                for (Platform p : getPlatformList()) {
                                        if (!p.isOldVersion()
-                                               && prop.getImageVersion().equals(p.getVersion())
-                                               && prop.getImageProfile().equals(p.getProfile())) {
+                                                       && prop.getImageVersion().equals(p.getVersion())
+                                                       && prop.getImageProfile().equals(p.getProfile())) {
                                                for (BaseImage b : p.getImageList()) {
                                                        if (prop.getBaseImageName().equals(b.getName())) {
-                                                               String binaryVersion = prop.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getVersion();
-                                                               String path = prop.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue();
-                                                               if (b.getPath().equals(path) && (binaryVersion == null || !binaryVersion.equals(b.binaryVersion))) {
+                                                               String binaryVersion = prop.getConfiguration()
+                                                                               .getBaseInformation().getDiskImage()
+                                                                               .getBaseDiskImage().getVersion();
+                                                               String path = prop.getConfiguration()
+                                                                               .getBaseInformation().getDiskImage()
+                                                                               .getBaseDiskImage().getValue();
+                                                               if (b.getPath().equals(path)
+                                                                               && (binaryVersion == null || !binaryVersion
+                                                                                               .equals(b.binaryVersion))) {
                                                                        try {
                                                                                prop.getWorker().deleteVM();
                                                                        } catch (VMWorkerException e) {
-                                                                               EMLogger.getLogger().warning(e.getMessage());
+                                                                               EMLogger.getLogger().warning(
+                                                                                               e.getMessage());
                                                                        }
                                                                }
                                                                break;
@@ -261,8 +284,9 @@ public class PlatformList {
                                } else {
                                        arr =  path.split(File.separator);
                                }
-                               String fileName = arr[arr.length-1];
-                               if (fileName.startsWith(StringResources.LAST_CREATED_XML_PREFIX)) {
+                               String fileName = arr[arr.length - 1];
+                               if (fileName
+                                               .startsWith(StringResources.LAST_CREATED_XML_PREFIX)) {
                                        boolean isOld = true;
                                        for (String currentPath : currentPathList) {
                                                if (path.equals(currentPath)) {
@@ -276,4 +300,32 @@ public class PlatformList {
                        }
                }
        }
+
+       public static List<IOption> getOptionList(VMProperty property) {
+               List<IOption> optionList = null;
+               String profile = property.getPropertyValue().profile;
+               boolean isStandard = property.getPropertyValue().isStandard;
+
+               if (isStandard) {
+                       String image = property.getPropertyValue().baseName;
+                       for (Platform p : platformList) {
+                               if (p.profile.equals(profile)) {
+                                       for (BaseImage img : p.getImageList()) {
+                                               if (img.imageName.equals(image)) {
+                                                       optionList = img.getOptionList();
+                                               }
+                                       }
+                               }
+                       }
+
+               } else { // custom
+                       for (CustomPlatform p : customList) {
+                               if (p.profile.equals(profile)) {
+                                       optionList = p.getImageList().get(0).getOptionList();
+                               }
+                       }
+               }
+
+               return optionList;
+       }
 }
index 075d20e..04d713b 100644 (file)
@@ -39,6 +39,7 @@ public class PluginStringResources {
        public final static String VMButtonPainter = "VMButton-Painter";
        // org.tizen.emulator.manager.vms.VMWorkerCommon
        public final static String VMWorker = "VM-Worker";
+       public final static String OptionFactory = "Option-Factory";
 
        public final static String PlatformVersion = "Platform-Version";
        public final static String PlatformProfile = "Platform-Profile";
@@ -48,6 +49,7 @@ public class PluginStringResources {
                pointList.add(ItemFactory);
                pointList.add(VMButtonPainter);
                pointList.add(VMWorker);
+               pointList.add(OptionFactory);
        }
 
        public static ArrayList<String> getPointList() {
index 8f6a3e9..1f354a9 100644 (file)
@@ -110,7 +110,10 @@ public class StringResources {
        public static final String SWAP_IMAGE = "swap.img";
 
        public static final String PROPERTY_XML_NAME = "vm_config.xml";
+       public static final String LAUNCH_CONF_NAME = "vm_launch.conf";
        public static final String LAST_CREATED_XML_PREFIX = "last-created";
 
        public static final String NEW_LINE = System.getProperty("line.separator");
+
+       public static final String EMULATOR_LOG = "emulator.log";
 }
index 8234e00..d2c7b20 100644 (file)
@@ -203,13 +203,13 @@ public class PInfoViewPage extends DetailViewPage {
                                                                        template, platform.getProfile(), image.getName(), false));
                                                }
                                        }
+
                                        // add itemlist for custom.
-                                       if (templateList.size() > 0) {
-                                               infoItemList.add(new InfoViewItemList(item, this.getItemListComposite(),
-                                                               templateList, platform.getProfile()));
-                                       } else {
-//                                             infoItemList.add(new InfoViewItemList(item, this.getItemListComposite(),
-//                                                             null, platform.getProfile(), null, true));
+                                       for (Platform custom : PlatformList.getCustomPlatform()) {
+                                               if (custom.getProfile().equals(platform.getProfile())) {
+                                                       infoItemList.add(new InfoViewItemList(item, this.getItemListComposite(),
+                                                                       custom.getImageList().get(0).getItemList(), custom.getProfile(), null, true));
+                                               }
                                        }
                                }
                        }
@@ -333,7 +333,7 @@ class InfoViewItemList extends ViewItemList{
        InfoViewItemList(ExtensionItem item, Composite parent, ItemList template,
                        String profile, String imageName, boolean isCustom) {
                super(item, profile, imageName, isCustom);
-               makeItemList(parent, template);
+               makeItemList(parent, template, isCustom);
                initItemList(parent);
        }
 
@@ -344,10 +344,10 @@ class InfoViewItemList extends ViewItemList{
        }
 
 
-       private void makeItemList(Composite parent, ItemList templateList) {
+       private void makeItemList(Composite parent, ItemList templateList, boolean isCustom) {
                IItemListFactory f = (IItemListFactory)(exItem.createClass());
                itemList = new ArrayList<IInfoViewItem>();
-               f.makeItemList(itemList, templateList);
+               f.makeItemList(itemList, templateList, isCustom);
 //             itemList = f.getInfoItemList(deviceItemList);
        }
 
index 101036c..4db981c 100644 (file)
@@ -181,12 +181,13 @@ public class PModifyViewPage extends DetailViewPage
                                                                        template, platform.getProfile(), image.getName(), false));
                                                }
                                        }
+
                                        // add itemlist for custom.
-                                       if (templateList.size() > 0) {
-                                               modifyItemList.add(new ModifyViewItemList(item, this,
-                                                               templateList, platform.getProfile()));
-                                       } else {
-//                                             modifyItemList.add(new ModifyViewItemList(item, this, null, platform.getProfile(), null, true));
+                                       for (Platform custom : PlatformList.getCustomPlatform()) {
+                                               if (custom.getProfile().equals(platform.getProfile())) {
+                                                       modifyItemList.add(new ModifyViewItemList(item, this,
+                                                                       custom.getImageList().get(0).getItemList(), custom.getProfile(), null, true));
+                                               }
                                        }
                                }
                        }
@@ -437,7 +438,7 @@ class ModifyViewItemList extends ViewItemList{
        ModifyViewItemList(ExtensionItem item, PModifyViewPage page, ItemList template
                        ,String profile, String imageName, boolean isCustom) {
                super(item, profile, imageName, isCustom);
-               makeItemList(page, template);
+               makeItemList(page, template, isCustom);
                initItemList(page);
        }
 
@@ -447,11 +448,11 @@ class ModifyViewItemList extends ViewItemList{
                initItemList(page);
        }
 
-       private void makeItemList(PModifyViewPage page, ItemList deviceItemList) {
+       private void makeItemList(PModifyViewPage page, ItemList deviceItemList, boolean isCustom) {
                IItemListFactory f = (IItemListFactory)(exItem.createClass());
                itemList = new ArrayList<IModifyViewItem>();
 //             itemList = f.getModifyItemList(deviceItemList);
-               f.makeItemList(itemList, deviceItemList);
+               f.makeItemList(itemList, deviceItemList, isCustom);
        }
 
        private void makeCustomItemList(PModifyViewPage page, List<ItemList> list) {
index 8a8b0d2..d2550a2 100644 (file)
@@ -35,6 +35,6 @@ import org.tizen.emulator.manager.vms.xml.template.ItemList;
 
 public interface IItemListFactory {
 
-       public void makeItemList(List<? extends IViewItem> itemList, ItemList template);
+       public void makeItemList(List<? extends IViewItem> itemList, ItemList template, boolean isCustom);
        public void makeCustomItemList(List<? extends IViewItem> itemList, List<ItemList> templateList);
 }
diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/item/ItemName.java b/common-project/src/org/tizen/emulator/manager/ui/detail/item/ItemName.java
new file mode 100644 (file)
index 0000000..6f7ccea
--- /dev/null
@@ -0,0 +1,58 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.ui.detail.item;
+
+public class ItemName {
+       public static final String VM_NAME = "vmName";
+       public static final String BASE_IMAGE = "baseImage";
+       public static final String DISPLAY = "display";
+       public static final String RAM_SIZE = "ramSize";
+       public static final String MAX_TOUCH = "maxTouch";
+       public static final String SUSPEND_SUPPORT = "suspendSupport";
+       public static final String FILE_SHARE = "fileShare";
+       public static final String HW_SUPPORT = "hwSupport";
+       public static final String PROCESSORS = "processors";
+
+       public static final String SENSOR = "sensor";
+       public static final String DEVICE = "device";
+       public static final String JACK = "jack";
+
+       public static final String NET_CONFIG = "netConfig";
+       public static final String NET_PROXY = "proxy";
+       public static final String NET_CONNECT_TYPE = "netConnectType";
+       public static final String NET_TAP_DEVICE = "netTapDevice";
+       public static final String NET_IP_INFO = "netIpInfo";
+       public static final String NET_DNS = "netDns";
+       public static final String NET_MAC = "netMac";
+
+       public static final String NET_USE_DHCP = "useDHCP";
+       public static final String NET_IP = "ipAddr";
+       public static final String NET_SUBNET = "subnet";
+       public static final String NET_GATEWAY = "gateway";
+}
index b5ebe90..2ac0124 100644 (file)
@@ -175,7 +175,7 @@ public class CustomSpinner extends Composite {
                        selection = min;
                }
                text.setText(String.valueOf(selection));
-               text.selectAll();
+//             text.selectAll();
        }
 
        public int getSelection() {
index b12b3bf..7a7b021 100644 (file)
@@ -43,6 +43,7 @@ import org.tizen.emulator.manager.vms.helper.QemuImgProc;
 import org.tizen.emulator.manager.vms.helper.VMCreatorException;
 import org.tizen.emulator.manager.vms.helper.VMWorkerException;
 import org.tizen.emulator.manager.vms.helper.WorkerLock;
+import org.tizen.emulator.manager.vms.option.LaunchConfig;
 import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
 import org.tizen.emulator.manager.vms.xml.ObjectFactory;
 
@@ -95,6 +96,7 @@ public class Creator {
 
                        settingProperty();
 
+                       LaunchConfig.createLaunchConfig(property);
                        EmulatorVMList.getInstance().storeXML(property);
 
                        // Save last created property file.
@@ -116,6 +118,7 @@ public class Creator {
 
                        EMLogger.getLogger().info("Success to create the " + property.getName() + " VM");
                } catch (VMWorkerException e) {
+                       deleteFolder(folder);
                        throw e;
                } finally {
                        // lock.release
@@ -124,7 +127,7 @@ public class Creator {
 
                return property;
        }
-       
+
        private void deleteFolder(File folder) {
                if (folder.exists()) {
                        for (File dir : folder.listFiles()) {
index 9a9d31b..1d442f4 100644 (file)
@@ -31,6 +31,7 @@
 package org.tizen.emulator.manager.vms;
 
 import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+import org.tizen.emulator.manager.vms.option.LaunchConfig;
 import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
 import org.tizen.emulator.manager.vms.xml.TouchType;
 
@@ -171,6 +172,8 @@ public class Modifier {
                        property.getConfiguration().getAdvancedOption().getOption().addAll(newVM.advancedOptionList);
                }
 
+               property.setPropertyValue(newVM);
+               LaunchConfig.createLaunchConfig(property);
                EmulatorVMList.getInstance().storeXML(property);
        }
 
diff --git a/common-project/src/org/tizen/emulator/manager/vms/VMLauncher.java b/common-project/src/org/tizen/emulator/manager/vms/VMLauncher.java
new file mode 100644 (file)
index 0000000..956c8da
--- /dev/null
@@ -0,0 +1,221 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.tool.PortHelper;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator;
+import org.tizen.emulator.manager.vms.helper.MonitoringEmulator;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+import org.tizen.emulator.manager.vms.helper.VMLogUtil;
+import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+import org.tizen.emulator.manager.vms.option.LaunchConfig;
+
+public class VMLauncher {
+
+       public static boolean Launch(VMProperty property, boolean wait, String path)
+                       throws VMLauncherException {
+
+               checkPortNumber();
+               checkDiskImage(property);
+
+               List<String> cmd = getCommand(property);
+
+               for (String str : LaunchConfig.readLaunchConfig(property.getName())) {
+                       System.out.println(str);
+               }
+
+               CheckingRunningEmulator.addEmulator(property);
+               MonitoringEmulator monitor = new MonitoringEmulator(property);
+               Process process = launch(property.getName(), cmd, path);
+               if (process != null) {
+                       monitor.setProcess(process);
+                       monitor.start();
+                       if (wait) {
+                               try {
+                                       monitor.join();
+                               } catch (InterruptedException e) {
+                                       EMLogger.getLogger().warning(e.getMessage());
+                               }
+                               if (monitor.isSuccess()) {
+                                       return true;
+                               } else {
+                                       return false;
+                               }
+                       }
+                       return true;
+               } else {
+                       CheckingRunningEmulator.removeEmulator(property, false);
+                       monitor.interrupt();
+                       return false;
+               }
+       }
+
+       private static void checkPortNumber() throws VMLauncherException {
+               /* check available port number */
+               if (new PortHelper().getPortNo() == -1) {
+                       String error = "Can not execute emulator."
+                                       + StringResources.NEW_LINE
+                                       + "All available ports are in use.";
+                       throw new VMLauncherException(error);
+               }
+       }
+
+       private static List<String> getCommand(VMProperty property)
+                       throws VMLauncherException {
+               String binaryPath = FilePathResources.getBinPath() + File.separator
+                               + getBinary(property.getArch().toString());
+               String configPath = LaunchConfig
+                               .getLaunchConfigPath(property.getName());
+               if (!new File(configPath).exists()) {
+                       try {
+                               LaunchConfig.createLaunchConfig(property);
+                       } catch (VMWorkerException e) {
+                               EMLogger.getLogger().warning(e.getMessage());
+                               throw new VMLauncherException("Failed to launch config file");
+                       }
+               }
+
+               List<String> cmd = new ArrayList<String>();
+               if (EmulatorManager.isWin()) {
+                       cmd.add("cmd");
+                       cmd.add("/c");
+               } else {
+                       cmd.add("/bin/sh");
+                       cmd.add("-c");
+               }
+               cmd.add(binaryPath + " -c " + configPath + " > "
+                               + VMLogUtil.getEmulatorLogPath(property.getName()) + " 2>&1");
+
+               return cmd;
+
+       }
+
+       private static void checkDiskImage(VMProperty property)
+                       throws VMLauncherException {
+               // check disk image
+               File child = new File(property.getConfiguration().getBaseInformation()
+                               .getDiskImage().getCurrentDiskImage().getValue());
+               File base = new File(property.getConfiguration().getBaseInformation()
+                               .getDiskImage().getBaseDiskImage().getValue());
+               if (!child.exists()) {
+                       throw new VMLauncherException("Child disk image does not exist."
+                                       + StringResources.NEW_LINE + child.getAbsolutePath(), true);
+               }
+               if (!base.exists()) {
+                       throw new VMLauncherException("Base disk image does not exist."
+                                       + StringResources.NEW_LINE + base.getAbsolutePath(), true);
+               }
+       }
+
+       private static String getBinary(String arch) {
+               String binary;
+               if (arch.equals("x86")) {
+                       if (EmulatorManager.isWin()) {
+                               binary = "emulator-x86.exe";
+                       } else {
+                               binary = "emulator-x86";
+                       }
+               } else {
+                       if (EmulatorManager.isWin()) {
+                               binary = "emulator-arm.exe";
+                       } else {
+                               binary = "emulator-arm";
+                       }
+               }
+               return binary;
+       }
+
+       public static Process launch(String vmName, List<String> cmd, String binPath) {
+               ProcessBuilder pb = new ProcessBuilder(cmd);
+
+               // Make backup log.
+               // LogUtil.makeVMBackupLog(vmName);
+
+               EMLogger.getLogger().info(pb.command().toString());
+               if (EmulatorManager.isLinux()) {
+                       Map<String, String> env = pb.environment();
+                       String value = env.get("LD_LIBRARY_PATH");
+                       env.put("LD_LIBRARY_PATH",
+                                       ((value == null) ? "" : value + ":")
+                                                       + FilePathResources.getBinPath() + ":"
+                                                       + FilePathResources.getRemotePath()
+                                                       + File.separator + "lib:");
+                       EMLogger.getLogger().log(Level.INFO,
+                                       "LD_LIBRARY_PATH=" + env.get("LD_LIBRARY_PATH"));
+               }
+
+               if (binPath == null || binPath.isEmpty()) {
+                       pb.directory(new File(FilePathResources.getBinPath()));
+               } else {
+                       pb.directory(new File(binPath));
+               }
+
+               // Log launch config.
+               String temp = LaunchConfig.getLaunchConfigPath(vmName)
+                               + StringResources.NEW_LINE;
+               for (String str : LaunchConfig.readLaunchConfig(vmName)) {
+                       temp += (str + StringResources.NEW_LINE);
+               }
+               EMLogger.getLogger().log(Level.INFO, "Starting Emulator Command : ");
+               EMLogger.getLogger().log(Level.INFO, temp);
+
+               Process process = null;
+               try {
+                       process = pb.start();
+               } catch (IOException e) {
+                       if (!EmulatorManager.isConsoleMode()) {
+                               MessageDialog msg = new MessageDialog(new Shell(
+                                               Display.getCurrent()));
+                               msg.openWarningDialog("Failed to launch"
+                                               + StringResources.NEW_LINE + e.getMessage());
+                       }
+                       EMLogger.getLogger().log(
+                                       Level.WARNING,
+                                       "Failed to launch." + StringResources.NEW_LINE
+                                                       + e.getMessage());
+               }
+
+               return process;
+       }
+
+}
index 7ce7c6e..1981c46 100644 (file)
@@ -51,6 +51,10 @@ public class VMProperty {
 
        private boolean isRunning = false;
 
+       public void setPropertyValue(VMPropertyValue value) {
+               this.value = value;
+       }
+
        @Override
        public boolean equals(Object obj) {
                if (obj == null) {
index 57c0c40..7b727a9 100644 (file)
@@ -38,29 +38,32 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
 
-import org.eclipse.swt.SWT;
 import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
 import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.platform.PlatformList;
 import org.tizen.emulator.manager.resources.FilePathResources;
 import org.tizen.emulator.manager.resources.StringResources;
-import org.tizen.emulator.manager.tool.CheckVirtualization;
 import org.tizen.emulator.manager.ui.VMsMainView;
-import org.tizen.emulator.manager.ui.dialog.MessageDialog;
 import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator;
 import org.tizen.emulator.manager.vms.helper.QemuImgProc;
 import org.tizen.emulator.manager.vms.helper.VMLauncherException;
 import org.tizen.emulator.manager.vms.helper.VMWorkerException;
 import org.tizen.emulator.manager.vms.helper.WorkerLock;
 import org.tizen.emulator.manager.vms.xml.CpuType;
-
+import org.tizen.emulator.manager.vms.option.IOption;
 
 public class VMWorkerCommon {
        private VMProperty property;
-       private ILauncher launcher;
-       private WorkerThread worker  = null;
+       private WorkerThread worker = null;
        private String baseImagePath = null;
        private String baseImagePartPath = null;
        private Object lock = new Object();
+       private ILauncher launcher;
+
+       public void sendRemoteLog(String msg) {
+
+       }
 
        public void initLauncher() {
 
@@ -70,14 +73,15 @@ public class VMWorkerCommon {
                this.launcher = launcher;
        }
 
-       public void setVMProperty(VMProperty property) {
-               this.property = property;
-       }
-
        public ILauncher getLauncher() {
                return launcher;
        }
 
+
+       public void setVMProperty(VMProperty property) {
+               this.property = property;
+       }
+
        public VMProperty getProperty() {
                return property;
        }
@@ -91,103 +95,67 @@ public class VMWorkerCommon {
        }
 
        public void launchVM() throws VMLauncherException, VMWorkerException {
-               launchVM(false);
+               launchVM(false, null);
        }
 
-       public void launchVM(boolean wait) throws VMLauncherException, VMWorkerException {
-
-               if (launcher != null) {
-                       // lock.acquire
-                       WorkerLock.acquire();
-
-                       try {
-                                       // check exist
-                                       if (!property.getPropertyFile().exists()) {
-                                               throw new VMWorkerException(
-                                                               "This VM had been deleted by other emulator manager."
-                                                               , true);
-                                       }
+       public void launchVM(boolean wait, String path) throws VMLauncherException,
+                       VMWorkerException {
 
-                                       if (isModified()) {
-                                               property = EmulatorVMList.getInstance().parseXML(property.getPropertyFile());
-                                               if (property == null) {
-                                                       throw new VMWorkerException(
-                                                                       "Failed to load modified property."
-                                                                       , true);
-                                               }
-                                               if (!EmulatorManager.isConsoleMode()) {
-                                                       VMsMainView.getInstance().setNeedRefresh(true);
-                                               }
-                                       }
+               // lock.acquire
+               WorkerLock.acquire();
 
-                                       // Check File sharing
-                                       String fileshare = property.getConfiguration().getUsability().getFileSharing().getPath();
-                                       if (fileshare != null) {
-                                               File f = new File(fileshare);
-                                               if (!f.exists()) {
-                                                       throw new VMWorkerException("File sharing path is invalid or not exist.");
-                                               }
-                                       }
+               try {
+                       // check exist
+                       if (!property.getPropertyFile().exists()) {
+                               throw new VMWorkerException(
+                                               "This VM had been deleted by other emulator manager.",
+                                               true);
+                       }
 
-                                       // Check graphic driver (only in linux)
-                                       if (EmulatorManager.isLinux() && CheckVirtualization.getInstance().isGallium()
-                                                       && property.getPropertyValue().isGLAcceleration) {
-                                               // show [ok/cancel] message.
-                                               MessageDialog dialog = new MessageDialog();
-                                               int response = dialog.openWarningAndSelectionDialog(
-                                                               "\n You are using invalid graphic card driver for the emulator."
-                                                               + "\n If you continue launching emulator, it may not work properly."
-
-                                                               + "\n\n You have to use the lastest vendor-provided graphic card driver."
-                                                               + "\n For more information, see under ubuntu driver help page."
-                                                               + "\n https://help.ubuntu.com/community/BinaryDriverHowto/ "
-
-                                                               + "\n\n Do you want to continue launching emulator?"
-                                                               + "\n (If you set GPU support \"off\", you can avoid this message.)"
-                                                               );
-                                               if (response != SWT.OK) {
-                                                       throw new VMWorkerException("User stops launching emulator.");
-                                               }
-                                       }
+                       if (isModified()) {
+                               property = EmulatorVMList.getInstance().parseXML(
+                                               property.getPropertyFile());
+                               if (property == null) {
+                                       throw new VMWorkerException(
+                                                       "Failed to load modified property.", true);
+                               }
+                               if (!EmulatorManager.isConsoleMode()) {
+                                       VMsMainView.getInstance().setNeedRefresh(true);
+                               }
+                       }
 
-                                       // Check non-UG mode.
-                                       CpuType cpuOption = property.getConfiguration().getDevice().getCPU();
-                                       if (cpuOption != null) {
-                                               int cpu = cpuOption.getValue().getValue();
-                                               if (CheckVirtualization.getInstance().isNonUG() && cpu > 1) {
-                                                       MessageDialog dialog = new MessageDialog();
-                                                       int response = dialog.openWarningAndSelectionDialog(
-                                                                       "Using multi-processor option might cause VM slower" +
-                                                                       "\nin non-UG platform." +
-                                                                       "\n\n Do you want to continue launching anyway?");
-                                                       if (response != SWT.OK){
-                                                               throw new VMWorkerException("User stops launching emulator.");
-                                                       }
-                                               }
-                                       }
+                       // Do argument validation.
+                       List<IOption> optList = PlatformList.getOptionList(property);
+                       if (optList == null) {
+                               throw new VMLauncherException("Failed to get option list.");
+                       }
+                       for (IOption option : optList) {
+                               option.checkArgument(property);
+                       }
 
-                                       isRunningNow();
+                       isRunningNow();
 
-                                       if (!launcher.launch(property, wait)) {
-                                               throw new VMWorkerException("");
-                                       } else {
-                                               // success to launch vm
-                                               property.setRunning(true);
-                                       }
+                       boolean isSuccess;
+                       if (EmulatorManager.getManagerMode() == ManagerModeType.INHOUSE_MODE) {
+                               isSuccess = VMLauncher.Launch(property, wait, path); 
+                       } else {
+                               isSuccess = launcher.launch(property, wait); 
+                       }
+                       if (!isSuccess) {
+                               throw new VMWorkerException("");
+                       } else {
+                               // success to launch vm
+                               property.setRunning(true);
+                       }
 
-                       } catch (VMWorkerException e) {
-                               if (!EmulatorManager.isConsoleMode()) {
-                                       VMsMainView.getInstance().setNeedRefresh(false);
-                               }
-                               throw e;
-                       } finally {
-                               //lock.release
-                               WorkerLock.release();
+               } catch (VMWorkerException e) {
+                       if (!EmulatorManager.isConsoleMode()) {
+                               VMsMainView.getInstance().setNeedRefresh(false);
                        }
-               } else {
-                       EMLogger.getLogger().warning("Failed to load 'ILauncher' class.");
-                       throw new VMWorkerException(
-                                       "Available launcher not exist.(Failed to load 'iLauncher' class.)");
+                       throw e;
+               } finally {
+                       // lock.release
+                       WorkerLock.release();
                }
        }
 
@@ -199,15 +167,15 @@ public class VMWorkerCommon {
                        // check exist
                        if (!property.getPropertyFile().exists()) {
                                throw new VMWorkerException(
-                                               "This VM had been deleted by other emulator manager."
-                                               true);
+                                               "This VM had been deleted by other emulator manager.",
+                                               true);
                        }
 
                        // TODO
                        if (isModified()) {
                                throw new VMWorkerException(
-                                               "This VM had been modified by other emulator manager."
-                                               true);
+                                               "This VM had been modified by other emulator manager.",
+                                               true);
                        }
 
                        isRunningNow();
@@ -221,7 +189,8 @@ public class VMWorkerCommon {
                }
        }
 
-       public void createNewBaseImage(VMProperty property, String dest) throws VMWorkerException {
+       public void createNewBaseImage(VMProperty property, String dest)
+                       throws VMWorkerException {
                // lock.acuire
                WorkerLock.acquire();
 
@@ -229,8 +198,8 @@ public class VMWorkerCommon {
                        // check exist
                        if (!property.getPropertyFile().exists()) {
                                throw new VMWorkerException(
-                                               "This VM had been deleted by other emulator manager."
-                                               true);
+                                               "This VM had been deleted by other emulator manager.",
+                                               true);
                        }
 
                        // TODO
@@ -245,14 +214,20 @@ public class VMWorkerCommon {
                        baseImagePath = dest;
                        baseImagePartPath = dest + ".part";
 
-                       File childImage = new File(property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue());
-                       File baseImage  = new File(property.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue());
-                       if(!childImage.exists()) {
-                               throw new VMWorkerException("File does not exist :" + childImage.getAbsolutePath());
+                       File childImage = new File(property.getConfiguration()
+                                       .getBaseInformation().getDiskImage().getCurrentDiskImage()
+                                       .getValue());
+                       File baseImage = new File(property.getConfiguration()
+                                       .getBaseInformation().getDiskImage().getBaseDiskImage()
+                                       .getValue());
+                       if (!childImage.exists()) {
+                               throw new VMWorkerException("File does not exist :"
+                                               + childImage.getAbsolutePath());
                        }
 
-                       if(!baseImage.exists()) {
-                               throw new VMWorkerException("File does not exist :" + baseImage.getAbsolutePath());
+                       if (!baseImage.exists()) {
+                               throw new VMWorkerException("File does not exist :"
+                                               + baseImage.getAbsolutePath());
                        }
 
                        String exe_path = FilePathResources.getEmulatorQemuImgPath(property.getPropertyValue().version);
@@ -267,29 +242,30 @@ public class VMWorkerCommon {
                        final QemuImgProc proc = new QemuImgProc(cmd);
 
                        /*
-                       long childSize = childImage.length();
-                       long baseSize = baseImage.length();
-                       final long maxSize = childSize + baseSize;
-                       final File destFile = new File(dest);
-                       final CreateBaseImageDialog dialog
-                       = new CreateBaseImageDialog(EmulatorManager.getInstance().getMainDialog().getShell());
-                       dialog.Open(destFile, maxSize);
-                       */
+                        * long childSize = childImage.length(); long baseSize =
+                        * baseImage.length(); final long maxSize = childSize + baseSize;
+                        * final File destFile = new File(dest); final CreateBaseImageDialog
+                        * dialog = new
+                        * CreateBaseImageDialog(EmulatorManager.getInstance().getMainDialog
+                        * ().getShell()); dialog.Open(destFile, maxSize);
+                        */
 
                        worker = new WorkerThread(proc, lock);
                        worker.setDaemon(false);
                        worker.start();
-                       synchronized(lock) {
+                       synchronized (lock) {
                                try {
                                        lock.wait(2000);
                                } catch (InterruptedException e) {
                                        e.printStackTrace();
                                }
                                if (worker.isError()) {
-                                       throw new VMWorkerException("Failed to create new base image becauese of failed qemu-img processing!"
-                                                       + StringResources.NEW_LINE
-                                                       + "You can get more information in log file ("
-                                                       + FilePathResources.getTizenVmsPath() +  File.separator + "emulator-manager)");
+                                       throw new VMWorkerException(
+                                                       "Failed to create new base image becauese of failed qemu-img processing!"
+                                                                       + StringResources.NEW_LINE
+                                                                       + "You can get more information in log file ("
+                                                                       + FilePathResources.getTizenVmsPath()
+                                                                       + File.separator + "emulator-manager)");
                                }
                        }
                } catch (VMWorkerException e) {
@@ -303,10 +279,11 @@ public class VMWorkerCommon {
                }
 
                if (EmulatorManager.isConsoleMode()) {
-                       System.out.println("Wait....while creating base image." + StringResources.NEW_LINE
-                                                               + "This task can take about 30 ~ 60 seconds");
-                       synchronized(lock) {
-                               while(worker.isAlive()) {
+                       System.out.println("Wait....while creating base image."
+                                       + StringResources.NEW_LINE
+                                       + "This task can take about 30 ~ 60 seconds");
+                       synchronized (lock) {
+                               while (worker.isAlive()) {
                                        try {
                                                lock.wait();
                                        } catch (InterruptedException e) {
@@ -314,23 +291,24 @@ public class VMWorkerCommon {
                                        }
                                }
                                if (worker.isError()) {
-                                       throw new VMWorkerException("Failed to create new base image becauese of failed qemu-img processing!"
-                                                       + StringResources.NEW_LINE
-                                                       + "You can get more information in log file ("
-                                                       + FilePathResources.getTizenVmsPath() +  File.separator + "emulator-manager)");
+                                       throw new VMWorkerException(
+                                                       "Failed to create new base image becauese of failed qemu-img processing!"
+                                                                       + StringResources.NEW_LINE
+                                                                       + "You can get more information in log file ("
+                                                                       + FilePathResources.getTizenVmsPath()
+                                                                       + File.separator + "emulator-manager)");
                                }
                        }
                }
 
                /*
-               if (! proc.Running()) {
-                       //dialog.Close();
-                       throw new VMsWorkerException("Failed to create new base image becauese of failed qemu-img processing!"
-                                       + StringResources.NEW_LINE
-                                       + "You can get more information in log file ("
-                                       + FileIO.getInstance().getTizenVmsArchPath() +  File.separator + "emulator-manager)");
-               }
-               //dialog.Close();
+                * if (! proc.Running()) { //dialog.Close(); throw new
+                * VMsWorkerException(
+                * "Failed to create new base image becauese of failed qemu-img processing!"
+                * + StringResources.NEW_LINE +
+                * "You can get more information in log file (" +
+                * FileIO.getInstance().getTizenVmsArchPath() + File.separator +
+                * "emulator-manager)"); } //dialog.Close();
                 */
        }
 
@@ -338,6 +316,7 @@ public class VMWorkerCommon {
                QemuImgProc proc;
                boolean isError;
                Object lock;
+
                public WorkerThread(QemuImgProc proc, Object lock) {
                        this.proc = proc;
                        this.lock = lock;
@@ -355,10 +334,10 @@ public class VMWorkerCommon {
                        }
                        //
 
-                       if (! proc.Running()) {
+                       if (!proc.Running()) {
                                isError = true;
                        }
-                       synchronized(lock) {
+                       synchronized (lock) {
                                if (file != null) {
                                        file.delete();
                                }
@@ -385,15 +364,15 @@ public class VMWorkerCommon {
                        // check exist
                        if (!property.getPropertyFile().exists()) {
                                throw new VMWorkerException(
-                                               "This VM had been deleted by other emulator manager."
-                                               true);
+                                               "This VM had been deleted by other emulator manager.",
+                                               true);
                        }
 
                        isRunningNow();
 
                        File vmDirectory = property.getPropertyFile().getParentFile();
 
-                       if(!vmDirectory.isDirectory()) {
+                       if (!vmDirectory.isDirectory()) {
                                throw new VMWorkerException("Check VM path!"
                                                + StringResources.NEW_LINE
                                                + vmDirectory.getAbsolutePath());
@@ -420,8 +399,8 @@ public class VMWorkerCommon {
                        // check exist
                        if (!property.getPropertyFile().exists()) {
                                throw new VMWorkerException(
-                                               "This VM had been deleted by other emulator manager."
-                                               true);
+                                               "This VM had been deleted by other emulator manager.",
+                                               true);
                        }
 
                        if (isModified()) {
@@ -432,8 +411,11 @@ public class VMWorkerCommon {
 
                        isRunningNow();
 
-                       String basePath = property.getConfiguration().getBaseInformation().getDiskImage().getBaseDiskImage().getValue();
-                       String targetPath = property.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
+                       String basePath = property.getConfiguration().getBaseInformation()
+                                       .getDiskImage().getBaseDiskImage().getValue();
+                       String targetPath = property.getConfiguration()
+                                       .getBaseInformation().getDiskImage().getCurrentDiskImage()
+                                       .getValue();
 
                        if (basePath == null || basePath.isEmpty()) {
                                throw new VMWorkerException("Base image path is empty.");
@@ -449,9 +431,13 @@ public class VMWorkerCommon {
 
                        Creator.createInitialVMImage(basePath, targetPath);
 
-                       if (property.getConfiguration().getBaseInformation().getDiskImage().getSwapDiskImage() != null) {
-                               String swapBasePath = FilePathResources.getSwapPath() + File.separator + StringResources.SWAP_IMAGE;
-                               String swapTargetPath = property.getConfiguration().getBaseInformation().getDiskImage().getSwapDiskImage().getValue();
+                       if (property.getConfiguration().getBaseInformation().getDiskImage()
+                                       .getSwapDiskImage() != null) {
+                               String swapBasePath = FilePathResources.getSwapPath()
+                                               + File.separator + StringResources.SWAP_IMAGE;
+                               String swapTargetPath = property.getConfiguration()
+                                               .getBaseInformation().getDiskImage().getSwapDiskImage()
+                                               .getValue();
                                if (!new File(swapBasePath).exists()) {
                                        return;
                                }
@@ -480,15 +466,16 @@ public class VMWorkerCommon {
                VMPropertyValue newValue = property.getPropertyValue();
                newValue.vmsName = newVMName;
                // TODO
-               newValue.isHWVirtualization = property.getConfiguration().getUsability().isHwVirtualization();
+               newValue.isHWVirtualization = property.getConfiguration()
+                               .getUsability().isHwVirtualization();
 
                // create lock acquire and release
                Creator.create(newValue);
        }
 
        public boolean isModified() {
-               if (property.getLastModifedPropertyFile()
-                               != property.getPropertyFile().lastModified()) {
+               if (property.getLastModifedPropertyFile() != property.getPropertyFile()
+                               .lastModified()) {
                        return true;
                }
 
@@ -500,7 +487,7 @@ public class VMWorkerCommon {
                // to check running 'create base image' routine
                if (worker != null) {
                        if (worker.isAlive()) {
-                               throw new VMWorkerException("[" + property.getName() +"]"
+                               throw new VMWorkerException("[" + property.getName() + "]"
                                                + " is using to create base image now...");
                        }
                }
@@ -508,42 +495,45 @@ public class VMWorkerCommon {
                File file = new File(FilePathResources.getTizenVmsPath()
                                + File.separator + property.getName() + ".lock");
                if (file.exists()) {
-                       throw new VMWorkerException("[" + property.getName() +"]"
+                       throw new VMWorkerException("[" + property.getName() + "]"
                                        + " is using to create base image now...");
                }
                //
 
                if (CheckingRunningEmulator.isContains(property)) {
-                       throw new VMWorkerException("[" + property.getName() + "] is running now...");
+                       throw new VMWorkerException("[" + property.getName()
+                                       + "] is running now...");
                }
 
                if (checking(property)) {
-                       if(!EmulatorManager.isConsoleMode()) {
+                       if (!EmulatorManager.isConsoleMode()) {
                                CheckingRunningEmulator.connectToECS(property);
                        }
-                       throw new VMWorkerException("[" + property.getName() + "] is running now...");
+                       throw new VMWorkerException("[" + property.getName()
+                                       + "] is running now...");
                } else {
                        return false;
                }
        }
 
        private static String isRunning(String line, VMProperty prop) {
-               if(EmulatorManager.isLinux()) {
-                       String imagePath = prop.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
-                       if(line.contains("emulator-x86") && line.contains(imagePath)) {
+               if (EmulatorManager.isLinux()) {
+                       String imagePath = prop.getConfiguration().getBaseInformation()
+                                       .getDiskImage().getCurrentDiskImage().getValue();
+                       if (line.contains("emulator-x86") && line.contains(imagePath)) {
                                return imagePath;
                        }
-               }
-               else if(EmulatorManager.isWin()) {
+               } else if (EmulatorManager.isWin()) {
                        String[] titleName = line.split(",");
                        // "split[split.length - 1]" is window title.
-                       if(titleName[titleName.length - 1].contains(prop.getName()+ ":261")) {
+                       if (titleName[titleName.length - 1].contains(prop.getName()
+                                       + ":261")) {
                                return titleName[titleName.length - 1];
                        }
-               }
-               else if(EmulatorManager.isMac()) {
-                       String imagePath = prop.getConfiguration().getBaseInformation().getDiskImage().getCurrentDiskImage().getValue();
-                       if(line.contains("emulator-x86") && line.contains(imagePath)) {
+               } else if (EmulatorManager.isMac()) {
+                       String imagePath = prop.getConfiguration().getBaseInformation()
+                                       .getDiskImage().getCurrentDiskImage().getValue();
+                       if (line.contains("emulator-x86") && line.contains(imagePath)) {
                                return imagePath;
                        }
                }
@@ -553,19 +543,17 @@ public class VMWorkerCommon {
 
        private static Process makeCheckingPropcess() {
                List<String> cmd = new ArrayList<String>();
-               if(EmulatorManager.isLinux()) {
+               if (EmulatorManager.isLinux()) {
                        cmd.add("/bin/ps");
                        cmd.add("-ef");
-               }
-               else if(EmulatorManager.isWin()) {
+               } else if (EmulatorManager.isWin()) {
                        cmd.add("tasklist");
                        cmd.add("/V");
                        cmd.add("/FI");
                        cmd.add("\"IMAGENAME eq java.exe\"");
                        cmd.add("/FO");
                        cmd.add("CSV");
-               }
-               else if (EmulatorManager.isMac()){
+               } else if (EmulatorManager.isMac()) {
                        cmd.add("/bin/ps");
                        cmd.add("-ef");
                }
@@ -577,58 +565,32 @@ public class VMWorkerCommon {
                try {
                        p = pb.start();
                } catch (IOException e) {
-                       EMLogger.getLogger().log(Level.SEVERE, "Error occured while checking if the same VM."
-                                       + StringResources.NEW_LINE
-                                       + e.getMessage());
+                       EMLogger.getLogger().log(
+                                       Level.SEVERE,
+                                       "Error occured while checking if the same VM."
+                                                       + StringResources.NEW_LINE + e.getMessage());
                        return null;
                }
                return p;
        }
-/*
-       public static void checking(VMProperty[] propList) {
-               String line;
-               Process p = null;
-               InputStreamReader inputReader = null;
-               BufferedReader stdOut = null;
-               try {
-                       p = makeCheckingPropcess();
-                       if (p == null) {
-                               return;
-                       }
 
-                       inputReader = new InputStreamReader(p.getInputStream());
-                       stdOut = new BufferedReader(inputReader);
-                       while ((line = stdOut.readLine()) != null) {
-                               for (VMProperty prop : propList) {
-                                       if (isRunning(line, prop) != null) {
-                                               prop.setRunning(true);
-                                               break;
-                                       }
-                               }
-                       }
-               } catch (IOException err) {
-                       EMLogger.getLogger().log(Level.SEVERE, "Error occured while checking if the same VM."
-                                       + StringResources.NEW_LINE
-                                       + err.getMessage());
-               } finally {
-                       // clear;
-                       if (stdOut != null) {
-                               try {
-                                       stdOut.close();
-                               } catch (IOException e) {
-                                       EMLogger.getLogger().log(Level.WARNING, e.getMessage());
-                               }
-                       }
-                       if (inputReader != null) {
-                               try {
-                                       inputReader.close();
-                               } catch (IOException e) {
-                                       EMLogger.getLogger().log(Level.WARNING, e.getMessage());
-                               }
-                       }
-               }
-       }
-*/
+       /*
+        * public static void checking(VMProperty[] propList) { String line; Process
+        * p = null; InputStreamReader inputReader = null; BufferedReader stdOut =
+        * null; try { p = makeCheckingPropcess(); if (p == null) { return; }
+        *
+        * inputReader = new InputStreamReader(p.getInputStream()); stdOut = new
+        * BufferedReader(inputReader); while ((line = stdOut.readLine()) != null) {
+        * for (VMProperty prop : propList) { if (isRunning(line, prop) != null) {
+        * prop.setRunning(true); break; } } } } catch (IOException err) {
+        * EMLogger.getLogger().log(Level.SEVERE,
+        * "Error occured while checking if the same VM." + StringResources.NEW_LINE
+        * + err.getMessage()); } finally { // clear; if (stdOut != null) { try {
+        * stdOut.close(); } catch (IOException e) {
+        * EMLogger.getLogger().log(Level.WARNING, e.getMessage()); } } if
+        * (inputReader != null) { try { inputReader.close(); } catch (IOException
+        * e) { EMLogger.getLogger().log(Level.WARNING, e.getMessage()); } } } }
+        */
        public static boolean checking(VMProperty prop) {
                boolean result = false;
 
@@ -648,27 +610,31 @@ public class VMWorkerCommon {
                        while ((line = stdOut.readLine()) != null) {
                                String re = isRunning(line, prop);
                                if (re != null) {
-                                       EMLogger.getLogger().log(Level.INFO, "emulator instance with the same name is running now (" + re + ")");
+                                       EMLogger.getLogger().log(
+                                                       Level.INFO,
+                                                       "emulator instance with the same name is running now ("
+                                                                       + re + ")");
                                        result = true;
                                }
                        }
                        /*
-                       if (!result) {
-                               EMLogger.getLogger().log(Level.INFO, "The same name of VM not exist anywhere. You can continue your job.");
-                       }
-                       */
-                       return result;                                                   
+                        * if (!result) { EMLogger.getLogger().log(Level.INFO,
+                        * "The same name of VM not exist anywhere. You can continue your job."
+                        * ); }
+                        */
+                       return result;
                } catch (IOException err) {
-                       EMLogger.getLogger().log(Level.SEVERE, "Error occured while checking if the same VM."
-                                       + StringResources.NEW_LINE
-                                       + err.getMessage());
+                       EMLogger.getLogger().log(
+                                       Level.SEVERE,
+                                       "Error occured while checking if the same VM."
+                                                       + StringResources.NEW_LINE + err.getMessage());
                        /*
-                       if (!EmulatorManager.isConsoleMode()) {
-                               MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
-                               msg.openWarningDialog("Error occured while checking if the same VM."
-                                               + StringResources.NEW_LINE + err.getMessage());
-                       }
-                       */
+                        * if (!EmulatorManager.isConsoleMode()) { MessageDialog msg = new
+                        * MessageDialog(new Shell(Display.getCurrent()));
+                        * msg.openWarningDialog
+                        * ("Error occured while checking if the same VM." +
+                        * StringResources.NEW_LINE + err.getMessage()); }
+                        */
 
                        return false;
                } finally {
@@ -692,7 +658,7 @@ public class VMWorkerCommon {
 
        // Remove directory files recursively.
        // Return false if one or more files fail to delete.
-       public static boolean deleteFile(File file){
+       public static boolean deleteFile(File file) {
                boolean result = true;
                if (!file.exists()) {
                        return result;
@@ -721,68 +687,42 @@ public class VMWorkerCommon {
 }
 
 /*
-class CreateBaseImageDialog {
-       private Shell dialog = null;
-       static private ProgressBar bar = null;
-
-       public CreateBaseImageDialog(Shell shell) {
-               Point p = shell.getLocation();
-               p = new Point(p.x + 300, p.y + 300);
-               dialog = new Shell(shell,  SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
-               dialog.setText("Info");
-               dialog.setSize(300, 100);
-               dialog.setLayout(new GridLayout(1, true));
-               dialog.setLocation(p);
-               //dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-               Label info = new Label(dialog, SWT.WRAP);
-               info.setText("Wait....while creating base image." + StringResources.NEW_LINE
-                                       + "This task can take about 30 ~ 60 seconds");
-               info.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
-
-               bar = new ProgressBar(dialog, SWT.SMOOTH);
-               bar.setBounds(10, 10, 200, 32);
-               bar.setMaximum(100);
-
-               dialog.addListener(SWT.Close, new Listener() {
-                       @Override
-                       public void handleEvent(Event event) {
-                               // Empty
-                       }
-
-               });
-               dialog.addMouseListener(new MouseListener(){
-
-                       @Override
-                       public void mouseDoubleClick(MouseEvent e) {
-                               // TODO Auto-generated method stub
-                       }
-
-                       @Override
-                       public void mouseDown(MouseEvent e) {
-                               // TODO Auto-generated method stub
-                       }
-
-                       @Override
-                       public void mouseUp(MouseEvent e) {
-                               // TODO Auto-generated method stub
-                       }
-               });
-       }
-
-       public void setSelection(int i) {
-               bar.setSelection(i);
-       }
-       public void Open(final File destFile, final long maxSize) {
-               dialog.open();
-       }
-
-       public void Close() {
-               dialog.close();
-       }
-
-       public boolean isDisposed() {
-               return dialog.isDisposed();
-       }
-}
-*/
+ * class CreateBaseImageDialog { private Shell dialog = null; static private
+ * ProgressBar bar = null;
+ *
+ * public CreateBaseImageDialog(Shell shell) { Point p = shell.getLocation(); p
+ * = new Point(p.x + 300, p.y + 300); dialog = new Shell(shell, SWT.DIALOG_TRIM
+ * | SWT.APPLICATION_MODAL); dialog.setText("Info"); dialog.setSize(300, 100);
+ * dialog.setLayout(new GridLayout(1, true)); dialog.setLocation(p);
+ * //dialog.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ *
+ * Label info = new Label(dialog, SWT.WRAP);
+ * info.setText("Wait....while creating base image." + StringResources.NEW_LINE
+ * + "This task can take about 30 ~ 60 seconds"); info.setLayoutData(new
+ * GridData(SWT.CENTER, SWT.CENTER, true, true));
+ *
+ * bar = new ProgressBar(dialog, SWT.SMOOTH); bar.setBounds(10, 10, 200, 32);
+ * bar.setMaximum(100);
+ *
+ * dialog.addListener(SWT.Close, new Listener() {
+ *
+ * @Override public void handleEvent(Event event) { // Empty }
+ *
+ * }); dialog.addMouseListener(new MouseListener(){
+ *
+ * @Override public void mouseDoubleClick(MouseEvent e) { // TODO Auto-generated
+ * method stub }
+ *
+ * @Override public void mouseDown(MouseEvent e) { // TODO Auto-generated method
+ * stub }
+ *
+ * @Override public void mouseUp(MouseEvent e) { // TODO Auto-generated method
+ * stub } }); }
+ *
+ * public void setSelection(int i) { bar.setSelection(i); } public void
+ * Open(final File destFile, final long maxSize) { dialog.open(); }
+ *
+ * public void Close() { dialog.close(); }
+ *
+ * public boolean isDisposed() { return dialog.isDisposed(); } }
+ */
index aa052d6..ca7822b 100644 (file)
@@ -51,6 +51,7 @@ import org.tizen.emulator.manager.ui.dialog.MessageDialog;
 import org.tizen.emulator.manager.vms.EmulatorVMList;
 import org.tizen.emulator.manager.vms.ILauncher;
 import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.VMWorkerCommon;
 import org.tizen.emulator.manager.vms.helper.VMSocketQueue.QueueObject;
 
 public class CheckingRunningEmulator {
@@ -141,9 +142,9 @@ public class CheckingRunningEmulator {
                } else {
                        addLaunchedVMList(prop.getName());
                        connectToECS(prop);
-                       ILauncher launcher = prop.getWorker().getLauncher();
-                       if (launcher != null) {
-                               launcher.sendRemoteLog("start");
+                       VMWorkerCommon worker = prop.getWorker();
+                       if (worker != null) {
+                               worker.sendRemoteLog("start");
                        }
                }
        }
@@ -417,9 +418,9 @@ public class CheckingRunningEmulator {
 
                private static void setVMExit(VMSocket vms) {
                        if (vms.getProperty() != null) {
-                               ILauncher launcher = vms.getProperty().getWorker().getLauncher();
-                               if (launcher != null) {
-                                       launcher.sendRemoteLog("stop");
+                               VMWorkerCommon worker = vms.getProperty().getWorker();
+                               if (worker != null) {
+                                       worker.sendRemoteLog("stop");
                                }
                        }
                        disconnect(vms);
index 13aa1d5..4f3e86a 100644 (file)
@@ -92,26 +92,32 @@ public class MonitoringEmulator extends Thread {
                try {
                        int exitValue = process.waitFor();
 
-                       EMLogger.getLogger().warning(String.format("Emulator has been terminated. Exit value: %X(%d)", exitValue, exitValue));
+                       EMLogger.getLogger().warning(
+                                       String.format(
+                                                       "Emulator has been terminated. Exit value: %X(%d)",
+                                                       exitValue, exitValue));
                        stdOut.printMessageList();
                        stdErr.printMessageList();
 
                        if (exitValue != 0) {
                                setSuccess(false);
-                               EMLogger.getLogger().warning("You can see more information in the emulator-manager.log or "
-                                               + property.getName() + "'s logs directory.");
+                               EMLogger.getLogger().warning(
+                                               "You can see more information in the emulator-manager.log or "
+                                                               + property.getName() + "'s logs directory.");
                                if (!EmulatorManager.isConsoleMode()) {
-                                       Display.getDefault().asyncExec(new Runnable(){
+                                       Display.getDefault().asyncExec(new Runnable() {
 
                                                @Override
                                                public void run() {
                                                        VMsMainView.getInstance().redraw();
-                                                       new MessageDialog().openWarningDialog("Emulator has been terminated."
-                                                                       + StringResources.NEW_LINE
-                                                                       + "You can see more information "
-                                                                       + StringResources.NEW_LINE
-                                                                       + "in the emulator-manager.log or "
-                                                                       + property.getName() + "'s logs directory.");
+                                                       new MessageDialog()
+                                                                       .openWarningDialog("Emulator has been terminated."
+                                                                                       + StringResources.NEW_LINE
+                                                                                       + "You can see more information "
+                                                                                       + StringResources.NEW_LINE
+                                                                                       + "in the emulator-manager.log or "
+                                                                                       + property.getName()
+                                                                                       + "'s logs directory.");
                                                }
 
                                        });
@@ -135,19 +141,15 @@ public class MonitoringEmulator extends Thread {
                }
 
                // close
-               if (readerOut != null) {
-                       try {
+               try {
+                       if (readerOut != null) {
                                readerOut.close();
-                       } catch (IOException e) {
-                               EMLogger.getLogger().warning(e.getMessage());
                        }
-               }
-               if (readerError != null) {
-                       try {
+                       if (readerError != null) {
                                readerError.close();
-                       } catch (IOException e) {
-                               EMLogger.getLogger().warning(e.getMessage());
                        }
+               } catch (IOException e) {
+                       EMLogger.getLogger().warning(e.getMessage());
                }
        }
 
@@ -158,11 +160,13 @@ public class MonitoringEmulator extends Thread {
        public void setSuccess(boolean success) {
                this.success = success;
        }
+
 }
 
 class Timer implements Runnable {
        private MonitoringEmulator monitor;
        private int count;
+
        public Timer(MonitoringEmulator m) {
                this(m, 8);
        }
@@ -172,9 +176,9 @@ class Timer implements Runnable {
                count = c;
        }
 
-       @ Override
+       @Override
        public void run() {
-               synchronized(this) {
+               synchronized (this) {
                        try {
                                this.wait(1000 * count);
                        } catch (InterruptedException e) {
@@ -189,27 +193,46 @@ class Timer implements Runnable {
 
 class StdOut implements Runnable {
        private BufferedReader reader;
-       private String emName;
-       private final ArrayList<String> list =  new ArrayList<String>();
+       private String vmName;
+       private final ArrayList<String> list = new ArrayList<String>();
+
        public StdOut(BufferedReader reader, String name) {
                this.reader = reader;
-               this.emName = name;
+               this.vmName = name;
        }
 
        public StdOut(InputStreamReader in, String name) {
                this.reader = new BufferedReader(in);
-               this.emName = name;
+               this.vmName = name;
        }
 
-       @ Override
+       @Override
        public void run() {
-               String msg;
+               String msg = "";
+
                if (reader != null) {
+                       char c;
+                       int i;
                        try {
                                do {
-                                       msg = reader.readLine();
-                                       if (msg != null) {
-                                               list.add(msg);
+                                       if (reader.ready()) { // To avoid blocking in following read()
+                                               i = (reader.read());
+                                               if (i == -1) { // EOF
+                                                       break;
+                                               }
+                                               if (Thread.currentThread().getName()
+                                                               .equals(vmName + "STDERR")) {
+                                                       c = (char) i;
+                                                       msg += c;
+                                                       if (msg.contains(StringResources.NEW_LINE)) {
+                                                               // Remove NEW_LINE
+                                                               msg = msg.substring(0, msg.length()
+                                                                               - StringResources.NEW_LINE.length());
+                                                               list.add(msg); // Add msg from STDERR.
+                                                               msg = "";
+                                                       }
+                                               }
+
                                        } else {
                                                try {
                                                        Thread.sleep(100);
@@ -218,7 +241,7 @@ class StdOut implements Runnable {
                                                        e.printStackTrace();
                                                }
                                        }
-                               } while (CheckingRunningEmulator.isContains(emName));
+                               } while (CheckingRunningEmulator.isContains(vmName));
                        } catch (IOException e) {
                                EMLogger.getLogger().info(e.getMessage());
                        } finally {
@@ -233,13 +256,15 @@ class StdOut implements Runnable {
                if (error) {
                        for (String s : list) {
                                if (s != null && !s.isEmpty()) {
-                                       EMLogger.getLogger().warning("Print Log From Emulator: " + s);
+                                       EMLogger.getLogger().warning(
+                                                       "Print Log From Emulator: " + s);
                                }
                        }
                }
        }
 
        private boolean error = false;
+
        public void printMessageList() {
                error = true;
        }
diff --git a/common-project/src/org/tizen/emulator/manager/vms/helper/VMLogUtil.java b/common-project/src/org/tizen/emulator/manager/vms/helper/VMLogUtil.java
new file mode 100644 (file)
index 0000000..6b7da21
--- /dev/null
@@ -0,0 +1,122 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.helper;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.resources.StringResources;
+
+public class VMLogUtil {
+
+       public static void makeVMBackupLog(String vmName) {
+               // Make emulator.log backup.
+               File emulatorLog = getEmulatorLogFile(vmName);
+               if (emulatorLog.exists()) {
+                       makeBackupLog(emulatorLog, vmName);
+               }
+       }
+
+
+       public static File getEmulatorLogFile(String vmName) {
+               File emulatorLog = new File(getEmulatorLogPath(vmName));
+               return emulatorLog;
+       }
+
+
+       public static String getEmulatorLogPath(String vmName) {
+               return FilePathResources.getVirtualTargetLogPath(vmName)
+                               + File.separator + StringResources.EMULATOR_LOG;
+       }
+
+
+       public static void makeBackupLog(File emulatorLog, String vmName) {
+               File backupDir = new File(
+                               FilePathResources.getVirtualTargetLogPath(vmName)
+                                               + File.separator + "backup");
+               if (!backupDir.exists()) {
+                       // Make backup directory. (vms/{vmName}/logs/backup)
+                       if (!backupDir.mkdir()) {
+                               EMLogger.getLogger().warning(
+                                               "Failed to create backup log directory." + "\n :"
+                                                               + backupDir.getAbsolutePath());
+                       }
+               }
+
+               // Make backup log file.
+               File backupLog = new File(backupDir, StringResources.EMULATOR_LOG);
+               copyTextFile(emulatorLog, backupLog);
+       }
+
+
+       public static void copyTextFile(File src, File dest) {
+               BufferedReader br = null;
+               BufferedWriter bw = null;
+               try {
+                       br = new BufferedReader(new FileReader(src));
+                       bw = new BufferedWriter(new FileWriter(dest));
+                       String readStr;
+                       while ((readStr = br.readLine()) != null) {
+                               bw.write(readStr + StringResources.NEW_LINE);
+                       }
+                       bw.flush();
+               } catch (FileNotFoundException e) {
+                       EMLogger.getLogger().warning(
+                                       "Failed to copy text file." + e.getMessage() + "\n src : "
+                                                       + src.getAbsolutePath() + "\n dest: "
+                                                       + dest.getAbsolutePath());
+
+               } catch (IOException e) {
+                       EMLogger.getLogger().warning(
+                                       "Failed to copy text file." + e.getMessage() + "\n src : "
+                                                       + src.getAbsolutePath() + "\n dest: "
+                                                       + dest.getAbsolutePath());
+
+               } finally {
+                       try {
+                               if (br != null) {
+                                       br.close();
+                               }
+                               if (bw != null) {
+                                       bw.close();
+                               }
+                       } catch (IOException e) {
+                               // TODO Auto-generated catch block
+                               e.printStackTrace();
+                       }
+               }
+       }
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/BaseImageOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/BaseImageOption.java
new file mode 100644 (file)
index 0000000..764e8ab
--- /dev/null
@@ -0,0 +1,51 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class BaseImageOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property) {
+
+               config.addVariable(VAR_DRIVE, "file="
+                               + property.getConfiguration().getBaseInformation()
+                                               .getDiskImage().getCurrentDiskImage().getValue()
+                               + ",if=virtio,index=1");
+               config.addVariable(VAR_SWAP, "file="
+                               + property.getConfiguration().getBaseInformation()
+                                               .getDiskImage().getSwapDiskImage().getValue()
+                               + ",if=virtio,index=2");
+
+               config.addQemuOption("-drive", varForm(VAR_DRIVE) + ",id=drive");
+               config.addQemuOption("-drive", varForm(VAR_SWAP) + ",id=swap");
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/CommonOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/CommonOption.java
new file mode 100644 (file)
index 0000000..34fae55
--- /dev/null
@@ -0,0 +1,75 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import java.io.File;
+
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+
+public class CommonOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property)
+                       throws VMLauncherException {
+
+               // Add variables
+               config.addVariable(VAR_VMS_PATH, FilePathResources.getTizenVmsPath());
+
+               // kernel log
+               config.addKernelOption("console", "ttyS0");
+               config.addVariable(VAR_KERNEL_LOG, varForm(VAR_VMS_PATH)
+                               + File.separator + varForm(VAR_VM_NAME) + File.separator
+                               + "logs" + File.separator + "emulator.klog");
+               config.addQemuOption("-chardev", "file,path=" + varForm(VAR_KERNEL_LOG)
+                               + ",id=con0");
+               config.addQemuOption("-device isa-serial,chardev=con0");
+               config.addQemuOption("-device virtio-serial");
+               if (EmulatorManager.isLinux()) {
+                       config.addQemuOption("-chardev socket,path=/tmp/virtcon,server,nowait,id=con1");
+                       config.addQemuOption("-device virtconsole,chardev=con1");
+               }
+
+               // bios
+               config.addVariable(VAR_BIOS_PATH, FilePathResources.getBiosPath());
+               config.addQemuOption("-L", varForm(VAR_BIOS_PATH));
+
+               // kernel image
+               config.addVariable(VAR_KERNEL, FilePathResources.getKernelPath()
+                               + File.separator + "bzImage." + property.getArch().toString());
+               config.addQemuOption("-kernel", varForm(VAR_KERNEL));
+
+               // kernel
+               config.addQemuOption("-append", varForm(VAR_APPEND));
+
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/DisplayOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/DisplayOption.java
new file mode 100644 (file)
index 0000000..676edd7
--- /dev/null
@@ -0,0 +1,72 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import java.io.File;
+
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class DisplayOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property) {
+               String skinPath = null;
+               if (property.getConfiguration().getDevice().getDisplay().getSkinPath() != null) {
+                       skinPath = property.getConfiguration().getDevice().getDisplay()
+                                       .getSkinPath().getPath();
+                       if (skinPath != null && skinPath.isEmpty()) {
+                               skinPath = null;
+                       }
+               }
+               int width = property.getConfiguration().getDevice().getDisplay()
+                               .getResolution().getWidth();
+               int height = property.getConfiguration().getDevice().getDisplay()
+                               .getResolution().getHeight();
+               int dpi = property.getConfiguration().getDevice().getDisplay()
+                               .getDensity().getValue();
+
+               if (skinPath != null) {
+                       config.addVariable(VAR_SKIN_PATH, skinPath);
+               }
+               config.addVariable(VAR_RESOLUTION, width + "x" + height);
+               config.addVariable(VAR_VMS_PATH, FilePathResources.getTizenVmsPath());
+
+               config.addSkinOption("skin.path", varForm(VAR_SKIN_PATH));
+               config.addSkinOption("resolution", varForm(VAR_RESOLUTION));
+               config.addSkinOption("vm.path", varForm(VAR_VMS_PATH) + File.separator
+                               + varForm(VAR_VM_NAME));
+
+               config.addKernelOption("video", "LVDS-1:" + varForm(VAR_RESOLUTION)
+                               + "-32@60");
+               config.addKernelOption("dpi", String.valueOf(dpi * 10));
+
+               // TODO var "vm.path" ?
+       }
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/FileShareOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/FileShareOption.java
new file mode 100644 (file)
index 0000000..1499d89
--- /dev/null
@@ -0,0 +1,65 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import java.io.File;
+
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+
+public class FileShareOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property) {
+               String fileshare = property.getConfiguration().getUsability()
+                               .getFileSharing().getPath();
+               if (fileshare != null) {
+                       config.addKernelOption("virtio-9p");
+                       config.addQemuOption("-virtfs", "local,path="
+                                       + property.getConfiguration().getUsability()
+                                                       .getFileSharing().getPath()
+                                       + ",security_model=none,mount_tag=fileshare");
+               }
+       }
+
+       @Override
+       public void checkArgument(VMProperty property) throws VMLauncherException {
+               // Check File sharing
+               String fileshare = property.getConfiguration().getUsability()
+                               .getFileSharing().getPath();
+               if (fileshare != null) {
+                       File f = new File(fileshare);
+                       if (!f.exists()) {
+                               throw new VMLauncherException(
+                                               "File sharing path is invalid or not exist.");
+                       }
+               }
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/HWSupportOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/HWSupportOption.java
new file mode 100644 (file)
index 0000000..f42e7e0
--- /dev/null
@@ -0,0 +1,93 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.eclipse.swt.SWT;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.tool.CheckVirtualization;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+
+public class HWSupportOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property)
+                       throws VMLauncherException {
+               // Set CPU option
+               String hwVirtualization = "";
+               if (property.getConfiguration().getUsability().isHwVirtualization()
+                               && CheckVirtualization.getInstance().isSupportVirtualization()) {
+                       hwVirtualization = CheckVirtualization.getInstance()
+                                       .getVirtualizationEnableCommnad();
+               } else {
+                       hwVirtualization = CheckVirtualization.getInstance()
+                                       .getVirtualizationDisableCommnad();
+               }
+               config.addQemuOption(hwVirtualization);
+
+               // Set GPU option
+               if (property.getConfiguration().getUsability().isHwGLAcceleration()
+                               && CheckVirtualization.getInstance().isSupportGPU()) {
+                       // config.addQemuOption("-vigs-backend", "gl");
+                       // config.addQemuOption("-enable-yagl");
+                       // config.addQemuOption("-yagl-backend", "vigs");
+                       config.addQemuOption("-device", "vigs,backend=gl");
+                       config.addQemuOption("-device", "yagl");
+
+               } else {
+                       config.addQemuOption("-yagl-backend", "sw");
+               }
+       }
+
+       @Override
+       public void checkArgument(VMProperty property) throws VMLauncherException {
+               // Check graphic driver (only in linux)
+               if (EmulatorManager.isLinux()
+                               && CheckVirtualization.getInstance().isGallium()
+                               && property.getPropertyValue().isGLAcceleration) {
+                       // show [ok/cancel] message.
+                       MessageDialog dialog = new MessageDialog();
+                       int response = dialog
+                                       .openWarningAndSelectionDialog("\n You are using invalid graphic card driver for the emulator."
+                                                       + "\n If you continue launching emulator, it may not work properly."
+
+                                                       + "\n\n You have to use the lastest vendor-provided graphic card driver."
+                                                       + "\n For more information, see under ubuntu driver help page."
+                                                       + "\n https://help.ubuntu.com/community/BinaryDriverHowto/ "
+
+                                                       + "\n\n Do you want to continue launching emulator?"
+                                                       + "\n (If you set GPU support \"off\", you can avoid this message.)");
+                       if (response != SWT.OK) {
+                               throw new VMLauncherException("User stops launching emulator.");
+                       }
+               }
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/IOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/IOption.java
new file mode 100644 (file)
index 0000000..53bec7a
--- /dev/null
@@ -0,0 +1,43 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+
+public interface IOption {
+
+       public void getLaunchArgument(LaunchConfig config, VMProperty property)
+                       throws VMWorkerException;
+
+       // Check option's validity
+       public void checkArgument(VMProperty property) throws VMLauncherException;
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/IOptionFactory.java b/common-project/src/org/tizen/emulator/manager/vms/option/IOptionFactory.java
new file mode 100644 (file)
index 0000000..767a950
--- /dev/null
@@ -0,0 +1,41 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import java.util.List;
+
+import org.tizen.emulator.manager.vms.xml.template.ItemList;
+
+public interface IOptionFactory {
+
+       public final String X86_STANDARD = "x86-standard";
+       public final String ARM = "arm";
+
+       public List<IOption> makeOptionList(ItemList itemTemplate);
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/LaunchConfig.java b/common-project/src/org/tizen/emulator/manager/vms/option/LaunchConfig.java
new file mode 100644 (file)
index 0000000..5b70fa0
--- /dev/null
@@ -0,0 +1,203 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.platform.PlatformList;
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+
+public class LaunchConfig {
+       List<String> skinOptions = new ArrayList<String>();
+       List<String> qemuOptions = new ArrayList<String>();
+       List<String> kernelOptions = new ArrayList<String>();
+       Map<String, String> variables = new HashMap<String, String>();
+
+       public static String DEFAULT_VALUE = "[[DEFAULT_VALUE]]";
+       public static String SKIN_OPTIONS = "[[SKIN_OPTIONS]]";
+       public static String QEMU_OPTIONS = "[[QEMU_OPTIONS]]";
+
+       public void addVariable(String key, String value) {
+               variables.put(key, value);
+       }
+
+       public void addQemuOption(String option) {
+               qemuOptions.add(option);
+       }
+
+       public void addQemuOption(String name, String value) {
+               qemuOptions.add(name + " " + value);
+       }
+
+       public void addSkinOption(String key, String value) {
+               skinOptions.add(key + "=" + value);
+       }
+
+       public void addKernelOption(String key, String value) {
+               kernelOptions.add(key + "=" + value);
+       }
+
+       public void addKernelOption(String option) {
+               kernelOptions.add(option);
+       }
+
+       public static void createLaunchConfig(VMProperty property)
+                       throws VMWorkerException {
+               // 1. Get option list which is matched with base-image.
+               List<IOption> optList = PlatformList.getOptionList(property);
+               if (optList == null) {
+                       throw new VMWorkerException("Failed to get option list.");
+               }
+
+               // 2. Get launch command
+               LaunchConfig config = new LaunchConfig();
+               for (IOption option : optList) {
+                       option.getLaunchArgument(config, property);
+               }
+
+               // 3. Create launch config file.
+               // "tizen-sdk-data/vms/{vm}/vm-launch.conf"
+               String configFilename = getLaunchConfigPath(property.getPropertyValue().vmsName);
+               config.writeFile(new File(configFilename));
+       }
+
+       public static String getLaunchConfigPath(String vmName) {
+               String configDirectoryName = FilePathResources.getTizenVmsPath()
+                               + File.separator + vmName;
+               return configDirectoryName + File.separator
+                               + StringResources.LAUNCH_CONF_NAME;
+       }
+
+       private void writeFile(File file) throws VMWorkerException {
+               BufferedWriter bw = null;
+               try {
+                       bw = new BufferedWriter(new FileWriter(file));
+
+                       // Write variables
+                       bw.write(DEFAULT_VALUE);
+                       bw.newLine();
+                       for (String str : variables.keySet()) {
+                               bw.write(str + "=" + variables.get(str));
+                               bw.newLine();
+                       }
+                       String kernelOption = "";
+                       for (String str : kernelOptions) {
+                               if (!str.isEmpty()) {
+                                       kernelOption += (str + " ");
+                               }
+                       }
+                       bw.write(Option.VAR_APPEND + "=\"" + kernelOption.trim() + "\"");
+                       bw.newLine();
+
+                       // Write skin options.
+                       bw.newLine();
+                       bw.write(SKIN_OPTIONS);
+                       bw.newLine();
+                       for (String str : skinOptions) {
+                               bw.write(str);
+                               bw.newLine();
+                       }
+
+                       // Write qemu options.
+                       bw.newLine();
+                       bw.write(QEMU_OPTIONS);
+                       bw.newLine();
+                       for (String str : qemuOptions) {
+                               bw.write(str);
+                               bw.newLine();
+                       }
+
+                       bw.flush();
+
+               } catch (IOException e) {
+                       EMLogger.getLogger().warning(
+                                       "Failed to create launch conf file." + e.getMessage());
+                       throw new VMWorkerException("Failed to create launch config file");
+
+               } finally {
+                       if (bw != null) {
+                               try {
+                                       bw.close();
+                               } catch (IOException e) {
+                                       EMLogger.getLogger().warning(e.getMessage());
+                               }
+                       }
+               }
+       }
+
+       public static List<String> readLaunchConfig(String vmName) {
+               List<String> list = new ArrayList<String>();
+               BufferedReader br = null;
+
+               try {
+                       br = new BufferedReader(new FileReader(new File(
+                                       getLaunchConfigPath(vmName))));
+                       String readStr;
+                       while ((readStr = br.readLine()) != null) {
+                               list.add(readStr);
+                       }
+
+               } catch (FileNotFoundException e) {
+                       EMLogger.getLogger().warning(
+                                       "Failed to read launch config file. " + e.getMessage());
+
+               } catch (IOException e) {
+                       EMLogger.getLogger().warning(
+                                       "Failed to read launch config file. " + e.getMessage());
+               } finally {
+                       if (br != null) {
+                               try {
+                                       br.close();
+                               } catch (IOException e) {
+                                       EMLogger.getLogger().warning(e.getMessage());
+                               }
+                       }
+               }
+               return list;
+
+       }
+
+       public static void loadTemplate(File file) {
+
+       }
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/NetProxyOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/NetProxyOption.java
new file mode 100644 (file)
index 0000000..cdf8756
--- /dev/null
@@ -0,0 +1,129 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.resources.FilePathResources;
+import org.tizen.emulator.manager.ui.detail.item.ItemName;
+import org.tizen.emulator.manager.ui.detail.item.property.NetProxyViewItem;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.HelperClass;
+import org.tizen.emulator.manager.vms.helper.ProcessResult;
+import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+
+public class NetProxyOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property)
+                       throws VMWorkerException {
+               if (EmulatorManager.isLinux() || EmulatorManager.isWin()) {
+                       config.addKernelOption(getProxy(property));
+               }
+       }
+
+       private String getProxy(VMProperty property) throws VMWorkerException {
+               String proxyConfig = "";
+               String proxyMode = property.getPropertyValue()
+                               .getAdvancedOptionSubValue(ItemName.NET_PROXY,
+                                               NetProxyViewItem.ITEM_PROXY_MODE);
+               if (proxyMode.equals(NetProxyViewItem.MODE_AUTO)) {
+                       proxyConfig = getHostProxy();
+
+               } else if (proxyMode.equals(NetProxyViewItem.MODE_MANUAL)) {
+                       proxyConfig = "http_proxy="
+                                       + property.getPropertyValue().getAdvancedOptionSubValue(
+                                                       ItemName.NET_PROXY,
+                                                       NetProxyViewItem.ITEM_HTTP_PROXY)
+                                       + " https_proxy="
+                                       + property.getPropertyValue().getAdvancedOptionSubValue(
+                                                       ItemName.NET_PROXY,
+                                                       NetProxyViewItem.ITEM_HTTPS_PROXY)
+                                       + " ftp_proxy="
+                                       + property.getPropertyValue()
+                                                       .getAdvancedOptionSubValue(ItemName.NET_PROXY,
+                                                                       NetProxyViewItem.ITEM_FTP_PROXY)
+                                       + " socks_proxy="
+                                       + property.getPropertyValue().getAdvancedOptionSubValue(
+                                                       ItemName.NET_PROXY,
+                                                       NetProxyViewItem.ITEM_SOCKS_PROXY);
+               }
+               return proxyConfig;
+
+       }
+
+       private String getHostProxy() throws VMWorkerException {
+               String result = null;
+               String proxyCommand = "check-net";
+               if (EmulatorManager.isWin()) {
+                       proxyCommand = "check-net.exe";
+               }
+
+               List<String> cmd = Arrays.asList(FilePathResources.getBinPath()
+                               + File.separator + proxyCommand, "--proxy");
+               ProcessResult res = HelperClass.runProcess(cmd);
+               boolean isCommandSuccess = false;
+               if (res.isSuccess()) {
+                       for (String str : res.getStdOutMsg()) {
+                               if (str.startsWith("MODE:")) {
+                                       isCommandSuccess = true;
+                               }
+                               if (str.startsWith("http_proxy")) {
+                                       result = str;
+                               }
+                       }
+
+               } else if (!res.isSuccess() || !isCommandSuccess) {
+                       EMLogger.getLogger().warning(res.getResultMessage());
+                       int dialogRes = new MessageDialog()
+                                       .openWarningAndSelectionDialog("Failed to get host proxy setting."
+                                                       + "\n"
+                                                       + res.getResultMessage()
+                                                       + "\nContinue creating anyway ?");
+                       if (dialogRes != SWT.OK) {
+                               throw new VMWorkerException("User canceled creating VM.");
+                       }
+               }
+
+               if (result == null) {
+                       EMLogger.getLogger().warning("Can't find host proxy setting.");
+                       EMLogger.getLogger().warning(
+                                       "check-net result : " + res.getResultMessage());
+                       result = "";
+               }
+
+               return result;
+       }
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/NetworkOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/NetworkOption.java
new file mode 100644 (file)
index 0000000..8ba5b53
--- /dev/null
@@ -0,0 +1,251 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import java.util.logging.Level;
+
+import org.eclipse.swt.SWT;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.tool.SettingInfoFile;
+import org.tizen.emulator.manager.tool.TapUtil;
+import org.tizen.emulator.manager.ui.detail.item.ItemName;
+import org.tizen.emulator.manager.ui.dialog.IPAddressInputDialog;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.EmulatorVMList;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+import org.tizen.emulator.manager.vms.helper.VMWorkerException;
+
+public class NetworkOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property)
+                       throws VMWorkerException {
+               boolean isBridge = property.getPropertyValue()
+                               .getAdvancedOptionValue(ItemName.NET_CONNECT_TYPE)
+                               .equals("Bridge")
+                               && (EmulatorManager.isLinux() || EmulatorManager.isWin());
+
+               // Qemu MAC argument
+               config.addVariable(VAR_MAC, getMacAddr(isBridge, property));
+               config.addQemuOption("-netdev", "user,id=net0");
+               config.addQemuOption("-device", "virtio-net-pci,netdev=net0,mac="
+                               + varForm(VAR_MAC));
+
+               // Kernel IP argument
+               config.addKernelOption(getIP(isBridge, property));
+
+               // Kernel host ip argument
+               config.addKernelOption("host_ip", getHostIP(isBridge, property));
+
+               // Qemu net argument
+               if (isBridge) {
+                       String tapName = property.getPropertyValue()
+                                       .getAdvancedOptionValue(ItemName.NET_TAP_DEVICE);
+                       config.addQemuOption("-net", "tap,ifname=" + tapName + ",script=no,downscript=no");
+               }
+
+       }
+
+       private String getMacAddr(boolean isBridge, VMProperty property) {
+               /* get MAC address of host set as guest MAC address */
+               String macAddr = isBridge ? property.getPropertyValue()
+                               .getAdvancedOptionValue(ItemName.NET_MAC) : SettingInfoFile
+                               .getMACaddr();
+               if (macAddr.isEmpty()) {
+                       macAddr = "52:54:00:12:34:56";
+                       EMLogger.getLogger().log(Level.INFO,
+                                       String.format("MAC set as default = %s", macAddr));
+               }
+               return macAddr;
+       }
+
+       private String getIP(boolean isBridge, VMProperty prop) {
+               StringBuilder sb = new StringBuilder();
+               sb.append("ip=");
+               if (isBridge) {
+                       String useDHCP = prop.getPropertyValue().getAdvancedOptionSubValue(
+                                       ItemName.NET_IP_INFO, ItemName.NET_USE_DHCP);
+                       if (checkOn(useDHCP)) {
+                               return "";
+                       }
+
+                       sb.append(prop.getPropertyValue().getAdvancedOptionSubValue(
+                                       ItemName.NET_IP_INFO, ItemName.NET_IP));
+                       sb.append("::");
+                       sb.append(prop.getPropertyValue().getAdvancedOptionSubValue(
+                                       ItemName.NET_IP_INFO, ItemName.NET_GATEWAY));
+                       sb.append(":");
+                       sb.append(prop.getPropertyValue().getAdvancedOptionSubValue(
+                                       ItemName.NET_IP_INFO, ItemName.NET_SUBNET));
+                       sb.append("::eth0:none:");
+                       sb.append(prop.getPropertyValue().getAdvancedOptionValue(
+                                       ItemName.NET_DNS));
+
+               } else { // NAT (default)
+                       // sb.append("10.0.2.16::10.0.2.2:255.255.255.0::eth0:none:10.0.2.3");
+                       return "";
+               }
+               return sb.toString();
+       }
+
+       private String getHostIP(boolean isBridge, VMProperty property)
+                       throws VMWorkerException {
+               String hostIp = "10.0.2.2";
+               if (isBridge) {
+                       String bridgeIp = TapUtil.getBridgeIpAddr(property
+                                       .getPropertyValue().getAdvancedOptionValue(
+                                                       ItemName.NET_TAP_DEVICE));
+                       if (bridgeIp == null) {
+                               MessageDialog dialog = new MessageDialog();
+                               int res = dialog
+                                               .openInfoDialog("\nCannot find host(bridge) IP address."
+                                                               + "\nTo use bridge network, host IP is required."
+                                                               + "\nPlease input manually.");
+                               if (res != SWT.OK) {
+                                       throw new VMWorkerException("User canceled.");
+                               }
+
+                               // Input host IP address.
+                               String ip = IPAddressInputDialog
+                                               .open("Input host's IP address");
+                               if (ip == null) {
+                                       throw new VMWorkerException("User canceled.");
+
+                               } else {
+                                       hostIp = ip;
+                               }
+
+                       } else {
+                               hostIp = bridgeIp;
+                       }
+               }
+               return hostIp;
+       }
+
+       private String getNetArgument(boolean isBridge, VMProperty property) {
+               String netArgument;
+               if (isBridge) {
+                       String tapName = property.getPropertyValue()
+                                       .getAdvancedOptionValue(ItemName.NET_TAP_DEVICE);
+                       netArgument = "tap,ifname=" + tapName + ",script=no,downscript=no";
+
+               } else {
+                       netArgument = ("user,dhcpstart=10.0.2.16");
+               }
+               return netArgument;
+       }
+
+       @Override
+       public void checkArgument(VMProperty property) throws VMLauncherException {
+               boolean isBridge = property.getPropertyValue()
+                               .getAdvancedOptionValue(ItemName.NET_CONNECT_TYPE)
+                               .equals("Bridge")
+                               && (EmulatorManager.isLinux() || EmulatorManager.isWin());
+
+               if (isBridge) {
+                       String tapName = property.getPropertyValue()
+                                       .getAdvancedOptionValue(ItemName.NET_TAP_DEVICE);
+                       if (TapUtil.nameNotExist(tapName))
+                               throw new VMLauncherException((new StringBuilder())
+                                               .append("Tap device is not exist : ").append(tapName)
+                                               .append("\nCheck VM's tap configuration.").toString());
+                       if (isTapUsing(tapName))
+                               throw new VMLauncherException(
+                                               (new StringBuilder())
+                                                               .append("Tap device(")
+                                                               .append(tapName)
+                                                               .append(") is being used by other VM.")
+                                                               .append("\nPlease select another tap device for current VM.")
+                                                               .toString());
+                       String ipAddr = property.getPropertyValue()
+                                       .getAdvancedOptionSubValue(ItemName.NET_IP_INFO, "ipAddr");
+                       if (isIpAddrUsing(ipAddr))
+                               throw new VMLauncherException((new StringBuilder())
+                                               .append("VM's ip address(").append(ipAddr)
+                                               .append(") is being used by other VM.")
+                                               .append("\nPlease modify current VM's ip address.")
+                                               .toString());
+                       try {
+                               if (!TapUtil.isTapInBridge(tapName)) {
+                                       MessageDialog dialog = new MessageDialog();
+                                       int res = dialog
+                                                       .openWarningAndSelectionDialog("\nTap device is not connected with Bridge."
+                                                                       + "\nGuest network would work as NAT."
+                                                                       + "\nKeep launching ?");
+                                       if (res != SWT.OK) {
+                                               throw new VMLauncherException("User canceled.");
+                                       }
+                                       isBridge = false;
+                               }
+
+                       } catch (VMWorkerException e) {
+                               throw new VMLauncherException(e.getMessage());
+                       }
+               }
+       }
+
+       private boolean isTapUsing(String tapName) {
+               boolean isUsing = false;
+               for (VMProperty prop : EmulatorVMList.getInstance().getProperties()) {
+                       if (!prop.isRunning()) {
+                               continue;
+                       }
+                       String name = prop.getPropertyValue().getAdvancedOptionValue(
+                                       ItemName.NET_TAP_DEVICE);
+                       if (tapName.equals(name)) {
+                               isUsing = true;
+                               break;
+                       }
+               }
+
+               return isUsing;
+       }
+
+       private boolean isIpAddrUsing(String ipAddr) {
+               boolean isUsing = false;
+
+               for (VMProperty prop : EmulatorVMList.getInstance().getProperties()) {
+                       if (!prop.isRunning()) {
+                               continue;
+                       }
+                       String ip = prop.getPropertyValue().getAdvancedOptionSubValue(
+                                       ItemName.NET_IP_INFO, "ipAddr");
+                       if (!ipAddr.equals(ip)) {
+                               continue;
+                       }
+                       isUsing = true;
+                       break;
+               }
+
+               return isUsing;
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/Option.java b/common-project/src/org/tizen/emulator/manager/vms/option/Option.java
new file mode 100644 (file)
index 0000000..a799203
--- /dev/null
@@ -0,0 +1,107 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+
+public abstract class Option implements IOption {
+
+       public static String VAR_VM_NAME = "vm_name";
+       public static String VAR_VMS_PATH = "vms_path";
+       public static String VAR_SDK_PATH = "sdk_path";
+       public static String VAR_DRIVE = "drive";
+       public static String VAR_SWAP = "swap";
+       public static String VAR_SKIN_PATH = "skin_path";
+       public static String VAR_RESOLUTION = "resolution";
+       public static String VAR_PROCESS_NUM = "process_num";
+       public static String VAR_RAM = "ram";
+       public static String VAR_MAX_POINT = "max_point";
+       public static String VAR_SENSORS = "sensors";
+       public static String VAR_JACKS = "jacks";
+       public static String VAR_MAC = "mac";
+       public static String VAR_BIOS_PATH = "bios_path";
+       public static String VAR_KERNEL = "kernel";
+       public static String VAR_KERNEL_LOG = "kernel_log";
+       public static String VAR_APPEND = "append";
+
+       private static Map<Class<? extends IOption>, IOption> instanceMap = new HashMap<Class<? extends IOption>, IOption>();
+
+       public static <T> IOption getInstance(Class<? extends IOption> type) {
+               IOption opt = instanceMap.get(type);
+               if (opt == null) {
+                       try {
+                               opt = (IOption) type.newInstance();
+                               instanceMap.put(type, opt);
+
+                       } catch (InstantiationException e) {
+                               EMLogger.getLogger().log(Level.SEVERE, e.getMessage());
+
+                       } catch (IllegalAccessException e) {
+                               EMLogger.getLogger().log(Level.SEVERE, e.getMessage());
+                       }
+               }
+               return opt;
+       }
+
+
+       public static String varForm(String var) {
+               return "${" + var + "}";
+       }
+
+       public static boolean checkOnOff(String value) {
+               if (value.toLowerCase().equals("on")) {
+                       return true;
+               } else if (value.toLowerCase().equals("off")) {
+                       return false;
+               } else if (value.isEmpty()) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       public boolean checkOn(String value) {
+               if (value.toLowerCase().equals("on")) {
+                       return true;
+               }
+               return false;
+       }
+
+       // Each option can override this if validation is needed at launch time.
+       @Override
+       public void checkArgument(VMProperty property) throws VMLauncherException {
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/ProcessorOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/ProcessorOption.java
new file mode 100644 (file)
index 0000000..9796637
--- /dev/null
@@ -0,0 +1,84 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.eclipse.swt.SWT;
+import org.tizen.emulator.manager.tool.CheckVirtualization;
+import org.tizen.emulator.manager.ui.dialog.MessageDialog;
+import org.tizen.emulator.manager.vms.CPU;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+import org.tizen.emulator.manager.vms.xml.CpuType;
+
+public class ProcessorOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property) {
+               config.addVariable(VAR_PROCESS_NUM, String.valueOf(getCpuNum(property)));
+               config.addQemuOption("-smp", varForm(VAR_PROCESS_NUM));
+       }
+
+       @Override
+       public void checkArgument(VMProperty property) throws VMLauncherException {
+               // Check non-UG mode.
+               int cpu = getCpuNum(property);
+               if (CheckVirtualization.getInstance().isNonUG() && cpu > 1) {
+                       MessageDialog dialog = new MessageDialog();
+                       int response = dialog
+                                       .openWarningAndSelectionDialog("Using multi-processor option might cause VM slower"
+                                                       + "\nin non-UG platform."
+                                                       + "\n\n Do you want to continue launching anyway?");
+                       if (response != SWT.OK) {
+                               throw new VMLauncherException("User stops launching emulator.");
+                       }
+               }
+       }
+
+       private int getCpuNum(VMProperty property) {
+               CpuType cpuType = property.getConfiguration().getDevice().getCPU();
+               if (cpuType != null) {
+                       return cpuType.getValue().getValue();
+
+               } else {
+                       if (CheckVirtualization.getInstance().isNonUG()) {
+                               return 1;
+
+                       } else {
+                               // Get max CPU num.
+                               CPU cpu = CPU.values().get(CPU.values().size()-1);
+                               if (cpu.getValue() > 4 ) {
+                                       return 4;
+
+                               } else {
+                                       return cpu.getValue();
+                               }
+                       }
+               }
+       }
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/RamSizeOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/RamSizeOption.java
new file mode 100644 (file)
index 0000000..53f693e
--- /dev/null
@@ -0,0 +1,43 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class RamSizeOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property) {
+               int ramSize = property.getConfiguration().getDevice().getRAM()
+                               .getSize().getValue();
+               config.addVariable(VAR_RAM, String.valueOf(ramSize));
+               config.addQemuOption("-m", varForm(VAR_RAM));
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/RemoteOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/RemoteOption.java
new file mode 100644 (file)
index 0000000..de13711
--- /dev/null
@@ -0,0 +1,58 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.tizen.emulator.manager.console.RemoteManager;
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator;
+import org.tizen.emulator.manager.vms.helper.VMLauncherException;
+
+public class RemoteOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property)
+                       throws VMLauncherException {
+               if (RemoteManager.getSpiceMode()) {
+                       config.addSkinOption("hb.ignore", "true");
+               }
+
+               /* spice options */
+               if (RemoteManager.getSpiceMode()
+                               || CheckingRunningEmulator.isRemote(property)) {
+                       config.addQemuOption("-spice", "disable-ticketing");
+                       config.addQemuOption("-device",
+                                       "virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0");
+                       config.addQemuOption("-chardev", "spicevmc,id=vdagent,name=vdagent");
+                       config.addQemuOption(
+                                       "-device",
+                                       "virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,name=com.redhat.spice.0");
+               }
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/SuspendSupportOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/SuspendSupportOption.java
new file mode 100644 (file)
index 0000000..7aa87ba
--- /dev/null
@@ -0,0 +1,42 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class SuspendSupportOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property) {
+               if (property.getConfiguration().getUsability().isSupoortSuspend()) {
+                       config.addQemuOption("-enable-suspend");
+               }
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/TouchPointOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/TouchPointOption.java
new file mode 100644 (file)
index 0000000..acf5682
--- /dev/null
@@ -0,0 +1,48 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.xml.TouchType;
+
+public class TouchPointOption extends Option {
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property) {
+               TouchType touchType = property.getConfiguration().getDevice()
+                               .getTouch();
+               if (touchType != null) {
+                       config.addVariable(VAR_MAX_POINT,
+                                       String.valueOf(touchType.getMaxTouchPoint()));
+               }
+               config.addQemuOption("-device", "virtio-touchscreen-pci,max_point="
+                               + varForm(VAR_MAX_POINT));
+       }
+
+}
diff --git a/common-project/src/org/tizen/emulator/manager/vms/option/VMNameOption.java b/common-project/src/org/tizen/emulator/manager/vms/option/VMNameOption.java
new file mode 100644 (file)
index 0000000..231ca89
--- /dev/null
@@ -0,0 +1,42 @@
+/* Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho1206.park@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+package org.tizen.emulator.manager.vms.option;
+
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class VMNameOption extends Option{
+
+       @Override
+       public void getLaunchArgument(LaunchConfig config, VMProperty property) {
+               config.addVariable(VAR_VM_NAME, property.getPropertyValue().vmsName);
+               config.addKernelOption("vm_name", varForm(VAR_VM_NAME));
+       }
+
+}