diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 76ad9089504f5f707873b782b16111f7ef86e500..3d8a0a1ad7e14586a130d059ad1a819686ec6e4e 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -467,11 +467,13 @@ typedef enum { */ VIR_DOMAIN_MEMORY_STAT_AVAILABLE = 5, + /* Current balloon value (in KB). */ + VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON = 6, /* * 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 = 6, + VIR_DOMAIN_MEMORY_STAT_NR = 7, } virDomainMemoryStatTags; typedef struct _virDomainMemoryStat virDomainMemoryStatStruct; diff --git a/src/libvirt.c b/src/libvirt.c index caace0124fec6353e5d83bdc344ec18a9baaf275..505481a69b7bdc28e72ec11bc5969ea64adda743 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -5750,6 +5750,8 @@ error: * The amount of memory which is not being used for any purpose (in kb). * VIR_DOMAIN_MEMORY_STAT_AVAILABLE: * The total amount of memory available to the domain's OS (in kb). + * VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON: + * Current balloon value (in kb). * * Returns: The number of stats provided or -1 in case of failure. */ diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 75adf661cc6e52093403ae18cfa94a58a03cc1f3..2680b3c3bbd9ce60261231b94f379d48bef43d8a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1119,6 +1119,18 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon, goto cleanup; } + if (virJSONValueObjectHasKey(data, "actual") && (got < nr_stats)) { + if (virJSONValueObjectGetNumberUlong(data, "actual", &mem) < 0) { + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("info balloon reply was missing balloon actual")); + ret = -1; + goto cleanup; + } + stats[got].tag = VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON; + stats[got].val = (mem/1024); + got++; + } + if (virJSONValueObjectHasKey(data, "mem_swapped_in") && (got < nr_stats)) { if (virJSONValueObjectGetNumberUlong(data, "mem_swapped_in", &mem) < 0) { qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 3b42e7ab432188985fe69e5c83475f91318ca457..d432027a6058b90b8ccaff0e8abc66802f43d520 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -549,7 +549,9 @@ static int qemuMonitorParseExtraBalloonInfo(char *text, parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_UNUSED, ",free_mem=", &stats[nr_stats_found]) || parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_AVAILABLE, - ",total_mem=", &stats[nr_stats_found])) + ",total_mem=", &stats[nr_stats_found]) || + parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, + ",actual=", &stats[nr_stats_found])) nr_stats_found++; /* Skip to the next label. When *p is ',' the last match attempt diff --git a/tools/virsh.c b/tools/virsh.c index 76478dc36faedc5fe78be9dc17e44a5d570badf8..863b2de1660678273d47ab8917bdcfdc5b2316eb 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1147,6 +1147,8 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) vshPrint (ctl, "unused %llu\n", stats[i].val); if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_AVAILABLE) 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); } virDomainFree(dom);