[libvirt] [PATCH python] include usable memory in virDomainMemoryStats

Tomáš Golembiovský posted 1 patch 6 years, 8 months ago
Failed in applying to current master (apply log)
libvirt-override.c | 3 +++
1 file changed, 3 insertions(+)
[libvirt] [PATCH python] include usable memory in virDomainMemoryStats
Posted by Tomáš Golembiovský 6 years, 8 months ago
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
---
 libvirt-override.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libvirt-override.c b/libvirt-override.c
index 0abfc37..832e05c 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -398,6 +398,9 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
         case VIR_DOMAIN_MEMORY_STAT_RSS:
             key = libvirt_constcharPtrWrap("rss");
             break;
+        case VIR_DOMAIN_MEMORY_STAT_USABLE:
+            key = libvirt_constcharPtrWrap("usable");
+            break;
         default:
             continue;
         }
-- 
2.13.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] include usable memory in virDomainMemoryStats
Posted by Michal Privoznik 6 years, 8 months ago
On 08/01/2017 03:23 PM, Tomáš Golembiovský wrote:
> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
> ---
>  libvirt-override.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libvirt-override.c b/libvirt-override.c
> index 0abfc37..832e05c 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -398,6 +398,9 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
>          case VIR_DOMAIN_MEMORY_STAT_RSS:
>              key = libvirt_constcharPtrWrap("rss");
>              break;
> +        case VIR_DOMAIN_MEMORY_STAT_USABLE:
> +            key = libvirt_constcharPtrWrap("usable");
> +            break;
>          default:
>              continue;
>          }
> 

Almost. Firstly, there's VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE which is not
handled either. Secondly, these two macros were introduced in libvirt
2.1.0. So we need a check that enables them iff building with 2.1.0 or
newer. I'm fixing both issues and pushing. I wonder if there's something
we can do to not forget about macros like these again.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] include usable memory in virDomainMemoryStats
Posted by Martin Kletzander 6 years, 8 months ago
On Wed, Aug 02, 2017 at 12:52:32PM +0200, Michal Privoznik wrote:
>On 08/01/2017 03:23 PM, Tomáš Golembiovský wrote:
>> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
>> ---
>>  libvirt-override.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/libvirt-override.c b/libvirt-override.c
>> index 0abfc37..832e05c 100644
>> --- a/libvirt-override.c
>> +++ b/libvirt-override.c
>> @@ -398,6 +398,9 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
>>          case VIR_DOMAIN_MEMORY_STAT_RSS:
>>              key = libvirt_constcharPtrWrap("rss");
>>              break;
>> +        case VIR_DOMAIN_MEMORY_STAT_USABLE:
>> +            key = libvirt_constcharPtrWrap("usable");
>> +            break;
>>          default:
>>              continue;
>>          }
>>
>
>Almost. Firstly, there's VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE which is not
>handled either. Secondly, these two macros were introduced in libvirt
>2.1.0. So we need a check that enables them iff building with 2.1.0 or
>newer. I'm fixing both issues and pushing. I wonder if there's something
>we can do to not forget about macros like these again.
>

You mean like this?  Or am I missing a reason why this won't work?

