src/util/vircgroup.c | 70 ++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 31 deletions(-)
virCgroupGetInode needs to be in '#ifdef __linux__'.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
src/util/vircgroup.c | 70 ++++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 31 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 4c9445340e..dc040a4822 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -3005,6 +3005,37 @@ virCgroupControllerAvailable(int controller)
return virCgroupHasController(cgroup, controller);
}
+
+/**
+ * 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;
+}
+
#else /* !__linux__ */
bool
@@ -3769,6 +3800,14 @@ virCgroupControllerAvailable(int controller G_GNUC_UNUSED)
{
return false;
}
+
+int
+virCgroupGetInode(virCgroup *cgroup)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
#endif /* !__linux__ */
@@ -3973,34 +4012,3 @@ 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;
-}
--
2.31.1
On Tue, Aug 17, 2021 at 02:46:31PM +0200, Pavel Hrdina wrote: >virCgroupGetInode needs to be in '#ifdef __linux__'. > >Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Oops, Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
On a Tuesday in 2021, Pavel Hrdina wrote:
>virCgroupGetInode needs to be in '#ifdef __linux__'.
>
>Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>---
> src/util/vircgroup.c | 70 ++++++++++++++++++++++++--------------------
> 1 file changed, 39 insertions(+), 31 deletions(-)
>
>diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
>index 4c9445340e..dc040a4822 100644
>--- a/src/util/vircgroup.c
>+++ b/src/util/vircgroup.c
>@@ -3005,6 +3005,37 @@ virCgroupControllerAvailable(int controller)
> return virCgroupHasController(cgroup, controller);
> }
>
>+
>+/**
>+ * 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;
>+}
>+
> #else /* !__linux__ */
>
> bool
>@@ -3769,6 +3800,14 @@ virCgroupControllerAvailable(int controller G_GNUC_UNUSED)
> {
> return false;
> }
>+
>+int
>+virCgroupGetInode(virCgroup *cgroup)
the parameter needs to be marked with G_GNUC_UNUSED
>+{
>+ virReportSystemError(ENOSYS, "%s",
>+ _("Control groups not supported on this platform"));
>+ return -1;
>+}
> #endif /* !__linux__ */
>
>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Jano
On Tue, Aug 17, 2021 at 03:15:50PM +0200, Ján Tomko wrote:
> On a Tuesday in 2021, Pavel Hrdina wrote:
> > virCgroupGetInode needs to be in '#ifdef __linux__'.
> >
> > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > ---
> > src/util/vircgroup.c | 70 ++++++++++++++++++++++++--------------------
> > 1 file changed, 39 insertions(+), 31 deletions(-)
> >
> > diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
> > index 4c9445340e..dc040a4822 100644
> > --- a/src/util/vircgroup.c
> > +++ b/src/util/vircgroup.c
> > @@ -3005,6 +3005,37 @@ virCgroupControllerAvailable(int controller)
> > return virCgroupHasController(cgroup, controller);
> > }
> >
> > +
> > +/**
> > + * 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;
> > +}
> > +
> > #else /* !__linux__ */
> >
> > bool
> > @@ -3769,6 +3800,14 @@ virCgroupControllerAvailable(int controller G_GNUC_UNUSED)
> > {
> > return false;
> > }
> > +
> > +int
> > +virCgroupGetInode(virCgroup *cgroup)
>
> the parameter needs to be marked with G_GNUC_UNUSED
Right, I should get a coffee or something today.
> > +{
> > + virReportSystemError(ENOSYS, "%s",
> > + _("Control groups not supported on this platform"));
> > + return -1;
> > +}
> > #endif /* !__linux__ */
> >
> >
>
> Reviewed-by: Ján Tomko <jtomko@redhat.com>
Thanks
© 2016 - 2026 Red Hat, Inc.