The code which set VNC passwords correctly had fallback for
the set_password command, but was lacking it for the
expire_password command. This made it impossible to start
a guest. It also failed to check whether QEMU was still
running after the initial 'set_password' command completed
* src/qemu/qemu_hotplug.c: Fix error handling when
password expiry fails
* src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_text.c: Fix
return code for missing expire_password command
---
src/qemu/qemu_hotplug.c | 12 ++++++++++++
src/qemu/qemu_monitor_json.c | 10 +++++++++-
src/qemu/qemu_monitor_text.c | 4 ++--
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7abdd0f..125d9b5 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1869,6 +1869,15 @@ qemuDomainChangeGraphicsPasswords(struct qemud_driver *driver,
auth->passwd ? auth->passwd :
defaultPasswd);
}
}
+ if (ret != 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ ret = -1;
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("guest unexpectedly quit"));
+ goto cleanup;
+ }
if (auth->expires) {
time_t lifetime = auth->validTo - now;
@@ -1888,9 +1897,12 @@ qemuDomainChangeGraphicsPasswords(struct qemud_driver *driver,
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Expiry of passwords is not supported"));
ret = -1;
+ } else {
+ ret = 0;
}
}
+cleanup:
qemuDomainObjExitMonitorWithDriver(driver, vm);
return ret;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 7387089..2e159c7 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1298,6 +1298,7 @@ cleanup:
return ret;
}
+/* Returns -1 on error, -2 if not supported */
int qemuMonitorJSONExpirePassword(qemuMonitorPtr mon,
const char *protocol,
const char *expire_time)
@@ -1313,9 +1314,16 @@ int qemuMonitorJSONExpirePassword(qemuMonitorPtr mon,
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
- if (ret == 0)
+ if (ret == 0) {
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
+ ret = -2;
+ goto cleanup;
+ }
+
ret = qemuMonitorJSONCheckError(cmd, reply);
+ }
+cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 291d958..4cf87fe 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -803,6 +803,7 @@ cleanup:
return ret;
}
+/* Returns -1 on error, -2 if not supported */
int qemuMonitorTextExpirePassword(qemuMonitorPtr mon,
const char *protocol,
const char *expire_time)
@@ -824,8 +825,7 @@ int qemuMonitorTextExpirePassword(qemuMonitorPtr mon,
}
if (strstr(reply, "unknown command:")) {
- qemuReportError(VIR_ERR_NO_SUPPORT,
- _("expiring password not supported by this qemu: %s"),
reply);
+ ret = -2;
goto cleanup;
}
--
1.7.3.4