[libvirt] virDomainGetVcpus error with Fedora 10

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Mar 19 18:15:22 UTC 2009

Daniel P. Berrange wrote:
> On Wed, Mar 11, 2009 at 10:12:16AM -0700, Kaitlin Rupert wrote:
>> Daniel P. Berrange wrote:
>>> On Fri, Feb 13, 2009 at 03:37:22PM -0800, Kaitlin Rupert wrote:
>>>> Hi,
>>>> I'm running Fedora 10 with the following libvirt version:  libvirt-0.6.0-3
>>>> I'm calling virDomainGetVcpus() with the following parameters: 
>>>> virDomainGetVcpus(dom, info, max, NULL, 0);  where max = 2 and dom and 
>>>> info are both non-NULL.
>>>> However, I'm getting the following error from libvirt: libvir: Domain 
>>>> error : invalid argument in virDomainGetVcpus
>>>> I tracked this down, and it's failing the if (cpumaps != NULL && maplen 
>>>> < 1) check in libvirt.c because cpumaps is non-NULL.  Which is very 
>>>> strange because I'm definitely passing a NULL value.
>>> The qemud/remote.c helper for the virDomainGetVcpus method is just 
>>> doing a totally bogus calculation/allocation for the cpumaps field.
>>> It needs fixing somehow, but I'm not sure how yet
>> Any update on this?
> I've had another look at it, and believe I have a suitable fix. There were
> two problems. 
>  - Not allocating a large enough array for the cpumaps field
>  - Not respecting a cpumaplen=0, as meaning pass cpumaps=NULL
> The latter is what was causing the error message you saw I believe. Can
> you try the following patch

+1 (although, i think this is already upstream, sorry for the slow 

I am seeing a new issue now.  After calling 
virDomainSetSchedulerParameters() on a KVM guest, virDomainGetVcpus() 
returns 0 processors even though virsh dumpxml of the guest shows 3 procs.

Looking at the code for qemudDomainGetVcpus(), maxinfo is set to:

     if (maxinfo > vm->nvcpupids)
         maxinfo = vm->nvcpupids;

I'm passing NULL in for cpumaps, so the whole if (cpumaps != NULL) {} 
block is skipped, which means the value for vm->nvcpupids is being returned.

Any thoughts?

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

More information about the libvir-list mailing list