--- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 11 +++++++++ src/qemu/qemu_driver.c | 48 ++++++++++++++++++++++++++++++++++++++++ tools/virsh-domain-monitor.c | 7 ++++++ 4 files changed, 67 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 598db28..696b686 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2041,6 +2041,7 @@ typedef enum { VIR_DOMAIN_STATS_INTERFACE = (1 << 4), /* return domain interfaces info */ VIR_DOMAIN_STATS_BLOCK = (1 << 5), /* return domain block info */ VIR_DOMAIN_STATS_PERF = (1 << 6), /* return domain perf event info */ + VIR_DOMAIN_STATS_RESCTRL = (1<<7), /* return resctrlfs mornitoring info */ } virDomainStatsTypes; typedef enum { diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 07a19a6..3f1e156 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11486,6 +11486,17 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * long long. It is produced by the * emulation_faults perf event * + * VIR_DOMAIN_STATS_RESCTRL + * "resctrl.cmt" - the usage of l3 cache (bytes) by applications running on + * the platform as unsigned long long. It is retrieved from + * resctrl file system. + * "resctrl.mbmt" - the total system bandwidth (bytes/s) from one level of + * cache to another as unsigned long long. Retrieved from + * resctrl file system. + * "resctrl.mbml" - the amount of data (bytes/s) sent through the memory + * controller on the socket as unsigned long long. Retrieved + * from resctrl file system. + * * Note that entire stats groups or individual stat fields may be missing from * the output in case they are not supported by the given hypervisor, are not * applicable for the current state of the guest domain, or their retrieval diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4075daa..8004e26 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20313,6 +20313,53 @@ qemuDomainGetStatsPerf(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, return ret; } +static int +qemuDomainGetStatsResctrl(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, + virDomainObjPtr vm, + virDomainStatsRecordPtr record, + int *maxparams, + unsigned int privflags ATTRIBUTE_UNUSED) +{ + size_t i; + unsigned int llc_occu; + unsigned int llc_occu_total= 0; + int ret = -1; +#define DOMAIN_STATE_STR_RESCTRL "resctrl" + + for (i = 0; i < vm->def->ncachetunes; i++) { + virDomainCachetuneDefPtr ct = vm->def->cachetunes[i]; + + if (virResctrlMonIsRunning(ct->mon)) { + VIR_DEBUG("llc_occupancy: checking cachetune [%ld] ", i); + if (virResctrlMonGetCacheOccupancy(ct->mon, &llc_occu) < 0) + goto cleanup; + llc_occu_total += llc_occu; + } + } + + if (vm->def->resctrlmon_noalloc && + virResctrlMonIsRunning(vm->def->resctrlmon_noalloc)) { + VIR_DEBUG("llc_occupancy: checking resctrl vcpu-rest"); + if (virResctrlMonGetCacheOccupancy( + vm->def->resctrlmon_noalloc, &llc_occu) < 0) + goto cleanup; + llc_occu_total += llc_occu; + } + + if (virTypedParamsAddInt(&record->params, + &record->nparams, + maxparams, + DOMAIN_STATE_STR_RESCTRL + ".cmt", + llc_occu_total) < 0){ + goto cleanup; + } + + ret = 0; +cleanup: + return ret; +} + typedef int (*qemuDomainGetStatsFunc)(virQEMUDriverPtr driver, virDomainObjPtr dom, @@ -20334,6 +20381,7 @@ static struct qemuDomainGetStatsWorker qemuDomainGetStatsWorkers[] = { { qemuDomainGetStatsInterface, VIR_DOMAIN_STATS_INTERFACE, false }, { qemuDomainGetStatsBlock, VIR_DOMAIN_STATS_BLOCK, true }, { qemuDomainGetStatsPerf, VIR_DOMAIN_STATS_PERF, false }, + { qemuDomainGetStatsResctrl, VIR_DOMAIN_STATS_RESCTRL, false }, { NULL, 0, false } }; diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 8cbb3db..b08d977 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1948,6 +1948,10 @@ static const vshCmdOptDef opts_domstats[] = { .type = VSH_OT_BOOL, .help = N_("report domain perf event statistics"), }, + {.name = "resctrl", + .type = VSH_OT_BOOL, + .help = N_("report resctrlfs mon group information"), + }, {.name = "list-active", .type = VSH_OT_BOOL, .help = N_("list only active domains"), @@ -2057,6 +2061,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "perf")) stats |= VIR_DOMAIN_STATS_PERF; + if (vshCommandOptBool(cmd, "resctrl")) + stats |= VIR_DOMAIN_STATS_RESCTRL; + if (vshCommandOptBool(cmd, "list-active")) flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list