qemu_driver: Probe capability before calculating dirty page rate

Probing QEMU_CAPS_CALC_DIRTY_RATE capability in advance
in case of failure when calculating dirty page rate.

Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Hyman Huang(黄勇) 2022-02-20 21:28:09 +08:00 committed by Michal Privoznik
parent b207f84901
commit f78b804b46

View File

@ -20693,6 +20693,16 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
if (virDomainStartDirtyRateCalcEnsureACL(dom->conn, vm->def) < 0) if (virDomainStartDirtyRateCalcEnsureACL(dom->conn, vm->def) < 0)
goto cleanup; goto cleanup;
if (virDomainObjCheckActive(vm) < 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;
}
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup; goto cleanup;
@ -20704,7 +20714,6 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
VIR_DEBUG("Calculate dirty rate in next %d seconds", seconds); VIR_DEBUG("Calculate dirty rate in next %d seconds", seconds);
priv = vm->privateData;
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorStartDirtyRateCalc(priv->mon, seconds); ret = qemuMonitorStartDirtyRateCalc(priv->mon, seconds);