hds: isolated hds path & attached state in emul_state
authorJinhyung Choi <jinhyung2.choi@samsung.com>
Tue, 28 Oct 2014 04:55:17 +0000 (13:55 +0900)
committerJinhyung Choi <jinhyung2.choi@samsung.com>
Wed, 29 Oct 2014 03:27:31 +0000 (12:27 +0900)
Change-Id: I0c681dce5a53d9708198d2b760e8560d46c59a07
Signed-off-by: Jinhyung Choi <jinhyung2.choi@samsung.com>
hw/9pfs/virtio-9p-device.c
tizen/src/ecs/ecs.h
tizen/src/ecs/ecs_msg_device.c
tizen/src/emul_state.c
tizen/src/emul_state.h
tizen/src/util/maru_device_hotplug.c
vl.c

index 519b6e3c83ee8bda1c36c642b6ee9abb5ed416df..d3df769fbc6acab47ef899caefadc30445597908 100644 (file)
@@ -22,6 +22,7 @@
 
 #ifdef CONFIG_MARU
 #include "tizen/src/util/maru_err_table.h"
+#include "tizen/src/emul_state.h"
 #endif
 
 static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features)
@@ -145,6 +146,12 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
         error_setg(errp, "share path %s is not a directory", fse->path);
         goto out;
     }
+
+#ifdef CONFIG_MARU
+    set_emul_hds_attached(true);
+    set_emul_hds_path(fse->path);
+#endif
+
     v9fs_path_free(&path);
 
     return;
index 4cd2f03632cbdbde53e670f09730743822c0ad3c..8d66324255245338e00036b94ab818c1bcfc1720 100644 (file)
 #define MSG_TYPE_GUEST          "guest"
 
 #define MSG_GROUP_STATUS        15
+#define MSG_GROUP_HDS           100
+
+#define HDS_ACTION_MOUNT        1
+#define HDS_ACTION_UMOUNT       2
 
 enum message_action {
     MSG_ACT_BATTERY_LEVEL = 100,
index 392285159e477377eb6031cfe3009ead31b923d8..dda5c7334bdae8a92d14808eac42a58f04996e2d 100644 (file)
@@ -322,8 +322,6 @@ static void msgproc_device_req_nfc(ECS_Client* ccli, ECS__DeviceReq* msg)
     }
 }
 
