From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGlOJ-0005Zf-6H for qemu-devel@nongnu.org; Thu, 29 Jan 2015 04:28:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGlO2-0004EM-Aq for qemu-devel@nongnu.org; Thu, 29 Jan 2015 04:27:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGlO2-0004E3-3c for qemu-devel@nongnu.org; Thu, 29 Jan 2015 04:27:42 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0T9RfmA004733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 29 Jan 2015 04:27:41 -0500 From: Markus Armbruster Date: Thu, 29 Jan 2015 10:27:30 +0100 Message-Id: <1422523658-3503-2-git-send-email-armbru@redhat.com> In-Reply-To: <1422523658-3503-1-git-send-email-armbru@redhat.com> References: <1422523658-3503-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/9] qmp hmp: Factor out common "using spice" test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, lcapitulino@redhat.com Into qemu_using_spice(). For want of a better place, put it next the existing monitor command handler dummies in qemu-spice.h. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Gerd Hoffmann --- include/ui/qemu-spice.h | 10 ++++++++++ monitor.c | 5 +++-- qmp.c | 11 +++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index a93b4b2..db7926d 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -88,4 +88,14 @@ static inline int qemu_spice_display_add_client(int csock, int skipauth, #endif /* CONFIG_SPICE */ +static inline bool qemu_using_spice(Error **errp) +{ + if (!using_spice) { + /* correct one? spice isn't a device ,,, */ + error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice"); + return false; + } + return true; +} + #endif /* QEMU_SPICE_H */ diff --git a/monitor.c b/monitor.c index 7e4f605..8323de3 100644 --- a/monitor.c +++ b/monitor.c @@ -1095,11 +1095,12 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict, const char *subject = qdict_get_try_str(qdict, "cert-subject"); int port = qdict_get_try_int(qdict, "port", -1); int tls_port = qdict_get_try_int(qdict, "tls-port", -1); + Error *err; int ret; if (strcmp(protocol, "spice") == 0) { - if (!using_spice) { - qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice"); + if (!qemu_using_spice(&err)) { + qerror_report_err(err); return -1; } diff --git a/qmp.c b/qmp.c index 963305c..ef155ff 100644 --- a/qmp.c +++ b/qmp.c @@ -287,9 +287,7 @@ void qmp_set_password(const char *protocol, const char *password, } if (strcmp(protocol, "spice") == 0) { - if (!using_spice) { - /* correct one? spice isn't a device ,,, */ - error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice"); + if (!qemu_using_spice(errp)) { return; } rc = qemu_spice_set_passwd(password, fail_if_connected, @@ -335,9 +333,7 @@ void qmp_expire_password(const char *protocol, const char *whenstr, } if (strcmp(protocol, "spice") == 0) { - if (!using_spice) { - /* correct one? spice isn't a device ,,, */ - error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice"); + if (!qemu_using_spice(errp)) { return; } rc = qemu_spice_set_pw_expire(when); @@ -575,8 +571,7 @@ void qmp_add_client(const char *protocol, const char *fdname, } if (strcmp(protocol, "spice") == 0) { - if (!using_spice) { - error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice"); + if (!qemu_using_spice(errp)) { close(fd); return; } -- 1.9.3