qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kraxel@redhat.com, lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH v2 1/9] qmp hmp: Factor out common "using spice" test
Date: Thu, 29 Jan 2015 10:27:30 +0100	[thread overview]
Message-ID: <1422523658-3503-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1422523658-3503-1-git-send-email-armbru@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 <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
---
 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

  reply	other threads:[~2015-01-29  9:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29  9:27 [Qemu-devel] [PATCH v2 0/9] qmp hmp balloon: Cleanups around error reporting Markus Armbruster
2015-01-29  9:27 ` Markus Armbruster [this message]
2015-01-29  9:27 ` [Qemu-devel] [PATCH v2 2/9] qmp hmp: Improve error messages when SPICE is not in use Markus Armbruster
2015-01-29  9:27 ` [Qemu-devel] [PATCH v2 3/9] hmp: Compile hmp_info_spice() only with CONFIG_SPICE Markus Armbruster
2015-01-29  9:27 ` [Qemu-devel] [PATCH v2 4/9] qmp: Clean up qmp_query_spice() #ifndef !CONFIG_SPICE dummy Markus Armbruster
2015-01-29  9:27 ` [Qemu-devel] [PATCH v2 5/9] qmp: Simplify recognition of capability negotiation command Markus Armbruster
2015-01-29  9:27 ` [Qemu-devel] [PATCH v2 6/9] qmp: Eliminate silly QERR_COMMAND_NOT_FOUND macro Markus Armbruster
2015-01-29  9:27 ` [Qemu-devel] [PATCH v2 7/9] balloon: Inline qemu_balloon(), qemu_balloon_status() Markus Armbruster
2015-01-29  9:27 ` [Qemu-devel] [PATCH v2 8/9] balloon: Factor out common "is balloon active" test Markus Armbruster
2015-01-29  9:27 ` [Qemu-devel] [PATCH v2 9/9] balloon: Eliminate silly QERR_ macros Markus Armbruster
2015-01-29 13:53   ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422523658-3503-2-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).