2 * QMP commands related to UI
4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
16 #include "qemu/osdep.h"
17 #include "qapi/qapi-commands-ui.h"
18 #include "qapi/qmp/qerror.h"
19 #include "qemu/cutils.h"
20 #include "ui/console.h"
21 #include "ui/qemu-spice.h"
23 void qmp_set_password(SetPasswordOptions
*opts
, Error
**errp
)
27 if (opts
->protocol
== DISPLAY_PROTOCOL_SPICE
) {
28 if (!qemu_using_spice(errp
)) {
31 rc
= qemu_spice
.set_passwd(opts
->password
,
32 opts
->connected
== SET_PASSWORD_ACTION_FAIL
,
33 opts
->connected
== SET_PASSWORD_ACTION_DISCONNECT
);
35 assert(opts
->protocol
== DISPLAY_PROTOCOL_VNC
);
36 if (opts
->connected
!= SET_PASSWORD_ACTION_KEEP
) {
37 /* vnc supports "connected=keep" only */
38 error_setg(errp
, QERR_INVALID_PARAMETER
, "connected");
42 * Note that setting an empty password will not disable login
43 * through this interface.
45 rc
= vnc_display_password(opts
->u
.vnc
.display
, opts
->password
);
49 error_setg(errp
, "Could not set password");
53 void qmp_expire_password(ExpirePasswordOptions
*opts
, Error
**errp
)
57 const char *whenstr
= opts
->time
;
58 const char *numstr
= NULL
;
61 if (strcmp(whenstr
, "now") == 0) {
63 } else if (strcmp(whenstr
, "never") == 0) {
65 } else if (whenstr
[0] == '+') {
74 if (qemu_strtou64(numstr
, NULL
, 10, &num
) < 0) {
75 error_setg(errp
, "Parameter 'time' doesn't take value '%s'",
82 if (opts
->protocol
== DISPLAY_PROTOCOL_SPICE
) {
83 if (!qemu_using_spice(errp
)) {
86 rc
= qemu_spice
.set_pw_expire(when
);
88 assert(opts
->protocol
== DISPLAY_PROTOCOL_VNC
);
89 rc
= vnc_display_pw_expire(opts
->u
.vnc
.display
, when
);
93 error_setg(errp
, "Could not set password expire time");
98 void qmp_change_vnc_password(const char *password
, Error
**errp
)
100 if (vnc_display_password(NULL
, password
) < 0) {
101 error_setg(errp
, "Could not set password");
106 void qmp_display_reload(DisplayReloadOptions
*arg
, Error
**errp
)
109 case DISPLAY_RELOAD_TYPE_VNC
:
111 if (arg
->u
.vnc
.has_tls_certs
&& arg
->u
.vnc
.tls_certs
) {
112 vnc_display_reload_certs(NULL
, errp
);
115 error_setg(errp
, "vnc is invalid, missing 'CONFIG_VNC'");
123 void qmp_display_update(DisplayUpdateOptions
*arg
, Error
**errp
)
126 case DISPLAY_UPDATE_TYPE_VNC
:
128 vnc_display_update(&arg
->u
.vnc
, errp
);
130 error_setg(errp
, "vnc is invalid, missing 'CONFIG_VNC'");