[libvirt] virDomainGetVcpus error with Fedora 10

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. Here's the relevant libvirtd debug: 15:38:07.332: debug : virGetDomain:287 : New hash entry 0x816ab0 15:38:07.332: debug : virDomainGetVcpus:4080 : domain=0x816ab0, info=0x800530, maxinfo=2, cpumaps=0x7f8fb0, maplen=0 15:38:07.332: error : invalid argument in virDomainGetVcpus libvir: Domain error : invalid argument in virDomainGetVcpus 15:38:07.332: debug : virDomainFree:1795 : domain=0x816ab0 Has anyone else hit this same issue? -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

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 Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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
Yep, I took a look at this bit of code, but I wasn't sure of a clear solution either. Have you taken another look at this? -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

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
Daniel
Hi Daniel, Any update on this? Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

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 Daniel Index: qemud/remote.c =================================================================== RCS file: /data/cvs/libvirt/qemud/remote.c,v retrieving revision 1.64 diff -u -p -r1.64 remote.c --- qemud/remote.c 3 Mar 2009 09:27:03 -0000 1.64 +++ qemud/remote.c 12 Mar 2009 11:50:58 -0000 @@ -1475,7 +1475,8 @@ remoteDispatchDomainGetVcpus (struct qem /* Allocate buffers to take the results. */ if (VIR_ALLOC_N(info, args->maxinfo) < 0) goto oom; - if (VIR_ALLOC_N(cpumaps, args->maxinfo) < 0) + if (args->maplen > 0 && + VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0) goto oom; info_len = virDomainGetVcpus (dom, -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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 response). 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@linux.vnet.ibm.com

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 response).
I am seeing a new issue now. After calling virDomainSetSchedulerParameters() on a KVM guest, virDomainGetVcpus()
Oops, the virDomainSetSchedulerParameters() here was a typo. Anyway, I tracked this issue down to a conflicting install of libvirt on the system. After removing all versions of libvirt and reinstalling, this is no longer any issue. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Daniel P. Berrange
-
Kaitlin Rupert