From nobody Thu May 9 13:44:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1659192733; cv=none; d=zohomail.com; s=zohoarc; b=eIAPaJIyiK9dIECiJIg4Cr6D6NaID4ukOlusTn6LayzVZnJHZP0x6t9WBi0EdvBPzjxMMP3bo0LCseyjxAZbz4lH2i2jPq9uELlWlvDH/zBKUCbAF0MbBuUA+55ovOrsitAPlHjoV3+MtT7PbPsDPakbzeLq87EVfUE0MQg8H40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659192733; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CAT2FKyokp6jIbF5cQnfF4hEF5YeiWS/OD4dpe4OUP4=; b=m9gUd81gKd5EiA0P8wY+Ego777tU+MYt9zfwYHe056eGfzBRdQOrp/gjfEY6s8FhocntmWx2IlcVomw8ZThef/MY0bW0i9O8opVvPAnMfFC/Tjp2D/umfHZDpJodH7vozBGaWQeodtvwJ9DcTM7S5SbcsQ4YYtbD4U838vyfFHc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659192733183309.7935352539939; Sat, 30 Jul 2022 07:52:13 -0700 (PDT) Received: from localhost ([::1]:43158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHnp4-000650-ET for importer@patchew.org; Sat, 30 Jul 2022 10:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHnnj-0004YU-9f for qemu-devel@nongnu.org; Sat, 30 Jul 2022 10:50:47 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:46936) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHnnh-0007ZP-Sd for qemu-devel@nongnu.org; Sat, 30 Jul 2022 10:50:47 -0400 Received: by mail-pj1-x1033.google.com with SMTP id q7-20020a17090a7a8700b001f300db8677so7798106pjf.5 for ; Sat, 30 Jul 2022 07:50:44 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id x11-20020aa78f0b000000b00525343b5047sm4882499pfr.76.2022.07.30.07.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 07:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CAT2FKyokp6jIbF5cQnfF4hEF5YeiWS/OD4dpe4OUP4=; b=cE8nL+RBiNlRWaapYpRyuRjmDBMIuHMh+AXyMHG6C2KVAMYdhRIhH+2D2Zl+7NqJcK ckZiPXFeZ9rosGe7fP0JQ1Syyn3wwu+5INIp3i5Cl9KTzaxnZDWmKcQzZXK4d//k9Lbt j+cmPRIpOfOjQ5Tg3/OPrd/OGvLoIVACj8GaeZIEN/A9aCAN5mumV41Q4hdo0sgjArDF bUYsUBr18SAGv8spy6McQL1jm9eFL4K6/d8P+YWG9x4+XAk7DC0YQ60LM7Na9kpfqk3W C/9bJaKMfWKhNlAKQIIPPRaIfO+N1/fiI9OkL0c17ZUQAfm7jVg7Fk/Ds1Pz1IxHbxN8 j6HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CAT2FKyokp6jIbF5cQnfF4hEF5YeiWS/OD4dpe4OUP4=; b=dVcDupGg43jubKx804viKueeP9AjlLlKtl+eRuWhxjtD4FdrYAKVyxTMU/gmdnX+Lx bOOHVY63Mb6EyEKGXcC4LLRb06CP4XJw5r8l3FEBjmPk7BB9BgzVBfF6Vx72za/GjSCB yewTVKfA/KHB7h5HNbW9ym+i96QF37Urb8kCe7yA6VEIA/B/cHzgMK7Vf/H0uxBdmULy /ypXL4fs54AlJhXHMUWUK3zsXlHRnhmg66/iWVgUWAK2ATIzFpif7iNFEv1GVHqhqaCp sbcG5VQEH5O0NF179Yr9yi4wjxlpsp6SA/E+EN0K619+T7N+2J9pE3FCO/0ahiR83jc1 YBxQ== X-Gm-Message-State: ACgBeo2EQSQwAd7ZBNpStiJuVnpDwwlnDfc1jdmRGP+EnB7q0WVVBYJd 5wt4CY37TziANCdw2rdr5MmzUY6T93M= X-Google-Smtp-Source: AA6agR7RM7OIBssW+TnhJSp3r84F2qwAeh+C1g7XOH9Q6hAjPIKzRtvZ94kw9dbAKl31LhQorBSyhg== X-Received: by 2002:a17:90a:1fcd:b0:1f2:1a72:ae5d with SMTP id z13-20020a17090a1fcd00b001f21a72ae5dmr10457165pjz.78.1659192643668; Sat, 30 Jul 2022 07:50:43 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 1/4] util/qemu-sockets: Replace the call to close a socket with closesocket() Date: Sat, 30 Jul 2022 22:50:33 +0800 Message-Id: <20220730145036.865854-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220730145036.865854-1-bmeng.cn@gmail.com> References: <20220730145036.865854-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1033.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1659192736318100001 From: Bin Meng close() is a *nix function. It works on any file descriptor, and sockets in *nix are an example of a file descriptor. closesocket() is a Windows-specific function, which works only specifically with sockets. Sockets on Windows do not use *nix-style file descriptors, and socket() returns a handle to a kernel object instead, so it must be closed with closesocket(). In QEMU there is already a logic to handle such platform difference in os-posix.h and os-win32.h, that: * closesocket maps to close on POSIX * closesocket maps to a wrapper that calls the real closesocket() on Windows Replace the call to close a socket with closesocket() instead. Signed-off-by: Bin Meng Reviewed-by: Marc-Andr=C3=A9 Lureau --- (no changes since v1) util/qemu-sockets.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 13b5b197f9..0e2298278f 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -487,7 +487,7 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error = **errp) =20 if (ret < 0) { error_setg_errno(errp, errno, "Unable to set KEEPALIVE"); - close(sock); + closesocket(sock); return -1; } } @@ -1050,7 +1050,7 @@ static int unix_connect_saddr(UnixSocketAddress *sadd= r, Error **errp) return sock; =20 err: - close(sock); + closesocket(sock); return -1; } =20 --=20 2.34.1 From nobody Thu May 9 13:44:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1659192816; cv=none; d=zohomail.com; s=zohoarc; b=QxHEcWVcIcIJZwvaWpQqIZoTpAQXc519Hsb5axH/6uIFxmWrhDsqUvDIG3btpdWP+cx6dJf83AS75Q7i5qA4EFuYDZK3nBjS55RDYa7av7npk9kGWtlH7BfzvGvELvqCmyWQjwoIG3B3W8T6OnhaHfVrKouY2zZndfhsU8Qk2yA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659192816; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UnQVL1Npd4eART+kRniE+KeFyZ5asD3O80TNp+3P8+k=; b=A4IHI4mXhDrqQ8aT2B0KliFDGu4xrHQb71PjtlGTNkGVeZVYIn1tvBLNoJv/eS7m7n3yMXm3fxn/ugUW7YDG8oMAYwKcXMwl1l6+Nj64CwwM5gsEZ3V2SMunaQinKX9s/cFSNZGGoul4WV4inkmM8DJlsSYkkrb7awpowdwEXO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659192816553997.4723261334785; Sat, 30 Jul 2022 07:53:36 -0700 (PDT) Received: from localhost ([::1]:47224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHnqR-0000MF-GM for importer@patchew.org; Sat, 30 Jul 2022 10:53:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHnnl-0004al-8b for qemu-devel@nongnu.org; Sat, 30 Jul 2022 10:50:49 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:41792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHnnj-0007Zc-Fs for qemu-devel@nongnu.org; Sat, 30 Jul 2022 10:50:49 -0400 Received: by mail-pl1-x62d.google.com with SMTP id v18so6897210plo.8 for ; Sat, 30 Jul 2022 07:50:47 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id x11-20020aa78f0b000000b00525343b5047sm4882499pfr.76.2022.07.30.07.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 07:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UnQVL1Npd4eART+kRniE+KeFyZ5asD3O80TNp+3P8+k=; b=poW0SWzKb47IRlxMH+pwikJRcSVlv+Rw9jUVwcL92qUIy4UEDFmhBvbR6ZpPGwjEVW mDLV4ayBNVO1F88f0q8UM8M7OR8+Xah9CKX03iHNFN02hzYOdbnPvvtLYZ/glPjRyU4s ZYmYyipJ8+WcuAChD+noX9L7EzY8JangKkwasoBuVyzSAz8AeMY2BTQJAJvtsfWPGGRr Oj65Os/Zl1kE7ai5fbIgdbEo5s2GAALVlVyuuTkd8Alwb8/gCvfvi7G2U2o9PGTRNzU/ Uc5AaoiNP3I4t2e7UmrgtAV11q7W6oZXlSo4LIbn2YFLmpWxTjvN+LYWqryxmkPWZHX7 CpyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UnQVL1Npd4eART+kRniE+KeFyZ5asD3O80TNp+3P8+k=; b=7gZG3p9wyVE/rwWjmRBvpxtuQAxNQ2G7hbLrJIbIkSIUuUhS/NewrfFFJaut0zaXJi mFeRKEp5G/6TyDZsntwwv8Xwqli76j1Q19xa50JxN+rh5Ox8XE7emWPCDQh6NbWgB2mT XXhP1K9GrNt5CofTUkyf8Mujr3938TD9aCfIhq27zL2e6NOebikmu397cYEhjGjiKZEt da7Y/KjF+fQI8KiJV7gOQszCssUmOUDPMtaiixYsW6qomoR3MlIVl5/s4aeLMM0xL7HK lsbi+Ff56x9G8daEtMS9K2BAs8Hb9u64yaOWUV19UOSfjJx4+BJTUF73SiKrP2+WkboF 9T3w== X-Gm-Message-State: ACgBeo2C02brKJ7MlVM8X4Dj4mYdTdZ1C8ANFmetu022lkPO0aW5MYY9 zbbMkAfuvIw6h8QN83GfJsEOBGSC7WQ= X-Google-Smtp-Source: AA6agR7F/+6VJuLT6azsym0RxxlGrToIIrDq4GBZHv4uziQlsC6XarJLMSRvWaVF0fFXpIIfL2KM/g== X-Received: by 2002:a17:902:d711:b0:16d:1665:1162 with SMTP id w17-20020a170902d71100b0016d16651162mr8681809ply.5.1659192645962; Sat, 30 Jul 2022 07:50:45 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Xuzhou Cheng , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stefan Weil Subject: [PATCH v3 2/4] util/qemu-sockets: Enable unix socket support on Windows Date: Sat, 30 Jul 2022 22:50:34 +0800 Message-Id: <20220730145036.865854-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220730145036.865854-1-bmeng.cn@gmail.com> References: <20220730145036.865854-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1659192818088100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng Support for the unix socket has existed both in BSD and Linux for the longest time, but not on Windows. Since Windows 10 build 17063 [1], the native support for the unix socket has come to Windows. Starting this build, two Win32 processes can use the AF_UNIX address family over Winsock API to communicate with each other. [1] https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng --- Changes in v3: - drop the run-time check afunix_available() Changes in v2: - move #include to os-win32.h - define WIN_BUILD_AF_UNIX only when CONFIG_WIN32 meson.build | 6 ++++++ include/sysemu/os-win32.h | 4 ++++ util/qemu-sockets.c | 14 +++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 294e9a8f32..3663b925d4 100644 --- a/meson.build +++ b/meson.build @@ -2327,6 +2327,12 @@ have_afalg =3D get_option('crypto_afalg') \ '''), error_message: 'AF_ALG requested but could not be detected').allow= ed() config_host_data.set('CONFIG_AF_ALG', have_afalg) =20 +if targetos !=3D 'windows' + config_host_data.set('CONFIG_AF_UNIX', true) +else + config_host_data.set('CONFIG_AF_UNIX', cc.has_header('afunix.h')) +endif + config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol( 'linux/vm_sockets.h', 'AF_VSOCK', prefix: '#include ', diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index edc3b38a57..cebf260694 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -30,6 +30,10 @@ #include #include =20 +#ifdef CONFIG_AF_UNIX +# include +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 0e2298278f..f9892506de 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -880,7 +880,7 @@ static int vsock_parse(VsockSocketAddress *addr, const = char *str, } #endif /* CONFIG_AF_VSOCK */ =20 -#ifndef _WIN32 +#ifdef CONFIG_AF_UNIX =20 static bool saddr_is_abstract(UnixSocketAddress *saddr) { @@ -1060,14 +1060,14 @@ static int unix_listen_saddr(UnixSocketAddress *sad= dr, int num, Error **errp) { - error_setg(errp, "unix sockets are not available on windows"); + error_setg(errp, "unix sockets are not available on your host"); errno =3D ENOTSUP; return -1; } =20 static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) { - error_setg(errp, "unix sockets are not available on windows"); + error_setg(errp, "unix sockets are not available on your host"); errno =3D ENOTSUP; return -1; } @@ -1335,7 +1335,7 @@ socket_sockaddr_to_address_inet(struct sockaddr_stora= ge *sa, } =20 =20 -#ifndef WIN32 +#ifdef CONFIG_AF_UNIX static SocketAddress * socket_sockaddr_to_address_unix(struct sockaddr_storage *sa, socklen_t salen, @@ -1362,7 +1362,7 @@ socket_sockaddr_to_address_unix(struct sockaddr_stora= ge *sa, addr->u.q_unix.path =3D g_strndup(su->sun_path, salen); return addr; } -#endif /* WIN32 */ +#endif /* CONFIG_AF_UNIX */ =20 #ifdef CONFIG_AF_VSOCK static SocketAddress * @@ -1394,10 +1394,10 @@ socket_sockaddr_to_address(struct sockaddr_storage = *sa, case AF_INET6: return socket_sockaddr_to_address_inet(sa, salen, errp); =20 -#ifndef WIN32 +#ifdef CONFIG_AF_UNIX case AF_UNIX: return socket_sockaddr_to_address_unix(sa, salen, errp); -#endif /* WIN32 */ +#endif =20 #ifdef CONFIG_AF_VSOCK case AF_VSOCK: --=20 2.34.1 From nobody Thu May 9 13:44:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1659192942; cv=none; d=zohomail.com; s=zohoarc; b=Z4zpEnL1AZIrkN06EzWtQLK5RAyp8WmG7UmZ8CUIjytee75TLbZyUtFvhi7G9mRDgVotx6+gtYaZzjPhpPd4e+lRr8Z5gstpiM+3kpbsVgCJc9HxZtr3EWX/U5qa40E4FVugYrT7I1/g+nUXaisM+6dDmkD777Pv1sfW/JFX1EE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659192942; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=To5bmQm11ZTI2o7stiEcQe4DIuFIjaF9pT8cpAzDEHI=; b=R5ZiHq10YqLa4PuV4wTtmIpSmMK8tBcsv0+ZnsqSDkqAB2IYak2QB7JuIjHUEPM59tXp5LlckruPKccm35Quzd0fl1MS0js0htaWCBryT7Pv6vBwuHRdIVbK/lnV7zbwkVxTmldi/WpDqSJaWL14qp8rTKwvX/Lya6kYoBy4qrE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659192942113321.17063202701956; Sat, 30 Jul 2022 07:55:42 -0700 (PDT) Received: from localhost ([::1]:50568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHnsT-0002do-4p for importer@patchew.org; Sat, 30 Jul 2022 10:55:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHnnm-0004bU-Ui for qemu-devel@nongnu.org; Sat, 30 Jul 2022 10:50:51 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:50755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHnnl-0007Zp-IC for qemu-devel@nongnu.org; Sat, 30 Jul 2022 10:50:50 -0400 Received: by mail-pj1-x1030.google.com with SMTP id f7so7229138pjp.0 for ; Sat, 30 Jul 2022 07:50:49 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id x11-20020aa78f0b000000b00525343b5047sm4882499pfr.76.2022.07.30.07.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 07:50:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=To5bmQm11ZTI2o7stiEcQe4DIuFIjaF9pT8cpAzDEHI=; b=RfBhcWDgOOQAXLCmTeI4MaAZKcTz/X7B05fd9BzVUusTR7qN0onRDM/dJ9MDI2luE2 PThnk5DXWOzKkcAq3XxQ1wT8nAumK7UpO0EWqwyePkDBfu0u7eKdjzVCgVEGjgr0YzNw STC/dlNCYgX6r+y2ipvNwKAFL12MHkSwdfe451tNe5Sa15QvwbQE7/vVVBBC4Z0BG/LY WTSlZ0P1RH5J0A+9jLmACfCoeitUxWEJIS1/hmPG8HA00tQlN09lavndn1hTRPL7c7vt bb/OhURuBs4vxnv5dddoF2YotMNZ+TdhO2eqip1o69aAEvN0oCFMVRRF1rBDJvryWDqB t2rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=To5bmQm11ZTI2o7stiEcQe4DIuFIjaF9pT8cpAzDEHI=; b=oP85VObt4yZlpgSSRXI/zi+Bacu+ofFN/u+deiXMNkPp3duwlDFc0fRneLNVgzy/73 wnD8LX+Sn5CKLXdlJFXSH4CbvIAgZHFHPXdDpKZd7HxdHc/gFogzOgitV99XXIBDUqOT /5nrSICGRx84Ut1fNjh+OFhzaKBdLC4FqknCHp2ZAUFAhOQBHcOrwvdJQ0/Ad8sPDx4v a/TrAXcl4/mSJxmeQYDLpnJMS2Qqdk61PvqjtuIxy8L1OqfpOgkO4n2O/tBLajazwfol +zu84yLQ8zqg9cs5do2VEotDCv9dsNywxPynmnHi9eS1M7ILWjwD8LU0jDKqdJVrIQUH NmwQ== X-Gm-Message-State: ACgBeo1xzudTmzvRbU3pvzhZKjNv9j6AFVnIeVI0UuQkKdkEr+aU4jm1 hz/05vwQONU8wka3BOpBRUbrORD9Uac= X-Google-Smtp-Source: AA6agR7M1KHgcrZFMEul7EXQtulNah1MnjeBdy3PMOhJ0vNPuptoXil5Z/00uwycQaqqBvtfHNeo1w== X-Received: by 2002:a17:902:ebc1:b0:168:fd13:8adc with SMTP id p1-20020a170902ebc100b00168fd138adcmr8665099plg.161.1659192648041; Sat, 30 Jul 2022 07:50:48 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Subject: [PATCH v3 3/4] chardev/char-socket: Update AF_UNIX for Windows Date: Sat, 30 Jul 2022 22:50:35 +0800 Message-Id: <20220730145036.865854-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220730145036.865854-1-bmeng.cn@gmail.com> References: <20220730145036.865854-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1659192942732100001 From: Bin Meng Now that AF_UNIX has come to Windows, update the existing logic in qemu_chr_compute_filename() and qmp_chardev_open_socket() for Windows. Signed-off-by: Bin Meng Reviewed-by: Marc-Andr=C3=A9 Lureau --- (no changes since v2) Changes in v2: - drop #include as it is now already included in osdep.h chardev/char-socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index dc4e218eeb..14a56b7b13 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -557,7 +557,7 @@ static char *qemu_chr_compute_filename(SocketChardev *s) const char *left =3D "", *right =3D ""; =20 switch (ss->ss_family) { -#ifndef _WIN32 +#ifdef CONFIG_AF_UNIX case AF_UNIX: return g_strdup_printf("unix:%s%s", ((struct sockaddr_un *)(ss))->sun_path, @@ -1372,10 +1372,12 @@ static void qmp_chardev_open_socket(Chardev *chr, } =20 qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE); +#ifndef _WIN32 /* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */ if (addr->type =3D=3D SOCKET_ADDRESS_TYPE_UNIX) { qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS); } +#endif =20 /* * In the chardev-change special-case, we shouldn't register a new yank --=20 2.34.1 From nobody Thu May 9 13:44:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1659192824; cv=none; d=zohomail.com; s=zohoarc; b=bEjSBPIDyqLmaP+TXU3VOjrHLr6kId2BgREpABLKKj3DClgYQIVRFP7qa0HWCKrRgPoIO67j3woqeuKA6hhfov668xUV+HmXLc99PqEI+D61mqe9prrJ8oY9EfxF2/Y5DB54qpVsDm0hnOQB/P8xZ0J6Td3R32yuFaEDDw+ghhI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659192824; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=syegDozyseUU5fCu7uAkgigwYdqDyHaqtGywnxSE5dY=; b=iATVaw3HbSAZ0AuLEeoShFFbstDso5NGEMz8WMlmEoXtqc6Mf+EF/9SElPdeA45j1wBK9wgPTiGldy/Te6q7llprhz50sDu7mkP9DTwHiX5tCrK9Jkt+76/9ZJpAGu0T6+zxfgyhUJjpN/9thpf2rnZk1najbD7laomCEb6KMZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659192824810535.8865178872945; Sat, 30 Jul 2022 07:53:44 -0700 (PDT) Received: from localhost ([::1]:47426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHnqX-0000US-6L for importer@patchew.org; Sat, 30 Jul 2022 10:53:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHnnp-0004cD-2i for qemu-devel@nongnu.org; Sat, 30 Jul 2022 10:50:53 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:50756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHnnn-0007a5-HJ for qemu-devel@nongnu.org; Sat, 30 Jul 2022 10:50:52 -0400 Received: by mail-pj1-x1031.google.com with SMTP id f7so7229186pjp.0 for ; Sat, 30 Jul 2022 07:50:51 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id x11-20020aa78f0b000000b00525343b5047sm4882499pfr.76.2022.07.30.07.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 07:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=syegDozyseUU5fCu7uAkgigwYdqDyHaqtGywnxSE5dY=; b=RD86hUB98JZ7/uSRJrWpP75KVcOeiY6VUrR3OVrTgZZex7JqyMIsJKgiXs/M2yBqgL 3Fr+YHpfvVNcny8IuUA11fjqDoXeWlRWYDZrFHm5VM6M72pWLVbH5pTX/O+YDh80nM+d pdtqWZT/5y7BgymgLZB9SeZvYGFRc23BswfNb8rxkCGeuAAnTkar3QadKjh8OrweqfC1 Qo2Y9C17GXhjbMM4/7ndo2D4MZIrieH6j7eZDjl/uZTxVGoGMQI0UGTssRvWKEP51+D7 p2aAjBFKRfN+r/J0HClck4mKIUav73s5dC1OhA+cngNcKmvQnY3G2RO770po5I7VXGYW Rurg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=syegDozyseUU5fCu7uAkgigwYdqDyHaqtGywnxSE5dY=; b=LVanwZTH+2aCRw1dtlUDFw5edNwZFxejTg2tT+T2to1+0AiXqmJoVCcrJB6niYxkYZ VxTONRnZrsyg0ckaLbO0LidEUZJughOqbyYRnKfthqT8wNbmR/LAoHI6u2parSq/ELUM j/PiFpiFuq5BK/J/jU2EoW26QU4M2W4hVSw6BZFKXl/aJFG/dC7necvxNet+6CY0p8NH 8qAi3Xrig4yoMUnBvGdZV27BiBZwbxUf9FuU7Of+Lwbi7apeWdCA5zzpd6mNCxVYyt0S nWfRSClJQ8c3VeR8IehqiiQK7OWINQ9FtI7QkkCFWAehC4kMSv8HJiXeIyxWba3Hh6DG i5Ww== X-Gm-Message-State: ACgBeo0FkWi95Qwy7WbFfmTX9MutchSb4wkoVfeishrWbZzKQ1pANes8 vSdHEkF8FuhFVIW6GsCD4u52cERdfW8= X-Google-Smtp-Source: AA6agR6C5jOpOfrXrEiGNJw13wpf1BdCfvBScHr4XHVX+k/+1nauTSgOTtokeJ4S8yKnIGVU0fEwhQ== X-Received: by 2002:a17:902:db0f:b0:16e:d419:85db with SMTP id m15-20020a170902db0f00b0016ed41985dbmr1736988plx.82.1659192650054; Sat, 30 Jul 2022 07:50:50 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v3 4/4] tests/unit: Update test-io-channel-socket.c for Windows Date: Sat, 30 Jul 2022 22:50:36 +0800 Message-Id: <20220730145036.865854-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220730145036.865854-1-bmeng.cn@gmail.com> References: <20220730145036.865854-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1659192825888100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng Enable the following 3 test cases for Windows when AF_UNIX is available: * test_io_channel_unix_sync * test_io_channel_unix_async * test_io_channel_unix_listen_cleanup Signed-off-by: Bin Meng --- (no changes since v2) Changes in v2: - new patch: tests/unit: Update test-io-channel-socket.c for Windows tests/unit/test-io-channel-socket.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-io-channel-socket.c b/tests/unit/test-io-chann= el-socket.c index 6713886d02..ec5df32489 100644 --- a/tests/unit/test-io-channel-socket.c +++ b/tests/unit/test-io-channel-socket.c @@ -179,10 +179,12 @@ static void test_io_channel(bool async, test_io_channel_setup_async(listen_addr, connect_addr, &srv, &src, &dst); =20 +#ifndef _WIN32 g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)= ); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)= ); +#endif g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN= )); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN= )); =20 @@ -206,10 +208,12 @@ static void test_io_channel(bool async, test_io_channel_setup_async(listen_addr, connect_addr, &srv, &src, &dst); =20 +#ifndef _WIN32 g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)= ); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)= ); +#endif g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN= )); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN= )); =20 @@ -236,10 +240,12 @@ static void test_io_channel(bool async, test_io_channel_setup_sync(listen_addr, connect_addr, &srv, &src, &dst); =20 +#ifndef _WIN32 g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)= ); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)= ); +#endif g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN= )); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN= )); =20 @@ -263,10 +269,12 @@ static void test_io_channel(bool async, test_io_channel_setup_sync(listen_addr, connect_addr, &srv, &src, &dst); =20 +#ifndef _WIN32 g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)= ); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)= ); +#endif g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN= )); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN= )); =20 @@ -367,7 +375,7 @@ static void test_io_channel_ipv6_async(void) } =20 =20 -#ifndef _WIN32 +#ifdef CONFIG_AF_UNIX static void test_io_channel_unix(bool async) { SocketAddress *listen_addr =3D g_new0(SocketAddress, 1); @@ -398,6 +406,7 @@ static void test_io_channel_unix_async(void) return test_io_channel_unix(true); } =20 +#ifndef _WIN32 static void test_io_channel_unix_fd_pass(void) { SocketAddress *listen_addr =3D g_new0(SocketAddress, 1); @@ -491,6 +500,7 @@ static void test_io_channel_unix_fd_pass(void) } g_free(fdrecv); } +#endif /* _WIN32 */ =20 static void test_io_channel_unix_listen_cleanup(void) { @@ -588,13 +598,15 @@ int main(int argc, char **argv) test_io_channel_ipv6_async); } =20 -#ifndef _WIN32 +#ifdef CONFIG_AF_UNIX g_test_add_func("/io/channel/socket/unix-sync", test_io_channel_unix_sync); g_test_add_func("/io/channel/socket/unix-async", test_io_channel_unix_async); +#ifndef _WIN32 g_test_add_func("/io/channel/socket/unix-fd-pass", test_io_channel_unix_fd_pass); +#endif g_test_add_func("/io/channel/socket/unix-listen-cleanup", test_io_channel_unix_listen_cleanup); #endif /* _WIN32 */ --=20 2.34.1