- Host proxy option is changed to set on emulator launch time.
(Launch config file's variable is overrided at launch time)
- Added double quotation mark at drive option.
Change-Id: Ie3b73aaf24f6843c70d959a986c6e516302dc39c
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
import org.tizen.emulator.manager.vms.helper.VMLogUtil;
import org.tizen.emulator.manager.vms.helper.VMWorkerException;
import org.tizen.emulator.manager.vms.option.LaunchConfig;
+import org.tizen.emulator.manager.vms.option.NetProxyOption;
+import org.tizen.emulator.manager.vms.option.Option;
public class VMLauncher {
}
List<String> cmd = new ArrayList<String>();
- String emulatorCmd = binaryPath + " --conf " + configPath;
+ String emulatorCmd = binaryPath + " --conf " + configPath
+ + getProxyArgument(property);
if (EmulatorManager.isWin()) {
cmd.add("cmd");
cmd.add("/c");
cmd.add("/bin/sh");
cmd.add("-c");
}
+ // Add log redirection to command.
+ cmd.add(emulatorCmd + getLogRedirectCmd(property.getName()));
+
System.out.println("Launch command : " + emulatorCmd);
EMLogger.getLogger().log(Level.INFO, "Starting Emulator Command : ");
EMLogger.getLogger().log(Level.INFO, emulatorCmd);
- // Add log redirection to command.
- cmd.add(emulatorCmd + " > " + VMLogUtil.getEmulatorLogPath(property.getName()) + " 2>&1");
return cmd;
}
+ private static String getProxyArgument(VMProperty property) {
+ String hostProxy = NetProxyOption.getHostProxyCmd(property);
+ if (hostProxy.isEmpty()) {
+ return "";
+
+ } else {
+ return " --" + Option.VAR_NETWORK_PROXY
+ + " \"" + hostProxy + "\"";
+ }
+ }
+
+ private static String getLogRedirectCmd(String vmName) {
+ return " > " + VMLogUtil.getEmulatorLogPath(vmName) + " 2>&1";
+ }
+
private static void checkDiskImage(VMProperty property)
throws VMLauncherException {
// check disk image
@Override
public void getLaunchArgument(LaunchConfig config, VMProperty property) {
- config.addVariable(VAR_DRIVE, "file="
+ config.addVariable(VAR_DRIVE, "\"file="
+ property.getConfiguration().getBaseInformation()
.getDiskImage().getCurrentDiskImage().getValue()
- + ",if=virtio,index=1,cache.no-flush=on");
- config.addVariable(VAR_SWAP, "file="
+ + ",if=virtio,index=1,cache.no-flush=on\"");
+ config.addVariable(VAR_SWAP, "\"file="
+ property.getConfiguration().getBaseInformation()
.getDiskImage().getSwapDiskImage().getValue()
- + ",if=virtio,index=2");
+ + ",if=virtio,index=2\"");
config.addQemuOption("-drive", varForm(VAR_DRIVE) + ",id=drive");
config.addQemuOption("-drive", varForm(VAR_SWAP) + ",id=swap");
List<String> qemuOptions = new ArrayList<String>();
List<String> kernelOptions = new ArrayList<String>();
Map<String, String> variables = new HashMap<String, String>();
+ Map<String, String> varComment = new HashMap<String, String>();
public static String DEFAULT_VALUE = "[[VARIABLES]]";
public static String SKIN_OPTIONS = "[[SKIN_OPTIONS]]";
variables.put(key, value);
}
+ public void addVariable(String key, String value, String comment) {
+ if (comment != null && !comment.isEmpty()) {
+ varComment.put(key, comment);
+ }
+ addVariable(key, value);
+ }
+
public void addQemuOption(String option) {
qemuOptions.add(option);
}
// Write variables
bw.write(DEFAULT_VALUE);
bw.newLine();
+ String comment = null;
for (String str : variables.keySet()) {
+ if ( (comment = varComment.get(str)) != null) {
+ bw.write(comment);
+ bw.newLine();
+ }
bw.write(str + "=" + variables.get(str));
bw.newLine();
}
public class NetProxyOption extends Option {
- @Override
- public void getLaunchArgument(LaunchConfig config, VMProperty property)
- throws VMWorkerException {
- String proxyArgument = getProxy(property);
- if (!proxyArgument.isEmpty()) {
- config.addVariable(VAR_NETWORK_PROXY, proxyArgument);
- config.addKernelOption(varForm(VAR_NETWORK_PROXY));
+ public static String hostProxy = "";
+ public static final String PROXY_COMMENT = "# network_proxy : use host's proxy configuration \n"
+ + "# (only if VM's proxy option is set as using host proxy)";
+ static {
+ try {
+ hostProxy = getHostProxy();
+ } catch (VMWorkerException e) {
+ EMLogger.getLogger().info("Failed to get host proxy :" + e.getMessage());
}
}
- private String getProxy(VMProperty property) throws VMWorkerException {
- String proxyConfig = "";
+ public static String getHostProxyCmd(VMProperty property) {
String proxyMode = property.getPropertyValue()
.getAdvancedOptionSubValue(ItemName.NET_PROXY,
NetProxyViewItem.ITEM_PROXY_MODE);
if (proxyMode.equals(NetProxyViewItem.MODE_AUTO)) {
- proxyConfig = getHostProxy(property.getPropertyValue().version);
-
- } 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 hostProxy;
+ }
+
+ return "";
+ }
+
+ @Override
+ public void getLaunchArgument(LaunchConfig config, VMProperty property)
+ throws VMWorkerException {
+ String proxyMode = property.getPropertyValue()
+ .getAdvancedOptionSubValue(ItemName.NET_PROXY,
+ NetProxyViewItem.ITEM_PROXY_MODE);
+
+ String comment = null;
+ String proxyConfig;
+ if (NetProxyViewItem.MODE_AUTO.equals(proxyMode)) {
+ comment = PROXY_COMMENT;
+ proxyConfig = "";
+
+ } else if (NetProxyViewItem.MODE_MANUAL.equals(proxyMode)) {
+ proxyConfig = getManualProxy(property);
+
+ } else { // Proxy is not used
+ proxyConfig = null;
}
- return proxyConfig;
+
+ if (proxyConfig != null) {
+ config.addVariable(VAR_NETWORK_PROXY, "\"" + proxyConfig + "\"", comment);
+ config.addKernelOption(varForm(VAR_NETWORK_PROXY));
+ }
+ }
+
+ private String getManualProxy(VMProperty property) {
+ return "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);
}
- private String getHostProxy(String platformVersion) throws VMWorkerException {
+ public static String getHostProxy() throws VMWorkerException {
String result = null;
String proxyCommand = "check-net";
if (EmulatorManager.isWin()) {