diff mbox

[2/2] python/libxc: extend the call to get/set cap for credit2

Message ID 20170927114622.14789-3-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu Sept. 27, 2017, 11:46 a.m. UTC
Commit 68817024 ("xen: credit2: allow to set and get utilization cap")
added a new parameter. Implement it for the python binding as well.

Coverity-ID: 1418532

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

Compile-test only.
---
 tools/python/xen/lowlevel/xc/xc.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Comments

Dario Faggioli Sept. 27, 2017, 12:18 p.m. UTC | #1
On Wed, 2017-09-27 at 12:46 +0100, Wei Liu wrote:
> Commit 68817024 ("xen: credit2: allow to set and get utilization
> cap")
> added a new parameter. Implement it for the python binding as well.
> 
> Coverity-ID: 1418532
> 
Right. Sorry, I tend to forget about these more often that I would want
to. :-(

I'll try to be more careful.

> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> Cc: George Dunlap <george.dunlap@eu.citrix.com>
> Cc: Dario Faggioli <dario.faggioli@citrix.com>
> Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> 
FWIW:

Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>

Regards,
Dario
Marek Marczykowski-Górecki Sept. 27, 2017, 12:38 p.m. UTC | #2
On Wed, Sep 27, 2017 at 12:46:22PM +0100, Wei Liu wrote:
> Commit 68817024 ("xen: credit2: allow to set and get utilization cap")
> added a new parameter. Implement it for the python binding as well.
> 
> Coverity-ID: 1418532
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>

Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

> ---
> Cc: George Dunlap <george.dunlap@eu.citrix.com>
> Cc: Dario Faggioli <dario.faggioli@citrix.com>
> Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> 
> Compile-test only.
> ---
>  tools/python/xen/lowlevel/xc/xc.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
> index aa9f8e4d9e..f501764100 100644
> --- a/tools/python/xen/lowlevel/xc/xc.c
> +++ b/tools/python/xen/lowlevel/xc/xc.c
> @@ -1348,16 +1348,19 @@ static PyObject *pyxc_sched_credit2_domain_set(XcObject *self,
>  {
>      uint32_t domid;
>      uint16_t weight;
> -    static char *kwd_list[] = { "domid", "weight", NULL };
> -    static char kwd_type[] = "I|H";
> -    struct xen_domctl_sched_credit2 sdom;
> +    uint16_t cap;
> +    static char *kwd_list[] = { "domid", "weight", "cap", NULL };
> +    static char kwd_type[] = "I|HH";
> +    struct xen_domctl_sched_credit2 sdom = { };
>  
>      weight = 0;
> +    cap = 0;
>      if( !PyArg_ParseTupleAndKeywords(args, kwds, kwd_type, kwd_list,
> -                                     &domid, &weight) )
> +                                     &domid, &weight, &cap) )
>          return NULL;
>  
>      sdom.weight = weight;
> +    sdom.cap = cap;
>  
>      if ( xc_sched_credit2_domain_set(self->xc_handle, domid, &sdom) != 0 )
>          return pyxc_error_to_exception(self->xc_handle);
> @@ -1369,7 +1372,7 @@ static PyObject *pyxc_sched_credit2_domain_set(XcObject *self,
>  static PyObject *pyxc_sched_credit2_domain_get(XcObject *self, PyObject *args)
>  {
>      uint32_t domid;
> -    struct xen_domctl_sched_credit2 sdom;
> +    struct xen_domctl_sched_credit2 sdom = { };
>  
>      if( !PyArg_ParseTuple(args, "I", &domid) )
>          return NULL;
> @@ -1377,8 +1380,8 @@ static PyObject *pyxc_sched_credit2_domain_get(XcObject *self, PyObject *args)
>      if ( xc_sched_credit2_domain_get(self->xc_handle, domid, &sdom) != 0 )
>          return pyxc_error_to_exception(self->xc_handle);
>  
> -    return Py_BuildValue("{s:H}",
> -                         "weight",  sdom.weight);
> +    return Py_BuildValue("{s:HH}",
> +                         "weight", "cap",  sdom.weight, sdom.cap);
>  }
>  
>  static PyObject *pyxc_domain_setmaxmem(XcObject *self, PyObject *args)
diff mbox

Patch

diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index aa9f8e4d9e..f501764100 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -1348,16 +1348,19 @@  static PyObject *pyxc_sched_credit2_domain_set(XcObject *self,
 {
     uint32_t domid;
     uint16_t weight;
-    static char *kwd_list[] = { "domid", "weight", NULL };
-    static char kwd_type[] = "I|H";
-    struct xen_domctl_sched_credit2 sdom;
+    uint16_t cap;
+    static char *kwd_list[] = { "domid", "weight", "cap", NULL };
+    static char kwd_type[] = "I|HH";
+    struct xen_domctl_sched_credit2 sdom = { };
 
     weight = 0;
+    cap = 0;
     if( !PyArg_ParseTupleAndKeywords(args, kwds, kwd_type, kwd_list,
-                                     &domid, &weight) )
+                                     &domid, &weight, &cap) )
         return NULL;
 
     sdom.weight = weight;
+    sdom.cap = cap;
 
     if ( xc_sched_credit2_domain_set(self->xc_handle, domid, &sdom) != 0 )
         return pyxc_error_to_exception(self->xc_handle);
@@ -1369,7 +1372,7 @@  static PyObject *pyxc_sched_credit2_domain_set(XcObject *self,
 static PyObject *pyxc_sched_credit2_domain_get(XcObject *self, PyObject *args)
 {
     uint32_t domid;
-    struct xen_domctl_sched_credit2 sdom;
+    struct xen_domctl_sched_credit2 sdom = { };
 
     if( !PyArg_ParseTuple(args, "I", &domid) )
         return NULL;
@@ -1377,8 +1380,8 @@  static PyObject *pyxc_sched_credit2_domain_get(XcObject *self, PyObject *args)
     if ( xc_sched_credit2_domain_get(self->xc_handle, domid, &sdom) != 0 )
         return pyxc_error_to_exception(self->xc_handle);
 
-    return Py_BuildValue("{s:H}",
-                         "weight",  sdom.weight);
+    return Py_BuildValue("{s:HH}",
+                         "weight", "cap",  sdom.weight, sdom.cap);
 }
 
 static PyObject *pyxc_domain_setmaxmem(XcObject *self, PyObject *args)