[Libvirt-cim] [PATCH 1 of 2] Add a domain_vcpu_count() function to return the number of active VCPUs for

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Oct 28 15:09:38 UTC 2008


> +        info = calloc(max, sizeof(*info));
> +        if (info == NULL) {
> +                CU_DEBUG("Failed to allocate %i vcpuinfo structures", max);
> +                return -1;
> +        }
> +
> +        count = virDomainGetVcpus(dom, info, max, NULL, 0);
> +
> +        free(info);

You free info here..

> +
> +        for (i = 0; i < count; i++) {
> +                if (info[i].cpu != -1)

But use one of its fields in the compare here.

> +                        actual++;
> +        }
> +
> +        return actual;
> +}

-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list