On Thu, Jan 27, 2022 at 15:25:18 +0800, 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 | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index 0a1ba74..0e8e9b1 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -20647,10 +20647,22 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, > virQEMUDriver *driver = dom->conn->privateData; > virDomainObj *vm = NULL; > qemuDomainObjPrivate *priv; > + g_autoptr(virQEMUCaps) qemucaps = NULL; > int ret = -1; > > virCheckFlags(0, -1); > > + if (!(qemucaps = virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, > + NULL, NULL, NULL, NULL, > + NULL, NULL, NULL))) > + return -1; This is not needed, qemuCaps for a running vm are stored in 'priv->qemuCaps'. In fact it's wrong to not use the stored capabilities. > + > + if (!virQEMUCapsGet(qemucaps, QEMU_CAPS_CALC_DIRTY_RATE)) { > + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", > + _("QEMU does not support calculating dirty page rate")); > + return -1; > + } Obviously the code will need to be moved to a place where 'priv' is already populated. > + > if (seconds < MIN_DIRTYRATE_CALC_PERIOD || > seconds > MAX_DIRTYRATE_CALC_PERIOD) { > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > -- > 1.8.3.1 > >