emul_state: added refined function for detecting tap netclient
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Sat, 30 May 2015 15:00:21 +0000 (00:00 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 2 Jun 2015 01:34:22 +0000 (10:34 +0900)
Change-Id: I39da8cc3c3ee1e351ca4d36a98561651f8e449d4
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/emul_state.c
tizen/src/emul_state.h

index ba14a681538320f752485f76459a76302a795633..9b2d162927dd23c9bc6a23800b13c9c470d346a5 100644 (file)
@@ -32,7 +32,6 @@
 #include "emul_state.h"
 
 #include <libgen.h>
-#include "sysemu/sysemu.h"
 #include "emulator_common.h"
 
 #if defined(CONFIG_LINUX)
@@ -45,8 +44,10 @@ extern bool hax_allowed;
 extern bool hax_allowed;
 #endif
 
+#include "sysemu/sysemu.h"
 #include "block/block_int.h"
 #include "sysemu/block-backend.h"
+#include "net/net.h"
 
 #include "emulator_options.h"
 #include "skin/maruskin_server.h"
@@ -185,10 +186,30 @@ bool is_emul_tap_enable(void)
 
 void set_emul_tap_enable(bool enable)
 {
-    LOG_INFO("%s: %s", __func__, enable ? "true" : "false");
+    LOG_INFO("%s: %s\n", __func__, enable ? "true" : "false");
     _emul_info.tap_enable = enable;
 }
 
+bool is_netclient_tap_attached(void)
+{
+    NetClientState *ncs[MAX_QUEUE_NUM];
+    int queues, i;
+
+    queues = qemu_find_net_clients_except(NULL, ncs,
+                                          NET_CLIENT_OPTIONS_KIND_NIC,
+                                          MAX_QUEUE_NUM);
+    for (i = 0; i < queues; ++i) {
+        if (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_TAP &&
+                (ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC ||
+                // for legacy -net option.
+                 ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT)) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 void set_emul_guest_ip(char *ip)
 {
     strncpy(_emul_info.guest_ip, ip, strlen(ip));
index a8454b3dad10b9900925de3d5c9f1f2a9ac43f67..76577610c617535fc5bae9b3cfe07e97613e7353 100644 (file)
@@ -211,6 +211,7 @@ bool get_emuld_connection(void);
 bool get_sdb_connection(void);
 const char* get_drive_image_file(void);
 const char* get_http_proxy_addr(void);
+bool is_netclient_tap_attached(void);
 
 /* multi-touch */
 MultiTouchState *get_emul_multi_touch_state(void);