-static char hds_path[PATH_MAX];
-
 static void msgproc_device_req_hds(ECS_Client* ccli, ECS__DeviceReq* msg, char * cmd)
 {
     char* data = NULL;
@@ -340,24 +338,23 @@ static void msgproc_device_req_hds(ECS_Client* ccli, ECS__DeviceReq* msg, char *
     if (group == MSG_GROUP_STATUS) {
         char hds_data_send[PATH_MAX + 3];
         if (is_hds_attached()) {
-            sprintf(hds_data_send, "1, %s", hds_path);
+            sprintf(hds_data_send, "1, %s", get_emul_hds_path());
         } else {
             sprintf(hds_data_send, "0, ");
         }
         make_send_device_ntf(cmd, group, 99, hds_data_send);
-    } else if (group == 100 && action == 1) {
+    } else if (group == MSG_GROUP_HDS && action == HDS_ACTION_MOUNT) {
         LOG_INFO("try attach with is_hds_attached : %d\n", is_hds_attached());
         if (data != NULL && !is_hds_attached()) {
-            LOG_INFO("do attach : %s\n", hds_path);
-            memset(hds_path, 0, sizeof(hds_path));
-            memcpy(hds_path, data, sizeof(hds_path) - 1);
-            do_hotplug(ATTACH_HDS, hds_path, strlen(hds_path) + 1);
+            LOG_INFO("do attach : %s\n", data);
+            set_emul_hds_path(data);
+            do_hotplug(ATTACH_HDS, data, strlen(data) + 1);
             LOG_INFO("send emuld to mount.\n");
             send_msg_to_guest(ccli, cmd, group, action, data, strlen(data));
         } else {
-            make_send_device_ntf(cmd, 100, 2, NULL);
+            make_send_device_ntf(cmd, group, 2, NULL);
         }
-    } else if (group == 100 && action == 2) {
+    } else if (group == MSG_GROUP_HDS && action == HDS_ACTION_UMOUNT) {
         LOG_INFO("try detach with is_hds_attached : %d\n", is_hds_attached());
         if (is_hds_attached()) {
             LOG_INFO("send emuld to umount.\n");
index 81828aa40804d89649f01486530d090bacf525f7..53d7a6b9c5cc86d8536bcf40dd10d404e73d016b 100644 (file)
@@ -377,3 +377,24 @@ char* get_emul_http_proxy_port(void)
 {
     return _emul_info.http_proxy_port;
 }
+
+void set_emul_hds_attached(bool attached)
+{
+    _emul_state.hds_attached = attached;
+}
+
+bool get_emul_hds_attached(void)
+{
+    return _emul_state.hds_attached;
+}
+
+void set_emul_hds_path(const char *path)
+{
+    strncpy(_emul_state.hds_path, path, sizeof(_emul_state.hds_path));
+    _emul_state.hds_path[sizeof(_emul_state.hds_path) -1] = 0;
+}
+
+char* get_emul_hds_path(void)
+{
+    return _emul_state.hds_path;
+}
index 0266102048f4a27dada00ab7092c868a2b9015b8..20ec3a2bf63c656246739092bd71cf8b8f3b75ca 100644 (file)
@@ -40,9 +40,7 @@
 #define MAX_ADDR_LEN    256
 #define MAX_PORT_LEN    256
 
-#define MAX_ADDR_LEN    256
-#define MAX_PORT_LEN    256
-
+#define MAX_HDS_PATH    256
 enum {
     RESET = 0,
     BOOT_COMPLETED = 1,
@@ -117,6 +115,8 @@ typedef struct EmulatorConfigState {
     int qemu_caps_lock;
     int qemu_num_lock;
     /* add here */
+    bool hds_attached;
+    char hds_path[MAX_HDS_PATH];
 } EmulatorConfigState;
 
 /* misc */
@@ -148,6 +148,8 @@ void set_emul_num_lock_state(int state);
 void set_emul_vm_name(char *vm_name);
 void set_emul_http_proxy_addr(char *addr);
 void set_emul_http_proxy_port(char *port);
+void set_emul_hds_attached(bool attached);
+void set_emul_hds_path(const char *path);
 
 /* getter */
 bool get_emul_skin_enable(void);
@@ -175,5 +177,7 @@ int get_emul_num_lock_state(void);
 char* get_emul_vm_name(void);
 char* get_emul_http_proxy_addr(void);
 char* get_emul_http_proxy_port(void);
+bool get_emul_hds_attached(void);
+char* get_emul_hds_path(void);
 
 #endif /* __EMUL_STATE_H__ */
index 4bc59c87f3c3d07dbb8f93d956ca499ce17596d9..ac598f61b358c2edf72669d1bbf3c35c2f8d3dca 100644 (file)
@@ -36,6 +36,7 @@
 #include "qemu/event_notifier.h"
 
 #include "emulator.h"
+#include "emul_state.h"
 #include "maru_device_hotplug.h"
 
 #define HOST_KEYBOARD_DRIVER        "virtio-keyboard-pci"
@@ -60,7 +61,6 @@ struct maru_device_hotplug {
     // FIXME: Should we query device every time ??
     bool host_keyboard_attached;
     bool sdcard_attached;
-    bool hds_attached;
 };
 
 static struct maru_device_hotplug *state;
@@ -192,7 +192,7 @@ static bool do_hds_attach(const char * const file)
 
     QDECREF(qdict);
 
-    state->hds_attached = true;
+    set_emul_hds_attached(true);
 
     return true;
 }
@@ -211,7 +211,7 @@ static bool do_hds_detach(void)
 
     QDECREF(qdict);
 
-    state->hds_attached = false;
+    set_emul_hds_attached(false);
 
     return true;
 }
@@ -291,6 +291,6 @@ bool is_sdcard_attached(void)
 
 bool is_hds_attached(void)
 {
-    return state->hds_attached;
+    return get_emul_hds_attached();
 }
 
diff --git a/vl.c b/vl.c
index 99b6614780bde2042d2067aabbf69d280f86857e..2e33b82eb268fa3e800411d9baac23e74667b14a 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3563,8 +3563,13 @@ int main(int argc, char **argv, char **envp)
 
                 qemu_opt_set_bool(fsdev, "readonly",
                                 qemu_opt_get_bool(opts, "readonly", 0));
+#ifdef CONFIG_MARU
+                device = qemu_opts_create(qemu_find_opts("device"), "fileshare", 0,
+                                          &error_abort);
+#else
                 device = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
                                           &error_abort);
+#endif
                 qemu_opt_set(device, "driver", "virtio-9p-pci");
                 qemu_opt_set(device, "fsdev",
                              qemu_opt_get(opts, "mount_tag"));