mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Avoid needless copies of static strings
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
77437410d7
commit
60f35e263f
@ -3952,7 +3952,8 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
char expire_time [64];
|
const char *expire;
|
||||||
|
char *validTo = NULL;
|
||||||
const char *connected = NULL;
|
const char *connected = NULL;
|
||||||
const char *password;
|
const char *password;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -3983,19 +3984,18 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto end_job;
|
goto end_job;
|
||||||
|
|
||||||
if (password[0] == '\0') {
|
if (password[0] == '\0' ||
|
||||||
snprintf(expire_time, sizeof(expire_time), "now");
|
(auth->expires && auth->validTo <= now)) {
|
||||||
|
expire = "now";
|
||||||
} else if (auth->expires) {
|
} else if (auth->expires) {
|
||||||
time_t lifetime = auth->validTo - now;
|
if (virAsprintf(&validTo, "%lu", (unsigned long) auth->validTo) < 0)
|
||||||
if (lifetime <= 0)
|
goto end_job;
|
||||||
snprintf(expire_time, sizeof(expire_time), "now");
|
expire = validTo;
|
||||||
else
|
|
||||||
snprintf(expire_time, sizeof(expire_time), "%lu", (long unsigned)auth->validTo);
|
|
||||||
} else {
|
} else {
|
||||||
snprintf(expire_time, sizeof(expire_time), "never");
|
expire = "never";
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemuMonitorExpirePassword(priv->mon, type, expire_time);
|
ret = qemuMonitorExpirePassword(priv->mon, type, expire);
|
||||||
|
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
/* XXX we could fake this with a timer */
|
/* XXX we could fake this with a timer */
|
||||||
@ -4012,6 +4012,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(validTo);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user