1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-28 11:21:44 +03:00

vircgroup: introduce virCgroupGetInode function

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>
This commit is contained in:
Pavel Hrdina 2021-07-29 17:13:39 +02:00
parent f14d6ab537
commit 10c2c0b249
3 changed files with 34 additions and 0 deletions

View File

@ -1922,6 +1922,7 @@ virCgroupGetCpuShares;
virCgroupGetDevicePermsString;
virCgroupGetDomainTotalCpuStats;
virCgroupGetFreezerState;
virCgroupGetInode;
virCgroupGetMemoryHardLimit;
virCgroupGetMemorySoftLimit;
virCgroupGetMemoryStat;

View 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;
}

View File

@ -283,3 +283,5 @@ int virCgroupSetOwner(virCgroup *cgroup,
int virCgroupHasEmptyTasks(virCgroup *cgroup, int controller);
bool virCgroupControllerAvailable(int controller);
int virCgroupGetInode(virCgroup *cgroup);