[Libvir] Add a timestamp to virDomainInfo ?

Daniel P. Berrange berrange at redhat.com
Thu Apr 13 17:49:33 UTC 2006

The primary use of the virDomainInfo data is in calculating resource
utilization over time. The CPU runtime data, however, is represented
as a counter, so to calulate utilization requires some transformations.
Basically subtract the CPU runtime value for time X, from the value
at time Y, and divide the result by Y-X. Obviously this requires us to
know the times X & Y. Currently the virDomainInfo structure does not
contain this information though, so apps have to call something like
gettimeofday() before virDomainGetInfo(), to record the timestamp of each
virDomainInfo record.

The problem is that this is a pretty poor approximation - particularly
if libvirt is talking via XenD, a non-trivial period of time can pass
between the call to gettimeofday() and the values for virDomainInfo 
actually sampled.

Thus I would like to suggest that the virtDomainInfo structure be expanded
to add an extra data field of type 'struct timeval' to record a high
resolution timestamp. Now currently this wouldn't help accuracy all that 
much, since libvirt would still be filling this in much the same way as
the app did. It does however, open the door to having Xen itself provide
an accurate timestamp back to libvirt, which would in turn benefit apps
without requiring further code change.

|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

More information about the libvir-list mailing list