[PATCH] hypervisor: interface: Stub out virDomainCreateInBridgePortWithHelper using 'socketpair' on win32

Peter Krempa posted 1 patch 2 months, 4 weeks ago
src/hypervisor/domain_interface.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
[PATCH] hypervisor: interface: Stub out virDomainCreateInBridgePortWithHelper using 'socketpair' on win32
Posted by Peter Krempa 2 months, 4 weeks ago
Mingw build failed after commit af87ee7927d3245582d82d36da25b4dc3b34465e
as 'socketpair()' is not available on that platform.

Stub out the function to return failure.

Fixes: af87ee7927d3245582d82d36da25b4dc3b34465e
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
Pipeline:
https://gitlab.com/pipo.sk/libvirt/-/pipelines/1428482965

(Ignore the broken Cirrus jobs. Something broke and it can't find
 master branch when building from my user. I blame github :D)


 src/hypervisor/domain_interface.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/hypervisor/domain_interface.c b/src/hypervisor/domain_interface.c
index fc82624bb9..5cdba279fa 100644
--- a/src/hypervisor/domain_interface.c
+++ b/src/hypervisor/domain_interface.c
@@ -532,6 +532,7 @@ virDomainClearNetBandwidth(virDomainDef *def)
  *
  * Returns 0 in case of success or -1 on failure
  */
+#ifndef WIN32
 static int
 virDomainCreateInBridgePortWithHelper(const char *bridgeHelperName,
                                       const char *brname,
@@ -583,9 +584,9 @@ virDomainCreateInBridgePortWithHelper(const char *bridgeHelperName,
     virCommandPassFD(cmd, pair[1],
                      VIR_COMMAND_PASS_FD_CLOSE_PARENT);
     virCommandClearCaps(cmd);
-#ifdef CAP_NET_ADMIN
+# ifdef CAP_NET_ADMIN
     virCommandAllowCap(cmd, CAP_NET_ADMIN);
-#endif
+# endif
     if (virCommandRunAsync(cmd, NULL) < 0) {
         *tapfd = -1;
         goto cleanup;
@@ -626,6 +627,20 @@ virDomainCreateInBridgePortWithHelper(const char *bridgeHelperName,
     return *tapfd < 0 ? -1 : 0;
 }

+#else /* WIN32 */
+
+static int
+virDomainCreateInBridgePortWithHelper(const char *bridgeHelperName G_GNUC_UNUSED,
+                                      const char *brname G_GNUC_UNUSED,
+                                      char **ifname G_GNUC_UNUSED,
+                                      int *tapfd G_GNUC_UNUSED,
+                                      unsigned int unusedflags G_GNUC_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("bridge port creation is not supported on this platform"));
+    return -1;
+}
+#endif

 /* virDomainInterfaceBridgeConnect:
  * @def: the definition of the VM
-- 
2.46.0
Re: [PATCH] hypervisor: interface: Stub out virDomainCreateInBridgePortWithHelper using 'socketpair' on win32
Posted by Jiri Denemark 2 months, 4 weeks ago
On Tue, Aug 27, 2024 at 10:02:37 +0200, Peter Krempa wrote:
> Mingw build failed after commit af87ee7927d3245582d82d36da25b4dc3b34465e
> as 'socketpair()' is not available on that platform.
> 
> Stub out the function to return failure.
> 
> Fixes: af87ee7927d3245582d82d36da25b4dc3b34465e
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
> Pipeline:
> https://gitlab.com/pipo.sk/libvirt/-/pipelines/1428482965
> 
> (Ignore the broken Cirrus jobs. Something broke and it can't find
>  master branch when building from my user. I blame github :D)
> 
> 
>  src/hypervisor/domain_interface.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>