structure: Modified emulator tools file path.
authorminkee.lee <minkee.lee@samsung.com>
Tue, 12 May 2015 08:19:21 +0000 (17:19 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 13 May 2015 05:44:14 +0000 (14:44 +0900)
- Path for check-xxx should be changed later.(tools/emulator/bin)

Change-Id: Ifecad5b01eaf84ab1ae2c854db559f4f9012f2dc
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
12 files changed:
common-project/src/org/tizen/emulator/manager/console/ActionList.java
common-project/src/org/tizen/emulator/manager/resources/FilePathResources.java
common-project/src/org/tizen/emulator/manager/tool/CheckVirtualization.java
common-project/src/org/tizen/emulator/manager/tool/TapUtil.java
common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetTapDeviceViewItemWin.java
common-project/src/org/tizen/emulator/manager/ui/dialog/TapDeviceDialogForWin.java
common-project/src/org/tizen/emulator/manager/vms/Creator.java
common-project/src/org/tizen/emulator/manager/vms/VMLauncher.java
common-project/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java
common-project/src/org/tizen/emulator/manager/vms/helper/QemuImgProc.java
common-project/src/org/tizen/emulator/manager/vms/option/CommonOption.java
common-project/src/org/tizen/emulator/manager/vms/option/NetProxyOption.java

index cc3958c..3b44c5e 100644 (file)
@@ -687,7 +687,7 @@ class Launch extends Action {
                commandList.add(new Command("n", Actions.OP_NAME,
                                Actions.DESC_LAUNCH_NAME,"", true, true));
                commandList.add(new Command("p", Actions.OP_PATH,
-                               Actions.DESC_LAUNCH_PATH, FilePathResources.getBinPath(), false, true));
+                               Actions.DESC_LAUNCH_PATH, FilePathResources.getEmulatorBinPath(""), false, true));
                commandList.add(new Command("t", Actions.OP_TEST,
                                Actions.DESC_TEST, "", false, false));
                /*
index 4a0bf10..9336197 100644 (file)
@@ -364,16 +364,24 @@ public class FilePathResources {
                return getEmulatorDataPath(platformVersion) + bios_suffix;
        }
 
-       public static String getEmulatorQemuImgPath(String platformVersion) {
-               return getEmulatorBinPath(platformVersion) + qemuImg_suffic;
+       public static String getEmulatorQemuImgPath() {
+               return getEmulatorToolPath() + qemuImg_suffic;
        }
 
        public static String getEmulatorDataPath(String platformVersion) {
                return getEmulatorPath(platformVersion) + data_suffix;
        }
 
+       public static String getEmulatorToolPath() {
+               // TODO return /tools/emulator/bin
+               return getEmulatorPath("2.4") + bin_suffix;
+       }
+
        public static String getEmulatorPath(String platformVersion) {
                String emulatorPath;
+               if (platformVersion == null || platformVersion.isEmpty()) {
+                       platformVersion = "2.4"; // TODO Get lastest version.
+               }
                try {
                        emulatorPath = new File(platformsPath + platform_prefix
                                        + platformVersion + common_suffix + emulator_suffix).getCanonicalPath();
index d8dfb22..0dea550 100644 (file)
@@ -152,10 +152,10 @@ public class CheckVirtualization {
                                int exitValue = 1;
 
                                List<String> cmd = new ArrayList<String>();
-                               cmd.add(FilePathResources.getBinPath() + File.separator +
+                               cmd.add(FilePathResources.getEmulatorToolPath() + File.separator +
                                                (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1 ? "check-hax.exe" : "check-hax"));
                                ProcessBuilder pb = new ProcessBuilder(cmd);
-                               pb.directory(new File(FilePathResources.getBinPath()));
+                               pb.directory(new File(FilePathResources.getEmulatorToolPath()));
 
                                try {
                                        Process process = pb.start();
@@ -208,10 +208,10 @@ public class CheckVirtualization {
                        int exitValue = 1;
 
                        List<String> cmd = new ArrayList<String>();
-                       cmd.add(FilePathResources.getBinPath() + File.separator +
+                       cmd.add(FilePathResources.getEmulatorToolPath() + File.separator +
                                        (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1 ? "check-gl.exe" : "check-gl"));
                        ProcessBuilder pb = new ProcessBuilder(cmd);
-                       pb.directory(new File(FilePathResources.getBinPath()));
+                       pb.directory(new File(FilePathResources.getEmulatorToolPath()));
 
                        try {
                                Process process = pb.start();
index c9640f8..c5d228a 100644 (file)
@@ -63,7 +63,12 @@ import com.sun.jna.platform.win32.WinReg.HKEY;
 import com.sun.jna.platform.win32.WinReg.HKEYByReference;
 
 public class TapUtil {
-       private static String devconPath = FilePathResources.getBinPath() + File.separator + "devcon.exe";
+
+       public static String getDevconPath(String platformVersion) {
+               return FilePathResources.getEmulatorBinPath(platformVersion)
+                               + File.separator + "devcon.exe";
+       }
+
        public static String getBridgeFromDevice(String device)
                        throws VMWorkerException {
 
@@ -918,13 +923,13 @@ public class TapUtil {
        }
 
        public static void createTapDevice(String tapName, String ifName,
-                       ComboViewItem comboViewItem) {
+                       ComboViewItem comboViewItem, String platformVersion) {
                if (EmulatorManager.isWin()) {
                        MessageDialog msgDialog = new MessageDialog();
                        msgDialog
                                        .openNoButtonInfoDialog("Creating tap device.\nThis will take minutes..");
                        TapCreateWorker worker = new TapCreateWorker(tapName, ifName,
-                                       msgDialog, comboViewItem);
+                                       msgDialog, comboViewItem, platformVersion);
                        worker.start();
                }
 
@@ -1040,7 +1045,7 @@ public class TapUtil {
        public static boolean isWinBridgeExist() {
                String proxyCommand = "check-net.exe";
                boolean isExist = false;
-               List<String> cmd = Arrays.asList(FilePathResources.getBinPath()
+               List<String> cmd = Arrays.asList(FilePathResources.getEmulatorToolPath()
                                + File.separator + proxyCommand, "--bridge");
                ProcessResult res = HelperClass.runProcess(cmd);
                boolean isCommandSuccess = false;
@@ -1163,13 +1168,15 @@ public class TapUtil {
                final String tapName;
                final String ifName;
                final ComboViewItem comboViewItem; // for refresh combo-list
+               final String platformVersion;
 
                public TapCreateWorker(String tapName, String ifName,
-                               MessageDialog dialog, ComboViewItem comboViewItem) {
+                               MessageDialog dialog, ComboViewItem comboViewItem, String platformVersion) {
                        this.dialog = dialog;
                        this.tapName = tapName;
                        this.ifName = ifName;
                        this.comboViewItem = comboViewItem;
+                       this.platformVersion = platformVersion;
                }
 
                @Override
@@ -1185,7 +1192,7 @@ public class TapUtil {
                                if (!EmulatorManager.isWin8()) {
                                        EMLogger.getLogger().info(
                                                        "get CompatibleIDs from pci network device");
-                                       cmd = Arrays.asList(devconPath, "find", "=net",
+                                       cmd = Arrays.asList(getDevconPath(platformVersion), "find", "=net",
                                                        "@pci*");
                                        res = HelperClass.runProcess(cmd);
                                        boolean isCommandSuccess = false;
@@ -1208,7 +1215,7 @@ public class TapUtil {
                                                // Create Bridge device and set IP
                                                EMLogger.getLogger().info("create bridge");
                                                cmd = Arrays
-                                                               .asList(devconPath,
+                                                               .asList(getDevconPath(platformVersion),
                                                                                "install",
                                                                                "c:\\windows\\inf\\netbrdgm.inf",
                                                                                "ms_bridgemp");
@@ -1218,7 +1225,7 @@ public class TapUtil {
                                                }
 
                                                EMLogger.getLogger().info("bind interface to bridge");
-                                               cmd = Arrays.asList(FilePathResources.getBinPath()
+                                               cmd = Arrays.asList(FilePathResources.getEmulatorBinPath(platformVersion)
                                                                + File.separator + "bindbridge.exe",
                                                                "ms_bridge", CompatibleIDs, "bind");
                                                res = HelperClass.runProcess(cmd);
@@ -1238,8 +1245,8 @@ public class TapUtil {
 
                                // Create new tap
                                EMLogger.getLogger().info("Create new tap.");
-                               cmd = Arrays.asList(devconPath, "install",
-                                               FilePathResources.getBinPath() + File.separator
+                               cmd = Arrays.asList(getDevconPath(platformVersion), "install",
+                                               FilePathResources.getEmulatorBinPath(platformVersion) + File.separator
                                                                + "OemWin2k.inf", "Tap0901");
                                res = HelperClass.runProcess(cmd);
 
@@ -1285,7 +1292,7 @@ public class TapUtil {
                                        EMLogger.getLogger().info("bind host network to bridge");
                                        String tapPnpInstanceID = getPnpInstanceIDFromName(tapName);
 
-                                       cmd = Arrays.asList(FilePathResources.getBinPath()
+                                       cmd = Arrays.asList(FilePathResources.getEmulatorBinPath(platformVersion)
                                                        + File.separator + "bindbridge.exe", "ms_bridge",
                                                        tapPnpInstanceID, "bind");
                                        res = HelperClass.runProcess(cmd);
@@ -1296,7 +1303,7 @@ public class TapUtil {
                                        EMLogger.getLogger().info(
                                                        "wait while finishing bridged network setting");
                                        String proxyCommand = "check-net.exe";
-                                       cmd = Arrays.asList(FilePathResources.getBinPath()
+                                       cmd = Arrays.asList(FilePathResources.getEmulatorToolPath()
                                                        + File.separator + proxyCommand, "--bridge");
                                        res = HelperClass.runProcess(cmd);
                                        while (!res.getStdOutMsg().isEmpty()) {
index e01365b..f00af9b 100644 (file)
@@ -67,6 +67,7 @@ public class NetTapDeviceViewItemWin extends ComboViewItem {
 
        boolean isBridge = false;
        NetTapDeviceViewItemWin thisItem;
+       String platformVersion = "";
 
        public NetTapDeviceViewItemWin(Item template,
                        LineLabelViewItem lineLabelViewItem) {
@@ -152,7 +153,7 @@ public class NetTapDeviceViewItemWin extends ComboViewItem {
 
                        @Override
                        public void widgetSelected(SelectionEvent arg0) {
-                               TapDeviceDialogForWin.open(thisItem);
+                               TapDeviceDialogForWin.open(thisItem, platformVersion);
                                resetCombo(NetConnectTypeViewItem.VALUE_BRIDGE);
                        }
 
@@ -166,6 +167,7 @@ public class NetTapDeviceViewItemWin extends ComboViewItem {
        @Override
        public boolean settingModifyItem(VMPropertyValue value) {
                oldValue = newValue = value.getAdvancedOptionValue(name);
+               platformVersion = value.version;
                // text.setText(newValue);
 
                AdvancedViewItem item = lineLabelViewItem
index 2e744b6..58cd688 100644 (file)
@@ -82,12 +82,13 @@ public class TapDeviceDialogForWin {
        private static String ifName;
 
        private static ComboViewItem comboViewItem;
+       private static String platformVersion;
 
        public static ArrayList<String> getInterfaceList() {
                // Get intereface list
                ProcessResult res;
                ArrayList<String> ifList = new ArrayList<String>();
-               List<String> cmd = Arrays.asList(FilePathResources.getBinPath()
+               List<String> cmd = Arrays.asList(FilePathResources.getEmulatorBinPath(platformVersion)
                                + File.separator + "devcon.exe", "find", "=net", "@pci*");
                res = HelperClass.runProcess(cmd);
                boolean isCommandSuccess = false;
@@ -109,8 +110,9 @@ public class TapDeviceDialogForWin {
                return ifList;
        }
 
-       public static void open(ComboViewItem comboViewItem) {
+       public static void open(ComboViewItem comboViewItem, String platformVersion) {
                TapDeviceDialogForWin.comboViewItem = comboViewItem;
+               TapDeviceDialogForWin.platformVersion = platformVersion;
                makeDialog();
                dialog.open();
                while (!dialog.isDisposed()) {
@@ -291,7 +293,7 @@ public class TapDeviceDialogForWin {
                                }
                                dialog.close();
 
-                               TapUtil.createTapDevice(tapName, ifName, comboViewItem);
+                               TapUtil.createTapDevice(tapName, ifName, comboViewItem, platformVersion);
 
                                // } else {
                                // new MessageDialog().openWarningDialog("Name already exist.");
index 7a7b021..c8145f8 100644 (file)
@@ -278,17 +278,18 @@ public class Creator {
                ec.getBaseInformation().setDiskImage(factory.createBaseInformationTypeDiskImage());
                if (newVM.isStandard) {
                        ec.getBaseInformation().getDiskImage().setType("standard");
-                       // TODO : get version
-                       if (newVM.version != null) {
-                               ec.getBaseInformation().getDiskImage().setVersion(newVM.version);
-                       } else {
-                               // TODO : temp name
-                               ec.getBaseInformation().getDiskImage().setVersion("Standard");
-                       }
                } else {
                        ec.getBaseInformation().getDiskImage().setType("custom");
                        ec.getBaseInformation().setArchitecture(EmulatorVMList.getInstance().CustomArch);
                }
+
+               // TODO : get version
+               if (newVM.version != null) {
+                       ec.getBaseInformation().getDiskImage().setVersion(newVM.version);
+               } else {
+                       // TODO : temp name
+                       ec.getBaseInformation().getDiskImage().setVersion("Standard");
+               }
                if (newVM.baseName != null) {
                        ec.getBaseInformation().getDiskImage().setBase(newVM.baseName);
                }
@@ -300,6 +301,8 @@ public class Creator {
                // TODO :
                ec.getBaseInformation().getDiskImage().getBaseDiskImage().setFormat("qcow2");
                ec.getBaseInformation().getDiskImage().getBaseDiskImage().setValue(newVM.baseImagePath);
+               ec.getBaseInformation().getDiskImage().setBase(newVM.baseName);
+
                if (!newVM.baseImage.getBinaryVersion().isEmpty()) {
                        ec.getBaseInformation().getDiskImage().getBaseDiskImage().setVersion(newVM.baseImage.getBinaryVersion());
                }
@@ -401,7 +404,7 @@ public class Creator {
 
        private String getQemuImgPath() {
 //             return FilePathResources.getBinPath() + File.separator + "qemu-img";
-               return FilePathResources.getEmulatorQemuImgPath(newVM.version);
+               return FilePathResources.getEmulatorQemuImgPath();
        }
 
 }
index 956c8da..0fd996b 100644 (file)
@@ -66,7 +66,8 @@ public class VMLauncher {
 
                CheckingRunningEmulator.addEmulator(property);
                MonitoringEmulator monitor = new MonitoringEmulator(property);
-               Process process = launch(property.getName(), cmd, path);
+               Process process = launch(property.getName(), property.getPropertyValue().version,
+                               cmd, path);
                if (process != null) {
                        monitor.setProcess(process);
                        monitor.start();
@@ -102,8 +103,8 @@ public class VMLauncher {
 
        private static List<String> getCommand(VMProperty property)
                        throws VMLauncherException {
-               String binaryPath = FilePathResources.getBinPath() + File.separator
-                               + getBinary(property.getArch().toString());
+               String binaryPath = FilePathResources.getEmulatorBinPath(property.getPropertyValue().version)
+                               + File.separator + getBinary(property.getArch().toString());
                String configPath = LaunchConfig
                                .getLaunchConfigPath(property.getName());
                if (!new File(configPath).exists()) {
@@ -165,7 +166,8 @@ public class VMLauncher {
                return binary;
        }
 
-       public static Process launch(String vmName, List<String> cmd, String binPath) {
+       public static Process launch(String vmName, String platformVersion,
+                       List<String> cmd, String binPath) {
                ProcessBuilder pb = new ProcessBuilder(cmd);
 
                // Make backup log.
@@ -177,7 +179,7 @@ public class VMLauncher {
                        String value = env.get("LD_LIBRARY_PATH");
                        env.put("LD_LIBRARY_PATH",
                                        ((value == null) ? "" : value + ":")
-                                                       + FilePathResources.getBinPath() + ":"
+                                                       + FilePathResources.getEmulatorBinPath(platformVersion) + ":"
                                                        + FilePathResources.getRemotePath()
                                                        + File.separator + "lib:");
                        EMLogger.getLogger().log(Level.INFO,
@@ -185,7 +187,7 @@ public class VMLauncher {
                }
 
                if (binPath == null || binPath.isEmpty()) {
-                       pb.directory(new File(FilePathResources.getBinPath()));
+                       pb.directory(new File(FilePathResources.getEmulatorBinPath(platformVersion)));
                } else {
                        pb.directory(new File(binPath));
                }
index 7b727a9..6a58aee 100644 (file)
@@ -230,7 +230,7 @@ public class VMWorkerCommon {
                                                + baseImage.getAbsolutePath());
                        }
 
-                       String exe_path = FilePathResources.getEmulatorQemuImgPath(property.getPropertyValue().version);
+                       String exe_path = FilePathResources.getEmulatorQemuImgPath();
 
                        List<String> cmd = new ArrayList<String>();
                        cmd.add(exe_path);
index da70ed2..cc7aba7 100644 (file)
@@ -54,7 +54,7 @@ public class QemuImgProc {
 
                isError  = false;
                ProcessBuilder pb = new ProcessBuilder(cmd);
-               pb.directory(new File(FilePathResources.getBinPath()));
+               pb.directory(new File(FilePathResources.getEmulatorToolPath()));
                try {
                        Process process = pb.start();
                        if (process != null) {
@@ -162,7 +162,7 @@ public class QemuImgProc {
 
                isError  = false;
                ProcessBuilder pb = new ProcessBuilder(cmd);
-               pb.directory(new File(FilePathResources.getBinPath()));
+               pb.directory(new File(FilePathResources.getEmulatorToolPath()));
                try {
                        Process process = pb.start();
                        if (process != null) {
index 34fae55..04b7f8b 100644 (file)
@@ -58,12 +58,13 @@ public class CommonOption extends Option {
                        config.addQemuOption("-device virtconsole,chardev=con1");
                }
 
+               String platformVersion = property.getPropertyValue().version;
                // bios
-               config.addVariable(VAR_BIOS_PATH, FilePathResources.getBiosPath());
+               config.addVariable(VAR_BIOS_PATH, FilePathResources.getEmulatorBiosPath(platformVersion));
                config.addQemuOption("-L", varForm(VAR_BIOS_PATH));
 
                // kernel image
-               config.addVariable(VAR_KERNEL, FilePathResources.getKernelPath()
+               config.addVariable(VAR_KERNEL, FilePathResources.getEmulatorKernelPath(platformVersion)
                                + File.separator + "bzImage." + property.getArch().toString());
                config.addQemuOption("-kernel", varForm(VAR_KERNEL));
 
index 602127a..4213130 100644 (file)
@@ -62,7 +62,7 @@ public class NetProxyOption extends Option {
                                .getAdvancedOptionSubValue(ItemName.NET_PROXY,
                                                NetProxyViewItem.ITEM_PROXY_MODE);
                if (proxyMode.equals(NetProxyViewItem.MODE_AUTO)) {
-                       proxyConfig = getHostProxy();
+                       proxyConfig = getHostProxy(property.getPropertyValue().version);
 
                } else if (proxyMode.equals(NetProxyViewItem.MODE_MANUAL)) {
                        proxyConfig = "http_proxy="
@@ -86,14 +86,14 @@ public class NetProxyOption extends Option {
 
        }
 
-       private String getHostProxy() throws VMWorkerException {
+       private String getHostProxy(String platformVersion) throws VMWorkerException {
                String result = null;
                String proxyCommand = "check-net";
                if (EmulatorManager.isWin()) {
                        proxyCommand = "check-net.exe";
                }
 
-               List<String> cmd = Arrays.asList(FilePathResources.getBinPath()
+               List<String> cmd = Arrays.asList(FilePathResources.getEmulatorToolPath()
                                + File.separator + proxyCommand, "--proxy");
                ProcessResult res = HelperClass.runProcess(cmd);
                boolean isCommandSuccess = false;