|
|
9119d9 |
From 6cacbd1b9233e98576c01f5245c7d95b2501f15d Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <6cacbd1b9233e98576c01f5245c7d95b2501f15d@dist-git>
|
|
|
9119d9 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
9119d9 |
Date: Mon, 19 Jan 2015 10:48:30 +0100
|
|
|
9119d9 |
Subject: [PATCH] Fix vmdef usage while in monitor in BlockStat* APIs
|
|
|
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 a local copy of the disk alias instead of pointing
|
|
|
9119d9 |
to the domain definition, which might get freed if
|
|
|
9119d9 |
the domain dies while we're in monitor.
|
|
|
9119d9 |
|
|
|
9119d9 |
Also exit early if that happens.
|
|
|
9119d9 |
|
|
|
9119d9 |
(cherry picked from commit 3f2139843760e6d5596b75db9df6af8c6e9c1ee6)
|
|
|
9119d9 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
9119d9 |
|
|
|
9119d9 |
Conflicts:
|
|
|
9119d9 |
src/qemu/qemu_driver.c - missing qemuDomainEndAPI and maxOptions
|
|
|
9119d9 |
for block IO throttle
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_driver.c | 26 +++++++++++++++++++-------
|
|
|
9119d9 |
1 file changed, 19 insertions(+), 7 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
index 97d850b..9eb5f9c 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_driver.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
@@ -10120,6 +10120,7 @@ qemuDomainBlockStats(virDomainPtr dom,
|
|
|
9119d9 |
virDomainObjPtr vm;
|
|
|
9119d9 |
virDomainDiskDefPtr disk = NULL;
|
|
|
9119d9 |
qemuDomainObjPrivatePtr priv;
|
|
|
9119d9 |
+ char *diskAlias = NULL;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (!*path) {
|
|
|
9119d9 |
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
|
9119d9 |
@@ -10155,11 +10156,14 @@ qemuDomainBlockStats(virDomainPtr dom,
|
|
|
9119d9 |
goto endjob;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (VIR_STRDUP(diskAlias, disk->info.alias) < 0)
|
|
|
9119d9 |
+ goto endjob;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
priv = vm->privateData;
|
|
|
9119d9 |
|
|
|
9119d9 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
9119d9 |
ret = qemuMonitorGetBlockStatsInfo(priv->mon,
|
|
|
9119d9 |
- disk->info.alias,
|
|
|
9119d9 |
+ diskAlias,
|
|
|
9119d9 |
&stats->rd_req,
|
|
|
9119d9 |
&stats->rd_bytes,
|
|
|
9119d9 |
NULL,
|
|
|
9119d9 |
@@ -10169,7 +10173,8 @@ qemuDomainBlockStats(virDomainPtr dom,
|
|
|
9119d9 |
NULL,
|
|
|
9119d9 |
NULL,
|
|
|
9119d9 |
&stats->errs);
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
|
|
|
9119d9 |
endjob:
|
|
|
9119d9 |
if (!qemuDomainObjEndJob(driver, vm))
|
|
|
9119d9 |
@@ -10178,6 +10183,7 @@ qemuDomainBlockStats(virDomainPtr dom,
|
|
|
9119d9 |
cleanup:
|
|
|
9119d9 |
if (vm)
|
|
|
9119d9 |
virObjectUnlock(vm);
|
|
|
9119d9 |
+ VIR_FREE(diskAlias);
|
|
|
9119d9 |
return ret;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -10193,11 +10199,11 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
|
|
|
9119d9 |
int idx;
|
|
|
9119d9 |
int tmp, ret = -1;
|
|
|
9119d9 |
virDomainObjPtr vm;
|
|
|
9119d9 |
- virDomainDiskDefPtr disk = NULL;
|
|
|
9119d9 |
qemuDomainObjPrivatePtr priv;
|
|
|
9119d9 |
long long rd_req, rd_bytes, wr_req, wr_bytes, rd_total_times;
|
|
|
9119d9 |
long long wr_total_times, flush_req, flush_total_times, errs;
|
|
|
9119d9 |
virTypedParameterPtr param;
|
|
|
9119d9 |
+ char *diskAlias = NULL;
|
|
|
9119d9 |
|
|
|
9119d9 |
virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -10226,6 +10232,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
if (*nparams != 0) {
|
|
|
9119d9 |
+ virDomainDiskDefPtr disk = NULL;
|
|
|
9119d9 |
if ((idx = virDomainDiskIndexByName(vm->def, path, false)) < 0) {
|
|
|
9119d9 |
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
9119d9 |
_("invalid path: %s"), path);
|
|
|
9119d9 |
@@ -10239,6 +10246,8 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
|
|
|
9119d9 |
disk->dst);
|
|
|
9119d9 |
goto endjob;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
+ if (VIR_STRDUP(diskAlias, disk->info.alias) < 0)
|
|
|
9119d9 |
+ goto endjob;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
priv = vm->privateData;
|
|
|
9119d9 |
@@ -10249,12 +10258,12 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
|
|
|
9119d9 |
ret = qemuMonitorGetBlockStatsParamsNumber(priv->mon, nparams);
|
|
|
9119d9 |
|
|
|
9119d9 |
if (tmp == 0 || ret < 0) {
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
|
|
9119d9 |
goto endjob;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
ret = qemuMonitorGetBlockStatsInfo(priv->mon,
|
|
|
9119d9 |
- disk->info.alias,
|
|
|
9119d9 |
+ diskAlias,
|
|
|
9119d9 |
&rd_req,
|
|
|
9119d9 |
&rd_bytes,
|
|
|
9119d9 |
&rd_total_times,
|
|
|
9119d9 |
@@ -10265,7 +10274,8 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
|
|
|
9119d9 |
&flush_total_times,
|
|
|
9119d9 |
&errs);
|
|
|
9119d9 |
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (ret < 0)
|
|
|
9119d9 |
goto endjob;
|
|
|
9119d9 |
@@ -10353,6 +10363,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
|
|
|
9119d9 |
cleanup:
|
|
|
9119d9 |
if (vm)
|
|
|
9119d9 |
virObjectUnlock(vm);
|
|
|
9119d9 |
+ VIR_FREE(diskAlias);
|
|
|
9119d9 |
return ret;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -16544,7 +16555,8 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
qemuDomainObjEnterMonitor(driver, vm);
|
|
|
9119d9 |
ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, &info;;
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, vm);
|
|
|
9119d9 |
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
|
|
9119d9 |
+ ret = -1;
|
|
|
9119d9 |
if (ret < 0)
|
|
|
9119d9 |
goto endjob;
|
|
|
9119d9 |
vm->def->disks[idx]->blkdeviotune = info;
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.1
|
|
|
9119d9 |
|