On Tue, Jun 05, 2018 at 03:36:14PM +0200, Michal Privoznik wrote:
On 06/05/2018 03:08 PM, Erik Skultety wrote:
> On Tue, Jun 05, 2018 at 01:41:02PM +0200, Tomáš Golembiovský wrote:
>> Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
>> ---
>> include/libvirt/libvirt-domain.h | 9 ++++++++-
>> src/qemu/qemu_monitor_json.c | 2 ++
>> 2 files changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/libvirt/libvirt-domain.h
b/include/libvirt/libvirt-domain.h
>> index da773b76cb..b96c018a90 100644
>> --- a/include/libvirt/libvirt-domain.h
>> +++ b/include/libvirt/libvirt-domain.h
>> @@ -628,11 +628,18 @@ typedef enum {
>> /* Timestamp of the last update of statistics, in seconds. */
>> VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE = 9,
>>
>> + /*
>> + * The amount of memory, in bytes, that can be quickly reclaimed without
>> + * additional I/O. Typically these pages are used for caching files from
>> + * disk.
>> + */
>> + VIR_DOMAIN_MEMORY_STAT_DISK_CACHES = 10,
>> +
>> /*
>> * 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 = 10,
>> + VIR_DOMAIN_MEMORY_STAT_NR = 11,
>
> this is a public header, this must never change, otherwise you break backwards
> compatibility...
Not true. This is meant to work roughly like this:
virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
nr_stats = virDomainMemoryStats(dom, stats, VIR_DOMAIN_MEMORY_STAT_NR, 0);
And depending what version you are compiled with you will get different
number of results. Important to say that to maintain backward
compatibility we have a rule that says _NR can only grow and never
shrink. Tomas' patch is actually correct (in this aspect).
View examples:
Doh! If only I read the commentary right above the enum it would tell me the
very same thing, I have to admit, I didn't even read properly, I saw a value
being changed and I immediately responded, sorry, I take it back.
Erik