diff --git a/libvirt-override.c b/libvirt-override.c
index 0abfc379c528..6e678d2efb2d 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -373,7 +373,7 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
         return NULL;

     for (i = 0; i < nr_stats; i++) {
-        switch (stats[i].tag) {
+        switch ((virDomainMemoryStatTags) stats[i].tag) {
         case VIR_DOMAIN_MEMORY_STAT_SWAP_IN:
             key = libvirt_constcharPtrWrap("swap_in");
             break;
@@ -398,7 +398,8 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
         case VIR_DOMAIN_MEMORY_STAT_RSS:
             key = libvirt_constcharPtrWrap("rss");
             break;
-        default:
+        case VIR_DOMAIN_MEMORY_STAT_NR:
+        case VIR_DOMAIN_MEMORY_STAT_LAST:
             continue;
         }
         val = libvirt_ulonglongWrap(stats[i].val);
--
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] include usable memory in virDomainMemoryStats
Posted by Michal Privoznik 6 years, 8 months ago
On 08/02/2017 01:17 PM, Martin Kletzander wrote:
> On Wed, Aug 02, 2017 at 12:52:32PM +0200, Michal Privoznik wrote:
>> On 08/01/2017 03:23 PM, Tomáš Golembiovský wrote:
>>> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
>>> ---
>>>  libvirt-override.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/libvirt-override.c b/libvirt-override.c
>>> index 0abfc37..832e05c 100644
>>> --- a/libvirt-override.c
>>> +++ b/libvirt-override.c
>>> @@ -398,6 +398,9 @@ libvirt_virDomainMemoryStats(PyObject *self
>>> ATTRIBUTE_UNUSED,
>>>          case VIR_DOMAIN_MEMORY_STAT_RSS:
>>>              key = libvirt_constcharPtrWrap("rss");
>>>              break;
>>> +        case VIR_DOMAIN_MEMORY_STAT_USABLE:
>>> +            key = libvirt_constcharPtrWrap("usable");
>>> +            break;
>>>          default:
>>>              continue;
>>>          }
>>>
>>
>> Almost. Firstly, there's VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE which is not
>> handled either. Secondly, these two macros were introduced in libvirt
>> 2.1.0. So we need a check that enables them iff building with 2.1.0 or
>> newer. I'm fixing both issues and pushing. I wonder if there's something
>> we can do to not forget about macros like these again.
>>
> 
> You mean like this?  Or am I missing a reason why this won't work?
> 
> diff --git a/libvirt-override.c b/libvirt-override.c
> index 0abfc379c528..6e678d2efb2d 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -373,7 +373,7 @@ libvirt_virDomainMemoryStats(PyObject *self
> ATTRIBUTE_UNUSED,
>         return NULL;
> 
>     for (i = 0; i < nr_stats; i++) {
> -        switch (stats[i].tag) {
> +        switch ((virDomainMemoryStatTags) stats[i].tag) {
>         case VIR_DOMAIN_MEMORY_STAT_SWAP_IN:
>             key = libvirt_constcharPtrWrap("swap_in");
>             break;
> @@ -398,7 +398,8 @@ libvirt_virDomainMemoryStats(PyObject *self
> ATTRIBUTE_UNUSED,
>         case VIR_DOMAIN_MEMORY_STAT_RSS:
>             key = libvirt_constcharPtrWrap("rss");
>             break;
> -        default:
> +        case VIR_DOMAIN_MEMORY_STAT_NR:
> +        case VIR_DOMAIN_MEMORY_STAT_LAST:
>             continue;
>         }
>         val = libvirt_ulonglongWrap(stats[i].val);
> -- 

Oh right. Apparently some time off is in place :-) Either of you care
posting the patch?

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] include usable memory in virDomainMemoryStats
Posted by Martin Kletzander 6 years, 8 months ago
On Wed, Aug 02, 2017 at 01:59:02PM +0200, Michal Privoznik wrote:
>On 08/02/2017 01:17 PM, Martin Kletzander wrote:
>> On Wed, Aug 02, 2017 at 12:52:32PM +0200, Michal Privoznik wrote:
>>> On 08/01/2017 03:23 PM, Tomáš Golembiovský wrote:
>>>> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
>>>> ---
>>>>  libvirt-override.c | 3 +++
>>>>  1 file changed, 3 insertions(+)
>>>>
>>>> diff --git a/libvirt-override.c b/libvirt-override.c
>>>> index 0abfc37..832e05c 100644
>>>> --- a/libvirt-override.c
>>>> +++ b/libvirt-override.c
>>>> @@ -398,6 +398,9 @@ libvirt_virDomainMemoryStats(PyObject *self
>>>> ATTRIBUTE_UNUSED,
>>>>          case VIR_DOMAIN_MEMORY_STAT_RSS:
>>>>              key = libvirt_constcharPtrWrap("rss");
>>>>              break;
>>>> +        case VIR_DOMAIN_MEMORY_STAT_USABLE:
>>>> +            key = libvirt_constcharPtrWrap("usable");
>>>> +            break;
>>>>          default:
>>>>              continue;
>>>>          }
>>>>
>>>
>>> Almost. Firstly, there's VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE which is not
>>> handled either. Secondly, these two macros were introduced in libvirt
>>> 2.1.0. So we need a check that enables them iff building with 2.1.0 or
>>> newer. I'm fixing both issues and pushing. I wonder if there's something
>>> we can do to not forget about macros like these again.
>>>
>>
>> You mean like this?  Or am I missing a reason why this won't work?
>>
>> diff --git a/libvirt-override.c b/libvirt-override.c
>> index 0abfc379c528..6e678d2efb2d 100644
>> --- a/libvirt-override.c
>> +++ b/libvirt-override.c
>> @@ -373,7 +373,7 @@ libvirt_virDomainMemoryStats(PyObject *self
>> ATTRIBUTE_UNUSED,
>>         return NULL;
>>
>>     for (i = 0; i < nr_stats; i++) {
>> -        switch (stats[i].tag) {
>> +        switch ((virDomainMemoryStatTags) stats[i].tag) {
>>         case VIR_DOMAIN_MEMORY_STAT_SWAP_IN:
>>             key = libvirt_constcharPtrWrap("swap_in");
>>             break;
>> @@ -398,7 +398,8 @@ libvirt_virDomainMemoryStats(PyObject *self
>> ATTRIBUTE_UNUSED,
>>         case VIR_DOMAIN_MEMORY_STAT_RSS:
>>             key = libvirt_constcharPtrWrap("rss");
>>             break;
>> -        default:
>> +        case VIR_DOMAIN_MEMORY_STAT_NR:
>> +        case VIR_DOMAIN_MEMORY_STAT_LAST:
>>             continue;
>>         }
>>         val = libvirt_ulonglongWrap(stats[i].val);
>> --
>
>Oh right. Apparently some time off is in place :-) Either of you care
>posting the patch?
>

Not erally, feel free to reuse that ^^, but someone could take their
time to check that it's done for all appropriate switches.

Have a nice day,
Martin
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list