*/
# define VIR_DOMAIN_STATS_STATE_REASON "state.reason"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_TIME:
+ *
+ * Total cpu time spent for this domain in nanoseconds as unsigned long long.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_TIME "cpu.time"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_USER:
+ *
+ * User cpu time spent in nanoseconds as unsigned long long.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_USER "cpu.user"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_SYSTEM:
+ *
+ * System cpu time spent in nanoseconds as unsigned long long.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_SYSTEM "cpu.system"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_HALTPOLL_SUCCESS_TIME:
+ *
+ * Halt-polling cpu usage about the VCPU polled until a virtual interrupt was
+ * delivered in nanoseconds as unsigned long long.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_HALTPOLL_SUCCESS_TIME "cpu.haltpoll.success.time"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_HALTPOLL_FAIL_TIME:
+ *
+ * Halt-polling cpu usage about the VCPU had to schedule out (either because
+ * the maximum poll time was reached or it needed to yield the CPU) in
+ * nanoseconds as unsigned long long.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_HALTPOLL_FAIL_TIME "cpu.haltpoll.fail.time"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_COUNT:
+ *
+ * The number of cache monitors for this domain as an unsigned int.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_COUNT "cpu.cache.monitor.count"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX:
+ *
+ * The parameter name prefix to access each cache monitor entry. Concatenate
+ * the prefix, the entry number formatted as an unsigned integer and one of
+ * the cache monitor suffix parameters to form a complete parameter name.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX "cpu.cache.monitor."
+
+/**
+ * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_NAME:
+ *
+ * The name of cache monitor as a string.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_NAME ".name"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_VCPUS:
+ *
+ * Vcpu list of cache monitor as a string.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_VCPUS ".vcpus"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_COUNT:
+ *
+ * The number of cache banks in cache monitor as an unsigned int.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_COUNT ".bank.count"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_PREFIX:
+ *
+ * The parameter name prefix to access each cache monitor bank entry.
+ * Concatenate the cache monitor prefix, the cache monitor entry number
+ * formatted as an unsigned integer, the bank prefix, the bank entry number
+ * formatted as an unsigned integer and one of the cache monitor bank suffix
+ * parameters to form a complete parameter name.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_PREFIX ".bank."
+
+/**
+ * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_SUFFIX_ID:
+ *
+ * Host allocated cache id for the bank as an unsigned int.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_SUFFIX_ID ".id"
+
+/**
+ * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_SUFFIX_BYTES:
+ *
+ * The number of bytes of last level cache that the domain is using as an
+ * unsigned long long.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_SUFFIX_BYTES ".bytes"
+
/**
* virDomainStatsTypes:
*
* parameter keys.
*
* VIR_DOMAIN_STATS_CPU_TOTAL:
- * Return CPU statistics and usage information. The typed parameter keys
- * are in this format:
- *
- * "cpu.time" - total cpu time spent for this domain in nanoseconds
- * as unsigned long long.
- * "cpu.user" - user cpu time spent in nanoseconds as unsigned long long.
- * "cpu.system" - system cpu time spent in nanoseconds as unsigned long
- * long.
- * "cpu.haltpoll.success.time" - halt-polling cpu usage about the VCPU polled
- * until a virtual interrupt was delivered in
- * nanoseconds as unsigned long long.
- * "cpu.haltpoll.fail.time" - halt-polling cpu usage about the VCPU had to schedule
- * out (either because the maximum poll time was reached
- * or it needed to yield the CPU) in nanoseconds as
- * unsigned long long.
- * "cpu.cache.monitor.count" - the number of cache monitors for this domain
- * "cpu.cache.monitor.<num>.name" - the name of cache monitor <num>
- * "cpu.cache.monitor.<num>.vcpus" - vcpu list of cache monitor <num>
- * "cpu.cache.monitor.<num>.bank.count" - the number of cache banks in
- * cache monitor <num>
- * "cpu.cache.monitor.<num>.bank.<index>.id" - host allocated cache id for
- * bank <index> in cache
- * monitor <num>
- * "cpu.cache.monitor.<num>.bank.<index>.bytes" - the number of bytes of
- * last level cache that the
- * domain is using on cache
- * bank <index>
+ * Return CPU statistics and usage information.
+ * The VIR_DOMAIN_STATS_CPU_* constants define the known typed
+ * parameter keys.
*
* VIR_DOMAIN_STATS_BALLOON:
* Return memory balloon device information.
return;
}
- virTypedParamListAddUInt(params, nresdata, "cpu.cache.monitor.count");
+ virTypedParamListAddUInt(params, nresdata,
+ VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_COUNT);
for (i = 0; i < nresdata; i++) {
- virTypedParamListAddString(params, resdata[i]->name, "cpu.cache.monitor.%zu.name", i);
- virTypedParamListAddString(params, resdata[i]->vcpus, "cpu.cache.monitor.%zu.vcpus", i);
- virTypedParamListAddUInt(params, resdata[i]->nstats, "cpu.cache.monitor.%zu.bank.count", i);
+ virTypedParamListAddString(params, resdata[i]->name,
+ VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX "%zu" VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_NAME, i);
+ virTypedParamListAddString(params, resdata[i]->vcpus,
+ VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX "%zu" VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_VCPUS, i);
+ virTypedParamListAddUInt(params, resdata[i]->nstats,
+ VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX "%zu" VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_COUNT, i);
for (j = 0; j < resdata[i]->nstats; j++) {
- virTypedParamListAddUInt(params, resdata[i]->stats[j]->id,
- "cpu.cache.monitor.%zu.bank.%zu.id", i, j);
+ virTypedParamListAddUInt(
+ params, resdata[i]->stats[j]->id,
+ VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX "%zu" VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_PREFIX "%zu" VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_SUFFIX_ID, i, j);
/* 'resdata[i]->stats[j]->vals[0]' keeps the value of how many last
* level cache in bank j currently occupied by the vcpus listed in
* than 4G bytes in size, to keep the 'domstats' interface
* historically consistent, it is safe to report the value with a
* truncated 'UInt' data type here. */
- virTypedParamListAddUInt(params, (unsigned int)resdata[i]->stats[j]->vals[0],
- "cpu.cache.monitor.%zu.bank.%zu.bytes", i, j);
+ virTypedParamListAddUInt(
+ params, (unsigned int)resdata[i]->stats[j]->vals[0],
+ VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX "%zu" VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_PREFIX "%zu" VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_SUFFIX_BYTES, i, j);
}
}
return;
if (virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time) == 0)
- virTypedParamListAddULLong(params, cpu_time, "cpu.time");
+ virTypedParamListAddULLong(params, cpu_time,
+ VIR_DOMAIN_STATS_CPU_TIME);
if (virCgroupGetCpuacctStat(priv->cgroup, &user_time, &sys_time) == 0) {
- virTypedParamListAddULLong(params, user_time, "cpu.user");
- virTypedParamListAddULLong(params, sys_time, "cpu.system");
+ virTypedParamListAddULLong(params, user_time,
+ VIR_DOMAIN_STATS_CPU_USER);
+ virTypedParamListAddULLong(params, sys_time,
+ VIR_DOMAIN_STATS_CPU_SYSTEM);
}
}
virHostCPUGetHaltPollTime(dom->pid, &haltPollSuccess, &haltPollFail) < 0)
return;
- virTypedParamListAddULLong(params, haltPollSuccess, "cpu.haltpoll.success.time");
- virTypedParamListAddULLong(params, haltPollFail, "cpu.haltpoll.fail.time");
+ virTypedParamListAddULLong(params, haltPollSuccess,
+ VIR_DOMAIN_STATS_CPU_HALTPOLL_SUCCESS_TIME);
+ virTypedParamListAddULLong(params, haltPollFail,
+ VIR_DOMAIN_STATS_CPU_HALTPOLL_FAIL_TIME);
return;
}