[PATCH v2] tests/unit/test-qga: enable on FreeBSD

Roman Bogorodskiy posted 1 patch 3 weeks, 4 days ago
tests/unit/meson.build | 2 +-
tests/unit/test-qga.c  | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
[PATCH v2] tests/unit/test-qga: enable on FreeBSD
Posted by Roman Bogorodskiy 3 weeks, 4 days ago
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>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
---
Changes since v1:

 - Drop SUN_LEN() for 'len' calculation on FreeBSD,
   use 'len = sizeof(remote)' on all platforms.

 tests/unit/meson.build | 2 +-
 tests/unit/test-qga.c  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index d17435c187..295df1a7eb 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..b1c84c188b 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,7 @@ static int connect_qga(char *path)
     remote.sun_family = AF_UNIX;
     do {
         strcpy(remote.sun_path, path);
-        len = strlen(remote.sun_path) + sizeof(remote.sun_family);
+        len = sizeof(remote);
         ret = connect(s, (struct sockaddr *)&remote, len);
         if (ret == -1) {
             g_usleep(G_USEC_PER_SEC);
-- 
2.55.0
Re: [PATCH v2] tests/unit/test-qga: enable on FreeBSD
Posted by Roman Bogorodskiy 2 days, 20 hours ago
  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>
> Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
> ---
> Changes since v1:
> 
>  - Drop SUN_LEN() for 'len' calculation on FreeBSD,
>    use 'len = sizeof(remote)' on all platforms.
> 
>  tests/unit/meson.build | 2 +-
>  tests/unit/test-qga.c  | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)

ping?
Re: [PATCH v2] tests/unit/test-qga: enable on FreeBSD
Posted by Daniel P. Berrangé 3 weeks, 4 days ago
On Tue, Sep 29, 2026 at 05:01:00PM +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>
> Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
> ---
> Changes since v1:
> 
>  - Drop SUN_LEN() for 'len' calculation on FreeBSD,
>    use 'len = sizeof(remote)' on all platforms.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


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 :|