]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroup: introduce virCgroupGetInode function
authorPavel Hrdina <phrdina@redhat.com>
Thu, 29 Jul 2021 15:13:39 +0000 (17:13 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 17 Aug 2021 10:35:45 +0000 (12:35 +0200)
For new feature Fibre Channel VMID we will need to get inode of the
VM root cgroup as it is used in the new kernel API together with VMID.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/libvirt_private.syms
src/util/vircgroup.c
src/util/vircgroup.h

index 51a400ba59a4bece434d04be26cea4cceceaec26..fcb02c21b17923fe33ab83d938ecb9852c453636 100644 (file)
@@ -1922,6 +1922,7 @@ virCgroupGetCpuShares;
 virCgroupGetDevicePermsString;
 virCgroupGetDomainTotalCpuStats;
 virCgroupGetFreezerState;
+virCgroupGetInode;
 virCgroupGetMemoryHardLimit;
 virCgroupGetMemorySoftLimit;
 virCgroupGetMemoryStat;
index 1b3b28342e9b452b0960f05146cce18b92f7b9e5..4c9445340e1ead10e541841eb46e2cde78693477 100644 (file)
@@ -3973,3 +3973,34 @@ virCgroupGetCpuPeriodQuota(virCgroup *cgroup, unsigned long long *period,
 
     return 0;
 }
+
+
+/**
+ * virCgroupGetInode:
+ *
+ * @cgroup: the cgroup to get inode for
+ *
+ * Get the @cgroup inode and return its value to the caller.
+ *
+ * Returns inode on success, -1 on error with error message reported.
+ */
+int
+virCgroupGetInode(virCgroup *cgroup)
+{
+    struct stat st;
+    int controller = virCgroupGetAnyController(cgroup);
+    g_autofree char *path = NULL;
+
+    if (controller < 0)
+        return -1;
+
+    if (virCgroupPathOfController(cgroup, controller, "", &path) < 0)
+        return -1;
+
+    if (stat(path, &st) < 0) {
+        virReportSystemError(errno, _("failed to get stat for '%s'"), path);
+        return -1;
+    }
+
+    return st.st_ino;
+}
index 8002cac570c9aed5a83c97e660d1290cd0956111..690f09465c80726bf8b2768c603e0ae1a9daeb5b 100644 (file)
@@ -283,3 +283,5 @@ int virCgroupSetOwner(virCgroup *cgroup,
 int virCgroupHasEmptyTasks(virCgroup *cgroup, int controller);
 
 bool virCgroupControllerAvailable(int controller);
+
+int virCgroupGetInode(virCgroup *cgroup);