[libvirt] [PATCHv5 03/19] util: Refactor code for adding PID to the resource group

Wang Huaqiang posted 19 patches 7 years, 4 months ago
There is a newer version of this series
[libvirt] [PATCHv5 03/19] util: Refactor code for adding PID to the resource group
Posted by Wang Huaqiang 7 years, 4 months ago
The code of adding PID to the allocation could be reused, refactor it
for later reusing.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
---
 src/util/virresctrl.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 18ee560..41c7e51 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -2359,24 +2359,21 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl,
 }
 
 
-int
-virResctrlAllocAddPID(virResctrlAllocPtr alloc,
-                      pid_t pid)
+static int
+virResctrlAddPID(const char *path,
+                 pid_t pid)
 {
     char *tasks = NULL;
     char *pidstr = NULL;
     int ret = 0;
 
-    if (!alloc)
-        return 0;
-
-    if (!alloc->path) {
+    if (!path) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot add pid to non-existing resctrl allocation"));
+                       _("Cannot add pid to non-existing resctrl group"));
         return -1;
     }
 
-    if (virAsprintf(&tasks, "%s/tasks", alloc->path) < 0)
+    if (virAsprintf(&tasks, "%s/tasks", path) < 0)
         return -1;
 
     if (virAsprintf(&pidstr, "%lld", (long long int) pid) < 0)
@@ -2398,6 +2395,17 @@ virResctrlAllocAddPID(virResctrlAllocPtr alloc,
 
 
 int
+virResctrlAllocAddPID(virResctrlAllocPtr alloc,
+                      pid_t pid)
+{
+    if (!alloc)
+        return 0;
+
+    return virResctrlAddPID(alloc->path, pid);
+}
+
+
+int
 virResctrlAllocRemove(virResctrlAllocPtr alloc)
 {
     int ret = 0;
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv5 03/19] util: Refactor code for adding PID to the resource group
Posted by John Ferlan 7 years, 4 months ago

On 10/9/18 6:30 AM, Wang Huaqiang wrote:
> The code of adding PID to the allocation could be reused, refactor it
> for later reusing.

reuse.

> 
> Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
> ---
>  src/util/virresctrl.c | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv5 03/19] util: Refactor code for adding PID to the resource group
Posted by Wang, Huaqiang 7 years, 4 months ago

> -----Original Message-----
> From: John Ferlan [mailto:jferlan@redhat.com]
> Sent: Wednesday, October 10, 2018 7:09 AM
> To: Wang, Huaqiang <huaqiang.wang@intel.com>; libvir-list@redhat.com
> Cc: Feng, Shaohe <shaohe.feng@intel.com>; Niu, Bing <bing.niu@intel.com>;
> Ding, Jian-feng <jian-feng.ding@intel.com>; Zang, Rui <rui.zang@intel.com>
> Subject: Re: [libvirt] [PATCHv5 03/19] util: Refactor code for adding PID to the
> resource group
> 
> 
> 
> On 10/9/18 6:30 AM, Wang Huaqiang wrote:
> > The code of adding PID to the allocation could be reused, refactor it
> > for later reusing.
> 
> reuse.

Thanks.

> 
> >
> > Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
> > ---
> >  src/util/virresctrl.c | 26 +++++++++++++++++---------
> >  1 file changed, 17 insertions(+), 9 deletions(-)
> >
> 
> Reviewed-by: John Ferlan <jferlan@redhat.com>
> 
> John


Thanks for review.
Huaqiang

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list