qmp hmp: Factor out common "using spice" test
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>
This commit is contained in:
parent
83761b9244
commit
b25d81ba33
@ -88,4 +88,14 @@ static inline int qemu_spice_display_add_client(int csock, int skipauth,
|
|||||||
|
|
||||||
#endif /* CONFIG_SPICE */
|
#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 */
|
#endif /* QEMU_SPICE_H */
|
||||||
|
@ -1095,11 +1095,12 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict,
|
|||||||
const char *subject = qdict_get_try_str(qdict, "cert-subject");
|
const char *subject = qdict_get_try_str(qdict, "cert-subject");
|
||||||
int port = qdict_get_try_int(qdict, "port", -1);
|
int port = qdict_get_try_int(qdict, "port", -1);
|
||||||
int tls_port = qdict_get_try_int(qdict, "tls-port", -1);
|
int tls_port = qdict_get_try_int(qdict, "tls-port", -1);
|
||||||
|
Error *err;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (strcmp(protocol, "spice") == 0) {
|
if (strcmp(protocol, "spice") == 0) {
|
||||||
if (!using_spice) {
|
if (!qemu_using_spice(&err)) {
|
||||||
qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice");
|
qerror_report_err(err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
qmp.c
11
qmp.c
@ -287,9 +287,7 @@ void qmp_set_password(const char *protocol, const char *password,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(protocol, "spice") == 0) {
|
if (strcmp(protocol, "spice") == 0) {
|
||||||
if (!using_spice) {
|
if (!qemu_using_spice(errp)) {
|
||||||
/* correct one? spice isn't a device ,,, */
|
|
||||||
error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rc = qemu_spice_set_passwd(password, fail_if_connected,
|
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 (strcmp(protocol, "spice") == 0) {
|
||||||
if (!using_spice) {
|
if (!qemu_using_spice(errp)) {
|
||||||
/* correct one? spice isn't a device ,,, */
|
|
||||||
error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rc = qemu_spice_set_pw_expire(when);
|
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 (strcmp(protocol, "spice") == 0) {
|
||||||
if (!using_spice) {
|
if (!qemu_using_spice(errp)) {
|
||||||
error_set(errp, QERR_DEVICE_NOT_ACTIVE, "spice");
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user