1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

Added RSS reporting

Added RSS information gathering into qemuMemoryStats into qemu driver
and the reporting into virsh dommemstat.
This commit is contained in:
Martin Kletzander 2012-01-24 14:25:05 +01:00 committed by Daniel Veillard
parent 350d6ccb91
commit 3d93706d0d
3 changed files with 26 additions and 6 deletions

View File

@ -884,11 +884,16 @@ typedef enum {
/* Current balloon value (in KB). */
VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON = 6,
/* Resident Set Size of the process running the domain. This value
* is in kB */
VIR_DOMAIN_MEMORY_STAT_RSS = 7,
/*
* The number of statistics supported by this version of the interface.
* To add new statistics, add them to the enum and increase this value.
*/
VIR_DOMAIN_MEMORY_STAT_NR = 7,
VIR_DOMAIN_MEMORY_STAT_NR = 8,
#ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_MEMORY_STAT_LAST = VIR_DOMAIN_MEMORY_STAT_NR

View File

@ -8035,7 +8035,7 @@ qemudDomainMemoryStats (virDomainPtr dom,
{
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
unsigned int ret = -1;
int ret = -1;
virCheckFlags(0, -1);
@ -8054,14 +8054,27 @@ qemudDomainMemoryStats (virDomainPtr dom,
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
goto cleanup;
if (virDomainObjIsActive(vm)) {
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
} else {
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetMemoryStats(priv->mon, stats, nr_stats);
qemuDomainObjExitMonitor(driver, vm);
} else {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
if (ret >= 0 && ret < nr_stats) {
long rss;
if (qemudGetProcessInfo(NULL, NULL, &rss, vm->pid, 0) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot get RSS for domain"));
} else {
stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_RSS;
stats[ret].val = rss;
ret++;
}
}
}
if (qemuDomainObjEndJob(driver, vm) == 0)

View File

@ -2052,6 +2052,8 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
vshPrint (ctl, "available %llu\n", stats[i].val);
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON)
vshPrint (ctl, "actual %llu\n", stats[i].val);
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_RSS)
vshPrint (ctl, "rss %llu\n", stats[i].val);
}
virDomainFree(dom);