Patchwork [07/10] qapi: Introduce change-vnc-password

login
register
mail settings
Submitter Luiz Capitulino
Date Jan. 9, 2012, 11:24 a.m.
Message ID <1326108257-13042-8-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/134999/
State New
Headers show

Comments

Luiz Capitulino - Jan. 9, 2012, 11:24 a.m.
New QMP command to change the VNC password.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qapi-schema.json |   15 +++++++++++++++
 qmp-commands.hx  |    6 ++++++
 qmp.c            |   14 ++++++++++++++
 3 files changed, 35 insertions(+), 0 deletions(-)

Patch

diff --git a/qapi-schema.json b/qapi-schema.json
index 42682eb..171e781 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1352,3 +1352,18 @@ 
 # Since: 0.14.0
 ##
 { 'command': 'eject', 'data': {'device': 'str', '*force': 'bool'} }
+
+##
+# @change-vnc-password:
+#
+# Change the VNC server password.
+#
+# @target:  the new password to use with VNC authentication
+#
+# Since: 1.1
+#
+# Notes:  An empty password in this command won't allow users to connect until
+#         the password is set again.  Existing clients are unaffected by
+#         executing this command.
+##
+{ 'command': 'change-vnc-password', 'data': {'password': 'str'} }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 185beba..886d589 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2018,3 +2018,9 @@  EQMP
 	.args_type  = "path:s,property:s",
 	.mhandler.cmd_new = qmp_qom_get,
     },
+
+    {
+        .name       = "change-vnc-password",
+        .args_type  = "password:s",
+        .mhandler.cmd_new = qmp_marshal_input_change_vnc_password,
+    },
diff --git a/qmp.c b/qmp.c
index 7c1815b..fb94f0f 100644
--- a/qmp.c
+++ b/qmp.c
@@ -341,3 +341,17 @@  void qmp_expire_password(const char *protocol, const char *whenstr,
 
     error_set(errp, QERR_INVALID_PARAMETER, "protocol");
 }
+
+void qmp_change_vnc_password(const char *password, Error **errp)
+{
+    if (!password || !password[0]) {
+        if (vnc_display_disable_login(NULL) < 0) {
+            error_set(errp, QERR_SET_PASSWD_FAILED);
+        }
+        return;
+    }
+
+    if (vnc_display_password(NULL, password) < 0) {
+        error_set(errp, QERR_SET_PASSWD_FAILED);
+    }
+}