|
|
9119d9 |
From 3a2b715e02c2e0205e7787d9aefd332743ef5599 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <3a2b715e02c2e0205e7787d9aefd332743ef5599@dist-git>
|
|
|
9119d9 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
9119d9 |
Date: Mon, 19 Jan 2015 10:48:31 +0100
|
|
|
9119d9 |
Subject: [PATCH] Fix vmdef usage while in monitor in qemu process
|
|
|
9119d9 |
MIME-Version: 1.0
|
|
|
9119d9 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9119d9 |
Content-Transfer-Encoding: 8bit
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1161024
|
|
|
9119d9 |
|
|
|
9119d9 |
Make local copy of the disk alias in qemuProcessInitPasswords,
|
|
|
9119d9 |
instead of referencing the one in domain definition, which
|
|
|
9119d9 |
might get freed if the domain crashes while we're in monitor.
|
|
|
9119d9 |
|
|
|
9119d9 |
Also copy the memballoon period value.
|
|
|
9119d9 |
|
|
|
9119d9 |
(cherry picked from commit c749eda4a2220cddb24467fbbcf22c9b7917b8a2)
|
|
|
9119d9 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_process.c | 31 +++++++++++++++++++------------
|
|
|
9119d9 |
1 file changed, 19 insertions(+), 12 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
|
|
9119d9 |
index 90e45a8..ae1dbdf 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_process.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_process.c
|
|
|
9119d9 |
@@ -2550,6 +2550,8 @@ qemuProcessInitPasswords(virConnectPtr conn,
|
|
|
9119d9 |
qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
9119d9 |
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
|
9119d9 |
size_t i;
|
|
|
9119d9 |
+ char *alias = NULL;
|
|
|
9119d9 |
+ char *secret = NULL;
|
|
|
9119d9 |
|
|
|
9119d9 |
for (i = 0; i < vm->def->ngraphics; ++i) {
|
|
|
9119d9 |
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
|
|
|
9119d9 |
@@ -2573,33 +2575,34 @@ qemuProcessInitPasswords(virConnectPtr conn,
|
|
|
9119d9 |
|
|
|
9119d9 |
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
|
|
|
9119d9 |
for (i = 0; i < vm->def->ndisks; i++) {
|
|
|
9119d9 |
- char *secret;
|
|
|
9119d9 |
size_t secretLen;
|
|
|
9119d9 |
- const char *alias;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (!vm->def->disks[i]->src->encryption ||
|
|
|
9119d9 |
!virDomainDiskGetSource(vm->def->disks[i]))
|
|
|
9119d9 |
continue;
|
|
|
9119d9 |
|
|
|
9119d9 |
+ VIR_FREE(secret);
|
|
|
9119d9 |
if (qemuProcessGetVolumeQcowPassphrase(conn,
|
|
|
9119d9 |
vm->def->disks[i],
|
|
|
9119d9 |
&secret, &secretLen) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
- alias = vm->def->disks[i]->info.alias;
|
|
|
9119d9 |
- if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) {
|
|
|
9119d9 |
- VIR_FREE(secret);
|
|
|
9119d9 |
+ VIR_FREE(alias);
|
|
|
9119d9 |
+ if (VIR_STRDUP(alias, vm->def->disks[i]->info.alias) < 0)
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
- }
|
|
|
9119d9 |
ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret);
|
|
|
9119d9 |
- VIR_FREE(secret);
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
if (ret < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
cleanup:
|
|
|
9119d9 |
+ VIR_FREE(alias);
|
|
|
9119d9 |
+ VIR_FREE(secret);
|
|
|
9119d9 |
virObjectUnref(cfg);
|
|
|
9119d9 |
return ret;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
@@ -4251,6 +4254,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|
|
9119d9 |
virCommandPtr cmd = NULL;
|
|
|
9119d9 |
struct qemuProcessHookData hookData;
|
|
|
9119d9 |
unsigned long cur_balloon;
|
|
|
9119d9 |
+ unsigned int period = 0;
|
|
|
9119d9 |
size_t i;
|
|
|
9119d9 |
bool rawio_set = false;
|
|
|
9119d9 |
char *nodeset = NULL;
|
|
|
9119d9 |
@@ -4864,15 +4868,18 @@ int qemuProcessStart(virConnectPtr conn,
|
|
|
9119d9 |
vm->def->mem.cur_balloon);
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
|
9119d9 |
- goto cleanup;
|
|
|
9119d9 |
if (vm->def->memballoon && vm->def->memballoon->period)
|
|
|
9119d9 |
- qemuMonitorSetMemoryStatsPeriod(priv->mon, vm->def->memballoon->period);
|
|
|
9119d9 |
+ period = vm->def->memballoon->period;
|
|
|
9119d9 |
+ if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ if (period)
|
|
|
9119d9 |
+ qemuMonitorSetMemoryStatsPeriod(priv->mon, period);
|
|
|
9119d9 |
if (qemuMonitorSetBalloon(priv->mon, cur_balloon) < 0) {
|
|
|
9119d9 |
qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
|
|
|
9119d9 |
VIR_DEBUG("Detecting actual memory size for video device");
|
|
|
9119d9 |
if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0)
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.1
|
|
|
9119d9 |
|