[libvirt] [PATCHv4 06/18] util: Add monitor interface to determine path

Wang Huaqiang huaqiang.wang at intel.com
Mon Oct 1 02:52:09 UTC 2018


Add interface for resctrl monitor to determine the path.

Signed-off-by: Wang Huaqiang <huaqiang.wang at intel.com>
---
 src/libvirt_private.syms |  1 +
 src/util/virresctrl.c    | 32 ++++++++++++++++++++++++++++++++
 src/util/virresctrl.h    |  3 +++
 3 files changed, 36 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a6259f7..5a408c8 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2678,6 +2678,7 @@ virResctrlInfoGetMonitorPrefix;
 virResctrlInfoMonFree;
 virResctrlInfoNew;
 virResctrlMonitorAddPID;
+virResctrlMonitorDeterminePath;
 virResctrlMonitorNew;
 
 
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 5beed92..de10a0c 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -2467,3 +2467,35 @@ virResctrlMonitorAddPID(virResctrlMonitorPtr monitor,
 {
     return virResctrlAddPID(monitor->path, pid);
 }
+
+int
+virResctrlMonitorDeterminePath(virResctrlMonitorPtr monitor,
+                               const char *machinename)
+{
+    char *alloc_path = NULL;
+    char *parentpath = NULL;
+
+    if (!monitor) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Invalid resctrl monitor"));
+        return -1;
+    }
+
+    if (monitor->alloc)
+        alloc_path = monitor->alloc->path;
+    else
+        alloc_path = (char *)SYSFS_RESCTRL_PATH;
+
+    if (virAsprintf(&parentpath, "%s/mon_groups", alloc_path) < 0)
+        return -1;
+
+    monitor->path = virResctrlDeterminePath(parentpath, machinename,
+                                            monitor->id);
+
+    VIR_FREE(parentpath);
+
+    if (!monitor->path)
+        return -1;
+
+    return 0;
+}
diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
index cb9bfae..69b6b1d 100644
--- a/src/util/virresctrl.h
+++ b/src/util/virresctrl.h
@@ -196,4 +196,7 @@ virResctrlMonitorNew(void);
 int
 virResctrlMonitorAddPID(virResctrlMonitorPtr monitor,
                         pid_t pid);
+int
+virResctrlMonitorDeterminePath(virResctrlMonitorPtr monitor,
+                               const char *machinename);
 #endif /*  __VIR_RESCTRL_H__ */
-- 
2.7.4




More information about the libvir-list mailing list