Re: [PATCH 03/12] conf: introduce a new func virDomainRNGEquals

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

 



Subject: ... How about

conf: Introduce function to compare RNG devices.


On 01/03/15 06:06, Luyao Huang wrote:
> virDomainRNGEquals is a func which check if two rng device
> are the same.
> 
> Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
> ---
>  src/conf/domain_conf.c | 34 ++++++++++++++++++++++++++++++++++
>  src/conf/domain_conf.h |  3 +++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index aafc05e..91c114e 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -11922,6 +11922,40 @@ virDomainChrRemove(virDomainDefPtr vmdef,
>      return ret;
>  }
>  
> +bool
> +virDomainRNGEquals(virDomainRNGDefPtr src,
> +                   virDomainRNGDefPtr tgt)
> +{
> +    if (!src || !tgt)
> +        return src == tgt;
> +
> +    if (src->model != tgt->model)
> +        return false;
> +
> +    if (src->rate != tgt->rate || src->period != tgt->period)
> +        return false;
> +
> +    switch ((virDomainRNGModel) src->model) {
> +    case VIR_DOMAIN_RNG_MODEL_VIRTIO:
> +        switch ((virDomainRNGBackend) src->backend) {
> +        case VIR_DOMAIN_RNG_BACKEND_RANDOM:
> +            return STREQ_NULLABLE(src->source.file, tgt->source.file);
> +            break;
> +        case VIR_DOMAIN_RNG_BACKEND_EGD:
> +            return virDomainChrSourceDefIsEqual((virDomainChrSourceDef *) src->source.chardev,
> +                                                (virDomainChrSourceDef *) tgt->source.chardev);

No need for typecast here; both src->source.chardev and tgt ... are
already in the required type.

> +            break;
> +        case VIR_DOMAIN_RNG_BACKEND_LAST:
> +            break;
> +        }
> +        break;
> +
> +    case VIR_DOMAIN_RNG_MODEL_LAST:
> +        break;
> +    }
> +    return false;
> +}
> +
>  char *
>  virDomainDefGetDefaultEmulator(virDomainDefPtr def,
>                                 virCapsPtr caps)
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 57297cd..c197095 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -2597,6 +2597,9 @@ virDomainChrInsert(virDomainDefPtr vmdef,
>  virDomainChrDefPtr
>  virDomainChrRemove(virDomainDefPtr vmdef,
>                     virDomainChrDefPtr chr);
> +bool
> +virDomainRNGEquals(virDomainRNGDefPtr src,
> +                   virDomainRNGDefPtr tgt);

As in the case below, please add the type to the same line as the
declaration.

>  
>  int virDomainSaveXML(const char *configDir,
>                       virDomainDefPtr def,
> 

Peter

Attachment: signature.asc
Description: OpenPGP digital signature

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