- Applied launch config file.
- Applied emulator log redirection.
Change-Id: Id0e7357684c53bdd77b1ec62e8288404ae265707
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
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;
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();
}
}
- 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;
}
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;
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 {
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;
loadTemplate();
}
+ public List<IOption> getOptionList() {
+ return optionList;
+ }
+
+ public void setOptionList(List<IOption> optionList) {
+ this.optionList = optionList;
+ }
+
public VMProperty getDefaultProperty() {
return defaultProperty;
}
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;
this.binaryVersion = "";
initLastCreatedPropertyPath();
loadProperty();
+ createTemplate();
}
protected void initLastCreatedPropertyPath() {
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
}
}
}
+
+ 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;
+ }
}
}
}
+
private void loadSkins() {
Platform latest = null;
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
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;
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;
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));
}
}
}
//addProfile(p.getProfile());
}
}
-
}
}
}
// 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) {
EmulatorVMList vms = EmulatorVMList.getInstance();
vms.refreshProperties();
- for(Platform p : getPlatformList()) {
+ for (Platform p : getPlatformList()) {
p.clearVMs();
}
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())) {
} 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;
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;
} 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)) {
}
}
}
+
+ 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;
+ }
}
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";
pointList.add(ItemFactory);
pointList.add(VMButtonPainter);
pointList.add(VMWorker);
+ pointList.add(OptionFactory);
}
public static ArrayList<String> getPointList() {
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";
}
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));
+ }
}
}
}
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);
}
}
- 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);
}
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));
+ }
}
}
}
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);
}
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) {
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);
}
--- /dev/null
+/* 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";
+}
selection = min;
}
text.setText(String.valueOf(selection));
- text.selectAll();
+// text.selectAll();
}
public int getSelection() {
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;
settingProperty();
+ LaunchConfig.createLaunchConfig(property);
EmulatorVMList.getInstance().storeXML(property);
// Save last created property file.
EMLogger.getLogger().info("Success to create the " + property.getName() + " VM");
} catch (VMWorkerException e) {
+ deleteFolder(folder);
throw e;
} finally {
// lock.release
return property;
}
-
+
private void deleteFolder(File folder) {
if (folder.exists()) {
for (File dir : folder.listFiles()) {
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;
property.getConfiguration().getAdvancedOption().getOption().addAll(newVM.advancedOptionList);
}
+ property.setPropertyValue(newVM);
+ LaunchConfig.createLaunchConfig(property);
EmulatorVMList.getInstance().storeXML(property);
}
--- /dev/null
+/* 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;
+ }
+
+}
private boolean isRunning = false;
+ public void setPropertyValue(VMPropertyValue value) {
+ this.value = value;
+ }
+
@Override
public boolean equals(Object obj) {
if (obj == null) {
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() {
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;
}
}
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();
}
}
// 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();
}
}
- public void createNewBaseImage(VMProperty property, String dest) throws VMWorkerException {
+ public void createNewBaseImage(VMProperty property, String dest)
+ throws VMWorkerException {
// lock.acuire
WorkerLock.acquire();
// 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
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);
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) {
}
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) {
}
}
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();
*/
}
QemuImgProc proc;
boolean isError;
Object lock;
+
public WorkerThread(QemuImgProc proc, Object lock) {
this.proc = proc;
this.lock = lock;
}
//
- if (! proc.Running()) {
+ if (!proc.Running()) {
isError = true;
}
- synchronized(lock) {
+ synchronized (lock) {
if (file != null) {
file.delete();
}
// 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());
// 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()) {
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.");
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;
}
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;
}
// 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...");
}
}
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;
}
}
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");
}
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;
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 {
// 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;
}
/*
-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(); } }
+ */
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 {
} 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");
}
}
}
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);
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.");
}
});
}
// 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());
}
}
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);
}
count = c;
}
- @ Override
+ @Override
public void run() {
- synchronized(this) {
+ synchronized (this) {
try {
this.wait(1000 * count);
} catch (InterruptedException e) {
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);
e.printStackTrace();
}
}
- } while (CheckingRunningEmulator.isContains(emName));
+ } while (CheckingRunningEmulator.isContains(vmName));
} catch (IOException e) {
EMLogger.getLogger().info(e.getMessage());
} finally {
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;
}
--- /dev/null
+/* 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();
+ }
+ }
+ }
+}
--- /dev/null
+/* 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");
+ }
+
+}
--- /dev/null
+/* 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));
+
+ }
+
+}
--- /dev/null
+/* 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" ?
+ }
+}
--- /dev/null
+/* 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.");
+ }
+ }
+ }
+
+}
--- /dev/null
+/* 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.");
+ }
+ }
+ }
+
+}
--- /dev/null
+/* 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;
+
+}
--- /dev/null
+/* 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);
+}
--- /dev/null
+/* 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) {
+
+ }
+}
--- /dev/null
+/* 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;
+ }
+}
--- /dev/null
+/* 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;
+ }
+
+}
--- /dev/null
+/* 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 {
+ }
+
+}
--- /dev/null
+/* 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();
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/* 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));
+ }
+
+}
--- /dev/null
+/* 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");
+ }
+ }
+
+}
--- /dev/null
+/* 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");
+ }
+ }
+
+}
--- /dev/null
+/* 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));
+ }
+
+}
--- /dev/null
+/* 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));
+ }
+
+}