Include the vendored vio_sockets.h on Windows, and set CONFIG_AF_VSOCK
unconditionally since the header is always present in-tree.

socket_parse("vsock:...") and the SOCKET_ADDRESS_TYPE_VSOCK dispatch
in socket_connect()/socket_listen() now resolve to the real
vsock_*_saddr() helpers on Windows instead of the vsock_unsupported()
stub.

Note that CONFIG_AF_VSOCK is a tree-wide switch: this enables the
vsock code paths for every Windows build, not just the guest agent.
QMP now accepts vsock socket addresses on Windows; without a viosock
provider installed they fail at runtime rather than being rejected
up front as unsupported.

Signed-off-by: Polina Vishneva <[email protected]>
---
 meson.build         | 15 +++++++++++----
 util/qemu-sockets.c |  4 ++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/meson.build b/meson.build
index e026851309..34268f0348 100644
--- a/meson.build
+++ b/meson.build
@@ -3136,10 +3136,17 @@ have_afalg = get_option('crypto_afalg') \
   '''), error_message: 'AF_ALG requested but could not be detected').allowed()
 config_host_data.set('CONFIG_AF_ALG', have_afalg)
 
-config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol(
-  'linux/vm_sockets.h', 'AF_VSOCK',
-  prefix: '#include <sys/socket.h>',
-))
+if host_os != 'windows'
+  config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol(
+    'linux/vm_sockets.h', 'AF_VSOCK',
+    prefix: '#include <sys/socket.h>',
+  ))
+else
+  # The vendored vio_sockets.h is always available.
+  # This guarantees compile-time availability only; at run-time, it's
+  # generally useless if viosock isn't installed (no AF_VSOCK WSP).
+  config_host_data.set('CONFIG_AF_VSOCK', true)
+endif
 
 have_vss = false
 have_vss_sdk = false # old xp/2003 SDK
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 4773755fd5..80bd5cca7f 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -18,7 +18,11 @@
 #include "qemu/osdep.h"
 
 #ifdef CONFIG_AF_VSOCK
+#ifndef _WIN32
 #include <linux/vm_sockets.h>
+#else
+#include "system/vio_sockets.h"
+#endif
 #endif /* CONFIG_AF_VSOCK */
 
 #include "monitor/monitor.h"
-- 
2.54.0


Reply via email to