package org.tizen.emulator.manager.vms;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.EmulatorManager.ManagerModeType;
+import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.tool.About;
import org.tizen.emulator.manager.tool.FileIO;
import org.tizen.emulator.manager.vms.VMsProperty.Architecture;
ProcessBuilder pb = new ProcessBuilder(cmd);
try {
- pb.start();
+ Process process = pb.start();
+
+ if (process != null) {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(process.getErrorStream()));
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ String str = null;
+ do {
+ str = in.readLine();
+ if (str!= null) {
+ EMLogger.getLogger().log(Level.WARNING,
+ "Error while running qemu-img\n" + str);
+ }
+ } while (str != null);
+ } catch (IOException e) {
+ EMLogger.getLogger().log(Level.WARNING,
+ "Error while running qemu-img\n" + e.getMessage());
+ }
+ }
+ }).start();
+
+ // wait for ending process
+ try {
+ if (process.waitFor() != 0){
+ throw new VMsCreatorException("Failed to create the VM because of failed qemu-img processing.\n"
+ + "You can get more information in log file ("
+ + FileIO.getInstance().getTizenVmsArchPath() + File.separator + "emulator-manager)");
+ }
+ } catch (InterruptedException e) {
+ throw new VMsCreatorException("Failed to create the VM while running qemu-img.\n" + e.getMessage());
+ }
+ }
} catch (IOException e) {
throw new VMsCreatorException("Failed to create the VM!\n" + e.getMessage());
}