2011/5/20 Daniel P. Berrange <berra...@redhat.com>:
> On Tue, May 17, 2011 at 04:01:36PM +0900, Minoru Usui wrote:
>> virNodeGetCPUTimeParameters: Expose new API
>>
>> Signed-off-by: Minoru Usui <u...@mxm.nes.nec.co.jp>
>> ---
>>  include/libvirt/libvirt.h.in |   65 
>> ++++++++++++++++++++++++++++++++++++++++++
>>  src/libvirt_public.syms      |    1 +
>>  2 files changed, 66 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
>> index f4d0b40..723fdf8 100644
>> --- a/include/libvirt/libvirt.h.in
>> +++ b/include/libvirt/libvirt.h.in
>> @@ -280,6 +280,58 @@ struct _virNodeInfo {
>>      unsigned int threads;/* number of threads per core */
>>  };
>>
>> +/**
>> + * VIR_CPU_TIME_FIELD_LENGTH:
>> + *
>> + * Macro providing the field length of virNodeCPUTimeParameters
>> + */
>> +#define VIR_CPU_TIME_FIELD_LENGTH 80
>> +
>> +/**
>> + * VIR_CPU_TIME_KERNEL:
>> + *
>> + * Macro for the cumulative CPU time which spends by kernel,
>> + * when the node booting up.(in nanoseconds).
>> + */
>> +#define VIR_CPU_TIME_KERNEL "kernel"
>> +
>> +/**
>> + * The cumulative CPU time which spends by user processes,
>> + * when the node booting up.(in nanoseconds).
>> + */
>> +#define VIR_CPU_TIME_USER "user"
>> +
>> +/**
>> + * The cumulative idle CPU time,
>> + * when the node booting up.(in nanoseconds).
>> + */
>> +#define VIR_CPU_TIME_IDLE "idle"
>> +
>> +/**
>> + * The cumulative I/O wait CPU time,
>> + * when the node booting up.(in nanoseconds).
>> + */
>> +#define VIR_CPU_TIME_IOWAIT "iowait"
>> +
>> +/**
>> + * The CPU utilization.
>> + * The usage value is in percent and 100% represents all CPUs on
>> + * the server.
>> + */
>> +#define VIR_CPU_TIME_UTILIZATION "utilization"
>> +
>> +/**
>> + * virCPUTimeParameter:
>> + *
>> + * a virNodeCPUTimeParameter is a structure filled by virNodeGetCPUTime()
>> + * and providing the information for the cpu time of the node.
>> + */
>> +typedef struct _virCPUTimeParameter virCPUTimeParameter;
>> +
>> +struct _virCPUTimeParameter {
>> +    char field[VIR_CPU_TIME_FIELD_LENGTH];
>> +    unsigned long long value;
>> +};
>>
>>  /**
>>   * virDomainSchedParameterType:
>> @@ -512,6 +564,14 @@ int virDomainMigrateSetMaxSpeed(virDomainPtr domain,
>>  typedef virNodeInfo *virNodeInfoPtr;
>>
>>  /**
>> + * virCPUTimeParameterPtr:
>> + *
>> + * a virCPUTimeParameterPtr is a pointer to a virCPUTimeParameter structure.
>> + */
>> +
>> +typedef virCPUTimeParameter *virCPUTimeParameterPtr;
>> +
>> +/**
>>   * virConnectFlags
>>   *
>>   * Flags when opening a connection to a hypervisor
>> @@ -645,6 +705,11 @@ int                     virNodeGetInfo          
>> (virConnectPtr conn,
>>                                                   virNodeInfoPtr info);
>>  char *                  virConnectGetCapabilities (virConnectPtr conn);
>>
>> +int                     virNodeGetCPUTimeParameters (virConnectPtr conn,
>> +                                                 virCPUTimeParameterPtr 
>> params,
>> +                                                 int *nparams,
>> +                                                 unsigned int flags);
>> +
>>  unsigned long long      virNodeGetFreeMemory    (virConnectPtr conn);
>>
>>  int                     virNodeGetSecurityModel (virConnectPtr conn,
>> diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
>> index 1444b55..fb8d3e0 100644
>> --- a/src/libvirt_public.syms
>> +++ b/src/libvirt_public.syms
>> @@ -441,6 +441,7 @@ LIBVIRT_0.9.2 {
>>          virDomainGetState;
>>          virDomainInjectNMI;
>>          virDomainScreenshot;
>> +        virNodeGetCPUTimeParameters;
>>  } LIBVIRT_0.9.0;
>>
>>  # .... define new API here using predicted next version number ....
>
> ACK.
>
> I'm wondering whether virCPUTimeParameter should be dropped and just use
> the generic virTypedParameter instead. It would be rather overkill since
> we only really want to ever use  'unsigned long long' for this data,
> but it might be simpler for apps to have the same struct, even if we only
> use one field of it.
>
> Daniel
>

Actually virNodeGetCPUTimeParameters is the wrong name. It's not a
parameter function, it's a statistics function. Therefore, it should
be called virNodeGetCPUTimeStats or virNodeGetCPUStats.

Matthias

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

Reply via email to