From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678105733; cv=none; d=zohomail.com; s=zohoarc; b=Fn9SdkhWf2HXHHl1FNULvQrIKwLD8QeZbsoEsCJL23f3QIyEbyH7Ii7i8UnjhrSazkmM1GmWknXV7aWq4zrfdD1C/L8Qus8JuCXUHDV0JFXiACzjQF5naszqVGMBdXx3wL65ycplpCjKiJD4zwkoyneVkcpdRIEneLgLE4+nL0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678105733; 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=uqYBYs4LdN6dBmFrEMhPGILJQ9TcsjWyR4NjanviF5M=; b=hof5cYhpDBBTnpXxhKnlVujjAyBOJCOQmDnEjbsUR/oQXiu3Wr+7Bfl7XnQJxAkUtuGMd5kX9MUtvqhOm3RPHa/JpE7/q9pR5slVJcMlHJdSy3kLhk/+wniiJqPOKWHRvcLAgOfwZ/SF1G0tRn+Z4ereVie1HlQpNtqpHTltBKM= 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+importer2=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 1678105733807796.8505198329026; Mon, 6 Mar 2023 04:28:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9wo-0007QS-LK; Mon, 06 Mar 2023 07:28:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9wk-0007Px-JW for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9wi-0003EG-SX for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:06 -0500 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-568-YrJRzMISN5aOOBcV8KiwBw-1; Mon, 06 Mar 2023 07:27:59 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38EC0802D38; Mon, 6 Mar 2023 12:27:59 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 067702166B26; Mon, 6 Mar 2023 12:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105684; 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=uqYBYs4LdN6dBmFrEMhPGILJQ9TcsjWyR4NjanviF5M=; b=XvG2Oa5QbdUMz7W8XW9SYOCbBpPhInXNJryQmu66wPwutuhJBO+lDID/4PSxFL+OliJot9 x//eoOLuO4w51n8Ax1UEjzfwH+sdp11aK8lY+oPU7KDogm2H7BMPqVCQl+50GYHFoZLqJv Cr0wXGacqvLh47yX+lS3V843CDaYbLs= X-MC-Unique: YrJRzMISN5aOOBcV8KiwBw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 01/11] tests: fix path separator, use g_build_filename() Date: Mon, 6 Mar 2023 16:27:41 +0400 Message-Id: <20230306122751.2355515-2-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 on 10.11.54.6 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+importer2=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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678105735347100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- tests/unit/test-io-channel-command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test-io-channel-command.c b/tests/unit/test-io-chan= nel-command.c index c6e66a8c33..4f022617df 100644 --- a/tests/unit/test-io-channel-command.c +++ b/tests/unit/test-io-channel-command.c @@ -35,7 +35,7 @@ static char *socat =3D NULL; static void test_io_channel_command_fifo(bool async) { g_autofree gchar *tmpdir =3D g_dir_make_tmp("qemu-test-io-channel.XXXX= XX", NULL); - g_autofree gchar *fifo =3D g_strdup_printf("%s/%s", tmpdir, TEST_FIFO); + g_autofree gchar *fifo =3D g_build_filename(tmpdir, TEST_FIFO, NULL); g_autofree gchar *srcargs =3D g_strdup_printf("%s - PIPE:%s,wronly", s= ocat, fifo); g_autofree gchar *dstargs =3D g_strdup_printf("%s PIPE:%s,rdonly -", s= ocat, fifo); g_auto(GStrv) srcargv =3D g_strsplit(srcargs, " ", -1); --=20 2.39.2 From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678105733; cv=none; d=zohomail.com; s=zohoarc; b=Ola6DWwjlRw2eIeZILBPOI/ProvQS2Zv5JsDcv/Sde797c00ajc3+aeoJWK7Qt0ipbqwIqcX/vRrJmmb6LXlrTNPBaW0ZyO/20Jq2VO/iBOzV532sEFUnDiwFt5bwr+eQgsvQnxjbiRPzTzsV6AHHpsdLpZMP8BqX2V2uv7WgD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678105733; 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=2XualEqgNZw0Wnsuj3XWHKjjZmni50V+ItpzW1Ciwos=; b=RcXfUjqhU5JpB4bCVG50hAiBqAtBUnOyCXQi+XEijI81+jbb7mD6gkTi5r55/PmoaCTq+c+sf1QWf/LfVmunDrvX9CMriPzRwbUlwJ3XuUMO4qcMCUEqY8lBW6M/qHwdRp+swM9cDhXgdTvbvEyA/+qgW1XUs/lpTSrA9YC9AQY= 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+importer2=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 16781057339487.968857455438865; Mon, 6 Mar 2023 04:28:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9wr-0007R7-IE; Mon, 06 Mar 2023 07:28:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9wp-0007Qg-AE for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9wn-0003FI-Os for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:11 -0500 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-614-6prPcMgiMYq0n0MN8bCYiQ-1; Mon, 06 Mar 2023 07:28:03 -0500 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 4EF31830F87; Mon, 6 Mar 2023 12:28:03 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A5EC14171C3; Mon, 6 Mar 2023 12:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105686; 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=2XualEqgNZw0Wnsuj3XWHKjjZmni50V+ItpzW1Ciwos=; b=PVXofujkVf4TQ3U19eDDNDUyZQ7lUckvgNZbdA5q9Cm6wEMSJxbqRkC1Er73oHq+9DpmU5 hA7K53nmIft0r2AGeWD8KEuhIaB53MlUvv95Lfl9Zz4w72aKb+zTvyre4EuwK8+dZT1pLn uQdAvW5bi4ZHNmOPpXj/IASvcSiVOU4= X-MC-Unique: 6prPcMgiMYq0n0MN8bCYiQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 02/11] char: do not double-close fd when failing to add client Date: Mon, 6 Mar 2023 16:27:42 +0400 Message-Id: <20230306122751.2355515-3-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 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+importer2=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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678105735352100002 From: Marc-Andr=C3=A9 Lureau The caller is already closing the fd on failure. Fixes: c3054a6e6a ("char: Factor out qmp_add_client() parts and move to cha= rdev/") Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- chardev/char.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 11eab7764c..e69390601f 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -1175,12 +1175,10 @@ bool qmp_add_client_char(int fd, bool has_skipauth,= bool skipauth, =20 if (!s) { error_setg(errp, "protocol '%s' is invalid", protocol); - close(fd); return false; } if (qemu_chr_add_client(s, fd) < 0) { error_setg(errp, "failed to add client"); - close(fd); return false; } return true; --=20 2.39.2 From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678105779727634.0674240181147; Mon, 6 Mar 2023 04:29:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9wu-0007Tk-Kp; Mon, 06 Mar 2023 07:28:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9ws-0007Rd-JZ for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9wq-0003Im-UU for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:14 -0500 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-610-gGoTo1PQN0WGi9DHxFRdYA-1; Mon, 06 Mar 2023 07:28:08 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EFAE299E741; Mon, 6 Mar 2023 12:28:08 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A72C492C3E; Mon, 6 Mar 2023 12:28:06 +0000 (UTC) X-MC-Unique: gGoTo1PQN0WGi9DHxFRdYA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 03/11] tests/docker: fix a win32 error due to portability Date: Mon, 6 Mar 2023 16:27:43 +0400 Message-Id: <20230306122751.2355515-4-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 on 10.11.54.10 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+importer2=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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1678105781511100001 From: Marc-Andr=C3=A9 Lureau docker.py is run during configure, and produces an error: No module named 'pwd'. Use a more portable and recommended alternative to lookup the user "login name". Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/docker/docker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 3a1ed7cb18..688ef62989 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -23,10 +23,10 @@ import tempfile import re import signal +import getpass from tarfile import TarFile, TarInfo from io import StringIO, BytesIO from shutil import copy, rmtree -from pwd import getpwuid from datetime import datetime, timedelta =20 =20 @@ -316,7 +316,7 @@ def build_image(self, tag, docker_dir, dockerfile, =20 if user: uid =3D os.getuid() - uname =3D getpwuid(uid).pw_name + uname =3D getpass.getuser() tmp_df.write("\n") tmp_df.write("RUN id %s 2>/dev/null || useradd -u %d -U %s" % (uname, uid, uname)) @@ -570,7 +570,7 @@ def run(self, args, argv): =20 if args.user: uid =3D os.getuid() - uname =3D getpwuid(uid).pw_name + uname =3D getpass.getuser() df.write("\n") df.write("RUN id %s 2>/dev/null || useradd -u %d -U %s" % (uname, uid, uname)) --=20 2.39.2 From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678105739; cv=none; d=zohomail.com; s=zohoarc; b=OLJGp7j+mlJZccH8t4uZ6vMNH1afWGTA5/RFqIbuB9EVpjnE8bvujExJcp5Tv+gxBcPiLjhot2SCIHwr5VRZv93OT/4AZOSFOo5gvwljm4Aju+3KnspIbxqNSxHGnad9PYqLZRRD30tebJZ1oWgNzt97kKhVYwHErT+LxG+bJaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678105739; 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=0ULK8E4KoGQ4cGDikNLsvRl5d0vZNm9xHdJjUtFzMw8=; b=R3PvK/L3rijmgHIamhS3x+H678HtXkZgRoQn//OAGCz/YXSUSamIRBTNqMHvS2yObDkjGxVHyKmZBTMUE6q5Fc6GZAvrBBr9w4KxW9EhSFq9PehrDN5NmHc9urQiCpt7wlMVPHHKT7pm9lugx9SXH/XJlQIxHT7PqweVq0sRHNA= 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+importer2=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 1678105739126732.3405889329105; Mon, 6 Mar 2023 04:28:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9x1-0007Ua-NP; Mon, 06 Mar 2023 07:28:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9ww-0007Ty-NZ for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9wu-0003KB-Mn for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:18 -0500 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-65-bIOOlE8vMs-zhRDWiEFWIA-1; Mon, 06 Mar 2023 07:28:12 -0500 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 4CA1A3C10225; Mon, 6 Mar 2023 12:28:12 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4384D1401C32; Mon, 6 Mar 2023 12:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105696; 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=0ULK8E4KoGQ4cGDikNLsvRl5d0vZNm9xHdJjUtFzMw8=; b=ilMOHPdhL5I52qihf4mbjKV0khqnS5ympf5bGEaQZmvQYhGOa5RJaHZO8LkA4APBI7IjIF 5U0Qutbl+xqQx7bm4VdbCJr+yOQuyOWhgH5pPdHohgqpZRTOxU3gUPAkJK+iQoQrTWXTf3 xA4pVdjcFJw14x7vxnLUneGRnUp3DE4= X-MC-Unique: bIOOlE8vMs-zhRDWiEFWIA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 04/11] osdep: implement qemu_socketpair() for win32 Date: Mon, 6 Mar 2023 16:27:44 +0400 Message-Id: <20230306122751.2355515-5-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 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+importer2=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: -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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678105741533100003 From: Marc-Andr=C3=A9 Lureau Manually implement a socketpair() function, using UNIX sockets and simple peer credential checking. QEMU doesn't make much use of socketpair, beside vhost-user which is not available for win32 at this point. However, I intend to use it for writing some new portable tests. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- include/qemu/sockets.h | 2 - util/oslib-win32.c | 110 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 2b0698a7c9..d935fd80da 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -15,7 +15,6 @@ int inet_aton(const char *cp, struct in_addr *ia); bool fd_is_socket(int fd); int qemu_socket(int domain, int type, int protocol); =20 -#ifndef WIN32 /** * qemu_socketpair: * @domain: specifies a communication domain, such as PF_UNIX @@ -30,7 +29,6 @@ int qemu_socket(int domain, int type, int protocol); * Return 0 on success. */ int qemu_socketpair(int domain, int type, int protocol, int sv[2]); -#endif =20 int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); /* diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 29a667ae3d..16f8a67f7e 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -310,6 +310,116 @@ bool qemu_socket_unselect(int sockfd, Error **errp) return qemu_socket_select(sockfd, NULL, 0, errp); } =20 +int qemu_socketpair(int domain, int type, int protocol, int sv[2]) +{ + struct sockaddr_un addr =3D { + 0, + }; + socklen_t socklen; + int listener =3D -1; + int client =3D -1; + int server =3D -1; + g_autofree char *path =3D NULL; + int tmpfd; + u_long arg; + int ret =3D -1; + + g_return_val_if_fail(sv !=3D NULL, -1); + + addr.sun_family =3D AF_UNIX; + socklen =3D sizeof(addr); + + tmpfd =3D g_file_open_tmp(NULL, &path, NULL); + if (tmpfd =3D=3D -1 || !path) { + errno =3D EACCES; + goto out; + } + + close(tmpfd); + + if (strlen(path) >=3D sizeof(addr.sun_path)) { + errno =3D EINVAL; + goto out; + } + + strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); + + listener =3D socket(domain, type, protocol); + if (listener =3D=3D -1) { + goto out; + } + + if (DeleteFile(path) =3D=3D 0 && GetLastError() !=3D ERROR_FILE_NOT_FO= UND) { + errno =3D EACCES; + goto out; + } + g_clear_pointer(&path, g_free); + + if (bind(listener, (struct sockaddr *)&addr, socklen) =3D=3D -1) { + goto out; + } + + if (listen(listener, 1) =3D=3D -1) { + goto out; + } + + client =3D socket(domain, type, protocol); + if (client =3D=3D -1) { + goto out; + } + + arg =3D 1; + if (ioctlsocket(client, FIONBIO, &arg) !=3D NO_ERROR) { + goto out; + } + + if (connect(client, (struct sockaddr *)&addr, socklen) =3D=3D -1 && + WSAGetLastError() !=3D WSAEWOULDBLOCK) { + goto out; + } + + server =3D accept(listener, NULL, NULL); + if (server =3D=3D -1) { + goto out; + } + + arg =3D 0; + if (ioctlsocket(client, FIONBIO, &arg) !=3D NO_ERROR) { + goto out; + } + + arg =3D 0; + if (ioctlsocket(client, SIO_AF_UNIX_GETPEERPID, &arg) !=3D NO_ERROR) { + goto out; + } + + if (arg !=3D GetCurrentProcessId()) { + errno =3D EPERM; + goto out; + } + + sv[0] =3D server; + server =3D -1; + sv[1] =3D client; + client =3D -1; + ret =3D 0; + +out: + if (listener !=3D -1) { + close(listener); + } + if (client !=3D -1) { + close(client); + } + if (server !=3D -1) { + close(server); + } + if (path) { + DeleteFile(path); + } + return ret; +} + #undef connect int qemu_connect_wrap(int sockfd, const struct sockaddr *addr, socklen_t addrlen) --=20 2.39.2 From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678105954; cv=none; d=zohomail.com; s=zohoarc; b=VlOfc1TROgiAKmlxZJ8nC/Kj/PzXziBMzpgvWY5LZG+9gIBEiEFUWG41NgJX7c+E+1x64eqf9Y40HNe/ptA0vIEi0vZSFix0p/jSeWzKostlkYZQ4qKRNTK1OwDc8lr8g7iQI4a1rlPUkvsdTbEuT2duGmQDNrGReJPgWfk4Ba8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678105954; 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=6oDzcu4rXp5BFuBHDHS9KJ/mY0E9Rd//C9mzFx6+PD0=; b=WLaPZBFFH0tQbg++PtCfEQRU7j0ri1a22mY4rDSC19KA+8yarD0ZK31W/C+MlqEMalKW1AuAC0ltENiox7O7B5GrEj3WLiScRbUQrTMpkfnUqRJWopxUzwHhjh9BnZZg6lcAzdB76fts/wq/11bDgcdBQTLrUxj+OTLjZ0m5JCI= 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+importer2=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 1678105954227490.5413776884383; Mon, 6 Mar 2023 04:32:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9x4-0007VR-1k; Mon, 06 Mar 2023 07:28:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9x2-0007Uf-2E for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9x0-0003Kn-Fo for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:23 -0500 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-443-b3vBMfoFPL-59KB3xLiemQ-1; Mon, 06 Mar 2023 07:28:17 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C039B830F84; Mon, 6 Mar 2023 12:28:16 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96D54175AD; Mon, 6 Mar 2023 12:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105700; 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=6oDzcu4rXp5BFuBHDHS9KJ/mY0E9Rd//C9mzFx6+PD0=; b=AHaDPddQaEhNvC4vtNqB31WYdODpBFJ1t6GgHL8vkQ4LEIymxMuFOiye96iBo0PfQnt+Lp B5X5bk/ldXhNCJRA6X5AAY+7IiHxL9L9TEXFV44euq750tuxL7UbOFjaCFRT7w28nkrGq/ g5XTKEu/orTMZU5bKcOhfq1Pikb237o= X-MC-Unique: b3vBMfoFPL-59KB3xLiemQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 05/11] qmp: 'add_client' actually expects sockets Date: Mon, 6 Mar 2023 16:27:45 +0400 Message-Id: <20230306122751.2355515-6-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 on 10.11.54.5 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+importer2=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: -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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678105955171100001 From: Marc-Andr=C3=A9 Lureau Whether it is SPICE, VNC, D-Bus, or the socket chardev, they all actually expect a socket kind or will fail in different ways at runtime. Throw an error early if the given 'add_client' fd is not a socket, and close it to avoid leaks. This allows to replace the close() call with a more correct & portable closesocket() version. (this will allow importing sockets on Windows with a specialized command in the following patch, while keeping the remaining monitor associated sockets/add_client code & usage untouched) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Markus Armbruster --- qapi/misc.json | 3 +++ monitor/qmp-cmds.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/qapi/misc.json b/qapi/misc.json index 27ef5a2b20..f0217cfba0 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -14,6 +14,9 @@ # Allow client connections for VNC, Spice and socket based # character devices to be passed in to QEMU via SCM_RIGHTS. # +# If the FD associated with @fdname is not a socket, the command will fail= and +# the FD will be closed. +# # @protocol: protocol name. Valid names are "vnc", "spice", "@dbus-display= " or # the name of a character device (eg. from -chardev id=3DXXXX) # diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 859012aef4..9f7751beeb 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -14,6 +14,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/sockets.h" #include "monitor-internal.h" #include "monitor/qdev.h" #include "monitor/qmp-helpers.h" @@ -139,6 +140,12 @@ void qmp_add_client(const char *protocol, const char *= fdname, return; } =20 + if (!fd_is_socket(fd)) { + error_setg(errp, "add_client expects a socket"); + close(fd); + return; + } + for (i =3D 0; i < ARRAY_SIZE(protocol_table); i++) { if (!strcmp(protocol, protocol_table[i].name)) { if (!protocol_table[i].add_client(fd, has_skipauth, skipauth, --=20 2.39.2 From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678105763; cv=none; d=zohomail.com; s=zohoarc; b=VFsYu8yTDd4EqvENdP37CxBrAzXHVKj15a2FQSFYm/uMw0mVNg04heCoVrfGrlY0G2s3sz4viBtpage7sN1aV1pu0YqvB+5DVkfRlB0kcfbhnqOmRHDQUZiRTVcBPvw6SgjTnWJIU4F+O3ScgX38Zq0nk2yjXGsGJnKGo+hxuWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678105763; 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=xTm8ubhtiWH/BhSjPXGZ796rUO6Hs5QQEafZA9VVO60=; b=dkTABeer1no8Rkt59PVuwqGKKhTHYA641H79CPxzyKPHUglhgih6lIcYaG1FtEl6SId0AfVJDxscy6vR3waVNiUE6zttgrGIs6noy+mI90KyK7QHCG4fgSZaP8G9LARia8WQXw+slzrAJfd25VTckS0ia6HlSUUnO02f1lRK1Ik= 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+importer2=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 1678105763149670.0520957438366; Mon, 6 Mar 2023 04:29:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9x8-0007WF-2A; Mon, 06 Mar 2023 07:28:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9x4-0007Vl-P4 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9x3-0003L4-6M for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:26 -0500 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-356-UHUvcAxjMmCyjNX2jDzSBA-1; Mon, 06 Mar 2023 07:28:21 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22B6F3811F25; Mon, 6 Mar 2023 12:28:21 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CB9640C10FA; Mon, 6 Mar 2023 12:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105704; 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=xTm8ubhtiWH/BhSjPXGZ796rUO6Hs5QQEafZA9VVO60=; b=f7TFiutBMIWeA3aXy8IHJ7oAihFpS43zYtY9l34mZKXmjPeQTH6Bx+UzqFXko+RxasQAlu qlaXBTrqthOU+yakISXdvDb9uyuahIPc74R2UPcsIIDcMOKELoL0GAuVYW+FGpdBiaHMEq KFEvN0ZFQj5kITfdM6raYRhm1YrfSwY= X-MC-Unique: UHUvcAxjMmCyjNX2jDzSBA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 06/11] monitor: release the lock before calling close() Date: Mon, 6 Mar 2023 16:27:46 +0400 Message-Id: <20230306122751.2355515-7-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 on 10.11.54.2 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+importer2=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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678105763427100001 From: Marc-Andr=C3=A9 Lureau As per comment, presumably to avoid syscall in critical section. Fixes: 0210c3b39bef08 ("monitor: Use LOCK_GUARD macros") Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- monitor/fds.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monitor/fds.c b/monitor/fds.c index 26b39a0ce6..7daf1064e1 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -80,7 +80,8 @@ void qmp_getfd(const char *fdname, Error **errp) return; } =20 - QEMU_LOCK_GUARD(&cur_mon->mon_lock); + /* See close() call below. */ + qemu_mutex_lock(&cur_mon->mon_lock); QLIST_FOREACH(monfd, &cur_mon->fds, next) { if (strcmp(monfd->name, fdname) !=3D 0) { continue; @@ -88,6 +89,7 @@ void qmp_getfd(const char *fdname, Error **errp) =20 tmp_fd =3D monfd->fd; monfd->fd =3D fd; + qemu_mutex_unlock(&cur_mon->mon_lock); /* Make sure close() is outside critical section */ close(tmp_fd); return; @@ -98,6 +100,7 @@ void qmp_getfd(const char *fdname, Error **errp) monfd->fd =3D fd; =20 QLIST_INSERT_HEAD(&cur_mon->fds, monfd, next); + qemu_mutex_unlock(&cur_mon->mon_lock); } =20 void qmp_closefd(const char *fdname, Error **errp) --=20 2.39.2 From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678106026; cv=none; d=zohomail.com; s=zohoarc; b=DXmzVuk2kKKFJ34X0yYhq6MUBgBXNx4aJEBXrQW3fjyZBJONIpjwBWPLf4uY+rnId6Kmu1poVxsr/DM/iLFikDnTyamISFJRRD8iH/dmvWc1gHhZsPZ/9Ac0P3TIe57yUX6kPIAJZDTQ/qhKS6LamK83uF5hDpjKyqYwC0mwP+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678106026; 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=bu0nSiCU+C/5t2FSu0ntDv4BlvxCta95wWhADz5BY5k=; b=NzXAZTJla5JAK/3WVrLdkc5pUILj5jXw61uxN971+ju6arQkwPD/AP1WYovWSIAg/ZRElzmDux7TfAX6Auy5v4pVGa2/pVzVHZ7HoHESojoRxpQSc9zlxzE55vm5HaquvDZmAAjwhDnB6gehMQ7iig48JGTX/XE+iVoJPNEP0oE= 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+importer2=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 1678106026620475.42911023239617; Mon, 6 Mar 2023 04:33:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9y4-0008NA-Mw; Mon, 06 Mar 2023 07:29:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xR-0007em-Eb for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xP-0003Lr-8v for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:49 -0500 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-591-hXOhZz99OHi_qz8bOu_QBQ-1; Mon, 06 Mar 2023 07:28:39 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE0E71C04325; Mon, 6 Mar 2023 12:28:30 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1736940C83B6; Mon, 6 Mar 2023 12:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105726; 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=bu0nSiCU+C/5t2FSu0ntDv4BlvxCta95wWhADz5BY5k=; b=eOROC2bRuutca29AbTERF4k78qc2N6pYBtljbNoA1OA2EiovXxCMBf88quvKRzxOIML7uo HYyQ5VMGsEcoLEm3doegq9AkGjBcTaaAoCwnce8IzZVtC16wmTlcyNY3ht47Bvv5pN5m0D 9afouVnIFhJa8qAW0oQZSxPAP1+nvBA= X-MC-Unique: hXOhZz99OHi_qz8bOu_QBQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 07/11] qapi/gen: run C code through clang-format, if possible Date: Mon, 6 Mar 2023 16:27:47 +0400 Message-Id: <20230306122751.2355515-8-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 on 10.11.54.1 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+importer2=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: -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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678106027631100005 From: Marc-Andr=C3=A9 Lureau Make the resulting code even prettier, if possible. Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/gen.py | 15 ++++++++++++++- scripts/qapi/introspect.py | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index b5a8d03e8e..c0ec9aa412 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -14,6 +14,7 @@ from contextlib import contextmanager import os import re +import subprocess from typing import ( Dict, Iterator, @@ -133,6 +134,7 @@ def build_params(arg_type: Optional[QAPISchemaObjectTyp= e], class QAPIGenCCode(QAPIGen): def __init__(self, fname: str): super().__init__(fname) + self.skip_format: bool =3D False self._start_if: Optional[Tuple[QAPISchemaIfCond, str, str]] =3D No= ne =20 def start_if(self, ifcond: QAPISchemaIfCond) -> None: @@ -149,7 +151,18 @@ def end_if(self) -> None: =20 def get_content(self) -> str: assert self._start_if is None - return super().get_content() + + text =3D super().get_content() + if not self.skip_format: + try: + text =3D subprocess.run(["clang-format"], + input=3Dtext, + text=3DTrue, + capture_output=3DTrue, + check=3DTrue).stdout + except FileNotFoundError: + pass + return text =20 =20 class QAPIGenC(QAPIGenCCode): diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 67c7d89aae..1a8cac37ef 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -174,6 +174,8 @@ def __init__(self, prefix: str, unmask: bool): super().__init__( prefix, 'qapi-introspect', ' * QAPI/QMP schema introspection', __doc__) + # for some reasons, the generated code is making clang-format go c= razy + self._genc.skip_format =3D True self._unmask =3D unmask self._schema: Optional[QAPISchema] =3D None self._trees: List[Annotated[SchemaInfo]] =3D [] --=20 2.39.2 From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678105996; cv=none; d=zohomail.com; s=zohoarc; b=PK63MBgglKayawjCZFPW0JrIn3tu3R9Hei/87m0Nha1ypv/6saPWFDGV4lZbXa0ll8MzbAmo8DoJztYW6nKo20wKSi/Y6KxxelFaxlNdU0l1oHKuQayTnOQoGAsB7xGlnUgjGb98gCG5kKtWwnMamaf6cgIPnvzsqs3n+tTxC4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678105996; 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=yImVHftO0FYzvgWDZfWuLhBoX9BrfgamfaSJVjQt9As=; b=E5ORl7e5EVz/cJBbxC7MLoHh19JWOPh+hgzyeMd69mEsannxLUeL+N3JHtuJngrdosIAxQkHkQvsT+ywIvDdLR01R3RNM7KczDJiWrdMrxbVCMdTvJeuiQvvmER/Gi4rbOqNpR648r0yDHz3k6OgsOpEaD2cbQji2PkoynB0Grw= 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+importer2=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 1678105996039348.60109341668885; Mon, 6 Mar 2023 04:33:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9yN-00008R-Ld; Mon, 06 Mar 2023 07:29:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xV-0007iw-F6 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xR-0003MQ-G5 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:51 -0500 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-410-8hkUvf_eOpOYPE0jSp-ong-1; Mon, 06 Mar 2023 07:28:42 -0500 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 935D8857A84; Mon, 6 Mar 2023 12:28:35 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B4EA2026D4B; Mon, 6 Mar 2023 12:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105728; 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=yImVHftO0FYzvgWDZfWuLhBoX9BrfgamfaSJVjQt9As=; b=A35hNYD4cKHBVdUfZhMbRAHW1mSTm4m+QRCzbkNL79/Qc2BpPCVG8ZN6yRMyWyuoBxUAy7 Xr/AUnj62KHMTt5boWxKfoWTykTqYq0oS2lcvUfEnR8xF9zExh+g94HSmSpz6AuGtWANjG JvrnEkoGQdJNHKXrNzPPL41idy6FtGQ= X-MC-Unique: 8hkUvf_eOpOYPE0jSp-ong-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 08/11] qmp: add 'get-win32-socket' Date: Mon, 6 Mar 2023 16:27:48 +0400 Message-Id: <20230306122751.2355515-9-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 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+importer2=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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678105997479100007 From: Marc-Andr=C3=A9 Lureau A process with enough capabilities can duplicate a socket to QEMU. Add a QMP command to import it and add it to the monitor fd list, so it can be later used by other commands. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Markus Armbruster --- qapi/misc.json | 30 ++++++++++++++++++++ monitor/fds.c | 76 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 90 insertions(+), 16 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index f0217cfba0..031c94050c 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -275,6 +275,36 @@ ## { 'command': 'getfd', 'data': {'fdname': 'str'} } =20 +## +# @get-win32-socket: +# +# Add a socket that was duplicated to QEMU process with WSADuplicateSocket= W() +# via WSASocket() & WSAPROTOCOL_INFOW structure and assign it a name (the = SOCKET +# is associated with a CRT file descriptor) +# +# @info: the WSAPROTOCOL_INFOW structure (encoded in base64) +# +# @fdname: file descriptor name +# +# Returns: Nothing on success +# +# Since: 8.0 +# +# Notes: If @fdname already exists, the file descriptor assigned to +# it will be closed and replaced by the received file +# descriptor. +# +# The 'closefd' command can be used to explicitly close the +# file descriptor when it is no longer needed. +# +# Example: +# +# -> { "execute": "get-win32-socket", "arguments": { "info": "abcd123..", = fdname": "skclient" } } +# <- { "return": {} } +# +## +{ 'command': 'get-win32-socket', 'data': {'info': 'str', 'fdname': 'str'},= 'if': 'CONFIG_WIN32' } + ## # @closefd: # diff --git a/monitor/fds.c b/monitor/fds.c index 7daf1064e1..9ed4197358 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -61,46 +61,55 @@ struct MonFdset { static QemuMutex mon_fdsets_lock; static QLIST_HEAD(, MonFdset) mon_fdsets; =20 -void qmp_getfd(const char *fdname, Error **errp) +static bool monitor_add_fd(Monitor *mon, int fd, const char *fdname, Error= **errp) { - Monitor *cur_mon =3D monitor_cur(); mon_fd_t *monfd; - int fd, tmp_fd; - - fd =3D qemu_chr_fe_get_msgfd(&cur_mon->chr); - if (fd =3D=3D -1) { - error_setg(errp, "No file descriptor supplied via SCM_RIGHTS"); - return; - } =20 if (qemu_isdigit(fdname[0])) { close(fd); error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "fdname", "a name not starting with a digit"); - return; + return false; } =20 /* See close() call below. */ - qemu_mutex_lock(&cur_mon->mon_lock); - QLIST_FOREACH(monfd, &cur_mon->fds, next) { + qemu_mutex_lock(&mon->mon_lock); + QLIST_FOREACH(monfd, &mon->fds, next) { + int tmp_fd; + if (strcmp(monfd->name, fdname) !=3D 0) { continue; } =20 tmp_fd =3D monfd->fd; monfd->fd =3D fd; - qemu_mutex_unlock(&cur_mon->mon_lock); + qemu_mutex_unlock(&mon->mon_lock); /* Make sure close() is outside critical section */ close(tmp_fd); - return; + return true; } =20 monfd =3D g_new0(mon_fd_t, 1); monfd->name =3D g_strdup(fdname); monfd->fd =3D fd; =20 - QLIST_INSERT_HEAD(&cur_mon->fds, monfd, next); - qemu_mutex_unlock(&cur_mon->mon_lock); + QLIST_INSERT_HEAD(&mon->fds, monfd, next); + qemu_mutex_unlock(&mon->mon_lock); + return true; +} + +void qmp_getfd(const char *fdname, Error **errp) +{ + Monitor *cur_mon =3D monitor_cur(); + int fd; + + fd =3D qemu_chr_fe_get_msgfd(&cur_mon->chr); + if (fd =3D=3D -1) { + error_setg(errp, "No file descriptor supplied via SCM_RIGHTS"); + return; + } + + monitor_add_fd(cur_mon, fd, fdname, errp); } =20 void qmp_closefd(const char *fdname, Error **errp) @@ -214,6 +223,41 @@ error: return NULL; } =20 +#ifdef WIN32 +void qmp_get_win32_socket(const char *infos, const char *fdname, Error **e= rrp) +{ + g_autofree WSAPROTOCOL_INFOW *info =3D NULL; + gsize len; + SOCKET sk; + int fd; + + info =3D (void *)g_base64_decode(infos, &len); + if (len !=3D sizeof(*info)) { + error_setg(errp, "Invalid WSAPROTOCOL_INFOW value"); + return; + } + + sk =3D WSASocketW(FROM_PROTOCOL_INFO, + FROM_PROTOCOL_INFO, + FROM_PROTOCOL_INFO, + info, 0, 0); + if (sk =3D=3D INVALID_SOCKET) { + error_setg_win32(errp, WSAGetLastError(), "Couldn't import socket"= ); + return; + } + + fd =3D _open_osfhandle(sk, _O_BINARY); + if (fd < 0) { + error_setg_errno(errp, errno, "Failed to associate a FD with the S= OCKET"); + closesocket(sk); + return; + } + + monitor_add_fd(monitor_cur(), fd, fdname, errp); +} +#endif + + void qmp_remove_fd(int64_t fdset_id, bool has_fd, int64_t fd, Error **errp) { MonFdset *mon_fdset; --=20 2.39.2 From nobody Sat May 4 21:35:12 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678105944; cv=none; d=zohomail.com; s=zohoarc; b=G6EP99TLQa2RUoN2J7JHh/8THtC+SNmnYUasabVmBDGBJXXE/wJUR0bDUsEq4pA6Q+EH72ZGqpky+3NTL6cBTQ2OeXlaxmH+QJlgKbB2H9f/856zrdpKig2qRNYa6SMohkIHvxGwceTjrOitKp8nfq7m9TLG8wWaNBhHNloBvNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678105944; 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=1HysE1kuWalsk4w3ERzspWxPnNfDVt/BKA0/9TjwlkE=; b=JPxwjqTZQcMj9n0B7Uiwg14WU7nTYbcM9zEz8TKbdqrBE9y4HDloAET5Z+gb9GoWNg7H5SgTUJSI7OfSTEmOaZ58xyyIDW+fVeuctpNYPAwO995IgSopupfs3KTpq2E+BrBfDGAQgEjIPLmZpOKAdPzFXo5EF3uzBY7vNXWfDhQ= 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+importer2=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 1678105944039366.4436585486151; Mon, 6 Mar 2023 04:32:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9xd-0007r1-Rh; Mon, 06 Mar 2023 07:29:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xP-0007bV-Fo for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xK-0003Ln-9L for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:46 -0500 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-224-1lmAyobrNaSqtp7sr4Ec6g-1; Mon, 06 Mar 2023 07:28:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1487A800B23; Mon, 6 Mar 2023 12:28:40 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09D1D2166B26; Mon, 6 Mar 2023 12:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105721; 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=1HysE1kuWalsk4w3ERzspWxPnNfDVt/BKA0/9TjwlkE=; b=UU3LGvY4A1BIXR5v7A9KuuEf5ff1GMz8GEWbCFkrNHT3nkUBjjqpaD8spTi1j/xLffLFq/ Q4Dd5l6yjD94pJ49tBjDIPOPjfZ9IeK2Vnl9VUfVp3ezpuvNPIzkxASEeepo/a/2U4PlEB QMImF29bB8RvuP6AqSxltzq9nq0GIkA= X-MC-Unique: 1lmAyobrNaSqtp7sr4Ec6g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 09/11] libqtest: make qtest_qmp_add_client work on win32 Date: Mon, 6 Mar 2023 16:27:49 +0400 Message-Id: <20230306122751.2355515-10-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 on 10.11.54.6 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+importer2=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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678105945228100003 From: Marc-Andr=C3=A9 Lureau Use the "get-win32-socket" function to pass an opened socket to QEMU, instead of using "getfd", which relies on socket ancillary FD message passing. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/qtest/libqtest.h | 5 ++--- tests/qtest/libqtest.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index fcf1c3c3b3..8d7d450963 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -758,17 +758,16 @@ void qtest_qmp_device_add_qdict(QTestState *qts, cons= t char *drv, void qtest_qmp_device_add(QTestState *qts, const char *driver, const char = *id, const char *fmt, ...) G_GNUC_PRINTF(4, 5); =20 -#ifndef _WIN32 /** * qtest_qmp_add_client: * @qts: QTestState instance to operate on * @protocol: the protocol to add to * @fd: the client file-descriptor * - * Call QMP ``getfd`` followed by ``add_client`` with the given @fd. + * Call QMP ``getfd`` (on Windows ``get-win32-socket``) followed by + * ``add_client`` with the given @fd. */ void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd); -#endif /* _WIN32 */ =20 /** * qtest_qmp_device_del_send: diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index dee2032331..c3a0ef5bb4 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1478,13 +1478,28 @@ void qtest_qmp_device_add(QTestState *qts, const ch= ar *driver, const char *id, qobject_unref(args); } =20 -#ifndef _WIN32 void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd) { QDict *resp; =20 +#ifdef WIN32 + WSAPROTOCOL_INFOW info; + g_autofree char *info64 =3D NULL; + SOCKET s; + + assert(fd_is_socket(fd)); + s =3D _get_osfhandle(fd); + if (WSADuplicateSocketW(s, GetProcessId((HANDLE)qts->qemu_pid), &info)= =3D=3D SOCKET_ERROR) { + g_autofree char *emsg =3D g_win32_error_message(WSAGetLastError()); + g_error("WSADuplicateSocketW failed: %s", emsg); + } + info64 =3D g_base64_encode((guchar *)&info, sizeof(info)); + resp =3D qtest_qmp(qts, "{'execute': 'get-win32-socket'," + "'arguments': {'fdname': 'fdname', 'info': %s}}", inf= o64); +#else resp =3D qtest_qmp_fds(qts, &fd, 1, "{'execute': 'getfd'," "'arguments': {'fdname': 'fdname'}}"); +#endif g_assert(resp); g_assert(!qdict_haskey(resp, "event")); /* We don't expect any events = */ g_assert(!qdict_haskey(resp, "error")); @@ -1498,7 +1513,6 @@ void qtest_qmp_add_client(QTestState *qts, const char= *protocol, int fd) g_assert(!qdict_haskey(resp, "error")); qobject_unref(resp); } -#endif =20 /* * Generic hot-unplugging test via the device_del QMP command. --=20 2.39.2 From nobody Sat May 4 21:35:13 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678106026; cv=none; d=zohomail.com; s=zohoarc; b=lBgjaJkr0gVK8lv9u8V5W6pFwU6y9VnOIM3Qh2P0i5jEZVk36tND7p+SmuknxgJfp4e8PD8J/m8dxbiVOzXfZWxa3LrSVxUZqx8dlk2dE05j6fGdAN64Wy0eNBMvJjhikXBNVMTKTBHHZwABGpyK3hZIpJk3e2ks5aG+97/km2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678106026; 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=fabF+/VqGsrwYEFvCtPe+ob3Xg9pzyTYeIb5h0qbImc=; b=SK4rBeSPOHmJMzawCAkKxI7AcfDZZPHE/8Q+P3FCh44WCLeYvOoRHLzHtREruCwNkOeat/fmNKtUl+IrmVX3WdSoIEyeTAv2s5/yAdmklbjkmmx0A5zQ7gOqGtGlMyd1W6ZDbmNVInwVS0Ecp8qsDEFoC07zkJEhEGTJNiEidpo= 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+importer2=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 1678106026356341.83918418910935; Mon, 6 Mar 2023 04:33:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9ya-0000AW-0J; Mon, 06 Mar 2023 07:30:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xT-0007fA-GQ for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xR-0003MG-4p for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:50 -0500 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-623-Q7uHlBAJNayMSyhwrs_62w-1; Mon, 06 Mar 2023 07:28:44 -0500 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 46282183B3C1; Mon, 6 Mar 2023 12:28:44 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0812F1121314; Mon, 6 Mar 2023 12:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105727; 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=fabF+/VqGsrwYEFvCtPe+ob3Xg9pzyTYeIb5h0qbImc=; b=Al3IrdNhNO0z1dd1G8yXwtCbA9jMx4WgKKhJZqkp91vsbm1FR9JVdAUw+RErM2iqDuoG7q EoqLJnp3imH+1DvO7sqZxtEfwORDE4BF1khlPGic4QA4AagOZbhzRMTw4HFj73lBJVJ2O2 +13i4u2DLUsSlvfA1wiCGcwRvgTDq+g= X-MC-Unique: Q7uHlBAJNayMSyhwrs_62w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 10/11] qtest: enable vnc-display test on win32 Date: Mon, 6 Mar 2023 16:27:50 +0400 Message-Id: <20230306122751.2355515-11-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 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+importer2=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: -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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678106027655100006 From: Marc-Andr=C3=A9 Lureau Now that qtest_qmp_add_client() works on win32, we can enable the VNC test. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Thomas Huth --- tests/qtest/vnc-display-test.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/qtest/vnc-display-test.c b/tests/qtest/vnc-display-test.c index e52a4326ec..f8933b0761 100644 --- a/tests/qtest/vnc-display-test.c +++ b/tests/qtest/vnc-display-test.c @@ -19,7 +19,7 @@ typedef struct Test { GMainLoop *loop; } Test; =20 -#if !defined(WIN32) && !defined(CONFIG_DARWIN) +#if !defined(CONFIG_DARWIN) =20 static void on_vnc_error(VncConnection* self, const char* msg) @@ -38,10 +38,7 @@ static void on_vnc_auth_failure(VncConnection *self, static bool test_setup(Test *test) { -#ifdef WIN32 - g_test_skip("Not supported on Windows yet"); - return false; -#elif defined(CONFIG_DARWIN) +#if defined(CONFIG_DARWIN) g_test_skip("Broken on Darwin"); return false; #else @@ -59,7 +56,12 @@ test_setup(Test *test) g_signal_connect(test->conn, "vnc-auth-failure", G_CALLBACK(on_vnc_auth_failure), NULL); vnc_connection_set_auth_type(test->conn, VNC_CONNECTION_AUTH_NONE); + +#ifdef WIN32 + vnc_connection_open_fd(test->conn, _get_osfhandle(pair[0])); +#else vnc_connection_open_fd(test->conn, pair[0]); +#endif =20 test->loop =3D g_main_loop_new(NULL, FALSE); return true; --=20 2.39.2 From nobody Sat May 4 21:35:13 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678105993; cv=none; d=zohomail.com; s=zohoarc; b=BgeyLDBp5MwIXTxrqsdA5dz1sPsK0uRCcPfwfGwtrAA4flg4tiMkhOyjWObsBvpIh1kltxRdbuYLepTAZMO0E+RWHghkeMilFbVvh5NOZHp5pkyYs1W4jgz5qnmb+J6eWn85YTZRggPCgcYi3B5b96eNVt5rwWUqaLduSGCDRwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678105993; 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=hmnVpN1pnMlbwAzSetIJsAtY9mzJIDmDABMnuHCGvIo=; b=AKBgpAP4kGkSgbL2Fbla8ih225W5Af8iWYf5a0cac7fBpjSn45fmT0JovFMzzqaH9mMReTLJ/pJ90S3vWcoYlOB4S/6PGXC4gky9rm4Pg+lEdNwdZBQ2LjsJWz7k3BKZDqNJ3tHHoS5O/ykGIvXWy2R3y1+feFYQE0dbwV+/dPQ= 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+importer2=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 1678105993467962.2764233330034; Mon, 6 Mar 2023 04:33:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ9yc-0000DX-8A; Mon, 06 Mar 2023 07:30:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xX-0007m4-CN for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ9xV-0003O4-6L for qemu-devel@nongnu.org; Mon, 06 Mar 2023 07:28:54 -0500 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-502-rO_DXviIMJabsmVB_8LLjg-1; Mon, 06 Mar 2023 07:28:49 -0500 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 DAD1685CCE1; Mon, 6 Mar 2023 12:28:48 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9CAF1121314; Mon, 6 Mar 2023 12:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678105732; 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=hmnVpN1pnMlbwAzSetIJsAtY9mzJIDmDABMnuHCGvIo=; b=IOrx4ZXNvj/eLGRZNgqr3xaGX3AGKhLREPp/jkoJ9w/vns9KW2Uc5LnTOxCRyHctatfocR KrUZu+x1NgKGBSOleFrnLaSo6Vq4GGeeMcV2gsPj7QWUULFBlloRF6M90qkLZk/8UOWivv /oZ+Y+OfBUSlxmqkUh/QyBk9jk9/CVw= X-MC-Unique: rO_DXviIMJabsmVB_8LLjg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Thomas Huth , Gerd Hoffmann , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Michael Roth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Beraldo Leal , Wainer dos Santos Moschetta , Stefan Weil , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Subject: [PATCH v4 11/11] QMP/HMP: only actually implement getfd on CONFIG_POSIX Date: Mon, 6 Mar 2023 16:27:51 +0400 Message-Id: <20230306122751.2355515-12-marcandre.lureau@redhat.com> In-Reply-To: <20230306122751.2355515-1-marcandre.lureau@redhat.com> References: <20230306122751.2355515-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 3.1 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+importer2=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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678105995411100003 From: Marc-Andr=C3=A9 Lureau Currently, the function will simply fail if ancillary fds are not provided, for ex on unsupported platforms. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- qapi/misc.json | 2 +- monitor/fds.c | 2 ++ monitor/hmp-cmds.c | 2 ++ hmp-commands.hx | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index 031c94050c..96c053e305 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -273,7 +273,7 @@ # <- { "return": {} } # ## -{ 'command': 'getfd', 'data': {'fdname': 'str'} } +{ 'command': 'getfd', 'data': {'fdname': 'str'}, 'if': 'CONFIG_POSIX' } =20 ## # @get-win32-socket: diff --git a/monitor/fds.c b/monitor/fds.c index 9ed4197358..d86c2c674c 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -98,6 +98,7 @@ static bool monitor_add_fd(Monitor *mon, int fd, const ch= ar *fdname, Error **err return true; } =20 +#ifdef CONFIG_POSIX void qmp_getfd(const char *fdname, Error **errp) { Monitor *cur_mon =3D monitor_cur(); @@ -111,6 +112,7 @@ void qmp_getfd(const char *fdname, Error **errp) =20 monitor_add_fd(cur_mon, fd, fdname, errp); } +#endif =20 void qmp_closefd(const char *fdname, Error **errp) { diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 34bd8c67d7..6c559b48c8 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -192,6 +192,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } =20 +#ifdef CONFIG_POSIX void hmp_getfd(Monitor *mon, const QDict *qdict) { const char *fdname =3D qdict_get_str(qdict, "fdname"); @@ -200,6 +201,7 @@ void hmp_getfd(Monitor *mon, const QDict *qdict) qmp_getfd(fdname, &err); hmp_handle_error(mon, err); } +#endif =20 void hmp_closefd(Monitor *mon, const QDict *qdict) { diff --git a/hmp-commands.hx b/hmp-commands.hx index b87c250e23..bb85ee1d26 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1486,6 +1486,7 @@ SRST Inject an MCE on the given CPU (x86 only). ERST =20 +#ifdef CONFIG_POSIX { .name =3D "getfd", .args_type =3D "fdname:s", @@ -1501,6 +1502,7 @@ SRST mechanism on unix sockets, it is stored using the name *fdname* for later use by other monitor commands. ERST +#endif =20 { .name =3D "closefd", --=20 2.39.2