emulator: introduced "--qemu" argument
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 31 Jul 2015 05:29:16 +0000 (14:29 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 3 Aug 2015 05:52:42 +0000 (14:52 +0900)
"--qemu" can be used by expert users. All args followed by "--qemu"
are passed to qemu directly.
So, we can use "help" using additional args "--qemu -help".

Change-Id: Ia2ae1a28a49b8d109906d0e240272bc50789fba2
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/emulator.c
vl.c

index 4909ab286e48760d389945cdd5bd9f3249bf021e..dd3854dc61afdbee4f86051104832ccafc469078 100644 (file)
@@ -185,11 +185,13 @@ static void print_options_info(void)
     fprintf(stdout, "\n====================================================\n");
 
 #if defined(CONFIG_JAVA_UI)
-    fprintf(stdout, "skin args: =========================================\n");
-    for (i = 0; i < _skin_argc; ++i) {
-        fprintf(stdout, "%s ", _skin_argv[i]);
+    if (_skin_argc > 0) {
+        fprintf(stdout, "skin args: =========================================\n");
+        for (i = 0; i < _skin_argc; ++i) {
+            fprintf(stdout, "%s ", _skin_argv[i]);
+        }
+        fprintf(stdout, "\n====================================================\n");
     }
-    fprintf(stdout, "\n====================================================\n");
 #endif
 
     fflush(stdout);
@@ -200,6 +202,7 @@ static void prepare_basic_features(gchar * const kernel_cmdline)
 {
     gchar * tmp_str;
 
+    LOG_INFO("Prepare_basic_features\n");
     set_base_port();
     tmp_str = g_strdup_printf(" sdb_port=%d,"
             " vm_resolution=%dx%d", get_emul_vm_base_port(),
@@ -213,9 +216,16 @@ const char *prepare_maru(const gchar * const kernel_cmdline)
 {
     LOG_INFO("Prepare maru specified feature\n");
 
+    atexit(maru_atexit);
+    emulator_add_exit_notifier(&emulator_exit);
+
+    socket_init();
+
+    print_system_info();
+
     g_strlcpy(maru_kernel_cmdline, kernel_cmdline, LEN_MARU_KERNEL_CMDLINE);
+
     /* Prepare basic features */
-    LOG_INFO("Prepare_basic_features\n");
     prepare_basic_features(maru_kernel_cmdline);
 
     LOG_INFO("kernel command : %s\n", maru_kernel_cmdline);
@@ -226,6 +236,7 @@ const char *prepare_maru(const gchar * const kernel_cmdline)
 void prepare_maru_after_device_init(void)
 {
     make_vm_lock_os();
+    set_qemu_input_mode();
     maru_device_hotplug_init();
     start_ecs();
     start_sdb_noti_server(get_emul_vm_base_port() + SDB_UDP_SENSOR_INDEX);
@@ -258,6 +269,7 @@ static int emulator_main(int argc, char *argv[], char **envp)
 #endif
 
     int c = 0;
+    int qemu_arg_index = 0;
 
     _qemu_argv = g_malloc(sizeof(char*) * ARGS_LIMIT);
 #if defined(CONFIG_JAVA_UI)
@@ -271,10 +283,11 @@ static int emulator_main(int argc, char *argv[], char **envp)
     while (c != -1) {
         static struct option long_options[] = {
             {"conf",        required_argument,  0,  'c' },
+            {"qemu",        required_argument,  0,  'q' },
             {0,             0,                  0,  0   }
         };
 
-        c = getopt_long(argc, argv, "c:", long_options, NULL);
+        c = getopt_long(argc, argv, "c:q:", long_options, NULL);
 
         if (c == -1)
             break;
@@ -286,12 +299,16 @@ static int emulator_main(int argc, char *argv[], char **envp)
         case 'c':
             launch_conf_file = g_strdup(optarg);
             break;
+        case 'q':
+            c = -1;
+            qemu_arg_index = optind - 1;
+            break;
         default:
             break;
         }
     }
 
-    if (!launch_conf_file) {
+    if (!launch_conf_file && qemu_arg_index == 0) {
         fprintf(stderr, "Usage: %s {-c|--conf} conf_file ...\n",
                         basename(argv[0]));
 
@@ -304,66 +321,64 @@ static int emulator_main(int argc, char *argv[], char **envp)
 
     set_bin_path_os(_qemu_argv[0]);
 
-    if (!load_conf(launch_conf_file)) {
-        return -1;
-    }
-
-    // set emulator resolution
-    {
-        char *resolution = get_variable("resolution");
-        if (!resolution) {
-            fprintf(stderr, "[resolution] is required.\n");
+    if (launch_conf_file) {
+        if (!load_conf(launch_conf_file)) {
             return -1;
         }
-        char **splitted = g_strsplit(resolution, "x", 2);
-        if (!splitted[0] || !splitted[1]) {
-            fprintf(stderr, "resolution value [%s] is weird. Please use format \"WIDTHxHEIGHT\"\n", resolution);
+
+        // set emulator resolution
+        {
+            char *resolution = get_variable("resolution");
+            if (!resolution) {
+                fprintf(stderr, "[resolution] is required.\n");
+                return -1;
+            }
+            char **splitted = g_strsplit(resolution, "x", 2);
+            if (!splitted[0] || !splitted[1]) {
+                fprintf(stderr, "resolution value [%s] is weird. Please use format \"WIDTHxHEIGHT\"\n", resolution);
+                g_strfreev(splitted);
+                return -1;
+            }
+            else {
+                set_emul_resolution(g_ascii_strtoull(splitted[0], NULL, 0),
+                        g_ascii_strtoull(splitted[1], NULL, 0));
+            }
             g_strfreev(splitted);
-            return -1;
-        }
-        else {
-            set_emul_resolution(g_ascii_strtoull(splitted[0], NULL, 0),
-                            g_ascii_strtoull(splitted[1], NULL, 0));
         }
-        g_strfreev(splitted);
-    }
 
-    // assemble arguments for qemu and skin
+        // assemble arguments for qemu and skin
 #ifdef SUPPORT_SKIN_OPTIONS
-    if (!assemble_emulator_args(&_qemu_argc, _qemu_argv,
-                        &_skin_argc, _skin_argv)) {
-        return -1;
-    }
+        if (!assemble_emulator_args(&_qemu_argc, _qemu_argv,
+                    &_skin_argc, _skin_argv)) {
+            return -1;
+        }
 #else
-    if (!assemble_emulator_args(&_qemu_argc, _qemu_argv)) {
-        return -1;
-    }
- #if defined(CONFIG_JAVA_UI)
-    // java skin is deprecated, it is used for only debugging...
-    _skin_argv[_skin_argc++] =
-        g_strdup_printf("skin.path=%s", get_emul_skin_path());
-    _skin_argv[_skin_argc++] =
-        g_strdup_printf("resolution=%s", get_variable("resolution"));
-    _skin_argv[_skin_argc++] =
-        g_strdup_printf("vm.path=%s/%s",
-                get_variable("vms_path"), get_variable("vm_name"));
- #endif
+        if (!assemble_emulator_args(&_qemu_argc, _qemu_argv)) {
+            return -1;
+        }
+#if defined(CONFIG_JAVA_UI)
+        // java skin is deprecated, it is used for only debugging...
+        _skin_argv[_skin_argc++] =
+            g_strdup_printf("skin.path=%s", get_emul_skin_path());
+        _skin_argv[_skin_argc++] =
+            g_strdup_printf("resolution=%s", get_variable("resolution"));
+        _skin_argv[_skin_argc++] =
+            g_strdup_printf("vm.path=%s/%s",
+                    get_variable("vms_path"), get_variable("vm_name"));
 #endif
+#endif
+    }
 
+    // if "--qemu" is specified, we should respect specified args
+    if (qemu_arg_index > 0) {
+        while (qemu_arg_index < argc) {
+            _qemu_argv[_qemu_argc++] = g_strdup(argv[qemu_arg_index++]);
+        }
+    }
 
     LOG_INFO("Start emulator...\n");
-    atexit(maru_atexit);
-    emulator_add_exit_notifier(&emulator_exit);
-
-    set_qemu_input_mode();
-
-    print_system_info();
-
     print_options_info();
 
-    LOG_INFO("socket initialize...\n");
-    socket_init();
-
     LOG_INFO("qemu main start...\n");
     qemu_main(_qemu_argc, _qemu_argv, envp);
 
diff --git a/vl.c b/vl.c
index 96fe56370a3e0bc81ffe51dd40ed7ee1470b5ad0..62f118f82f9e52bcbb0fa24f2d27c3882e367b83 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4004,10 +4004,6 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
-#ifdef CONFIG_MARU
-    maru_display_early_init(display_type);
-#endif
-
     current_machine = MACHINE(object_new(object_class_get_name(
                           OBJECT_CLASS(machine_class))));
     object_property_add_child(object_get_root(), "machine",
@@ -4228,6 +4224,13 @@ int main(int argc, char **argv, char **envp)
     }
 #endif
 
+#ifdef CONFIG_MARU
+    if (display_type == DT_MARU_QT_ONSCREEN ||
+            display_type == DT_MARU_QT_OFFSCREEN) {
+        maru_display_early_init(display_type);
+    }
+#endif
+
 #ifndef CONFIG_MARU
     socket_init();
 #endif