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

Re: [libvirt] [PATCH v2.1 04/21] add function bitmapFromBytemap() to convert bytemap to bitmap



On Tue, Aug 21, 2012 at 05:18:27PM +0800, Hu Tao wrote:
> ---
>  src/conf/domain_conf.c |   39 +++++++++++++++++++++++++--------------
>  1 file changed, 25 insertions(+), 14 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index c9f5a3c..4e52177 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -10893,36 +10893,47 @@ virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
>      return NULL;
>  }
>  
> -int
> -virDomainVcpuPinAdd(virDomainDefPtr def,
> -                    unsigned char *cpumap,
> -                    int maplen,
> -                    int vcpu)
> +char *bitmapFromBytemap(unsigned char *bytemap, int maplen)

  I had to make that function static as it is not used anywhere else and
not exported .

>  {
> -    virDomainVcpuPinDefPtr *vcpupin_list = NULL;
> -    virDomainVcpuPinDefPtr vcpupin = NULL;
> -    char *cpumask = NULL;
> +    char *bitmap = NULL;
>      int i;
>  
> -    if (VIR_ALLOC_N(cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) {
> +    if (VIR_ALLOC_N(bitmap, VIR_DOMAIN_CPUMASK_LEN) < 0) {
>          virReportOOMError();
>          goto cleanup;
>      }
>  
> -    /* Reset cpumask to all 0s. */
> +    /* Reset bitmap to all 0s. */
>      for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++)
> -        cpumask[i] = 0;
> +        bitmap[i] = 0;
>  
> -    /* Convert bitmap (cpumap) to cpumask, which is byte map? */
> +    /* Convert bitmap (bytemap) to bitmap, which is byte map? */
>      for (i = 0; i < maplen; i++) {
>          int cur;
>  
>          for (cur = 0; cur < 8; cur++) {
> -            if (cpumap[i] & (1 << cur))
> -                cpumask[i * 8 + cur] = 1;
> +            if (bytemap[i] & (1 << cur))
> +                bitmap[i * 8 + cur] = 1;
>          }
>      }
>  
> +cleanup:
> +    return bitmap;
> +}
> +
> +int
> +virDomainVcpuPinAdd(virDomainDefPtr def,
> +                    unsigned char *cpumap,
> +                    int maplen,
> +                    int vcpu)
> +{
> +    virDomainVcpuPinDefPtr *vcpupin_list = NULL;
> +    virDomainVcpuPinDefPtr vcpupin = NULL;
> +    char *cpumask = NULL;
> +
> +    if ((cpumask = bitmapFromBytemap(cpumap, maplen)) == NULL)
> +        goto cleanup;
> +
>      /* No vcpupin exists yet. */
>      if (!def->cputune.nvcpupin) {
>          if (VIR_ALLOC(vcpupin) < 0) {

  Fine other wise, ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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