Re: [PATCHv2 2/4] util: add virNetDevVlanType

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

 



On 08/14/2012 01:15 AM, Laine Stump wrote:
> To allow for the possibility of vlan "trunks", which have more than
> one vlan tag associated with them, we need a vlan struct. Since it
> will be used by multiple files in src/util, src/conf, src/network, and
> src/qemu, it must be defined in src/util. Unfortunately there isn't
> currently a common file for simple netdev data definitions, so I
> created a new file.

> +int
> +virNetDevVlanEqual(const virNetDevVlanPtr a, const virNetDevVlanPtr b)
> +{
> +    int ii;
> +
> +    if (!(a || b))
> +        return true;
> +    if (!a || !b)
> +        return false;
> +
> +    if (a->trunk != b->trunk ||
> +        a->nTags != b->nTags) {
> +        return false;
> +    }
> +
> +    for (ii = 0; ii < a->nTags; ii++) {
> +        if (a->tag[ii] != b->tag[ii])
> +            return false;

I think this requires the user to list tags in identical order.  Should
two virNetDevVlanPtr be considered equal if the only difference is the
order in which tags are listed, or is there some other reason why an
unsorted list would lose significance if sorted?

> +int
> +virNetDevVlanCopy(virNetDevVlanPtr dst, const virNetDevVlanPtr src)
> +{
> +    if (!src || src->nTags == 0)
> +        return 0;
> +
> +    if (VIR_ALLOC_N(dst->tag, src->nTags) < 0) {
> +        virReportOOMError();
> +        return -1;
> +    }
> +
> +    dst->trunk = src->trunk;
> +    dst->nTags = src->nTags;
> +    memmove(dst->tag, src->tag, src->nTags * sizeof(*src->tag));

src and dst better not overlap; therefore, memcpy() is a better fit.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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]