Re: [PATCHv2 1/2] Add a new flag VIR_DOMAIN_CPU_STATS_VCPU to virDomainGetCPUStats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 02, 2012 at 01:43:03PM -0600, Eric Blake wrote:
> On 04/24/2012 03:20 AM, Hu Tao wrote:
> > Currently virDomainGetCPUStats gets total cpu usage, which consists
> > of:
> > 
> >   1. vcpu usage: the physical cpu time consumed by virtual cpu(s) of
> >      domain
> >   2. hypervisor: `total cpu usage' - `vcpu usage'
> > 
> > The flag VIR_DOMAIN_CPU_STATS_VCPU is for getting vcpu usages.
> > ---
> >  include/libvirt/libvirt.h.in |    8 ++++++++
> >  src/libvirt.c                |    9 +++++++--
> >  tools/virsh.c                |   16 +++++++++++-----
> >  3 files changed, 26 insertions(+), 7 deletions(-)
> 
> Question: is it better to make the user call virDomainGetCPUStats twice
> (once for total with flags==0, once for vcpu with flags=VCPU), where
> there is a race between the two calls?  Or should we instead return both
> counts in the same call, by having two separate virTypedParameter stat
> names and no flag?

Slightly off-topic ...

My opinion on this -- and it applies to many libvirt calls -- is that
APIs where you have to call them twice, once to size the result, and a
second time to get the result, are obtuse and hard to use.

In libguestfs I took the approach that all calls return malloc'd
strings, arrays, etc of the right size.  The caller has to free the
data, but that's the lesser of two evils.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]