return _emul_info.skin_path;
}
-const char* get_emul_guest_home_path(void)
-{
- return _emul_info.guest_home_path;
-}
-
-void set_emul_guest_home_path(char *home_path)
-{
- if (!_emul_info.guest_home_path) {
- _emul_info.guest_home_path = home_path;
- } else {
- LOG_INFO("guest home path is already set : %s\n", _emul_info.guest_home_path);
- }
-}
-
/* CPU virtualization */
bool get_emul_cpu_accel(void)
{
return qemu_console_get_height(NULL, initial_resolution_height);
}
+// guest default home
+static const char *platform_default_home = NULL;
+const char* get_platform_default_home(void)
+{
+ return platform_default_home;
+}
+
+void set_platform_default_home(const char *path)
+{
+ if (!platform_default_home) {
+ platform_default_home = g_strdup(path);
+ } else {
+ LOG_INFO("platform home path is already set : %s\n",
+ platform_default_home);
+ }
+}
+
static void emul_state_notify_exit(Notifier *notifier, void *data)
{
g_free((void *)launch_conf_file);
g_free((void *)host_ip);
host_ip = NULL;
+
+ g_free((void *)platform_default_home);
+ platform_default_home = NULL;
}
+
static Notifier emul_state_exit = { .notify = emul_state_notify_exit };
void init_emul_state(void)
#include "ecs/ecs.h"
#include "new_debug_ch.h"
-DECLARE_DEBUG_CHANNEL(sdb);
+DECLARE_DEBUG_CHANNEL(net_helper);
#define BUF_SIZE 64
#define MAX_TRIAL 20
int emul_vm_base_socket;
static bool sdb_daemon_is_initialized = false;
static QemuThread thread_id;
-bool processing = false;
int inet_strtoip(const char* str, uint32_t *ip)
{
static SDB_Noti_Server *current_server;
static QemuMutex mutex_clients;
+static QemuMutex mutex_request;
static void remove_sdb_client(SDB_Client* client)
{
static void *get_user_home_path(void *args)
{
FILE *fp;
- char user_name[MAX_USER_NAME_LEN];
+ char user_name[MAX_USER_NAME_LEN] = { 0, } ;
int index = 0;
#ifndef CONFIG_WIN32
const char *sdb_path = "../../../../../tools/sdb";
#else
const char *sdb_path = "..\\..\\..\\..\\..\\tools\\sdb.exe";
#endif
- if (processing) {
- return NULL;
- }
- processing = true;
const char *bin_dir = get_bin_path();
- if (get_emul_guest_home_path()) {
- processing = false;
+ qemu_mutex_lock(&mutex_request);
+
+ if (get_platform_default_home()) {
return NULL;
}
- gchar *cmd_root_off = g_strdup_printf("\"%s%s\" -s emulator-%d root off", bin_dir, sdb_path, get_vm_device_serial_number());
- gchar *cmd_get_home = g_strdup_printf("\"%s%s\" -s emulator-%d shell id -un",
- bin_dir, sdb_path, get_vm_device_serial_number());
+
+ char *cmd_root_off = g_strdup_printf("\"%s%s\" -s emulator-%d root off",
+ bin_dir, sdb_path, get_vm_device_serial_number());
+ char *cmd_get_home = g_strdup_printf("\"%s%s\" -s emulator-%d shell id -un",
+ bin_dir, sdb_path, get_vm_device_serial_number());
//FIXME: (sdb) cannot check sdb root status
fp = popen(cmd_root_off, "r");
if (fp == NULL) {
LOG_WARNING("Failed to run command\n");
g_free(cmd_root_off);
- processing = false;
return NULL;
}
g_free(cmd_root_off);
break;
}
- while (fgets(user_name, sizeof(user_name), fp) != NULL) {
- LOG_INFO("user name: %s", user_name);
- if (strlen(user_name) > 2) {
- /* to remove carrige return and new line character */
- user_name[strlen(user_name) - 2] = '\0';
+ if (fgets(user_name, sizeof(user_name), fp)) {
+ g_strstrip(user_name);
+ if (strlen(user_name) > 0) {
+ char *path = g_strdup_printf("/home/%s/", user_name);
+ set_platform_default_home(path);
+ g_free(path);
+ pclose(fp);
+
+ break;
}
}
- if (strlen(user_name) > 0) {
- gchar *user_home_path = g_strdup_printf("/home/%s/", user_name);
- LOG_INFO("guest_home_user_name: %s\n", user_home_path);
- set_emul_guest_home_path(user_home_path);
- pclose(fp);
- break;
- }
pclose(fp);
}
g_free(cmd_get_home);
- processing = false;
+
+ if (!get_platform_default_home()) {
+ set_platform_default_home("/tmp/");
+ }
+
+ LOG_INFO("platform_default_user_home: %s\n", get_platform_default_home());
+
+ qemu_mutex_unlock(&mutex_request);
+
return NULL;
}
LOG_TRACE("command:%s\n", command);
if (strcmp(command, "2\n" ) == 0) {
sdb_daemon_is_initialized = true;
- qemu_thread_create(&thread_id, "get_home_path", get_user_home_path, NULL, QEMU_THREAD_DETACHED);
+ if (!get_platform_default_home()) {
+ qemu_thread_create(&thread_id, "get_platform_default_home",
+ get_user_home_path, NULL, QEMU_THREAD_DETACHED);
+ }
} else if (strcmp(command, "5\n") == 0) {
register_sdb_server(readbuf, client_addr);
set_sdb_connection(true);
return;
}
+ qemu_mutex_init(&mutex_clients);
+ qemu_mutex_init(&mutex_request);
+
server->server_chan = io_channel_from_socket(server->server_fd);
server->server_tag = g_io_add_watch(server->server_chan, G_IO_IN, sdb_noti_read, server);
current_server = server;
- qemu_mutex_init(&mutex_clients);
-
LOG_INFO("success to bind port[127.0.0.1:%d/udp] for sdb noti server in host \n", server_port);
emulator_add_exit_notifier(&sdb_noti_server_exit);