[Libvirt-cim] [PATCH] Add dynamic VCPU adjustments

Jay Gagnon grendel at linux.vnet.ibm.com
Wed Jan 23 14:49:02 UTC 2008


Dan Smith wrote:
> # HG changeset patch
> # User Dan Smith <danms at us.ibm.com>
> # Date 1201029734 28800
> # Node ID 84f80a8040eb29109d0fce50b582582527c2e50e
> # Parent  47438edf32be70e65bdb814ab609a70304fad2f4
> Add dynamic VCPU adjustments
>
> Signed-off-by: Dan Smith <danms at us.ibm.com>
>
> diff -r 47438edf32be -r 84f80a8040eb libxkutil/device_parsing.c
> --- a/libxkutil/device_parsing.c	Tue Jan 22 10:55:59 2008 -0800
> +++ b/libxkutil/device_parsing.c	Tue Jan 22 11:22:14 2008 -0800
> @@ -897,11 +897,38 @@ static int change_memory(virDomainPtr do
>          return 1;
>  }
>
> +static int change_vcpus(virDomainPtr dom, int delta)
> +{
> +        int count = 32;
> +        int max;
> +        virVcpuInfoPtr foo;
> +
> +        /* This is retarded, but I don't think there's an API to
> +         *   expose the total VCPU number otherwise
> +         */
> +        for (max = count; max == count; max += 32) {
> +                foo = calloc(max, sizeof(*foo));
> +                count = virDomainGetVcpus(dom, foo, max, NULL, 0);
> +                free(foo);
> +        }
>   
I just spent the last ten minutes trying to figure out how to say that I
have no idea what's going on with that loop without it sounding like I
was calling at least one of use stupid.  So far, the best I've come up
with is, "I have no idea what's going on with that loop."  Judging by
your comment, you aren't exactly thrilled with it, and your track record
indicates you certainly wouldn't do something like this without a good
reason, but if you could explain things a little more I'd appreciate it.

The rest looks good to me.

-- 

-Jay




More information about the Libvirt-cim mailing list