Skip to contentSkip to conversation

Coverity issues for credit2 CAP series

PATCH In review Wei Liu 3 participants 6 messages Sep 27, 2017 Arm/actions semi architecture

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

cover Coverity issues for credit2 CAP series

Wei Liu (2):
xen/credit2: add missing unlock
python/libxc: extend the call to get/set cap for credit2

 tools/python/xen/lowlevel/xc/xc.c | 17 ++++++++++-------
 xen/common/sched_credit2.c        |  1 +
 2 files changed, 11 insertions(+), 7 deletions(-)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#3 lore raw

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

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

---
Cc: George Dunlap <[email protected]>
Cc: Dario Faggioli <[email protected]>
Cc: Marek Marczykowski-Górecki <[email protected]>

Compile-test only.

---
 tools/python/xen/lowlevel/xc/xc.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
tools/python/xen/lowlevel/xc/xc.c +10 -7
index aa9f8e4d9e..f501764100 100644
@@ -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)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#1 lore raw

PATCH 1/2 xen/credit2: add missing unlock

In reply to Wei Liu

Coverity-ID: 1418531

---
Cc: George Dunlap <[email protected]>
Cc: Dario Faggioli <[email protected]>

---
 xen/common/sched_credit2.c | 1 +
 1 file changed, 1 insertion(+)
xen/common/sched_credit2.c +1 -0
index d33c881c3d..18f39cafe4 100644
@@ -2831,6 +2831,7 @@ csched2_dom_cntl(
             if ( op->u.credit2.cap > 100 * sdom->nr_vcpus )
             {
                 rc = -EINVAL;
+                write_unlock_irqrestore(&prv->lock, flags);
                 break;
             }
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] xen/credit2: add missing unlock

Quoted 9 lines · Wei Liu

Coverity-ID: 1418531

---

xen/common/sched_credit2.c +0 -0
index d33c881c3d..18f39cafe4 100644

xen/common/sched_credit2.c csched2_dom_cntl( · line 2835

Quoted 5 lines
xen/common/sched_credit2.c +1 -0
@@ -2831,6 +2831,7 @@ csched2_dom_cntl(
              if ( op->u.credit2.cap > 100 * sdom->nr_vcpus )
              {
                  rc = -EINVAL;
+                write_unlock_irqrestore(&prv->lock, flags);
 

Indeed... :-/

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 2/2
#4 lore raw

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

In reply to Wei Liu
Quoted 6 lines · Wei Liu

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.

Quoted 6 lines

---
Cc: George Dunlap <[email protected]>
Cc: Dario Faggioli <[email protected]>
Cc: Marek Marczykowski-Górecki <[email protected]>

FWIW:

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v1 2/2
#5 lore raw

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

In reply to Wei Liu
Quoted 6 lines · Wei Liu

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

Quoted 58 lines

---
Cc: George Dunlap <[email protected]>
Cc: Dario Faggioli <[email protected]>
Cc: Marek Marczykowski-Górecki <[email protected]>

Compile-test only.

---
 tools/python/xen/lowlevel/xc/xc.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
tools/python/xen/lowlevel/xc/xc.c +10 -7
index aa9f8e4d9e..f501764100 100644
@@ -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)
Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel