[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libvirt-users
Subject:    Re: [libvirt-users] What does cpu_time returned by virDomainGetCPUStats mean?
From:       Zhihua Che <zhihua.che () gmail ! com>
Date:       2012-04-17 6:40:18
Message-ID: CABexPfH77-WtHQyNDyufmKGexpE0Ttzc6k-RCbDhrmPzJKZJSQ () mail ! gmail ! com
[Download RAW message or body]

=E5=9C=A8 2012=E5=B9=B44=E6=9C=8817=E6=97=A5 =E4=B8=8A=E5=8D=884:11=EF=BC=
=8CEric Blake <eblake@redhat.com> =E5=86=99=E9=81=93=EF=BC=9A
> On 04/16/2012 05:37 AM, Zhihua Che wrote:
>>
>> =C2=A0 =C2=A0I thought this value store the run time of the cpu since la=
st boot.
>
> The intent is to store run time of the hypervisor process managing the
> guest (which therefore is larger than the amount of time that the guest
> thinks it has been running, since the hypervisor has some overhead).
> But the API is flexible enough that we can add more statistics, if it
> proves easy to collect such additional statistics.
>
>> But I find I was wrong because this value would increase until it
>> wraps down and doesn't reset even the domain is restarted.
>
> How are you restarting the guest? =C2=A0If it is by rebooting the guest
> _within the same qemu process_, then no, the numbers won't reset. =C2=A0B=
ased
> on how the cpuacct cgroup works, the numbers should only wrap when you
> actually create a new qemu process (actually stop the guest and boot it
> fresh in a new qemu process, rather than rebooting the guest within the
> same qemu process).
>
> Perhaps we should be improving our XML to track delta usage since a
> given point in time, and when we detect a domain reboot, update that
> delta point so that the usage will again appear to be 0; allowing a
> delta calculation would also let us "track" CPU usage even across domain
> migration or managedsave/restore.
>
>>
>> =C2=A0 =C2=A0So, what does this value mean?
>>
>> =C2=A0 =C2=A0How can I get the CPU usage of the domain?
>>
>> =C2=A0 =C2=A0I found nothing on the API reference doc page:-(. No word i=
s
>> related with the meaning of the returned array of virTypedParameter by
>> virDomainGetCPUStats().
>
> I found this:
>
> http://libvirt.org/html/libvirt-libvirt.html#VIR_DOMAIN_CPU_STATS_CPUTIME
>
> "cpu usage in nanoseconds, as a ullong"
>
> and looking at libvirt.h, VIR_DOMAIN_CPU_STATS_CPUTIME maps to the
> "cpu_time" name of your API call.
>
> If that still isn't enough information, could you help out by submitting
> patches to improve our documentation?
>
> --

I hope this help user to know what the virTypedParameters mean. As for
me, I didn't connect the function with macros like
VIR_DOMAIN_CPU_STATS_CPUTIME.

I don't know which files in directory docs I should modify. I guess
our docs are generated by extracting comments in source code. So I
modify in comments above virDomainGetCPUStats().

Feel free to tell me if I'm wrong.

["doc-virDomainGetCPUStats.patch" (text/x-patch)]

diff --git a/src/libvirt.c b/src/libvirt.c
index 53b485a..c32d828 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -18642,7 +18642,8 @@ error:
  * any unpopulated parameters will be zeroed on success (this includes
  * skipped elements if @nparams is too large, and tail elements if
  * @ncpus is too large).  The caller is responsible for freeing any
- * returned string parameters.
+ * returned string parameters. See VIR_DOMAIN_CPU_STATS_CPUTIME etc for more
+ * information on exact meaning of parameters returned here.
  */
 int virDomainGetCPUStats(virDomainPtr domain,
                          virTypedParameterPtr params,


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic