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

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

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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