Add interfaces monitor group to support operations such
as add PID, set ID, remove group ... etc.
Signed-off-by: Wang Huaqiang <huaqiang.wang(a)intel.com>
---
src/libvirt_private.syms | 5 +++++
src/util/virresctrl.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
src/util/virresctrl.h | 14 ++++++++++++++
3 files changed, 66 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b47b60d..239b979 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2683,7 +2683,12 @@ virResctrlInfoNew;
virResctrlMonitorAddPID;
virResctrlMonitorCreate;
virResctrlMonitorDeterminePath;
+virResctrlMonitorGetID;
virResctrlMonitorNew;
+virResctrlMonitorRemove;
+virResctrlMonitorSetAlloc;
+virResctrlMonitorSetID;
+
# util/virrotatingfile.h
virRotatingFileReaderConsume;
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index e97127c..b4b63b6 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -2563,3 +2563,50 @@ virResctrlMonitorCreate(virResctrlMonitorPtr monitor,
virResctrlUnlock(lockfd);
return ret;
}
+
+
+int
+virResctrlMonitorSetID(virResctrlMonitorPtr monitor,
+ const char *id)
+{
+ if (!id) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Resctrl monitor 'id' cannot be NULL"));
+ return -1;
+ }
+
+ return VIR_STRDUP(monitor->id, id);
+}
+
+
+const char *
+virResctrlMonitorGetID(virResctrlMonitorPtr monitor)
+{
+ return monitor->id;
+}
+
+
+void
+virResctrlMonitorSetAlloc(virResctrlMonitorPtr monitor,
+ virResctrlAllocPtr alloc)
+{
+ monitor->alloc = virObjectRef(alloc);
+}
+
+
+int
+virResctrlMonitorRemove(virResctrlMonitorPtr monitor)
+{
+ int ret = 0;
+
+ if (!monitor->path)
+ return 0;
+
+ VIR_DEBUG("Removing resctrl monitor%s", monitor->path);
+ if (rmdir(monitor->path) != 0 && errno != ENOENT) {
+ ret = -errno;
+ VIR_ERROR(_("Unable to remove %s (%d)"), monitor->path, errno);
+ }
+
+ return ret;
+}
diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h
index 76e40a2..804d6f5 100644
--- a/src/util/virresctrl.h
+++ b/src/util/virresctrl.h
@@ -205,4 +205,18 @@ virResctrlMonitorAddPID(virResctrlMonitorPtr monitor,
int
virResctrlMonitorCreate(virResctrlMonitorPtr monitor,
const char *machinename);
+
+int
+virResctrlMonitorSetID(virResctrlMonitorPtr monitor,
+ const char *id);
+
+const char *
+virResctrlMonitorGetID(virResctrlMonitorPtr monitor);
+
+void
+virResctrlMonitorSetAlloc(virResctrlMonitorPtr monitor,
+ virResctrlAllocPtr alloc);
+
+int
+virResctrlMonitorRemove(virResctrlMonitorPtr monitor);
#endif /* __VIR_RESCTRL_H__ */
--
2.7.4