[PATCH-for-10.2 1/3] qga/commands: Include proper Solaris header for getloadavg()

Philippe Mathieu-Daudé posted 3 patches 2 days, 15 hours ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Li Zhijian <lizhijian@fujitsu.com>, Peter Xu <peterx@redhat.com>, Michael Roth <michael.roth@amd.com>, Kostiantyn Kostiuk <kkostiuk@redhat.com>, Peter Maydell <peter.maydell@linaro.org>
[PATCH-for-10.2 1/3] qga/commands: Include proper Solaris header for getloadavg()
Posted by Philippe Mathieu-Daudé 2 days, 15 hours ago
Solaris declares getloadavg() in <sys/loadavg.h>:

    getloadavg(3C)       Standard C Library Functions       getloadavg(3C)

    NAME
           getloadavg - get system load averages

    SYNOPSIS
           #include <sys/loadavg.h>

           int getloadavg(double loadavg[], int nelem);

    [...]

    Oracle Solaris 11.4           23 Jul 2020               getloadavg(3C)

Include it in order to avoid:

  ../qga/commands-posix.c: In function 'qmp_guest_get_load':
  ../qga/commands-posix.c:1408:9: error: implicit declaration of function 'getloadavg' [-Wimplicit-function-declaration]
   1408 |     if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) {
      |         ^~~~~~~~~~
  ../qga/commands-posix.c:1408:9: warning: nested extern declaration of 'getloadavg' [-Wnested-externs]

../configure relevant output:

  C compiler for the host machine: gcc (gcc 14.2.0 "gcc (GCC) 14.2.0")
  C linker for the host machine: gcc ld.solaris 5.11-1.3315

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 qga/commands-posix.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index c7059857e44..66f3e6f6733 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -43,6 +43,9 @@
 #include <net/ethernet.h>
 #endif
 #ifdef CONFIG_SOLARIS
+#ifdef CONFIG_GETLOADAVG
+#include <sys/loadavg.h>
+#endif
 #include <sys/sockio.h>
 #endif
 #endif
-- 
2.51.0


Re: [PATCH-for-10.2 1/3] qga/commands: Include proper Solaris header for getloadavg()
Posted by Richard Henderson 2 days, 3 hours ago
On 11/17/25 21:38, Philippe Mathieu-Daudé wrote:
> Solaris declares getloadavg() in <sys/loadavg.h>:
> 
>      getloadavg(3C)       Standard C Library Functions       getloadavg(3C)
> 
>      NAME
>             getloadavg - get system load averages
> 
>      SYNOPSIS
>             #include <sys/loadavg.h>
> 
>             int getloadavg(double loadavg[], int nelem);
> 
>      [...]
> 
>      Oracle Solaris 11.4           23 Jul 2020               getloadavg(3C)
> 
> Include it in order to avoid:
> 
>    ../qga/commands-posix.c: In function 'qmp_guest_get_load':
>    ../qga/commands-posix.c:1408:9: error: implicit declaration of function 'getloadavg' [-Wimplicit-function-declaration]
>     1408 |     if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) {
>        |         ^~~~~~~~~~
>    ../qga/commands-posix.c:1408:9: warning: nested extern declaration of 'getloadavg' [-Wnested-externs]
> 
> ../configure relevant output:
> 
>    C compiler for the host machine: gcc (gcc 14.2.0 "gcc (GCC) 14.2.0")
>    C linker for the host machine: gcc ld.solaris 5.11-1.3315
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   qga/commands-posix.c | 3 +++
>   1 file changed, 3 insertions(+)

Acked-by: Richard Henderson <richard.henderson@linaro.org>

r~

> 
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index c7059857e44..66f3e6f6733 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -43,6 +43,9 @@
>   #include <net/ethernet.h>
>   #endif
>   #ifdef CONFIG_SOLARIS
> +#ifdef CONFIG_GETLOADAVG
> +#include <sys/loadavg.h>
> +#endif
>   #include <sys/sockio.h>
>   #endif
>   #endif


Re: [PATCH-for-10.2 1/3] qga/commands: Include proper Solaris header for getloadavg()
Posted by Kostiantyn Kostiuk 2 days, 4 hours ago
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>

On Mon, Nov 17, 2025 at 10:38 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> Solaris declares getloadavg() in <sys/loadavg.h>:
>
>     getloadavg(3C)       Standard C Library Functions       getloadavg(3C)
>
>     NAME
>            getloadavg - get system load averages
>
>     SYNOPSIS
>            #include <sys/loadavg.h>
>
>            int getloadavg(double loadavg[], int nelem);
>
>     [...]
>
>     Oracle Solaris 11.4           23 Jul 2020               getloadavg(3C)
>
> Include it in order to avoid:
>
>   ../qga/commands-posix.c: In function 'qmp_guest_get_load':
>   ../qga/commands-posix.c:1408:9: error: implicit declaration of function
> 'getloadavg' [-Wimplicit-function-declaration]
>    1408 |     if (getloadavg(loadavg, G_N_ELEMENTS(loadavg)) < 0) {
>       |         ^~~~~~~~~~
>   ../qga/commands-posix.c:1408:9: warning: nested extern declaration of
> 'getloadavg' [-Wnested-externs]
>
> ../configure relevant output:
>
>   C compiler for the host machine: gcc (gcc 14.2.0 "gcc (GCC) 14.2.0")
>   C linker for the host machine: gcc ld.solaris 5.11-1.3315
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  qga/commands-posix.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index c7059857e44..66f3e6f6733 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -43,6 +43,9 @@
>  #include <net/ethernet.h>
>  #endif
>  #ifdef CONFIG_SOLARIS
> +#ifdef CONFIG_GETLOADAVG
> +#include <sys/loadavg.h>
> +#endif
>  #include <sys/sockio.h>
>  #endif
>  #endif
> --
> 2.51.0
>
>