mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
Fix startup with VNC password expiry on old QEMU
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
This commit is contained in:
parent
f0bbf96047
commit
87a183f698
@ -1751,6 +1751,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;
|
||||
@ -1770,9 +1779,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;
|
||||
|
@ -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)
|
||||
ret = qemuMonitorJSONCheckError(cmd, reply);
|
||||
if (ret == 0) {
|
||||
if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
|
||||
ret = -2;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = qemuMonitorJSONCheckError(cmd, reply);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(cmd);
|
||||
virJSONValueFree(reply);
|
||||
return ret;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user