lib: Introduce API for retrieving bulk domain stats

The motivation for this API is that management layers that use libvirt
usually poll for statistics using various split up APIs we currently
provide. To get all the necessary stuff, the app needs to issue a lot of
calls and aggregate the results.

The APIs I'm introducing here:
1) Returns data in a format that we can expand in the future and is
(pseudo) hierarchical. The data is returned as typed parameters where
the fields are constructed as dot-separated strings containing names and
other stuff in a list of typed params.

2) Stats for multiple (all) domains can be queried at once and are
returned in one call. This will decrease the overhead necessary to issue
multiple calls per domain multiplied by the count of domains.

3) Selectable (bit mask) fields in the returned format. This will allow
to retrieve only specific stats according to the app's need.

The stats groups will be enabled using a bit field @stats passed as the
function argument. A few sample stats groups that this API will support:

VIR_DOMAIN_STATS_STATE
VIR_DOMAIN_STATS_CPU
VIR_DOMAIN_STATS_BLOCK
VIR_DOMAIN_STATS_INTERFACE

(Note that this is only an example, the initial implementation supports
 only VIR_DOMAIN_STATS_STATE while others will be added later.)

the returned typed params will use the following scheme

state.state = VIR_DOMAIN_RUNNING
state.reason = VIR_DOMAIN_RUNNING_BOOTED (the actual values according to
                                          the enum)
cpu.count = 8
cpu.0.state = running
cpu.0.time = 1234
This commit is contained in:
Peter Krempa
2014-08-26 21:11:42 +02:00
parent 27a20b6c1a
commit 76a5bc4eef
4 changed files with 224 additions and 2 deletions

View File

@@ -2501,6 +2501,30 @@ int virDomainDetachDeviceFlags(virDomainPtr domain,
int virDomainUpdateDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags);
typedef struct _virDomainStatsRecord virDomainStatsRecord;
typedef virDomainStatsRecord *virDomainStatsRecordPtr;
struct _virDomainStatsRecord {
virDomainPtr dom;
virTypedParameterPtr params;
int nparams;
};
typedef enum {
VIR_DOMAIN_STATS_STATE = (1 << 0), /* return domain state */
} virDomainStatsTypes;
int virConnectGetAllDomainStats(virConnectPtr conn,
unsigned int stats,
virDomainStatsRecordPtr **retStats,
unsigned int flags);
int virDomainListGetStats(virDomainPtr *doms,
unsigned int stats,
virDomainStatsRecordPtr **retStats,
unsigned int flags);
void virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats);
/*
* BlockJob API
*/