Re: [PATCHv4 6/5] conf: reject controllers with duplicate indexes

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

 



On 04/23/2013 06:47 AM, Ján Tomko wrote:
> Reject multiple controllers with the same index,
> except for USB controllers.
> Multi-function USB controllers can have the same index.
> ---
>  src/conf/domain_conf.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 5740009..dd9beba 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -2574,6 +2574,68 @@ virDomainDeviceInfoIterate(virDomainDefPtr def,
>  
>  
>  static int
> +virDomainDefRejectDuplicateControllers(virDomainDefPtr def)
> +{
> +    int max_idx[VIR_DOMAIN_CONTROLLER_TYPE_LAST];
> +    virDomainControllerDefPtr cont;
> +    virBitmapPtr *bitmaps = NULL;
> +    size_t nbitmaps = 0;
> +    int ret = -1;
> +    bool b;
> +    int i;
> +
> +    if (VIR_ALLOC_N(bitmaps, VIR_DOMAIN_CONTROLLER_TYPE_LAST) < 0)
> +        goto no_memory;

Why do you stack allocate an array of max_idx, but heap allocate an
array of bitmap pointers?  It should be possible to stack allocate both
arrays, without exceeding max stack bounds, since
VIR_DOMAIN_CONTROLLER_TYPE_LAST is small.

> +
> +    for (i = 0; i < VIR_DOMAIN_CONTROLLER_TYPE_LAST; i++)
> +        max_idx[i] = -1;

Would a memset be any faster than a for loop here?

What you have is correct, so I'm comfortable giving ACK, but if you want
to post a v5 with the tweaks I mentioned, I'll review that too.

-- 
Eric Blake   eblake redhat com    +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]