[PATCH] virprocess: Provide non-Linux stubs for virProcessGet{Stat, Sched}Info

Ani Sinha ani at anisinha.ca
Fri Jan 7 08:05:27 UTC 2022



On Fri, 7 Jan 2022, Michal Privoznik wrote:

> Both virProcessGetStatInfo() and virProcessGetSchedInfo() are
> Linux centric. Provide stubs for non-Linux platforms.
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/util/virprocess.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/src/util/virprocess.c b/src/util/virprocess.c
> index c74bd16fe6..5788faea9c 100644
> --- a/src/util/virprocess.c
> +++ b/src/util/virprocess.c
> @@ -1766,6 +1766,7 @@ virProcessGetStat(pid_t pid,
>  }
>
>
> +#ifdef __linux__
>  int
>  virProcessGetStatInfo(unsigned long long *cpuTime,
>                        int *lastCpu,
> @@ -1873,3 +1874,26 @@ virProcessGetSchedInfo(unsigned long long *cpuWait,
>
>      return 0;
>  }
> +
> +#else
> +int
> +virProcessGetStatInfo(unsigned long long *cpuTime G_GNUC_UNUSED,
> +                      int *lastCpu G_GNUC_UNUSED,
> +                      long *vm_rss G_GNUC_UNUSED,
> +                      pid_t pid G_GNUC_UNUSED,
> +                      pid_t tid G_GNUC_UNUSED)
> +{
> +    errno = ENOSYS;
> +    return -1;
> +}
> +
> +int
> +virProcessGetSchedInfo(unsigned long long *cpuWait G_GNUC_UNUSED,
> +                       pid_t pid G_GNUC_UNUSED,
> +                       pid_t tid G_GNUC_UNUSED)
> +{
> +    virReportSystemError(ENOSYS, "%s",
> +                         _("scheduler information is not supported on this platform"));

We should do this for both functions for non-linux platforms or not do it
at all. Like it should be consistent IMHO.

> +    return -1;
> +}
> +#endif /* __linux__ */
> --
> 2.34.1
>
>




More information about the libvir-list mailing list