Re: [PATCH v2 2/6] qemu_driver: Probe capability before calculating dirty page rate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
> 
> 




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux