From b5ee83f081c2098f6f29e008bd8994c132e72013 Mon Sep 17 00:00:00 2001 From: Munkyu Im Date: Mon, 24 Aug 2015 15:38:06 +0900 Subject: [PATCH] qmp: modify return type - primitive type is not supported as return value. so make structure. - remove unused command Change-Id: I5e0a309f2cd31623bff89b9c45a067bec90139c4 Signed-off-by: Munkyu Im --- hmp.c | 10 +++++++--- hmp.h | 2 ++ net/net.c | 13 ++++++++----- qapi-schema.json | 20 +++----------------- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/hmp.c b/hmp.c index 26b89bcf15..77294f989f 100644 --- 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 279a36910f..3c93ac8886 100644 --- 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); diff --git a/net/net.c b/net/net.c index 959ceb72cf..f8a6bd1f07 100644 --- 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) { diff --git a/qapi-schema.json b/qapi-schema.json index 10e1c56ddd..a3d87e9b5c 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1467,7 +1467,9 @@ # 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: @@ -2814,22 +2816,6 @@ ## { '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: # -- 2.34.1