From patchwork Wed Jul 27 13:27:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12930422 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2869C04A68 for ; Wed, 27 Jul 2022 13:31:42 +0000 (UTC) Received: from localhost ([::1]:46056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGh8X-0005b1-Gu for qemu-devel@archiver.kernel.org; Wed, 27 Jul 2022 09:31:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGh5C-0003VX-VZ for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:14 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:44580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGh5B-00022W-Dj for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:14 -0400 Received: by mail-pl1-x635.google.com with SMTP id p1so7618686plr.11 for ; Wed, 27 Jul 2022 06:28:10 -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=RFwJC4o8e5unv4cZEgy8YcWZ7BgqUqHRQ5uPl7IbilA=; b=Eoyll8sl06IqX1xvXH9a8yezpz/NHz96QCtlVdBOp0M7Xcxf4mtBIeCru8ExEpYdEw Uu+5kQ6lt0vu1iEUJd74UlOel1oMcsigKXPR3mpLHrdaKW3qLNs1yzoqFwm3uAOPmNgY skR7KcCWcD+56zeFxvRaU+yeIJWurayX2FOmP6GhxkRgqwjITvFCw0AsI8qOarvfOO+w gDl3dVjWjYCsdTaiduOsqcAV5wGoRMlc7b5aFTdpC40KFaW7/WHDe22xrBInBU/QnFHk rxK+Qwz3sG7hxslasHkQdAlZuv13+lfm2pkDG/VqrqCwLkkIdFWHXsa5+qEZ7W7p/qM1 +Vjg== 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=RFwJC4o8e5unv4cZEgy8YcWZ7BgqUqHRQ5uPl7IbilA=; b=oE4fPJAvikIzYIbKIA5/T346wUskqzH8G7KtKK5JRk3b2NFRshrFOtdxWEppojksXh ulona1ixt6+w1Y+qgw+tSIhWqiGsECACYSeYlnxaKlVO/JipSvEZdSbAPPuOE1LmYAL3 nYVLCCsHoB0z4MZMVrTYvKo+UC6j0KI/9qrQwHjoSd93wTKxBgOz0g6Ps2Qp0KpCB8c5 /Nfg4eKH+SN8nY+IcCUscz1HNjFDjKFbzv5MUUC7knp865T/yyydTk2HfiaQO9FncKCJ sa3EDjDpHKufb+cToobabLyfayy7UfFRVZKsQv311cuZYfQi9oTzsDoniTxzry1PD83h NnAg== X-Gm-Message-State: AJIora+HdVP0IDkHukGE1gBX7gPStqh77gHYLN2LYaTrFhpASfIXtEcU EqvnsBVvjct8igwDqsncVTVwBgV01aQ= X-Google-Smtp-Source: AGRyM1tL6mMepQ2rVum+15fCRIEsq1tCfUxfhx/xg8Q6Yl87nNhVq8s3eU4mHVJ3owSod5x6cpWDaA== X-Received: by 2002:a17:90b:3c8c:b0:1f2:205c:2480 with SMTP id pv12-20020a17090b3c8c00b001f2205c2480mr4723848pjb.54.1658928489233; Wed, 27 Jul 2022 06:28:09 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id ij13-20020a170902ab4d00b0016daee46b72sm1971192plb.237.2022.07.27.06.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 06:28:08 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v2 1/6] util/qemu-sockets: Replace the call to close a socket with closesocket() Date: Wed, 27 Jul 2022 21:27:57 +0800 Message-Id: <20220727132802.812580-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727132802.812580-1-bmeng.cn@gmail.com> References: <20220727132802.812580-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é 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) 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 *saddr, Error **errp) return sock; err: - close(sock); + closesocket(sock); return -1; } From patchwork Wed Jul 27 13:27:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12930425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9820AC04A68 for ; Wed, 27 Jul 2022 13:36:39 +0000 (UTC) Received: from localhost ([::1]:51436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGhDK-0001Wf-K2 for qemu-devel@archiver.kernel.org; Wed, 27 Jul 2022 09:36:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGh5C-0003VY-Uy for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:14 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:35633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGh5B-00022w-Ds for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:14 -0400 Received: by mail-pg1-x536.google.com with SMTP id r186so15943515pgr.2 for ; Wed, 27 Jul 2022 06:28:12 -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=1Phf7RRs9YPshwkeWcjieRVLG6Kz9qCuEGQI3Aw89tI=; b=IbBmHuDpEMfiwARyflJ/ijqAcCXoeCQelqeV2vCNdnxhEsWEsLUX2J04zTEkqU+BY4 4GqWH0JuDKGePQ9/ft3eIgq1BMD3W9G1SWp6gfZ4H9Vner9wVIdDDSKlp3Ouc3G53dCl LxY5rWWp71Zw+wj0Yg/OKwpymz++VGXQLsv8lQjVIHVLlHXM4XPSOVLIFAIQ8RY89uKz jfttPn3zSnVd7lg1myvAY+wFRNZ0Ca+gyhT+zDGjxx2iSkM52hpVJMyQntn+iqG+UJbb FbKFRgU4TMyR0XgGuKmI56wpRGSxNw1xCFLqrjH+ObHHvNzVQgn0TslJIbbuiAqjUZU1 hOlA== 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=1Phf7RRs9YPshwkeWcjieRVLG6Kz9qCuEGQI3Aw89tI=; b=LJ0nwBkcKHMUm7jamhEJBWJvfEWdEVAhVjDrmPhc5kDqVJ8d8DTfVreH0w22nORDP8 J6dmr+8zgIhJuuUYURVLTBh4h5+HsGjLSxGjf1XZF30oVXTtMsV2BSUEAKaj/51CSb5N qMBnOmIMvutbYkA4qA9cZ1M/KjtZEVlLBxKrPOEyXXW9MXRj1jzKbOCCmR+tdpSNcMvJ umyI78iT1ISg6MrtnwpIcW/bbhAC8fAeciUo+UlwnBxybSfzoFICZSYu74MF9ceS1a83 z93EngzwDYKB1GjLqgWVRt037D742PEVRjln283WaDG4DD6qY5eqUbK7sFf3fueZaUj6 ykQw== X-Gm-Message-State: AJIora+hSiryWbciiXIbkNFkw3qWHvDFG7qgPmV8M4M0IOBsKRKEMIWX jInCAbtETw8EcczYCR8dv25AF15zSig= X-Google-Smtp-Source: AGRyM1vbTnT8CHLbgBJ4/4Xxxm42QwPeT5nG7135p5idU6HI7nmN0gU7R4zMC0NNEnEIS1RtHGU7tQ== X-Received: by 2002:a63:6e85:0:b0:41b:42d0:83ef with SMTP id j127-20020a636e85000000b0041b42d083efmr3454252pgc.236.1658928491393; Wed, 27 Jul 2022 06:28:11 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id ij13-20020a170902ab4d00b0016daee46b72sm1971192plb.237.2022.07.27.06.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 06:28:10 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Xuzhou Cheng , Stefan Weil Subject: [PATCH v2 2/6] util/oslib-win32: Add a helper to get the Windows version Date: Wed, 27 Jul 2022 21:27:58 +0800 Message-Id: <20220727132802.812580-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727132802.812580-1-bmeng.cn@gmail.com> References: <20220727132802.812580-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x536.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This adds a helper to get the Windows version via the RtlGetVersion call, for QEMU codes to determine the Windows version at run-time. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng --- (no changes since v1) include/sysemu/os-win32.h | 2 ++ util/oslib-win32.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index edc3b38a57..1e324026a4 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -204,6 +204,8 @@ ssize_t qemu_recv_wrap(int sockfd, void *buf, size_t len, int flags); ssize_t qemu_recvfrom_wrap(int sockfd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen); +void os_get_win_version(RTL_OSVERSIONINFOEXW *info); + #ifdef __cplusplus } #endif diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 5723d3eb4c..6d2387b9ff 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -547,3 +547,18 @@ int qemu_msync(void *addr, size_t length, int fd) */ return qemu_fdatasync(fd); } + +void os_get_win_version(RTL_OSVERSIONINFOEXW *info) +{ + typedef LONG (WINAPI *rtl_get_version_t)(PRTL_OSVERSIONINFOEXW); + + /* RtlGetVersion is available starting with Windows 2000 */ + HMODULE module = GetModuleHandle("ntdll"); + PVOID fun = GetProcAddress(module, "RtlGetVersion"); + rtl_get_version_t rtl_get_version = (rtl_get_version_t)fun; + + info->dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); + rtl_get_version(info); + + return; +} From patchwork Wed Jul 27 13:27:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12930424 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6EBA4C04A68 for ; Wed, 27 Jul 2022 13:31:48 +0000 (UTC) Received: from localhost ([::1]:46292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGh8d-0005kP-F3 for qemu-devel@archiver.kernel.org; Wed, 27 Jul 2022 09:31:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGh5F-0003aH-WF for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:18 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:44580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGh5E-00022W-Eb for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:17 -0400 Received: by mail-pl1-x635.google.com with SMTP id p1so7618891plr.11 for ; Wed, 27 Jul 2022 06:28:16 -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=K5RpPkx1Tcaz5Omqx39MjgHtnMsOaSt7tarRvfh7ii0=; b=n22+ofw9nMS/BRENh9Kg8p9NzD8aGfslVNNtxySXeee1BBcxj/fIyKiMZJ7glPLxUc 5srfZ4nbsN8t16nesMiuwUJJGQxjwtlNgObBXE/LcaOj6FegTWIYF/zg1OAZy08EPkDE cNmmAKG5eHAcdGcwD0MZ0SSJSWM4GJ1x+EfHt6lOe3BLffRlPOWp/OVYg3M1jdnSPWpz jAognOqsTMo2Ev2L5iOLpeGb0FmNKQ2kB7VpdLtKpq3LVDonLqY1/2xgORjVNetvoVw1 Q17L6vZWSgwRHLJhuoxx2jpn39rJrVZ1tpP9z7GDOCFRIBv33io2F+G/hrSU8y8lKhx5 BCFw== 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=K5RpPkx1Tcaz5Omqx39MjgHtnMsOaSt7tarRvfh7ii0=; b=EKx+9ejSVSI4NfIusIKJksBviwRAtv4CxfWTMp02O2jReFQG5/0hipdU5AvJ8qUwoo 4j786/D7cJ+CC2MKAdC85bp8lUMX8AUmniYjKTY+wm4cfyesZsqeYf65f884ZGO3u+mt 8HZnMPXOPujnQ2g6bfia0C90YyxmQrvBccTSr6OcjyTZrQVV8tbmfTWH1CpKn7ncqM1B x1FH4EjZTML0Y6c8tRV0FEcfcqAXKdC5htOa606mC/rCcs0k+GlpWTl3oG6MyVa2fm0S WH94itFRYU9w5kJDDvRQ8i8pcA9nvc9wc/PQqpNy/WN7R2y+uwx3MzEVhahdgOSco6jt B84w== X-Gm-Message-State: AJIora/c6Rcah9j5xlSDH+gT+RgIqpKgctW7AGhBGAur0n1og37UrJ8w o9ut7wz/MWylLQDceKi6i06M7ZZ2wDg= X-Google-Smtp-Source: AGRyM1u1K0nWw3+XrlOmBKON3YI+U+iQ35DaUqsFTSaEnIkoDaU39IlppvdHplQxwt8/EWOLx9zhVA== X-Received: by 2002:a17:90b:38cf:b0:1f2:fb9c:6003 with SMTP id nn15-20020a17090b38cf00b001f2fb9c6003mr4613578pjb.214.1658928494033; Wed, 27 Jul 2022 06:28:14 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id ij13-20020a170902ab4d00b0016daee46b72sm1971192plb.237.2022.07.27.06.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 06:28:13 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Konstantin Kostiuk , Michael Roth Subject: [PATCH v2 3/6] qga/commands-win32: Use os_get_win_version() Date: Wed, 27 Jul 2022 21:27:59 +0800 Message-Id: <20220727132802.812580-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727132802.812580-1-bmeng.cn@gmail.com> References: <20220727132802.812580-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x635.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Drop its own ga_get_win_version() implementation, and use the one provided in oslib-win32 instead. Signed-off-by: Bin Meng --- (no changes since v1) qga/commands-win32.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 7ed7664715..6186f2e1f2 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -2178,26 +2178,6 @@ static ga_win_10_0_t const WIN_10_0_CLIENT_VERSION_MATRIX[3] = { {0, 0} }; -static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp) -{ - typedef NTSTATUS(WINAPI *rtl_get_version_t)( - RTL_OSVERSIONINFOEXW *os_version_info_ex); - - info->dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); - - HMODULE module = GetModuleHandle("ntdll"); - PVOID fun = GetProcAddress(module, "RtlGetVersion"); - if (fun == NULL) { - error_setg(errp, QERR_QGA_COMMAND_FAILED, - "Failed to get address of RtlGetVersion"); - return; - } - - rtl_get_version_t rtl_get_version = (rtl_get_version_t)fun; - rtl_get_version(info); - return; -} - static char *ga_get_win_name(OSVERSIONINFOEXW const *os_version, bool id) { DWORD major = os_version->dwMajorVersion; @@ -2312,17 +2292,12 @@ static char *ga_get_current_arch(void) GuestOSInfo *qmp_guest_get_osinfo(Error **errp) { - Error *local_err = NULL; OSVERSIONINFOEXW os_version = {0}; bool server; char *product_name; GuestOSInfo *info; - ga_get_win_version(&os_version, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return NULL; - } + os_get_win_version(&os_version); server = os_version.wProductType != VER_NT_WORKSTATION; product_name = ga_get_win_product_name(errp); From patchwork Wed Jul 27 13:28:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12930426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E76F2C19F2B for ; Wed, 27 Jul 2022 13:36:41 +0000 (UTC) Received: from localhost ([::1]:51502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGhDN-0001b9-0I for qemu-devel@archiver.kernel.org; Wed, 27 Jul 2022 09:36:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGh5I-0003fO-S7 for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:20 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:38772) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGh5G-00024W-P0 for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:20 -0400 Received: by mail-pl1-x630.google.com with SMTP id o3so714490ple.5 for ; Wed, 27 Jul 2022 06:28:18 -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=bcdb9+/+AcWEckEkuoxNuUyFBTQkLyiHLCzbjRH2NRw=; b=UrjMEzyw4IahPN4j6DS8m4fFtbLAbVzWjLMsLoNh35o+2XO2QFNdemlkh2HN5DiNoe 708hB2agzh+8X9BihzqbPZq5GYxDe57oIHOePYfw9MEpYV9Btpc1TwG5s0ttFW7TNn07 Z5x8pQ/7R/oWSmXARFxvjc4nvzI6dvtsYbae+XCu7uZ9+JCEhVULD1pwPSpHGLsRXt+Y MgiNw1woP80uL+SOMmuM31iXI7wutdc7VOCdBJ49oVmpbzLEvnF9LLVEbWQK6VlU74EN lK2N+JIf4nFmP7k4rpecW3F2mOBRoEA2jD15keZwRmOV9fiEspPzhVgTe/yq1sc+1Gno stOg== 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=bcdb9+/+AcWEckEkuoxNuUyFBTQkLyiHLCzbjRH2NRw=; b=E1z2fA51DrQlB/pdf+brYUm+dFXu7bwGMpfCMD7Esc4fQMGsrNO48UqJimrizzmVVY zI4WBIl1zgpG6mJoHGodtYHMM7cRvdBsRbMFHrKSOL5qX+kjD++gZlMWXLAjJVDRRUm0 WozIT9PJQKA/Y8BPrSluO6+/swdBGsqbGSumlwiuVFAeINcAPFLYQjf8v0HO2Ir2BZny 07o2Srbl0a5o4yvFmz5/LrG5LKMe2LJzgEE4gK1qhOUjd/A8O2kWoYrndpN2/bH/SCE0 0LqlxwRv9uTVE1ljCFfINXf7VkrqMKWkeE+AjLk7lB9BfKtkc9cOVMGB+lPDhnMdUDFz /Hug== X-Gm-Message-State: AJIora8N1OGgJQi/qAMVTXsJvQxJPvjzIdtOKaQ+cAvEmX1JA74zuamX 1JX1Uk5eKV9N5TuvDQ6pRjWht4CBerQ= X-Google-Smtp-Source: AGRyM1vFDOUzHGag5jDxhkfLr6NsOjFRv6IMXPnRpRkoXEFx9+kdt6pvEcgS9QRJXm/4JC++sks+Xg== X-Received: by 2002:a17:90a:d3d8:b0:1f2:2cd:a1ca with SMTP id d24-20020a17090ad3d800b001f202cda1camr4628543pjw.135.1658928497184; Wed, 27 Jul 2022 06:28:17 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id ij13-20020a170902ab4d00b0016daee46b72sm1971192plb.237.2022.07.27.06.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 06:28:16 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Xuzhou Cheng , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Stefan Weil Subject: [PATCH v2 4/6] util/qemu-sockets: Enable unix socket support on Windows Date: Wed, 27 Jul 2022 21:28:00 +0800 Message-Id: <20220727132802.812580-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727132802.812580-1-bmeng.cn@gmail.com> References: <20220727132802.812580-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x630.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 came to Windows. Starting this build, two Win32 processes can use the AF_UNIX address family over Winsock API to communicate with each other. Introduce a new build time config option CONFIG_AF_UNIX when the build host has such a capability, and a run-time check afunix_available() for Windows host in the QEMU sockets util codes. [1] https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng --- 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 | 45 +++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 75aaca8462..73e5de5957 100644 --- a/meson.build +++ b/meson.build @@ -2327,6 +2327,12 @@ 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) +if targetos != '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 1e324026a4..62aac7c930 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -30,6 +30,10 @@ #include #include +#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..c5c1c3bbaf 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 */ -#ifndef _WIN32 +#ifdef CONFIG_AF_UNIX static bool saddr_is_abstract(UnixSocketAddress *saddr) { @@ -900,6 +900,23 @@ static bool saddr_is_tight(UnixSocketAddress *saddr) #endif } +#ifdef CONFIG_WIN32 +/* + * AF_UNIX support is available since Windows 10 build 17063 + * See https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ + */ +#define WIN_BUILD_AF_UNIX 17063 + +static bool afunix_available(void) +{ + OSVERSIONINFOEXW os_version = { 0 }; + + os_get_win_version(&os_version); + + return os_version.dwBuildNumber >= WIN_BUILD_AF_UNIX; +} +#endif + static int unix_listen_saddr(UnixSocketAddress *saddr, int num, Error **errp) @@ -912,6 +929,13 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, size_t pathlen; size_t addrlen; +#ifdef CONFIG_WIN32 + if (!afunix_available()) { + error_setg(errp, "AF_UNIX is not available on your Windows"); + return -1; + } +#endif + sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { error_setg_errno(errp, errno, "Failed to create Unix socket"); @@ -1004,6 +1028,13 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) return -1; } +#ifdef CONFIG_WIN32 + if (!afunix_available()) { + error_setg(errp, "AF_UNIX is not available on your Windows"); + return -1; + } +#endif + sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { error_setg_errno(errp, errno, "Failed to create socket"); @@ -1060,14 +1091,14 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, 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 = ENOTSUP; return -1; } 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 = ENOTSUP; return -1; } @@ -1335,7 +1366,7 @@ socket_sockaddr_to_address_inet(struct sockaddr_storage *sa, } -#ifndef WIN32 +#ifdef CONFIG_AF_UNIX static SocketAddress * socket_sockaddr_to_address_unix(struct sockaddr_storage *sa, socklen_t salen, @@ -1362,7 +1393,7 @@ socket_sockaddr_to_address_unix(struct sockaddr_storage *sa, addr->u.q_unix.path = g_strndup(su->sun_path, salen); return addr; } -#endif /* WIN32 */ +#endif /* CONFIG_AF_UNIX */ #ifdef CONFIG_AF_VSOCK static SocketAddress * @@ -1394,10 +1425,10 @@ socket_sockaddr_to_address(struct sockaddr_storage *sa, case AF_INET6: return socket_sockaddr_to_address_inet(sa, salen, errp); -#ifndef WIN32 +#ifdef CONFIG_AF_UNIX case AF_UNIX: return socket_sockaddr_to_address_unix(sa, salen, errp); -#endif /* WIN32 */ +#endif #ifdef CONFIG_AF_VSOCK case AF_VSOCK: From patchwork Wed Jul 27 13:28:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12930427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37C4AC04A68 for ; Wed, 27 Jul 2022 13:39:24 +0000 (UTC) Received: from localhost ([::1]:55606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGhFz-0004Yf-B3 for qemu-devel@archiver.kernel.org; Wed, 27 Jul 2022 09:39:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGh5K-0003jI-S1 for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:22 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:45798) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGh5J-00025m-4T for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:22 -0400 Received: by mail-pg1-x536.google.com with SMTP id f65so15907669pgc.12 for ; Wed, 27 Jul 2022 06:28:20 -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=nMS9OUaYa/QNvkZNXsceR+8orBdBvzp5WVQGR+Vg1S4=; b=C4yzPKsAOPDvDOD111R/Qo8VNVOO8DwQ5TQfjBcRTk+nc1j68LZMGPpFA1jkN4M1nZ BqfIFToDfcnakKNmASwxteTX682XNV6/yGaZFnavBjnA9Zc3DyxFNw7ySfni8NYTWIV6 tRCkHm0j2XsTQ6T80VNz1YVjupjmSw9m7EvntoGienwu6kSmGaacvk80mfZRR4lBeClb hhUY719dZs/WSXdGOYoMMEmUTW7tu7zUCisx4mk79TRUZnQ5udVzVmd7rG0jZLkBDFWW 689JXjkhE++iTKOKBo8nmDoDkbZWIJxqpJOihNjuAWVCwYlHyNruMeCrqn14LmtCUi9z 6mSA== 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=nMS9OUaYa/QNvkZNXsceR+8orBdBvzp5WVQGR+Vg1S4=; b=sjgpVMOq7wAEjfNAmuSQap1cVJMQHC/QsWDO1xSBYx6alfxZlhOqJKV+WpcuzPv/M0 tDtVY6I94ozDv27fZ3Sg3zNzD00RKXPpZ36kpK8BcsA+0KHQolcY7Yh+BVMfqyilh/Rs I3S1Ks9ZJKuL0EgjWnqdIZJA7qy9r/4Oiuhg9GE8WBG3Y2l8g/D/QDt5rdYSlMgbJDFG DLhMWBXeiBCFOhe8daW4TsPput8T6C502s4sN61Rtrv5luTxDpieBpyHQYlQyXYorJOQ rhgqIPNO/4gvdHTWsKyZM2eo6Dig4lJK7byaFBkWfDqRxhsBpt4cC8wTEpKuA6tRS4gW /LDQ== X-Gm-Message-State: AJIora9YO+Ju/jArYtLN871vLb9OED1w/XiNtC0eHuczP92ENe5LZOYV hkOWHDAAh8IQFZDwsuD0xgQfrCaIYGE= X-Google-Smtp-Source: AGRyM1v0SbqL6cdNcSmyLBaF9TibFcrJwbrnuQh+ESXPdlBe9pCqe3/afNUTqcBf1dzzJvbAXT7K4w== X-Received: by 2002:a63:1658:0:b0:41a:4118:f4b9 with SMTP id 24-20020a631658000000b0041a4118f4b9mr19090047pgw.153.1658928499493; Wed, 27 Jul 2022 06:28:19 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id ij13-20020a170902ab4d00b0016daee46b72sm1971192plb.237.2022.07.27.06.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 06:28:19 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini Subject: [PATCH v2 5/6] chardev/char-socket: Update AF_UNIX for Windows Date: Wed, 27 Jul 2022 21:28:01 +0800 Message-Id: <20220727132802.812580-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727132802.812580-1-bmeng.cn@gmail.com> References: <20220727132802.812580-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x536.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é Lureau --- 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 = "", *right = ""; 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, } qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE); +#ifndef _WIN32 /* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */ if (addr->type == SOCKET_ADDRESS_TYPE_UNIX) { qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS); } +#endif /* * In the chardev-change special-case, we shouldn't register a new yank From patchwork Wed Jul 27 13:28:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12930429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4CD1EC04A68 for ; Wed, 27 Jul 2022 13:43:12 +0000 (UTC) Received: from localhost ([::1]:60344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGhJf-0008PV-5S for qemu-devel@archiver.kernel.org; Wed, 27 Jul 2022 09:43:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGh5N-0003n0-Od for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:30 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:46662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGh5M-000268-4B for qemu-devel@nongnu.org; Wed, 27 Jul 2022 09:28:25 -0400 Received: by mail-pl1-x632.google.com with SMTP id p8so16087748plq.13 for ; Wed, 27 Jul 2022 06:28:23 -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=HDgvtILjqj7f5GpmrtAwzXuf0Dj9yuPEjtZ/JywTSCI=; b=jFQqEByrKfoCmaPxP29emG7lOgK3vdfw2yThoYKnTZe3b748sh2BnAt+pPcHSz7BAc 9zMwUWP7I2WQa8hbOL0Ps/MorjVNV0TmzA9+eomvlR5lFdybXDLAzi1q5FLJHCHEYfqz e2nYiTey8LC56vO1VCONugJ3lMD//6RnCCWeYoA/BkXHUo9MXjdV5o80VIeRv2JeovB5 qMKYEwb8ORNrqZbbZq9oYkNuZLIV6lfpmsQ5ANyPDc50CLIuxiPjNjPxherBVL5sLLtZ N002RB/nWHrtBChJLk/z195E2mpclWYgUucFRd2VUgzGSqNs2g/HtXvAv+7v3CChII3L C0ng== 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=HDgvtILjqj7f5GpmrtAwzXuf0Dj9yuPEjtZ/JywTSCI=; b=benOb2Q52+n772le8b5/fRDheqH7BeP5zTY70Vpez+Aq3d1r+O8XTOdyp+b65Wkgfm vokJxVdjQNNR5lIGPe0F8NN6iRYBT/FdFZ7Ojv1B36Ir6iiuSM4aKAXHAUwUGrbDbqbN F0ePOQc3G1l3Pi6cqETjSTDhwnfxPPwG+B4/Eh+d4SyxoKvRwv2qeeZUxEJQTV0mwzdo cU37zI0FQEaySAq/aDwxFgIZoug9jGQK/eHFB5DOrPT6uz8V10QB6DMol8dC9OUsR+Lk 356O/yW35J8X9S4mxiIOeNHc5zEQBQD1PqeWg/0KP+lj529avVe8A31aOM6N9KUVN2fz 7S0Q== X-Gm-Message-State: AJIora+jpxnRniD64xE3L+5K0nsDKgQE77CwDtzn2cZQPQW0VZwdig3D dD5tgHuBE8uQetHZ5+JgYxTZ4sVSIPc= X-Google-Smtp-Source: AGRyM1vFXDXa+yGKOQ85f7nocsiXkHWrmvHZIolu8DMKmZBl65QJbIThpvkvyu4+OesFhnpytGQ+Rg== X-Received: by 2002:a17:90a:e7cd:b0:1f0:2304:f579 with SMTP id kb13-20020a17090ae7cd00b001f02304f579mr4677566pjb.212.1658928502177; Wed, 27 Jul 2022 06:28:22 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id ij13-20020a170902ab4d00b0016daee46b72sm1971192plb.237.2022.07.27.06.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 06:28:21 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v2 6/6] tests/unit: Update test-io-channel-socket.c for Windows Date: Wed, 27 Jul 2022 21:28:02 +0800 Message-Id: <20220727132802.812580-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727132802.812580-1-bmeng.cn@gmail.com> References: <20220727132802.812580-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x632.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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-channel-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); +#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)); @@ -206,10 +208,12 @@ static void test_io_channel(bool async, test_io_channel_setup_async(listen_addr, connect_addr, &srv, &src, &dst); +#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)); @@ -236,10 +240,12 @@ static void test_io_channel(bool async, test_io_channel_setup_sync(listen_addr, connect_addr, &srv, &src, &dst); +#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)); @@ -263,10 +269,12 @@ static void test_io_channel(bool async, test_io_channel_setup_sync(listen_addr, connect_addr, &srv, &src, &dst); +#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)); @@ -367,7 +375,7 @@ static void test_io_channel_ipv6_async(void) } -#ifndef _WIN32 +#ifdef CONFIG_AF_UNIX static void test_io_channel_unix(bool async) { SocketAddress *listen_addr = g_new0(SocketAddress, 1); @@ -398,6 +406,7 @@ static void test_io_channel_unix_async(void) return test_io_channel_unix(true); } +#ifndef _WIN32 static void test_io_channel_unix_fd_pass(void) { SocketAddress *listen_addr = g_new0(SocketAddress, 1); @@ -491,6 +500,7 @@ static void test_io_channel_unix_fd_pass(void) } g_free(fdrecv); } +#endif /* _WIN32 */ static void test_io_channel_unix_listen_cleanup(void) { @@ -588,13 +598,15 @@ int main(int argc, char **argv) test_io_channel_ipv6_async); } -#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 */