From nobody Mon Feb 9 19:09:10 2026 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1662125365; cv=none; d=zohomail.com; s=zohoarc; b=HRgl8E1iidvR2XLfHcJErRabYDKPdTMA1OC9R7aHCHh2ViDUJp8IYSs4wVRiTEqAo369PjTepLqa1rCfAqzj+sIjsxBslx3Lc5sIAqCbfpaHh4Zupm85OzJB3RWgaQsmJUmsKxu8BEsd78nNe/TKlmLPLK23nrWAlFYugAdmjgs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662125365; 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=0Qhey8UdkAuQpF4oKR1Sd+bmNkNumqxDJpDYRMIJmXQ=; b=MlyTXD/YnZZMT2ZcCnjcu60l6TK6EelaYjI/Q6lS/YSZ6Y/UKjVPPWnXC6mIGzew7RimZGSN5iziSySfDT8KD1o5RRd2inWMY7sdTsuJ0PVqsrfC9J/BTPX78qW/AzITpkHaa6N/oZtQkwIJfG697QPEMCKVmRx31esM+hJz0uw= 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 1662125365875199.99224034360248; Fri, 2 Sep 2022 06:29:25 -0700 (PDT) Received: from localhost ([::1]:37612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oU6jb-0003Ny-S7 for importer@patchew.org; Fri, 02 Sep 2022 09:29:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU6V8-00065c-NN for qemu-devel@nongnu.org; Fri, 02 Sep 2022 09:14:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU6V6-0001wD-U9 for qemu-devel@nongnu.org; Fri, 02 Sep 2022 09:14:26 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-t3aTfMbTNjahFNTCdFUL7w-1; Fri, 02 Sep 2022 09:14:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DF4FF29AB3E2; Fri, 2 Sep 2022 13:14:20 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 159561415125; Fri, 2 Sep 2022 13:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662124464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Qhey8UdkAuQpF4oKR1Sd+bmNkNumqxDJpDYRMIJmXQ=; b=TNDnLwsnv7RwGtnamZ2DPeC/esFpNu+ILLrg+msoSyfap5VuWd/qhkGD3FMtr1iKOY/hXD 9QBDoonlyAV8IIH190le4NJ3kuNX84Vk3MDf8TGWTltf8BGogXSsZxoF0YTcCxhcBg6kUg HIlctJEPG5255rBd7IPxyrEI+DKoF7o= X-MC-Unique: t3aTfMbTNjahFNTCdFUL7w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , bin.meng@windriver.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Stefan Weil , Paolo Bonzini , Xuzhou Cheng Subject: [PULL 1/4] util/qemu-sockets: Enable unix socket support on Windows Date: Fri, 2 Sep 2022 17:14:09 +0400 Message-Id: <20220902131412.3125752-2-marcandre.lureau@redhat.com> In-Reply-To: <20220902131412.3125752-1-marcandre.lureau@redhat.com> References: <20220902131412.3125752-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 @redhat.com) X-ZM-MESSAGEID: 1662125367599100001 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 Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220802075200.907360-3-bmeng.cn@gmail.com> --- meson.build | 3 +++ include/sysemu/os-win32.h | 17 +++++++++++++++++ util/qemu-sockets.c | 25 ------------------------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/meson.build b/meson.build index 20fddbd707..169b18a279 100644 --- a/meson.build +++ b/meson.build @@ -1890,6 +1890,9 @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty= .h')) config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h')) config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) +if targetos =3D=3D 'windows' + config_host_data.set('HAVE_AFUNIX_H', cc.has_header('afunix.h')) +endif =20 # has_function config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4')) diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index edc3b38a57..5b38c7bd04 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -30,6 +30,23 @@ #include #include =20 +#ifdef HAVE_AFUNIX_H +#include +#else +/* + * Fallback definitions of things we need in afunix.h, if not available fr= om + * the used Windows SDK or MinGW headers. + */ +#define UNIX_PATH_MAX 108 + +typedef struct sockaddr_un { + ADDRESS_FAMILY sun_family; + char sun_path[UNIX_PATH_MAX]; +} SOCKADDR_UN, *PSOCKADDR_UN; + +#define SIO_AF_UNIX_GETPEERPID _WSAIOR(IOC_VENDOR, 256) +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 0e2298278f..83f4bd6fd2 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -880,8 +880,6 @@ static int vsock_parse(VsockSocketAddress *addr, const = char *str, } #endif /* CONFIG_AF_VSOCK */ =20 -#ifndef _WIN32 - static bool saddr_is_abstract(UnixSocketAddress *saddr) { #ifdef CONFIG_LINUX @@ -1054,25 +1052,6 @@ static int unix_connect_saddr(UnixSocketAddress *sad= dr, Error **errp) return -1; } =20 -#else - -static int unix_listen_saddr(UnixSocketAddress *saddr, - int num, - Error **errp) -{ - error_setg(errp, "unix sockets are not available on windows"); - errno =3D ENOTSUP; - return -1; -} - -static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) -{ - error_setg(errp, "unix sockets are not available on windows"); - errno =3D ENOTSUP; - return -1; -} -#endif - /* compatibility wrapper */ int unix_listen(const char *str, Error **errp) { @@ -1335,7 +1314,6 @@ socket_sockaddr_to_address_inet(struct sockaddr_stora= ge *sa, } =20 =20 -#ifndef WIN32 static SocketAddress * socket_sockaddr_to_address_unix(struct sockaddr_storage *sa, socklen_t salen, @@ -1362,7 +1340,6 @@ 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 */ =20 #ifdef CONFIG_AF_VSOCK static SocketAddress * @@ -1394,10 +1371,8 @@ socket_sockaddr_to_address(struct sockaddr_storage *= sa, case AF_INET6: return socket_sockaddr_to_address_inet(sa, salen, errp); =20 -#ifndef WIN32 case AF_UNIX: return socket_sockaddr_to_address_unix(sa, salen, errp); -#endif /* WIN32 */ =20 #ifdef CONFIG_AF_VSOCK case AF_VSOCK: --=20 2.37.2 From nobody Mon Feb 9 19:09:10 2026 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1662125021; cv=none; d=zohomail.com; s=zohoarc; b=VAGRoDewgFfTma/o1T5xOr9uSG+737r61+0z0j9FK7TGL4tuZeazrPRWRnJyZbwhQDVaqboM8kissoqvt9vDgwoTsPpmm4PYGnAqhcgPaofNcI605b8+EaMmlTzEYID5TlmWQ63vuVkwIoKo4lCKNwwQtwV6gRuig7/nOvKCc+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662125021; 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=JeQgff18/wjt2z9nrM7eBmSQtcsPIZiDZo+RGap6TtU=; b=UIbyIGdj+PdaL5RpsQx4N6RKWzYuvGefHEiWvYpUk8Dn7YPmqCTjt9+/fIZg8dOAUAhi2jE1h2UVk5d3I8VxPa0U/zH6VJdUbzHV/hIvzijImCYZV2+gTS2ylj/nn9lhkLSvn5yi4DiL5ho2/TbAi2suDMewxzwhH9bntmBIdSQ= 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 1662125021446393.6135120950122; Fri, 2 Sep 2022 06:23:41 -0700 (PDT) Received: from localhost ([::1]:53744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oU6e3-0002Tk-WB for importer@patchew.org; Fri, 02 Sep 2022 09:23:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU6VE-0006Fh-Ch for qemu-devel@nongnu.org; Fri, 02 Sep 2022 09:14:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53473) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU6VB-0001xE-7F for qemu-devel@nongnu.org; Fri, 02 Sep 2022 09:14:30 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-UsXnDdUFPK2UBkiDeIt5_Q-1; Fri, 02 Sep 2022 09:14:25 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DEB7B101A56C; Fri, 2 Sep 2022 13:14:24 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 222381415125; Fri, 2 Sep 2022 13:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662124468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JeQgff18/wjt2z9nrM7eBmSQtcsPIZiDZo+RGap6TtU=; b=XO6JiMPGGttXMWbl5KE+Pm/pdQYDS9SaLw354EyMwcJq3qgVKAhKcCszOoIcltubI/iBSk ZpUuwjiRu49blCe3kri4RXUp3Jm8BERLwEqMKUXigJbTA28D2qLSGh15hOjtjCp3+tyfLI EGEJ5/UI9o7DzKS7/U1j02HDchZU00s= X-MC-Unique: UsXnDdUFPK2UBkiDeIt5_Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , bin.meng@windriver.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Stefan Weil , Paolo Bonzini Subject: [PULL 2/4] chardev/char-socket: Update AF_UNIX for Windows Date: Fri, 2 Sep 2022 17:14:10 +0400 Message-Id: <20220902131412.3125752-3-marcandre.lureau@redhat.com> In-Reply-To: <20220902131412.3125752-1-marcandre.lureau@redhat.com> References: <20220902131412.3125752-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 @redhat.com) X-ZM-MESSAGEID: 1662125023548100001 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 Message-Id: <20220802075200.907360-4-bmeng.cn@gmail.com> --- chardev/char-socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index dc4e218eeb..879564aa8a 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -557,12 +557,10 @@ static char *qemu_chr_compute_filename(SocketChardev = *s) const char *left =3D "", *right =3D ""; =20 switch (ss->ss_family) { -#ifndef _WIN32 case AF_UNIX: return g_strdup_printf("unix:%s%s", ((struct sockaddr_un *)(ss))->sun_path, s->is_listen ? ",server=3Don" : ""); -#endif case AF_INET6: left =3D "["; right =3D "]"; @@ -1372,10 +1370,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.37.2 From nobody Mon Feb 9 19:09:10 2026 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1662125692; cv=none; d=zohomail.com; s=zohoarc; b=OYUmbi7UGgZdsBfBYQxtzmsKjWui4Ww2L2wC2CmXODNq8zuJXEDQIl4u0Uq5GUgwfaPSe/pgGLdKS02Q87ep3JsnAcWfdKtLtNqKXxvh7xgnayD2LE+EvZRJbIlOB16mxItsCHo2ro0ORAdoZsoARqkaPu0qWh2D5mZt90mRFLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662125692; 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=DKsQRbQJVekZAv9r8iJf3OczES+5LL6qa1RDJ5gL6Ys=; b=WWx3fRGUaAeWR/yALZ8Bp0NUqxqRuDnmIB/5N7XQBKjQOV6TvfZtVZTyDGLkoxU8/u+NQ+gIbGejeHdjbofNpXJ9Fo+IjPeLIRZ+TUGW8CEw5vfi+kcep2eamqutrS/qMhgYifrvX5EBQAwiYDe0RwmSEHspN+LlRD4aHfo4ivM= 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 1662125692804993.5407918988412; Fri, 2 Sep 2022 06:34:52 -0700 (PDT) Received: from localhost ([::1]:54922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oU6os-0000nN-Lx for importer@patchew.org; Fri, 02 Sep 2022 09:34:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU6VG-0006P1-Tx for qemu-devel@nongnu.org; Fri, 02 Sep 2022 09:14:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37782) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU6VF-0001xs-5s for qemu-devel@nongnu.org; Fri, 02 Sep 2022 09:14:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-FLQTqvp7OHq0pqW9O8Wvyg-1; Fri, 02 Sep 2022 09:14:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0DFF92A2AD74; Fri, 2 Sep 2022 13:14:29 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D151121314; Fri, 2 Sep 2022 13:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662124472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DKsQRbQJVekZAv9r8iJf3OczES+5LL6qa1RDJ5gL6Ys=; b=DJGpgXaKBoYhtOg1Qsy21XnNatkD+jlmE0lRCjnlQFbD1P841X4xIybLkYXapMzhF7To2R KZ2owfTmoaeNcm6+G70mQtM3CHWPfg4vkUXMlQkV9k35nk+92bG5zsD0cSo4+pNj5rojie Xe0L5VPZhkPddC/3a6H9T5p29bIZ8DY= X-MC-Unique: FLQTqvp7OHq0pqW9O8Wvyg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , bin.meng@windriver.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Stefan Weil , Paolo Bonzini Subject: [PULL 3/4] tests/unit: Update test-io-channel-socket.c for Windows Date: Fri, 2 Sep 2022 17:14:11 +0400 Message-Id: <20220902131412.3125752-4-marcandre.lureau@redhat.com> In-Reply-To: <20220902131412.3125752-1-marcandre.lureau@redhat.com> References: <20220902131412.3125752-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 @redhat.com) X-ZM-MESSAGEID: 1662125695019100001 From: Bin Meng Change to dynamically include the test cases by checking AF_UNIX availability using a new helper socket_check_afunix_support(). With such changes testing on a Windows host can be covered as well. Signed-off-by: Bin Meng Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20220802075200.907360-5-bmeng.cn@gmail.com> --- tests/unit/socket-helpers.h | 9 +++++++ tests/unit/socket-helpers.c | 16 +++++++++++++ tests/unit/test-io-channel-socket.c | 37 ++++++++++++++++++----------- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/tests/unit/socket-helpers.h b/tests/unit/socket-helpers.h index 512a004811..ed8477ceb3 100644 --- a/tests/unit/socket-helpers.h +++ b/tests/unit/socket-helpers.h @@ -32,4 +32,13 @@ */ int socket_check_protocol_support(bool *has_ipv4, bool *has_ipv6); =20 +/* + * @has_afunix: set to true on return if unix socket support is available + * + * Check whether unix domain socket support is available for use. + * On success, @has_afunix will be set to indicate whether AF_UNIX protocol + * is available. + */ +void socket_check_afunix_support(bool *has_afunix); + #endif diff --git a/tests/unit/socket-helpers.c b/tests/unit/socket-helpers.c index 5af4de513b..eecadf3a3c 100644 --- a/tests/unit/socket-helpers.c +++ b/tests/unit/socket-helpers.c @@ -154,3 +154,19 @@ int socket_check_protocol_support(bool *has_ipv4, bool= *has_ipv6) =20 return 0; } + +void socket_check_afunix_support(bool *has_afunix) +{ + int fd; + + fd =3D socket(PF_UNIX, SOCK_STREAM, 0); + closesocket(fd); + +#ifdef _WIN32 + *has_afunix =3D (fd !=3D (int)INVALID_SOCKET); +#else + *has_afunix =3D (fd >=3D 0); +#endif + + return; +} diff --git a/tests/unit/test-io-channel-socket.c b/tests/unit/test-io-chann= el-socket.c index 6713886d02..b36a5d972a 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,6 @@ static void test_io_channel_ipv6_async(void) } =20 =20 -#ifndef _WIN32 static void test_io_channel_unix(bool async) { SocketAddress *listen_addr =3D g_new0(SocketAddress, 1); @@ -398,6 +405,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 +499,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) { @@ -522,9 +531,6 @@ static void test_io_channel_unix_listen_cleanup(void) unlink(TEST_SOCKET); } =20 -#endif /* _WIN32 */ - - static void test_io_channel_ipv4_fd(void) { QIOChannel *ioc; @@ -555,7 +561,7 @@ static void test_io_channel_ipv4_fd(void) =20 int main(int argc, char **argv) { - bool has_ipv4, has_ipv6; + bool has_ipv4, has_ipv6, has_afunix; =20 module_call_init(MODULE_INIT_QOM); qemu_init_main_loop(&error_abort); @@ -588,16 +594,19 @@ int main(int argc, char **argv) test_io_channel_ipv6_async); } =20 + socket_check_afunix_support(&has_afunix); + if (has_afunix) { + 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-sync", - test_io_channel_unix_sync); - g_test_add_func("/io/channel/socket/unix-async", - test_io_channel_unix_async); - g_test_add_func("/io/channel/socket/unix-fd-pass", - test_io_channel_unix_fd_pass); - g_test_add_func("/io/channel/socket/unix-listen-cleanup", - test_io_channel_unix_listen_cleanup); -#endif /* _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); + } =20 end: return g_test_run(); --=20 2.37.2 From nobody Mon Feb 9 19:09:10 2026 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1662124792; cv=none; d=zohomail.com; s=zohoarc; b=FvefrMwUm98lGNCcJJ/qjazIfC1wqTWeDQbbSe6gW7i6vqHXwZwQCaLl51jMYMZS/By19HnEZOQgevG95y6an0dJ21ZP5FWdTgQCCF3cG4bD5W9BJpdG+ndW5RNuQx6fVv1QAzQlHOMezpLWHND7nEkFQK+YHsB3chi8J6QbnH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662124792; 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=8QFjtBZt0DPnJQiiGJpxsGG8YEYGBM+M+39eZCCzJyU=; b=LmEz0BciAYWpBBv2fPVdExx8f40c4IAB01jpSA2nHTDMGYh9nTsPIv3+hvnPssTBqrMq5bq4kMpjqcUPCldMYGFTzNhSHT4l8SqHWUkt8LdgZTwJnMrBNYvinMg2wCIX0C4sGv0pQ9cGbmlB2SmakyI7YXDCWObvdwkP+s9EOkE= 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 1662124792012292.32542357731256; Fri, 2 Sep 2022 06:19:52 -0700 (PDT) Received: from localhost ([::1]:47970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oU6aK-0000m2-5a for importer@patchew.org; Fri, 02 Sep 2022 09:19:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU6VK-0006Uh-4E for qemu-devel@nongnu.org; Fri, 02 Sep 2022 09:14:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU6VI-0001yt-F3 for qemu-devel@nongnu.org; Fri, 02 Sep 2022 09:14:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-77-rwMFiuyBMkui6QgKSRsZWQ-1; Fri, 02 Sep 2022 09:14:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 65A5485A58B; Fri, 2 Sep 2022 13:14:33 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E5462026D4C; Fri, 2 Sep 2022 13:14:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662124475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8QFjtBZt0DPnJQiiGJpxsGG8YEYGBM+M+39eZCCzJyU=; b=YRNT7dDb8+RSga5WJqB3llt5ngWjpOnquZHvQ1a9HdxzPDPVVW0mAeG6jX+eqsbDdjW9FM nzHg7Rwu9gbxq2CiWZ/wNc5J5hoYHhwXIOCMPPK3461PwkssR+hPBQBNdLLbO48j30lCwQ uEjOkd/jvhRnXhf0Glp0aYGZlnELJrg= X-MC-Unique: rwMFiuyBMkui6QgKSRsZWQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , bin.meng@windriver.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Stefan Weil , Paolo Bonzini Subject: [PULL 4/4] audio: exit(1) if audio backend failed to be found or initialized Date: Fri, 2 Sep 2022 17:14:12 +0400 Message-Id: <20220902131412.3125752-5-marcandre.lureau@redhat.com> In-Reply-To: <20220902131412.3125752-1-marcandre.lureau@redhat.com> References: <20220902131412.3125752-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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 @redhat.com) X-ZM-MESSAGEID: 1662124793293100001 From: Marc-Andr=C3=A9 Lureau If you specify a known backend but it isn't compiled in, or failed to initialize, you get a simple warning and the "none" backend as a fallback, and QEMU runs happily: $ qemu-system-x86_64 -audiodev id=3Daudio,driver=3Ddsound audio: Unknown audio driver `dsound' audio: warning: Using timer based audio emulation ... Instead, QEMU should fail to start: $ qemu-system-x86_64 -audiodev id=3Daudio,driver=3Ddsound audio: Unknown audio driver `dsound' $ Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1983493 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Volker R=C3=BCmelin Message-Id: <20220822131021.975656-1-marcandre.lureau@redhat.com> --- audio/audio.h | 2 +- audio/audio.c | 14 +++++++++++--- softmmu/vl.c | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/audio/audio.h b/audio/audio.h index b5e17cd218..27e67079a0 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -170,7 +170,7 @@ void audio_sample_from_uint64(void *samples, int pos, =20 void audio_define(Audiodev *audio); void audio_parse_option(const char *opt); -void audio_init_audiodevs(void); +bool audio_init_audiodevs(void); void audio_legacy_help(void); =20 AudioState *audio_state_by_name(const char *name); diff --git a/audio/audio.c b/audio/audio.c index a02f3ce5c6..76b8735b44 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1743,7 +1743,6 @@ static AudioState *audio_init(Audiodev *dev, const ch= ar *name) atexit(audio_cleanup); atexit_registered =3D true; } - QTAILQ_INSERT_TAIL(&audio_states, s, list); =20 s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); =20 @@ -1769,6 +1768,10 @@ static AudioState *audio_init(Audiodev *dev, const c= har *name) } else { dolog ("Unknown audio driver `%s'\n", drvname); } + if (!done) { + free_audio_state(s); + return NULL; + } } else { for (i =3D 0; audio_prio_list[i]; i++) { AudiodevListEntry *e =3D audiodev_find(&head, audio_prio_list[= i]); @@ -1806,6 +1809,7 @@ static AudioState *audio_init(Audiodev *dev, const ch= ar *name) "(Audio can continue looping even after stopping the VM)\n"= ); } =20 + QTAILQ_INSERT_TAIL(&audio_states, s, list); QLIST_INIT (&s->card_head); vmstate_register (NULL, 0, &vmstate_audio, s); return s; @@ -2119,13 +2123,17 @@ void audio_define(Audiodev *dev) QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); } =20 -void audio_init_audiodevs(void) +bool audio_init_audiodevs(void) { AudiodevListEntry *e; =20 QSIMPLEQ_FOREACH(e, &audiodevs, next) { - audio_init(e->dev, NULL); + if (!audio_init(e->dev, NULL)) { + return false; + } } + + return true; } =20 audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) diff --git a/softmmu/vl.c b/softmmu/vl.c index 706bd7cff7..dea4005e47 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1885,7 +1885,9 @@ static void qemu_create_early_backends(void) * setting machine properties, so they can be referred to. */ configure_blockdev(&bdo_queue, machine_class, snapshot); - audio_init_audiodevs(); + if (!audio_init_audiodevs()) { + exit(1); + } } =20 =20 --=20 2.37.2