在 2022/2/21 20:34, Michal Prívozník 写道:
On 2/20/22 14:28, huangy81@xxxxxxxxxxxxxxx wrote:
From: Hyman Huang(黄勇) <huangy81@xxxxxxxxxxxxxxx>
Probing QEMU_CAPS_CALC_DIRTY_RATE capability in advance
in case of failure when calculating dirty page rate.
Signed-off-by: Hyman Huang(黄勇) <huangy81@xxxxxxxxxxxxxxx>
---
src/qemu/qemu_driver.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f1f708e..9b50f5f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20693,6 +20693,13 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
if (virDomainStartDirtyRateCalcEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
+ priv = vm->privateData;
+ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CALC_DIRTY_RATE)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("QEMU does not support calculating dirty page rate"));
+ goto cleanup;
+ }
+
Sorry for not telling you the whole truth. priv->qemuCaps is populated
only when domain is running. Therefore for inactive domains this ^^^
error message is reported which may be a bit misleading. But the fix is
trivial, just check whether domain is active before querying priv-qemuCaps.
Ok, got it :)
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
@@ -20704,7 +20711,6 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
VIR_DEBUG("Calculate dirty rate in next %d seconds", seconds);
- priv = vm->privateData;
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorStartDirtyRateCalc(priv->mon, seconds);
Michal
--
Best regard
Hyman Huang(黄勇)