[libvirt] [PATCH v3 16/36] util: add API for copying virtual port profile data

Laine Stump laine at laine.org
Fri Mar 22 15:40:44 UTC 2019


On 3/19/19 8:46 AM, Daniel P. Berrangé wrote:
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>   src/libvirt_private.syms         |  1 +
>   src/util/virnetdevvportprofile.c | 16 ++++++++++++++++
>   src/util/virnetdevvportprofile.h |  2 ++
>   3 files changed, 19 insertions(+)
>
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 0694db7089..1e405cbe5f 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -2490,6 +2490,7 @@ virNetDevVlanFree;
>   virNetDevVPortProfileAssociate;
>   virNetDevVPortProfileCheckComplete;
>   virNetDevVPortProfileCheckNoExtras;
> +virNetDevVPortProfileCopy;
>   virNetDevVPortProfileDisassociate;
>   virNetDevVPortProfileEqual;
>   virNetDevVPortProfileMerge3;
> diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
> index fb05190c02..b6e8365e61 100644
> --- a/src/util/virnetdevvportprofile.c
> +++ b/src/util/virnetdevvportprofile.c
> @@ -125,6 +125,22 @@ virNetDevVPortProfileEqual(virNetDevVPortProfilePtr a, virNetDevVPortProfilePtr
>       return true;
>   }
>   
> +
> +int virNetDevVPortProfileCopy(virNetDevVPortProfilePtr *dst, const virNetDevVPortProfile *src)
> +{
> +    if (!src) {
> +        *dst = NULL;
> +        return 0;
> +    }
> +
> +    if (VIR_ALLOC(*dst) < 0)
> +        return -1;
> +
> +    memcpy(*dst, src, sizeof(*src));


Kind of surprising that the entire thing has no pointers to anything 
else, but it doesn't!


Reviewed-by: Laine Stump <laine at laine.org>


> +    return 0;
> +}
> +
> +
>   /* virNetDevVPortProfileCheckComplete() checks that all attributes
>    * required for the type of virtport are specified. When
>    * generateMissing is true, any missing attribute that can be
> diff --git a/src/util/virnetdevvportprofile.h b/src/util/virnetdevvportprofile.h
> index 65b4779861..503c44e086 100644
> --- a/src/util/virnetdevvportprofile.h
> +++ b/src/util/virnetdevvportprofile.h
> @@ -79,6 +79,8 @@ struct _virNetDevVPortProfile {
>   
>   bool virNetDevVPortProfileEqual(virNetDevVPortProfilePtr a,
>                                   virNetDevVPortProfilePtr b);
> +int virNetDevVPortProfileCopy(virNetDevVPortProfilePtr *dst,
> +                              const virNetDevVPortProfile *src);
>   
>   int virNetDevVPortProfileCheckComplete(virNetDevVPortProfilePtr virtport,
>                                          bool generateMissing);





More information about the libvir-list mailing list