All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/unit/test-qga: enable on FreeBSD
@ 2026-09-16 16:56 Roman Bogorodskiy
  2026-09-29  6:57 ` Kostiantyn Kostiuk
  2026-09-29  8:36 ` Daniel P. Berrangé
  0 siblings, 2 replies; 3+ messages in thread
From: Roman Bogorodskiy @ 2026-09-16 16:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Roman Bogorodskiy, Michael Roth, Kostiantyn Kostiuk

FreeBSD has all necessary commands implemented,
so enable test-qga for it.

Requires only minimal portability fixes for sockets
in connect_qga().

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
 tests/unit/meson.build | 2 +-
 tests/unit/test-qga.c  | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index e47bc7225a..0ca0d8974e 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -169,7 +169,7 @@ if have_system
   tests += {'test-qdev': [qom, hwcore]}
 endif
 
-if have_ga and host_os == 'linux'
+if have_ga and host_os in ['freebsd', 'linux']
   tests += {'test-qga': ['../qtest/libqmp.c', '../qtest/libqtest.c']}
   test_deps += {'test-qga': qga}
 endif
diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
index 01ccf826e6..dbedfe3d5f 100644
--- a/tests/unit/test-qga.c
+++ b/tests/unit/test-qga.c
@@ -18,7 +18,7 @@ typedef struct {
 static int connect_qga(char *path)
 {
     int s, ret, len, i = 0;
-    struct sockaddr_un remote;
+    struct sockaddr_un remote = { 0 };
 
     s = socket(AF_UNIX, SOCK_STREAM, 0);
     g_assert(s != -1);
@@ -26,7 +26,11 @@ static int connect_qga(char *path)
     remote.sun_family = AF_UNIX;
     do {
         strcpy(remote.sun_path, path);
+#ifdef SUN_LEN
+        len = SUN_LEN(&remote);
+#else
         len = strlen(remote.sun_path) + sizeof(remote.sun_family);
+#endif
         ret = connect(s, (struct sockaddr *)&remote, len);
         if (ret == -1) {
             g_usleep(G_USEC_PER_SEC);
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tests/unit/test-qga: enable on FreeBSD
  2026-09-16 16:56 [PATCH] tests/unit/test-qga: enable on FreeBSD Roman Bogorodskiy
@ 2026-09-29  6:57 ` Kostiantyn Kostiuk
  2026-09-29  8:36 ` Daniel P. Berrangé
  1 sibling, 0 replies; 3+ messages in thread
From: Kostiantyn Kostiuk @ 2026-09-29  6:57 UTC (permalink / raw)
  To: Roman Bogorodskiy; +Cc: qemu-devel, Michael Roth

[-- Attachment #1: Type: text/plain, Size: 1858 bytes --]

Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>

On Wed, Sep 16, 2026 at 7:57 PM Roman Bogorodskiy <bogorodskiy@gmail.com>
wrote:

> FreeBSD has all necessary commands implemented,
> so enable test-qga for it.
>
> Requires only minimal portability fixes for sockets
> in connect_qga().
>
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/unit/meson.build | 2 +-
>  tests/unit/test-qga.c  | 6 +++++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tests/unit/meson.build b/tests/unit/meson.build
> index e47bc7225a..0ca0d8974e 100644
> --- a/tests/unit/meson.build
> +++ b/tests/unit/meson.build
> @@ -169,7 +169,7 @@ if have_system
>    tests += {'test-qdev': [qom, hwcore]}
>  endif
>
> -if have_ga and host_os == 'linux'
> +if have_ga and host_os in ['freebsd', 'linux']
>    tests += {'test-qga': ['../qtest/libqmp.c', '../qtest/libqtest.c']}
>    test_deps += {'test-qga': qga}
>  endif
> diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
> index 01ccf826e6..dbedfe3d5f 100644
> --- a/tests/unit/test-qga.c
> +++ b/tests/unit/test-qga.c
> @@ -18,7 +18,7 @@ typedef struct {
>  static int connect_qga(char *path)
>  {
>      int s, ret, len, i = 0;
> -    struct sockaddr_un remote;
> +    struct sockaddr_un remote = { 0 };
>
>      s = socket(AF_UNIX, SOCK_STREAM, 0);
>      g_assert(s != -1);
> @@ -26,7 +26,11 @@ static int connect_qga(char *path)
>      remote.sun_family = AF_UNIX;
>      do {
>          strcpy(remote.sun_path, path);
> +#ifdef SUN_LEN
> +        len = SUN_LEN(&remote);
> +#else
>          len = strlen(remote.sun_path) + sizeof(remote.sun_family);
> +#endif
>          ret = connect(s, (struct sockaddr *)&remote, len);
>          if (ret == -1) {
>              g_usleep(G_USEC_PER_SEC);
> --
> 2.55.0
>
>

[-- Attachment #2: Type: text/html, Size: 2514 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tests/unit/test-qga: enable on FreeBSD
  2026-09-16 16:56 [PATCH] tests/unit/test-qga: enable on FreeBSD Roman Bogorodskiy
  2026-09-29  6:57 ` Kostiantyn Kostiuk
@ 2026-09-29  8:36 ` Daniel P. Berrangé
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel P. Berrangé @ 2026-09-29  8:36 UTC (permalink / raw)
  To: Roman Bogorodskiy; +Cc: qemu-devel, Michael Roth, Kostiantyn Kostiuk

On Wed, Sep 16, 2026 at 06:56:20PM +0200, Roman Bogorodskiy wrote:
> FreeBSD has all necessary commands implemented,
> so enable test-qga for it.
> 
> Requires only minimal portability fixes for sockets
> in connect_qga().
> 
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
>  tests/unit/meson.build | 2 +-
>  tests/unit/test-qga.c  | 6 +++++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/unit/meson.build b/tests/unit/meson.build
> index e47bc7225a..0ca0d8974e 100644
> --- a/tests/unit/meson.build
> +++ b/tests/unit/meson.build
> @@ -169,7 +169,7 @@ if have_system
>    tests += {'test-qdev': [qom, hwcore]}
>  endif
>  
> -if have_ga and host_os == 'linux'
> +if have_ga and host_os in ['freebsd', 'linux']
>    tests += {'test-qga': ['../qtest/libqmp.c', '../qtest/libqtest.c']}
>    test_deps += {'test-qga': qga}
>  endif
> diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
> index 01ccf826e6..dbedfe3d5f 100644
> --- a/tests/unit/test-qga.c
> +++ b/tests/unit/test-qga.c
> @@ -18,7 +18,7 @@ typedef struct {
>  static int connect_qga(char *path)
>  {
>      int s, ret, len, i = 0;
> -    struct sockaddr_un remote;
> +    struct sockaddr_un remote = { 0 };
>  
>      s = socket(AF_UNIX, SOCK_STREAM, 0);
>      g_assert(s != -1);
> @@ -26,7 +26,11 @@ static int connect_qga(char *path)
>      remote.sun_family = AF_UNIX;
>      do {
>          strcpy(remote.sun_path, path);
> +#ifdef SUN_LEN
> +        len = SUN_LEN(&remote);
> +#else
>          len = strlen(remote.sun_path) + sizeof(remote.sun_family);
> +#endif

This conditional shouldn't be needed, as this ought to be written
as

    len = sizeof(remote)

given that sun_path is NUL terminate, there's no reason to try
to calculate a shorter size, only paths in the abstract namespace
need special length handling.

>          ret = connect(s, (struct sockaddr *)&remote, len);
>          if (ret == -1) {
>              g_usleep(G_USEC_PER_SEC);
> -- 
> 2.55.0
> 
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-29  8:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 16:56 [PATCH] tests/unit/test-qga: enable on FreeBSD Roman Bogorodskiy
2026-09-29  6:57 ` Kostiantyn Kostiuk
2026-09-29  8:36 ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.