aboutsummaryrefslogtreecommitdiff
path: root/qmp.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2011-12-07 11:47:57 -0200
committerLuiz Capitulino <lcapitulino@redhat.com>2012-01-18 10:23:38 -0200
commit9ad5372daa3100d78b12aad59054970f15692a90 (patch)
tree28059b2e628eac297566f4d3230193423cce34a1 /qmp.c
parentfbf796fd6f855313d2c02b7d8e1a0c4241b1e0b6 (diff)
qapi: Convert expire_password
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'qmp.c')
-rw-r--r--qmp.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/qmp.c b/qmp.c
index 9ef43a857c..8b7b37999d 100644
--- a/qmp.c
+++ b/qmp.c
@@ -303,3 +303,43 @@ void qmp_set_password(const char *protocol, const char *password,
error_set(errp, QERR_INVALID_PARAMETER, "protocol");
}
+
+void qmp_expire_password(const char *protocol, const char *whenstr,
+ Error **errp)
+{
+ time_t when;
+ int rc;
+
+ if (strcmp(whenstr, "now") == 0) {
+ when = 0;
+ } else if (strcmp(whenstr, "never") == 0) {
+ when = TIME_MAX;
+ } else if (whenstr[0] == '+') {
+ when = time(NULL) + strtoull(whenstr+1, NULL, 10);
+ } else {
+ when = strtoull(whenstr, NULL, 10);
+ }
+
+ if (strcmp(protocol, "spice") == 0) {
+ if (!using_spice) {
+ /* correct one? spice isn't a device ,,, */
+ error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
+ return;
+ }
+ rc = qemu_spice_set_pw_expire(when);
+ if (rc != 0) {
+ error_set(errp, QERR_SET_PASSWD_FAILED);
+ }
+ return;
+ }
+
+ if (strcmp(protocol, "vnc") == 0) {
+ rc = vnc_display_pw_expire(NULL, when);
+ if (rc != 0) {
+ error_set(errp, QERR_SET_PASSWD_FAILED);
+ }
+ return;
+ }
+
+ error_set(errp, QERR_INVALID_PARAMETER, "protocol");
+}