qmp: modify return type
authorMunkyu Im <munkyu.im@samsung.com>
Mon, 24 Aug 2015 06:38:06 +0000 (15:38 +0900)
committerMunkyu Im <munkyu.im@samsung.com>
Fri, 28 Aug 2015 04:26:26 +0000 (13:26 +0900)
- primitive type is not supported as return value.
  so make structure.
- remove unused command

Change-Id: I5e0a309f2cd31623bff89b9c45a067bec90139c4
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
hmp.c
hmp.h
net/net.c
qapi-schema.json

diff --git a/hmp.c b/hmp.c
index 26b89bcf1541d1be8b26431c67068ff05aed85e9..77294f989f0779aee5b0a0f64aa1b3a5e58ad1ec 100644 (file)
--- a/hmp.c
+++ b/hmp.c
@@ -1003,18 +1003,22 @@ void hmp_set_link(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
 }
 
+#if defined(CONFIG_MARU)
 void hmp_get_link(Monitor *mon, const QDict *qdict)
 {
     const char *name = qdict_get_str(qdict, "name");
     Error *errp = NULL;
-
-    bool is_up = qmp_get_link(name, &errp);
+    LinkInfo *info;
+    info = qmp_get_link(name, &errp);
     if (errp) {
         hmp_handle_error(mon, &errp);
+        g_free(info);
         return;
     }
-    monitor_printf(mon, "%s\n", is_up ? "on": "off");
+    monitor_printf(mon, "%s\n", info->is_up ? "on": "off");
+    g_free(info);
 }
+#endif
 
 void hmp_block_passwd(Monitor *mon, const QDict *qdict)
 {
diff --git a/hmp.h b/hmp.h
index 279a36910ff862ea4c3531919fa26a5eee3b4b39..3c93ac88869d5b475f72fa73dabd270a71b59f9e 100644 (file)
--- a/hmp.h
+++ b/hmp.h
@@ -52,7 +52,9 @@ void hmp_cont(Monitor *mon, const QDict *qdict);
 void hmp_system_wakeup(Monitor *mon, const QDict *qdict);
 void hmp_nmi(Monitor *mon, const QDict *qdict);
 void hmp_set_link(Monitor *mon, const QDict *qdict);
+#if defined(CONFIG_MARU)
 void hmp_get_link(Monitor *mon, const QDict *qdict);
+#endif
 void hmp_block_passwd(Monitor *mon, const QDict *qdict);
 void hmp_balloon(Monitor *mon, const QDict *qdict);
 void hmp_block_resize(Monitor *mon, const QDict *qdict);
index 959ceb72cf93b5b3853fd8b20e47fb289e242034..f8a6bd1f075ea3398eaffb538657b80be46e3f4c 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -1275,11 +1275,13 @@ static void net_vm_change_state_handler(void *opaque, int running,
     }
 }
 
-bool qmp_get_link(const char *name, Error **errp)
+#if defined(CONFIG_MARU)
+LinkInfo *qmp_get_link(const char *name, Error **errp)
 {
     NetClientState *ncs[MAX_QUEUE_NUM];
     int queues, i;
-    bool down = false;
+    LinkInfo *info;
+    info = g_malloc0(sizeof (struct LinkInfo));
 
     queues = qemu_find_net_clients_except(name, ncs,
                                           NET_CLIENT_OPTIONS_KIND_MAX,
@@ -1288,14 +1290,15 @@ bool qmp_get_link(const char *name, Error **errp)
     if (queues == 0) {
         error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
                     "Device '%s' not found", name);
-        return false;
+        return info;
     }
 
     for (i = 0; i < queues; i++) {
-        down = ncs[i]->link_down;
+        info->is_up = !(ncs[i]->link_down);
     }
-    return !down;
+    return info;
 }
+#endif
 
 void net_cleanup(void)
 {
index 10e1c56ddd4c378ee97c45c3a8bb273980cd9c52..a3d87e9b5c0f70ee652f44fcd196de98ca3c1f28 100644 (file)
 #        will succeed even if the network adapter does not support link status
 #        notification.
 ##
-{ 'command': 'get_link', 'data': {'name': 'str'}, 'returns': 'bool' }
+
+{ 'struct': 'LinkInfo', 'data': {'is_up': 'bool'} }
+{ 'command': 'get_link', 'data': {'name': 'str'}, 'returns': 'LinkInfo' }
 
 ##
 # @balloon:
 ##
 { 'command': 'query-target', 'returns': 'TargetInfo' }
 
-## Eric 2013.3.7 ##
-
-##
-# @AccelInfo:
-#
-# Information describing the acceleration sensor value
-#
-# @Xaxis: x axis value of the acceleration sensor
-# @Yaxis: y axis value of the acceleration sensor
-# @Zaxis: z axis value of the acceleration sensor
-#
-# Since: 1.2.0
-##
-{ 'type': 'AccelInfo',
-  'data': { 'Xaxis': 'int', 'Yaxis': 'int', 'Zaxis' : 'int'} }
-
 ##
 # @QKeyCode:
 #