qemu_driver: Extend flags parameter of virDomainStartDirtyRateCalc

Extend flags parameter of virDomainStartDirtyRateCalc as a
superset of virDomainDirtyRateCalcFlags, parse the flags and
handle it correspondingly in qemuDomainStartDirtyRateCalc.

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

View File

@ -20676,7 +20676,9 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
qemuMonitorDirtyRateCalcMode mode = QEMU_MONITOR_DIRTYRATE_CALC_MODE_PAGE_SAMPLING;
int ret = -1;
virCheckFlags(0, -1);
virCheckFlags(VIR_DOMAIN_DIRTYRATE_MODE_PAGE_SAMPLING |
VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP |
VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING, -1);
if (seconds < MIN_DIRTYRATE_CALC_PERIOD ||
seconds > MAX_DIRTYRATE_CALC_PERIOD) {
@ -20704,6 +20706,25 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
goto cleanup;
}
if (flags & VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_BITMAP) {
mode = QEMU_MONITOR_DIRTYRATE_CALC_MODE_DIRTY_BITMAP;
} else if (flags & VIR_DOMAIN_DIRTYRATE_MODE_DIRTY_RING) {
if (vm->def->features[VIR_DOMAIN_FEATURE_KVM] != VIR_TRISTATE_SWITCH_ON ||
vm->def->kvm_features->features[VIR_DOMAIN_KVM_DIRTY_RING] != VIR_TRISTATE_SWITCH_ON) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("dirty-ring calculation mode requires dirty-ring feature enabled."));
goto cleanup;
}
mode = QEMU_MONITOR_DIRTYRATE_CALC_MODE_DIRTY_RING;
}
if (mode != QEMU_MONITOR_DIRTYRATE_CALC_MODE_PAGE_SAMPLING &&
!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DIRTYRATE_MODE)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("QEMU does not support dirty page rate calculation mode."));
goto cleanup;
}
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;