From patchwork Mon Dec 5 20:00:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 129427 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 655461007D5 for ; Tue, 6 Dec 2011 07:55:46 +1100 (EST) Received: from localhost ([::1]:39653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXejB-0004K7-SW for incoming@patchwork.ozlabs.org; Mon, 05 Dec 2011 15:01:29 -0500 Received: from eggs.gnu.org ([140.186.70.92]:41729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXeiY-0002h0-Q9 for qemu-devel@nongnu.org; Mon, 05 Dec 2011 15:00:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXeiW-00060E-NO for qemu-devel@nongnu.org; Mon, 05 Dec 2011 15:00:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:65351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXeiW-000603-Ae for qemu-devel@nongnu.org; Mon, 05 Dec 2011 15:00:48 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB5K0kGX011427 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Dec 2011 15:00:46 -0500 Received: from localhost (ovpn-113-50.phx2.redhat.com [10.3.113.50]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pB5K0j8A020864; Mon, 5 Dec 2011 15:00:45 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 5 Dec 2011 18:00:18 -0200 Message-Id: <1323115226-16817-9-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1323115226-16817-1-git-send-email-lcapitulino@redhat.com> References: <1323115226-16817-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 08/16] qapi: Convert set_link X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Anthony Liguori Signed-off-by: Luiz Capitulino --- hmp-commands.hx | 3 +-- hmp.c | 10 ++++++++++ hmp.h | 1 + net.c | 10 ++++------ net.h | 1 - qapi-schema.json | 20 ++++++++++++++++++++ qmp-commands.hx | 5 +---- 7 files changed, 37 insertions(+), 13 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index b82aff8..93d4a7e 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1038,8 +1038,7 @@ ETEXI .args_type = "name:s,up:b", .params = "name on|off", .help = "change the link status of a network adapter", - .user_print = monitor_user_noop, - .mhandler.cmd_new = do_set_link, + .mhandler.cmd = hmp_set_link, }, STEXI diff --git a/hmp.c b/hmp.c index 0ebc398..5d1687d 100644 --- a/hmp.c +++ b/hmp.c @@ -601,3 +601,13 @@ void hmp_inject_nmi(Monitor *mon, const QDict *qdict) qmp_inject_nmi(&errp); hmp_handle_error(mon, &errp); } + +void hmp_set_link(Monitor *mon, const QDict *qdict) +{ + const char *name = qdict_get_str(qdict, "name"); + int up = qdict_get_bool(qdict, "up"); + Error *errp = NULL; + + qmp_set_link(name, up, &errp); + hmp_handle_error(mon, &errp); +} diff --git a/hmp.h b/hmp.h index 8a31f87..32d7f68 100644 --- a/hmp.h +++ b/hmp.h @@ -41,5 +41,6 @@ void hmp_memsave(Monitor *mon, const QDict *qdict); void hmp_pmemsave(Monitor *mon, const QDict *qdict); void hmp_cont(Monitor *mon, const QDict *qdict); void hmp_inject_nmi(Monitor *mon, const QDict *qdict); +void hmp_set_link(Monitor *mon, const QDict *qdict); #endif diff --git a/net.c b/net.c index cb52050..f7bebf8 100644 --- a/net.c +++ b/net.c @@ -34,6 +34,7 @@ #include "monitor.h" #include "qemu-common.h" #include "qemu_socket.h" +#include "qmp-commands.h" #include "hw/qdev.h" #include "iov.h" @@ -1258,12 +1259,10 @@ void do_info_network(Monitor *mon) } } -int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data) +void qmp_set_link(const char *name, bool up, Error **errp) { VLANState *vlan; VLANClientState *vc = NULL; - const char *name = qdict_get_str(qdict, "name"); - int up = qdict_get_bool(qdict, "up"); QTAILQ_FOREACH(vlan, &vlans, next) { QTAILQ_FOREACH(vc, &vlan->clients, next) { @@ -1280,8 +1279,8 @@ int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data) done: if (!vc) { - qerror_report(QERR_DEVICE_NOT_FOUND, name); - return -1; + error_set(errp, QERR_DEVICE_NOT_FOUND, name); + return; } vc->link_down = !up; @@ -1300,7 +1299,6 @@ done: if (vc->peer && vc->peer->info->link_status_changed) { vc->peer->info->link_status_changed(vc->peer); } - return 0; } void net_cleanup(void) diff --git a/net.h b/net.h index 9f633f8..c6b4190 100644 --- a/net.h +++ b/net.h @@ -122,7 +122,6 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models, const char *default_model); void do_info_network(Monitor *mon); -int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data); /* NIC info */ diff --git a/qapi-schema.json b/qapi-schema.json index fea513f..1d6fb4d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -979,3 +979,23 @@ # Notes: Only x86 Virtual Machines support this command. ## { 'command': 'inject-nmi' } + +## +# @set_link: +# +# Sets the link status of a virtual network adapter. +# +# @name: the device name of the virtual network adapter +# +# @up: true to set the link status to be up +# +# Returns: Nothing on success +# If @name is not a valid network device, DeviceNotFound +# +# Since: 0.14.0 +# +# Notes: Not all network adapters support setting link status. This command +# will succeed even if the network adapter does not support link status +# notification. +## +{ 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} } diff --git a/qmp-commands.hx b/qmp-commands.hx index 2e76708..5054da3 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -730,10 +730,7 @@ EQMP { .name = "set_link", .args_type = "name:s,up:b", - .params = "name on|off", - .help = "change the link status of a network adapter", - .user_print = monitor_user_noop, - .mhandler.cmd_new = do_set_link, + .mhandler.cmd_new = qmp_marshal_input_set_link, }, SQMP