All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH 04/10] ui: Improve some set_passwd, expire_password error messages
Date: Fri, 13 Nov 2020 09:26:20 +0100	[thread overview]
Message-ID: <20201113082626.2725812-5-armbru@redhat.com> (raw)
In-Reply-To: <20201113082626.2725812-1-armbru@redhat.com>

set_passwd and expire_password reject invalid "protocol" with "Invalid
parameter 'protocol'".  Misleading; the parameter is valid, its value
isn't.  Improve to "Parameter 'protocol' expects 'vnc' or 'spice'".

expire_password fails with "Could not set password".  Misleading;
improve to "Could not set password expire time".

QERR_SET_PASSWD_FAILED is now unused.  Drop.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/qapi/qmp/qerror.h |  3 ---
 monitor/qmp-cmds.c        | 38 +++++++++++++++-----------------------
 2 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 5d7e69cc1f..d8267129bc 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -65,9 +65,6 @@
 #define QERR_REPLAY_NOT_SUPPORTED \
     "Record/replay feature is not supported for '%s'"
 
-#define QERR_SET_PASSWD_FAILED \
-    "Could not set password"
-
 #define QERR_UNDEFINED_ERROR \
     "An undefined error has occurred"
 
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index a08143b323..ffbf948d55 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -199,13 +199,7 @@ void qmp_set_password(const char *protocol, const char *password,
         }
         rc = qemu_spice.set_passwd(password, fail_if_connected,
                                    disconnect_if_connected);
-        if (rc != 0) {
-            error_setg(errp, QERR_SET_PASSWD_FAILED);
-        }
-        return;
-    }
-
-    if (strcmp(protocol, "vnc") == 0) {
+    } else if (strcmp(protocol, "vnc") == 0) {
         if (fail_if_connected || disconnect_if_connected) {
             /* vnc supports "connected=keep" only */
             error_setg(errp, QERR_INVALID_PARAMETER, "connected");
@@ -214,13 +208,15 @@ void qmp_set_password(const char *protocol, const char *password,
         /* Note that setting an empty password will not disable login through
          * this interface. */
         rc = vnc_display_password(NULL, password);
-        if (rc < 0) {
-            error_setg(errp, QERR_SET_PASSWD_FAILED);
-        }
+    } else {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
+                   "'vnc' or 'spice'");
         return;
     }
 
-    error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
+    if (rc != 0) {
+        error_setg(errp, "Could not set password");
+    }
 }
 
 void qmp_expire_password(const char *protocol, const char *whenstr,
@@ -244,28 +240,24 @@ void qmp_expire_password(const char *protocol, const char *whenstr,
             return;
         }
         rc = qemu_spice.set_pw_expire(when);
-        if (rc != 0) {
-            error_setg(errp, QERR_SET_PASSWD_FAILED);
-        }
-        return;
-    }
-
-    if (strcmp(protocol, "vnc") == 0) {
+    } else if (strcmp(protocol, "vnc") == 0) {
         rc = vnc_display_pw_expire(NULL, when);
-        if (rc != 0) {
-            error_setg(errp, QERR_SET_PASSWD_FAILED);
-        }
+    } else {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol",
+                   "'vnc' or 'spice'");
         return;
     }
 
-    error_setg(errp, QERR_INVALID_PARAMETER, "protocol");
+    if (rc != 0) {
+        error_setg(errp, "Could not set password expire time");
+    }
 }
 
 #ifdef CONFIG_VNC
 void qmp_change_vnc_password(const char *password, Error **errp)
 {
     if (vnc_display_password(NULL, password) < 0) {
-        error_setg(errp, QERR_SET_PASSWD_FAILED);
+        error_setg(errp, "Could not set password");
     }
 }
 
-- 
2.26.2



  parent reply	other threads:[~2020-11-13  8:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13  8:26 [PATCH 00/10] Chipping away at qerror.h Markus Armbruster
2020-11-13  8:26 ` [PATCH 01/10] qerror: Drop unused QERR_ macros Markus Armbruster
2020-11-16 12:41   ` Philippe Mathieu-Daudé
2020-11-13  8:26 ` [PATCH 02/10] qerror: Eliminate QERR_ macros used in just one place Markus Armbruster
2020-11-13  8:26 ` [PATCH 03/10] block: Improve some block-commit, block-stream error messages Markus Armbruster
2020-11-13 13:30   ` Max Reitz
2020-11-13  8:26 ` Markus Armbruster [this message]
2020-11-13  8:26 ` [PATCH 05/10] ui: Improve a client_migrate_info error message Markus Armbruster
2020-11-13  8:26 ` [PATCH 06/10] ui: Tweak " Markus Armbruster
2020-11-13  8:26 ` [PATCH 07/10] qga: Replace an unreachable error by abort() Markus Armbruster
2020-11-13  8:26 ` [PATCH 08/10] qga: Tweak a guest-shutdown error message Markus Armbruster
2020-11-13  8:26 ` [PATCH 09/10] qom: Improve {qom, device}-list-properties error messages Markus Armbruster
2020-11-13  9:09   ` [PATCH 09/10] qom: Improve {qom,device}-list-properties " Paolo Bonzini
2020-11-13 13:39     ` Markus Armbruster
2020-11-13  8:26 ` [PATCH 10/10] Tweak a few "Parameter 'NAME' expects THING" error message Markus Armbruster

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=20201113082626.2725812-5-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=kraxel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.