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

Re: [libvirt] [PATCH v3 REBASE 07/16] qemu: simplify getting completed job stats



On Thu, Aug 24, 2017 at 09:56:44 +0300, Nikolay Shirokovskiy wrote:
> ---
>  src/qemu/qemu_driver.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index c62d416..b8a4df7 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -12905,12 +12905,18 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver,
>                                qemuDomainJobInfoPtr jobInfo)
>  {
>      qemuDomainObjPrivatePtr priv = vm->privateData;
> -    qemuDomainJobInfoPtr info;
>      bool fetch = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVENT);
>      int ret = -1;
>  
> -    if (completed)
> -        fetch = false;
> +    if (completed) {
> +        if (priv->job.current || !priv->job.completed) {
> +            jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE;
> +            return 0;
> +        }
> +
> +        *jobInfo = *priv->job.completed;
> +        return 0;

I think keeping just one return would make the code a bit easier to
read:

          if (priv->job.current || !priv->job.completed)
              jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE;
          else
              *jobInfo = *priv->job.completed;

          return 0;

Or even

          if (priv->job.completed && !priv->job.current)
              *jobInfo = *priv->job.completed;
          else
              jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE;

          return 0;

> +    }
>  
>      /* Do not ask QEMU if migration is not even running yet  */
>      if (!priv->job.current || !priv->job.current->stats.status)
...

Jirka


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