mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: Refactor 'virResctrlMonitorStats'
Refactor 'virResctrlMonitorStats' to track multiple statistical records. Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
782dd229ac
commit
c09a14e5b4
src
@ -20842,7 +20842,7 @@ qemuDomainGetStatsCpuCache(virDomainObjPtr dom,
|
|||||||
"cpu.cache.monitor.%zu.bank.%zu.bytes", i, j);
|
"cpu.cache.monitor.%zu.bank.%zu.bytes", i, j);
|
||||||
if (virTypedParamsAddUInt(&record->params, &record->nparams,
|
if (virTypedParamsAddUInt(&record->params, &record->nparams,
|
||||||
maxparams, param_name,
|
maxparams, param_name,
|
||||||
resdata[i]->stats[j]->val) < 0)
|
resdata[i]->stats[j]->vals[0]) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2687,6 +2687,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
|
|||||||
{
|
{
|
||||||
int rv = -1;
|
int rv = -1;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
unsigned int val = 0;
|
||||||
DIR *dirp = NULL;
|
DIR *dirp = NULL;
|
||||||
char *datapath = NULL;
|
char *datapath = NULL;
|
||||||
char *filepath = NULL;
|
char *filepath = NULL;
|
||||||
@ -2743,7 +2744,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
|
|||||||
if (virStrToLong_uip(node_id, NULL, 0, &stat->id) < 0)
|
if (virStrToLong_uip(node_id, NULL, 0, &stat->id) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
rv = virFileReadValueUint(&stat->val, "%s/%s/%s", datapath,
|
rv = virFileReadValueUint(&val, "%s/%s/%s", datapath,
|
||||||
ent->d_name, resource);
|
ent->d_name, resource);
|
||||||
if (rv == -2) {
|
if (rv == -2) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -2753,6 +2754,12 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monitor,
|
|||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (VIR_APPEND_ELEMENT(stat->vals, stat->nvals, val) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virStringListAdd(&stat->features, resource) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_APPEND_ELEMENT(*stats, *nstats, stat) < 0)
|
if (VIR_APPEND_ELEMENT(*stats, *nstats, stat) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -2777,6 +2784,8 @@ virResctrlMonitorStatsFree(virResctrlMonitorStatsPtr stat)
|
|||||||
if (!stat)
|
if (!stat)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
virStringListFree(stat->features);
|
||||||
|
VIR_FREE(stat->vals);
|
||||||
VIR_FREE(stat);
|
VIR_FREE(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,8 +193,16 @@ typedef virResctrlMonitor *virResctrlMonitorPtr;
|
|||||||
typedef struct _virResctrlMonitorStats virResctrlMonitorStats;
|
typedef struct _virResctrlMonitorStats virResctrlMonitorStats;
|
||||||
typedef virResctrlMonitorStats *virResctrlMonitorStatsPtr;
|
typedef virResctrlMonitorStats *virResctrlMonitorStatsPtr;
|
||||||
struct _virResctrlMonitorStats {
|
struct _virResctrlMonitorStats {
|
||||||
unsigned int id;
|
/* The system assigned cache ID associated with statistical record */
|
||||||
unsigned int val;
|
unsigned int id;
|
||||||
|
/* @features is a NULL terminal string list tracking the statistical record
|
||||||
|
* name.*/
|
||||||
|
char **features;
|
||||||
|
/* @vals store the statistical record values and @val[0] is the value for
|
||||||
|
* @features[0], @val[1] for@features[1] ... respectively */
|
||||||
|
unsigned int *vals;
|
||||||
|
/* The length of @vals array */
|
||||||
|
size_t nvals;
|
||||||
};
|
};
|
||||||
|
|
||||||
virResctrlMonitorPtr
|
virResctrlMonitorPtr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user