mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
Fix vmdef usage while in monitor in qemu process
Make local copy of the disk alias in qemuProcessInitPasswords, instead of referencing the one in domain definition, which might get freed if the domain crashes while we're in monitor. Also copy the memballoon period value.
This commit is contained in:
parent
3f21398437
commit
c749eda4a2
@ -2584,6 +2584,8 @@ qemuProcessInitPasswords(virConnectPtr conn,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
char *alias = NULL;
|
||||||
|
char *secret = NULL;
|
||||||
|
|
||||||
for (i = 0; i < vm->def->ngraphics; ++i) {
|
for (i = 0; i < vm->def->ngraphics; ++i) {
|
||||||
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
|
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
|
||||||
@ -2607,33 +2609,34 @@ qemuProcessInitPasswords(virConnectPtr conn,
|
|||||||
|
|
||||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
||||||
for (i = 0; i < vm->def->ndisks; i++) {
|
for (i = 0; i < vm->def->ndisks; i++) {
|
||||||
char *secret;
|
|
||||||
size_t secretLen;
|
size_t secretLen;
|
||||||
const char *alias;
|
|
||||||
|
|
||||||
if (!vm->def->disks[i]->src->encryption ||
|
if (!vm->def->disks[i]->src->encryption ||
|
||||||
!virDomainDiskGetSource(vm->def->disks[i]))
|
!virDomainDiskGetSource(vm->def->disks[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
VIR_FREE(secret);
|
||||||
if (qemuProcessGetVolumeQcowPassphrase(conn,
|
if (qemuProcessGetVolumeQcowPassphrase(conn,
|
||||||
vm->def->disks[i],
|
vm->def->disks[i],
|
||||||
&secret, &secretLen) < 0)
|
&secret, &secretLen) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
alias = vm->def->disks[i]->info.alias;
|
VIR_FREE(alias);
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) {
|
if (VIR_STRDUP(alias, vm->def->disks[i]->info.alias) < 0)
|
||||||
VIR_FREE(secret);
|
goto cleanup;
|
||||||
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret);
|
ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret);
|
||||||
VIR_FREE(secret);
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
ret = -1;
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(alias);
|
||||||
|
VIR_FREE(secret);
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4258,6 +4261,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
struct qemuProcessHookData hookData;
|
struct qemuProcessHookData hookData;
|
||||||
unsigned long cur_balloon;
|
unsigned long cur_balloon;
|
||||||
|
unsigned int period = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
bool rawio_set = false;
|
bool rawio_set = false;
|
||||||
char *nodeset = NULL;
|
char *nodeset = NULL;
|
||||||
@ -4870,15 +4874,18 @@ int qemuProcessStart(virConnectPtr conn,
|
|||||||
vm->def->mem.cur_balloon);
|
vm->def->mem.cur_balloon);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
if (vm->def->memballoon && vm->def->memballoon->period)
|
||||||
|
period = vm->def->memballoon->period;
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (vm->def->memballoon && vm->def->memballoon->period)
|
if (period)
|
||||||
qemuMonitorSetMemoryStatsPeriod(priv->mon, vm->def->memballoon->period);
|
qemuMonitorSetMemoryStatsPeriod(priv->mon, period);
|
||||||
if (qemuMonitorSetBalloon(priv->mon, cur_balloon) < 0) {
|
if (qemuMonitorSetBalloon(priv->mon, cur_balloon) < 0) {
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
VIR_DEBUG("Detecting actual memory size for video device");
|
VIR_DEBUG("Detecting actual memory size for video device");
|
||||||
if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0)
|
if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user