emul_state: introduced get_swap_image_file()
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 18 Aug 2015 09:01:58 +0000 (18:01 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 19 Aug 2015 04:33:26 +0000 (13:33 +0900)
Introduced get_swap_image_file() that provide swap image file name.

Change-Id: I5fa9bb4140fbcbd19361fdd57492dfb2c20d1d87
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/emul_state.c
tizen/src/emul_state.h

index 3ea18a7a339f4914d069674021b07f15c1d48cb9..42217b3924b67e1db7df8bbba6b44cc8af511601 100644 (file)
@@ -468,7 +468,6 @@ const char *get_log_redirect_file(void)
     return log_redirect_file;
 }
 
-
 // drive image file
 static const char *drive_image_file = NULL;
 
@@ -495,6 +494,31 @@ const char *get_drive_image_file(void)
     return "";
 }
 
+// swap image file
+static const char *swap_image_file = NULL;
+
+const char *get_swap_image_file(void)
+{
+    if (swap_image_file) {
+        return swap_image_file;
+    }
+
+    // we should parse from "swap" parameter.
+    // so qemu_main() had to be called before.
+    BlockBackend *bb = blk_by_name("swap");
+    if (bb) {
+        BlockDriverState *bs = blk_bs(bb);
+        swap_image_file = g_strdup(bs->filename);
+
+        return swap_image_file;
+    }
+
+    // called before device initialized
+    // or very weired situation
+    LOG_WARNING("Can not identify swap image file !!!\n");
+
+    return "";
+}
 
 // http proxy
 static const char *http_proxy_addr = NULL;
@@ -840,6 +864,9 @@ static void emul_state_notify_exit(Notifier *notifier, void *data)
     g_free((void *)drive_image_file);
     drive_image_file = NULL;
 
+    g_free((void *)swap_image_file);
+    swap_image_file = NULL;
+
     g_free((void *)http_proxy_addr);
     http_proxy_addr = NULL;
 
index 8aef4c889ac63471176591bd721b7cdc146260ec..fe1a73fff2f4eea14b83488b5674342b4bc364ed 100644 (file)
@@ -181,6 +181,7 @@ char const *get_bin_path(void);
 char const *get_log_redirect_file(void);
 char const *get_kernel_log_redirect_file(void);
 const char *get_drive_image_file(void);
+const char *get_swap_image_file(void);
 const char *get_http_proxy_addr(void);
 const char *get_vm_name(void);
 const char *get_profile_name(void);