Hi. Any opinions on this?
At Thu, 13 Feb 2014 14:50:08 +0100,
Claudio Bley wrote:
>
> Hi.
>
> When calling virDomainGetMaxVcpus
> (
http://libvirt.org/html/libvirt-libvirt.html#virDomainGetMaxVcpus) on
> an inactive domain, I receive this error:
>
> scala> res2.getMaxVcpus()
> libvirt: Domain Config error : Requested operation is not valid: domain is not
running
> org.libvirt.LibvirtException: Requested operation is not valid: domain is not
running
> at org.libvirt.ErrorHandler.processError(ErrorHandler.java:31)
> at org.libvirt.ErrorHandler.processError(ErrorHandler.java:46)
> at org.libvirt.Domain.getMaxVcpus(Domain.java:571)
> at .<init>(<console>:13)
> ...
>
> (this is from Java, but that doesn't matter)
>
> The docs say:
>
>> If the guest is inactive, this is basically the same as
>> virConnectGetMaxVcpus(). If the guest is running this will reflect
>> the maximum number of virtual CPUs the guest was booted with.
>
> But, apparently, all the driver implementations for
> virDomainGetMaxVcpus forward to
> <driver>DomainGetVcpusFlags(.., VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_VCPU_MAXIMUM).
> _______________________________,~~~~~~~~~~~~~~~~~~~~~~
>
>
> $ git grep --show-function 'GetVcpusFlags.*AFFECT_LIVE'
> src/esx/esx_driver.c=esxDomainGetMaxVcpus(virDomainPtr domain)
> src/esx/esx_driver.c: return esxDomainGetVcpusFlags(domain,
(VIR_DOMAIN_AFFECT_LIVE |
> src/openvz/openvz_driver.c=static int openvzDomainGetMaxVcpus(virDomainPtr dom)
> src/openvz/openvz_driver.c: return openvzDomainGetVcpusFlags(dom,
(VIR_DOMAIN_AFFECT_LIVE |
> src/qemu/qemu_driver.c=qemuDomainGetMaxVcpus(virDomainPtr dom)
> src/qemu/qemu_driver.c: return qemuDomainGetVcpusFlags(dom,
(VIR_DOMAIN_AFFECT_LIVE |
> src/test/test_driver.c=testDomainGetMaxVcpus(virDomainPtr domain)
> src/test/test_driver.c: return testDomainGetVcpusFlags(domain,
(VIR_DOMAIN_AFFECT_LIVE |
> src/vbox/vbox_tmpl.c=vboxDomainGetMaxVcpus(virDomainPtr dom)
> src/vbox/vbox_tmpl.c: return vboxDomainGetVcpusFlags(dom, (VIR_DOMAIN_AFFECT_LIVE
|
>
>
> AFAICS, this was introduced with
>
> commit 50c51f13e2af04afac46e181c4ed62581545a488
> Author: Eric Blake <eblake(a)redhat.com>
> Date: Mon Sep 27 16:37:53 2010 -0600
>
> vcpu: make old API trivially wrap to new API
>
>
> Whereas the function's contract was documented earlier by
>
> commit b412cfadb502c76df095c2c4548c27abf7c4873f
> Author: Daniel Veillard <veillard(a)redhat.com>
> Date: Thu Mar 8 08:31:07 2007 +0000
>
>
> To be honest, I'm not sure whether this worked as described at some
> time in the past _at all_.
>
> How to fix this? Change the documentation or the flag?
>
I think the implementations just need to do something like:
if (domain_is_active)
return DomainGetMaxVCPUs()
return ConnectGetMaxVCPUs()
So, code change not documentation change.
- Cole