From patchwork Mon Feb 10 16:14:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 292EDC0219B for ; Mon, 10 Feb 2025 16:16:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWRs-0005Py-4N; Mon, 10 Feb 2025 11:15:52 -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 1thWR2-000487-6P for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:01 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWQy-0001UL-TR for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:14:59 -0500 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-ab795ebaa02so518914866b.1 for ; Mon, 10 Feb 2025 08:14:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204093; x=1739808893; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s+bgwk18lKdsHzokGpBgI91DaZBecMvO8llhyl5xsWo=; b=YDRaIuP6/zYmQI7dc+3k6pGxtQ+RjHPS81cJoG/oqi2KgPlOMoRHmccsv6PzZeauzK 42QgrBLVoa0Xo+IPfhcXltX3qBU+uij1S3I/H/WsUYWInT2jOE8MoJBne4kQ3tv6y9ql NI4xUukilOCzIQ7dMjcwIiBGYMbtPsfP1C3G3kRw43lg6uL4O5Ka50/YohL1GUBRByU+ dD6h6eJrGT3NeOZOYnjgyUpAJq4lY+4RbvlctLXZnqIYVCjf5zGa4Gmz/wI7dFGZ0DmO y/N7QwezSlULO/g6mxr109X6H696Reb9lYf5nnymOxPHtaPOw/GPBO9etG50u1CDa+XQ JamQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204093; x=1739808893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s+bgwk18lKdsHzokGpBgI91DaZBecMvO8llhyl5xsWo=; b=gx0+tk7iADvzlIFssrsWLG13DnWZvyPpY++XdFlD12g0DDVKyeTa2w9cwC0FvnjaEx 1NdM/bP8NDyVYLMGpQ9PREUTh/xmS0Xg2dkavGI5l+zPY+FNaOqb4c0Z6RyouWKsvT3U p5E3RBwSUjn+o8xIVP17IdTZUpITXNUh3w6AfbQDIm3WGRvJavrBvgk7qi6zkotOgv41 fjeZkERw336WFYXzLuTMec/4TGATt/tvwVRXAPAIySYCCsdypO7W+oOVrTAI4sFnSXui 5qoEBagdEFN8eTuAGppCRqMw1unx26HrkDp5GqY/SoVbcUb1Qqw7h9qxUMPZASOvNCcV xA6A== X-Gm-Message-State: AOJu0Ywhne6JuKs8TCHnu4YTUuMFgMdS9rGVafkFWU/Vt6JVOY5B+pfZ Fvd+qc4Tp6McIoV8lglcvdkPwF1ZSDMhljpKr8YNdANm44gzLnxlUVeeUFsQiS4= X-Gm-Gg: ASbGncuI6EaJaEtC0IS0QaRtpDmLIRQV3fG7fLrMEODUJ+Pjxqzn1VpyJdh53a6zpRz Qy/n8a1JVLJGZAAY+zr470wFEQZlpiEjcXMriRekrBcZ9UPLjhRpXByC60xdn4iAIxES+7H1CvI 1PsdZvqqu5owXdUfADlCcu2mPQUU3nmp4U0z1I3fl6EC4WuLWl3effcQ04b9qckla+7nkXx58av oevnZ5N4F3zB7rI4XWy9GhwpkTYKPu6fBboVIqEDFqEMmkhDkFqm+/dpaKWz4JK6zSqf5HRJ4cX 4AiYmikSE3H1EqALeA== X-Google-Smtp-Source: AGHT+IFr2A58jx4kKR8nVUg6w6bivqW1VmnAzxHJV+dJtiq1/zgsS0YfJ7zBCGfSA/4mUNBRtLrTew== X-Received: by 2002:a17:906:f59e:b0:ab7:1816:e8a with SMTP id a640c23a62f3a-ab789c47d9fmr1843499666b.36.1739204093555; Mon, 10 Feb 2025 08:14:53 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab78ec15421sm715275266b.157.2025.02.10.08.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E05065F91D; Mon, 10 Feb 2025 16:14:51 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Thomas Huth , qemu-rust@nongnu.org (open list:Rust-related patc...) Subject: [PULL 01/17] tests/docker: replicate the check-rust-tools-nightly CI job Date: Mon, 10 Feb 2025 16:14:35 +0000 Message-Id: <20250210161451.3273284-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x633.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This allows people to run the test locally: make docker-test-rust@fedora-rust-nightly Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-2-alex.bennee@linaro.org> diff --git a/MAINTAINERS b/MAINTAINERS index 0091bd1a90..aac7404473 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3386,6 +3386,7 @@ F: rust/rustfmt.toml Rust-related patches CC here L: qemu-rust@nongnu.org +F: tests/docker/test-rust F: rust/ SLIRP diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include index fead7d3abe..fa1cbb6726 100644 --- a/tests/docker/Makefile.include +++ b/tests/docker/Makefile.include @@ -236,3 +236,6 @@ docker-image: ${DOCKER_IMAGES:%=docker-image-%} docker-clean: $(call quiet-command, $(DOCKER_SCRIPT) clean) + +# Overrides +docker-test-rust%: NETWORK=1 diff --git a/tests/docker/test-rust b/tests/docker/test-rust new file mode 100755 index 0000000000..e7e3e94a55 --- /dev/null +++ b/tests/docker/test-rust @@ -0,0 +1,21 @@ +#!/bin/bash -e +# +# Run the rust code checks (a.k.a. check-rust-tools-nightly) +# +# Copyright (c) 2025 Linaro Ltd +# +# Authors: +# Alex Bennée +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +. common.rc + +cd "$BUILD_DIR" + +configure_qemu --disable-user --disable-docs --enable-rust +pyvenv/bin/meson devenv -w $QEMU_SRC/rust ${CARGO-cargo} fmt --check +make clippy +make rustdoc From patchwork Mon Feb 10 16:14:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968214 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE1C6C02198 for ; Mon, 10 Feb 2025 16:26:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWSR-0007ww-Id; Mon, 10 Feb 2025 11:16: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 1thWR1-00047H-76 for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:00 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWQy-0001UJ-TN for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:14:58 -0500 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-ab7d7f0a2cfso27744466b.3 for ; Mon, 10 Feb 2025 08:14:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204093; x=1739808893; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s99h8qs7nLU97pBsNxE2tPpHIjsUUYJGtsusMGsaa/8=; b=BD5ea4PI8Dt8AolnwvtAaw0bICWxlybaFw2E+QaBGaaudQqwguh0lIY8LgUHYYC3WL jBgJgV/RW5V/GQ31KCJWxOlzQLJw9Djo3bVSIDo6a0O3qvvvFFnQSuwxUl9YY3etlqD4 7yEX3gNn+/vc88cc8mRpGmUYLgdTmC7nKcr0yuc5wC+P1l+x4yg+fOvdP/tNwvIM1h68 7Nhjr0ESMyZRyVVHRragmY+mg1G6JnCkxtAKg8Zvc7AyIYfoonsXluTrv7aAlTSB9tuw SNUM6/+ZETXSe5gwSEWvPe+kKKRtdIFRxqy3nPISP8FXlTHGW319Npsg2J/ACXoZeUEa TxKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204093; x=1739808893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s99h8qs7nLU97pBsNxE2tPpHIjsUUYJGtsusMGsaa/8=; b=GjdnYWDFdDi1WeBWDX1Gub/XJc332b7NER9peO0RbMSHMjXIfuYvoSPafnL9JpE89A ueIFEvULkkcUURQxSRDfG9+EGqwKuPSsaTVWY+MBaEcN/mU6N9CW6qcar+q/4GYxTVoP pFh1+N/SwKSffjBK3n/PQoxyLPWMESPWf7eAiYMF/1SX8pymPxZoIBlqpDai+/XbJACT 1CYc35uadDTr5rqYLUZaEToCUo50dBboy7lywhXbmki85Bc2GpDreYM8riKGAiQC3R7l Cs6zzrRriVcWhxZsU+VuAtqCvXmj+0r/Ql4CbS8WMfq/+g08a/aI56nmrEr4/OKs1X2x Tbbg== X-Gm-Message-State: AOJu0YxYbz7g/d7Hl1wr8uAnoknRxlT/zNPuZ6239V6831p00T/6Wx9B YNhXBt3mDYalSRYCE9V2kmK3b99yB0ymm8zM0g/9Kfj4TS7wwqPWZfaO5gsuipU= X-Gm-Gg: ASbGncue7z5rStU94NPMVqicPWDzio+p+JZx3p2kADUwj4xdpZhb+kSjYV6eaMsPKl/ wy2oVzg3K6YVDKhOXpN6lwvxxmkLHY5olFvULbJocv5xW4gsjAUXfMxYR9rpteGxOq1e3P1y0ev qR0p8M1DKQNHid7RqHtox1eugmqxoCiK8w6uxnGvAZCkAwUIX82pvj9Dt3lh0hPzkH6ubNZbn++ J5cVb+CSzpsr/1vBcpWCZeI7+K/WSoQuyS1mSllBIS70ENDjFXQhoNOGTw1GbM/579pzXJc/e9a ph7KMtdee+pJIBJXnw== X-Google-Smtp-Source: AGHT+IFGJNL4/5aTq82tA2me+RItBC0qU0FUHs3T7zfmGdcDVC5cUol9Gi0CWxTbattkKHqVAxrH6w== X-Received: by 2002:a17:906:7310:b0:ab7:6c4e:8e52 with SMTP id a640c23a62f3a-ab789a9bd9bmr1690898666b.5.1739204093237; Mon, 10 Feb 2025 08:14:53 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7d6acd8f1sm35552466b.50.2025.02.10.08.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id F38575F9FA; Mon, 10 Feb 2025 16:14:51 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL 02/17] tests/qtest: don't attempt to clock_step while waiting for virtio ISR Date: Mon, 10 Feb 2025 16:14:36 +0000 Message-Id: <20250210161451.3273284-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62d.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This replicates the changes from 92cb8f8bf6 (tests/qtest: remove clock_steps from virtio tests) as there are no timers in the virtio code. We still busy wait and timeout though. Reviewed-by: Thomas Huth Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-3-alex.bennee@linaro.org> diff --git a/tests/qtest/libqos/virtio-pci-modern.c b/tests/qtest/libqos/virtio-pci-modern.c index 18d118866f..4e67fcbd5d 100644 --- a/tests/qtest/libqos/virtio-pci-modern.c +++ b/tests/qtest/libqos/virtio-pci-modern.c @@ -173,13 +173,11 @@ static bool get_config_isr_status(QVirtioDevice *d) static void wait_config_isr_status(QVirtioDevice *d, gint64 timeout_us) { - QVirtioPCIDevice *dev = container_of(d, QVirtioPCIDevice, vdev); gint64 start_time = g_get_monotonic_time(); - do { + while (!get_config_isr_status(d)) { g_assert(g_get_monotonic_time() - start_time <= timeout_us); - qtest_clock_step(dev->pdev->bus->qts, 100); - } while (!get_config_isr_status(d)); + } } static void queue_select(QVirtioDevice *d, uint16_t index) diff --git a/tests/qtest/libqos/virtio-pci.c b/tests/qtest/libqos/virtio-pci.c index 485b8f6b7e..002bf8b8c2 100644 --- a/tests/qtest/libqos/virtio-pci.c +++ b/tests/qtest/libqos/virtio-pci.c @@ -171,13 +171,11 @@ static bool qvirtio_pci_get_config_isr_status(QVirtioDevice *d) static void qvirtio_pci_wait_config_isr_status(QVirtioDevice *d, gint64 timeout_us) { - QVirtioPCIDevice *dev = container_of(d, QVirtioPCIDevice, vdev); gint64 start_time = g_get_monotonic_time(); - do { + while (!qvirtio_pci_get_config_isr_status(d)) { g_assert(g_get_monotonic_time() - start_time <= timeout_us); - qtest_clock_step(dev->pdev->bus->qts, 100); - } while (!qvirtio_pci_get_config_isr_status(d)); + } } static void qvirtio_pci_queue_select(QVirtioDevice *d, uint16_t index) From patchwork Mon Feb 10 16:14:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC8E8C0219B for ; Mon, 10 Feb 2025 16:16:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWRh-0004tF-W5; Mon, 10 Feb 2025 11:15:42 -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 1thWR1-00047F-3K for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:00 -0500 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWQy-0001Ud-Tn for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:14:58 -0500 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-ab78e6edb48so454676666b.2 for ; Mon, 10 Feb 2025 08:14:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204095; x=1739808895; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cgHEs4UjXEPONNRSfBLs6a+I9ub5T+ewhfrcjtrhUWQ=; b=La1vGC0ddQglcVkkun47313KFV30aByQDJ2Hr612sSdPJuci/wQ0RM4PcLq9NfeNCp MnPT039Ms87IO5lzrLEwyaOu38uGeEYm8qTE3eCo5mmIMikMXqbb0AW+47mzmxqPdI8v TD94y3fKke0/2WNmRdDjtUsVmBFtYMvLNcvX/Llwc1v4+3i5B7a8BAXvTVieRulbAcST TIzasjJej3yGisdtTMNcKHprLPl2cn470NmgCRfpOH1nH894JUJg9s//aT9AXRvfkpV6 XlP58lsuoy9HESUY2xMN06dJn8EJoCzyLHauC0+bZ3XdR0BEUIJXs/Rkx/Of7TxCE1+3 +1MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204095; x=1739808895; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cgHEs4UjXEPONNRSfBLs6a+I9ub5T+ewhfrcjtrhUWQ=; b=vOPi2FI9VjY7y9wAHJW6ugIkXT+qe+qDTyiiLgKzuXesBwrQHLUwzAfPctL/6oeUqi Tfq23hNqExEDYIID5mO0CdBKNj65hEfNf1WqFWgFaH1G4c1lNxrSMCviIvE+eG00rahl q3WsTRIlrEWZIDc/aBk5nyBYFfx/vo18U0QqrWaqLo4Z9qSbVSnFwHGIqqvOA5yRL91O 2Cvd7mveBroVTudIvy+9cKcjYwd5MiODGbCJuzSaV0zRAD+9brGPauuQvVRtsuqSLGR/ AfT8+xwZ29T7U8ICh7WuU5jr8HxBrTXMhXHQ855l+N6FThkTJz/1rjZoePRd3XJgCqJQ m4DA== X-Gm-Message-State: AOJu0YyizRxB95pjchQYoCjm6LwvY94FydqnlU2TY7TV9KAljNuyQrWi h8YmY8Z5hNNLquW6jqSSkLY/N6sslDxGxSMKhEDJ+8UGV4YHJWK//ndqAIfE/s8= X-Gm-Gg: ASbGnctYxp96A/CldaSAiSjTKuQKja5v4T5NlHiBJUty8cA4TxVnWVas/mcSlkvccRJ OkzC9sDofQ4MFeRZgZ70xqn8onFXaW670Wvln13sV96YaO9TMlQChDSxT4OVAC8l7hmKVmGtol0 a8nWdJyS8tVM9D6bbbg39ssERh+kNxqHgNG/wCVZ5T53liA+JThTRI84W2Ic6CL3vozz194oluf EPx0LHe1g1xbrSQftU5hYeM0ui2AZjpC8ujGH5FnzkCkiMLMEbPBSysUNDqmx4fTy8AOK4AajWK H8G78viFF/tHtahzAQ== X-Google-Smtp-Source: AGHT+IE+1nSSACPNzPBxGI3gEjERuVGGbI12sXgyLDT9D246YqT3THYbiTqgghfFY1LgnZJ/r/ZEAQ== X-Received: by 2002:a05:6402:194b:b0:5dc:a44e:7644 with SMTP id 4fb4d7f45d1cf-5de44fe95c1mr38189449a12.2.1739204094616; Mon, 10 Feb 2025 08:14:54 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5de4e6d60bbsm6224628a12.15.2025.02.10.08.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:52 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 11D805FA16; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Hao Wu , Tyrone Ting , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-arm@nongnu.org (open list:Nuvoton NPCM7xx) Subject: [PULL 03/17] tests/qtest: don't step clock at start of npcm7xx periodic IRQ test Date: Mon, 10 Feb 2025 16:14:37 +0000 Message-Id: <20250210161451.3273284-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x631.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Until there are timers enabled the semantics of clock_step_next() will fail. Since d524441a36 (system/qtest: properly feedback results of clock_[step|set]) we will signal a FAIL if time doesn't advance. Reviewed-by: Hao Wu Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-4-alex.bennee@linaro.org> diff --git a/tests/qtest/npcm7xx_timer-test.c b/tests/qtest/npcm7xx_timer-test.c index 58f58c2f71..43711049ca 100644 --- a/tests/qtest/npcm7xx_timer-test.c +++ b/tests/qtest/npcm7xx_timer-test.c @@ -465,7 +465,6 @@ static void test_periodic_interrupt(gconstpointer test_data) int i; tim_reset(td); - clock_step_next(); tim_write_ticr(td, count); tim_write_tcsr(td, CEN | IE | MODE_PERIODIC | PRESCALE(ps)); From patchwork Mon Feb 10 16:14:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAD45C02198 for ; Mon, 10 Feb 2025 16:17:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWRf-0004ht-Qa; Mon, 10 Feb 2025 11:15:40 -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 1thWR2-000489-Bu for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:01 -0500 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR0-0001Up-F2 for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:00 -0500 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5de4d4adac9so6064050a12.3 for ; Mon, 10 Feb 2025 08:14:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204097; x=1739808897; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ALPFRjqBCzN5IspKKvq+gGyQjhJlGV0zlBdiRI50u44=; b=qrWk3F7Qo+P9t3BXpU3FAF8mqCa878vHuRKnKf+Na5kDSZCkK89ZcrAPOSwuQjdt08 xtqGO7E2EHPVESs4D0KVaZ3RbQPSG75msyqYPL5Vi9UrgaY4g0Mwo/37NH18w3rbIDVJ pVOaFkHJ0XuQZyZ69nKeVw8jhIUof3RPFOLsKxgL9JiKTUNGETl6ETnDcniAw85l/1nf a7V2wvCDSuXyPXrIcMd2VI3w2KG/A8F0IpKhY5walszHEBhVHtBsQ7YiJ24K5I0txeb+ TfVext7UVasrzMWjLD8XdSyMA888rnS7xeHjka2Xr25u3xElo2kam9EuaGlst5nBt07Q hE1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204097; x=1739808897; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ALPFRjqBCzN5IspKKvq+gGyQjhJlGV0zlBdiRI50u44=; b=hdF1wqaDILAG6iA7xD+TFqc/4+M2a5IemmRZflvZ65KeXPhwqoVGNZWATNHRdaVJkm E3a6M7IHs2fdRtjWQwuYejPo7BHhjjbMDXIce1jVx5dJkdG+MWdLDW6D2uMJZG3Lxw47 ZVx0pLdsp5Tho46X9GUsM2EVA2x8PVThHi9VCSTLfIzyA/XIY66Ccy4m4TrmfWV8X/+P AG95X9hFVTTwGWlhkxQ1E6rsx6ENhZJWQG2DInbec9ESzxzW+EfrLIc3FbaJ8QxOTvty kauwEC2qs3j21OgBplQHQvhIdvMdRZBoxr+DuhFCRnHe0hsOs72lX8r6kDGOe9Y8u1Bh AaGQ== X-Gm-Message-State: AOJu0YzQGSyKXb/i2JxeIVIGbfaGXd0KFYUrZMLTVUsQxqTHdmMc8HdM bmdlQnWeylD0R9LXJK8AYoXyAygtLsUFL82TaOSTYhacIL4li9lshoFLdyCS9Gk= X-Gm-Gg: ASbGncsTg4Bj3kjvUiuZtPYDEKMkv0OKOxegLdtPTCdfhVNrzjPF51fk3WYEAxaUpIJ 5nbGa3x8FKpf5JBdGHwx/GQiFrsSzPVVDFHCVXnWbZiub7MuMVCsoSHMo/IEcV1pz8/qoNvuqCp 9cOkFNEToZkCkpsS6IE4d4YuyVc/KVnQNzkrGkQ23KS71E4icKFDAcvojGTSb++vNJKVUe/V2jj QFa/ZPa5Oy0yQi+cWN9wZKN7mF95IZ3AmSwT/e72ic2G/SHrfGfhiquTGzfSPkWo+YpbNGVeR6J OTb9o1eymfJD/syYYg== X-Google-Smtp-Source: AGHT+IErRl2CvwHSOtOdyPyDYD9WUPeegFpG0YcGycdZEE4aU3VltBS7tgdl78Mkg0cQ1H4CEiFaGw== X-Received: by 2002:a05:6402:194b:b0:5dc:7fbe:730d with SMTP id 4fb4d7f45d1cf-5de44fe9d71mr17348939a12.6.1739204096717; Mon, 10 Feb 2025 08:14:56 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dcf1b73f8csm8003497a12.8.2025.02.10.08.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 23FB25FB53; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL 04/17] tests/qtest: simplify qtest_process_inbuf Date: Mon, 10 Feb 2025 16:14:38 +0000 Message-Id: <20250210161451.3273284-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x533.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Don't both creating a GString to temporarily hold our qtest command. Instead do a simpler g_strndup and use autofree to clean up afterwards. Reviewed-by: Peter Maydell Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-5-alex.bennee@linaro.org> diff --git a/system/qtest.c b/system/qtest.c index e68ed0f2a8..bb1efba9fd 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -763,25 +763,21 @@ static void qtest_process_command(CharBackend *chr, gchar **words) } } +/* + * Process as much of @inbuf as we can in newline terminated chunks. + * Remove the processed commands from @inbuf as we go. + */ static void qtest_process_inbuf(CharBackend *chr, GString *inbuf) { char *end; while ((end = strchr(inbuf->str, '\n')) != NULL) { - size_t offset; - GString *cmd; - gchar **words; - - offset = end - inbuf->str; + size_t len = end - inbuf->str; + g_autofree char *cmd = g_strndup(inbuf->str, len); + g_auto(GStrv) words = g_strsplit(cmd, " ", 0); - cmd = g_string_new_len(inbuf->str, offset); - g_string_erase(inbuf, 0, offset + 1); - - words = g_strsplit(cmd->str, " ", 0); + g_string_erase(inbuf, 0, len + 1); qtest_process_command(chr, words); - g_strfreev(words); - - g_string_free(cmd, TRUE); } } From patchwork Mon Feb 10 16:14:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3557C0219B for ; Mon, 10 Feb 2025 16:17:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWSL-0007hs-Ms; Mon, 10 Feb 2025 11:16:21 -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 1thWRB-0004NK-8j for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:09 -0500 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR5-0001WV-I7 for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:07 -0500 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5de74599749so2112103a12.1 for ; Mon, 10 Feb 2025 08:15:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204101; x=1739808901; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mdv6BlsMATdrpGMkUawzyb+JI/nA7/PsR2TQFJvlMrU=; b=tOmD8Hckbb2Wit1UXynwN+dYkmUfd8ktr/6NXVn54s/2D/QNjV92J6tGOxrAPR29hZ SxyvO+olgFqtCvdyZhdB2QkIbpqItRm1HMbjYcksmUZt7tYSBJoGqh08CLfFMI1osbU1 7WlipXKsbG1zmLR57WRZwhEPRzrqKY5k7UX+LEC4QVsCzcOWNg8SZL0zvFHvloM+b7nh QIgHgcaI6NKlqCZ0l5DAq7zrkfiTZVats2C735ZwxzWI85vPiXeZaElc37LQi20q4UAT xt9NHzMS+JNXgSgk7GSITR5Ff9Bw7bEYQLnr6BCdwn5vomTTDJxeck/yRRqa0rhy1Qb8 pGTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204101; x=1739808901; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mdv6BlsMATdrpGMkUawzyb+JI/nA7/PsR2TQFJvlMrU=; b=W1rT5eaCZDiwKLWAoWnZfwlnihDNZ9MZ/RbDlCNSDTZ6sV6NhqQntmbYeS4Dc8V7pW uHzVUfoJ48KpLk3In7cAKzOBBhK0i9HWKLBPPfAd2yB+nvKmuSmjXik/c3+BdJ1dIVEE pWMTOHIy0QIeeLDrSiQJ7jsSMg7AWpbZnVHK9Sjcx252MDIbDuDtWJZCaUBI6qAe+5rP VwTNOGfJR1ybxtZf+I/0i8ka85ZuWwpJpChgyymAq9CP5wGhRWXjImt9jJmcSGbJ9mTb LM7ebwpGlQ543a1D8nac1CSpFy9+YRJQaJCXGwwMnmTYttoy0PxJABTbYucG+zd/cln5 CfCw== X-Gm-Message-State: AOJu0YyXbWzNWW26ZA/keXFrZBVglaTwxPcS0F4ZXHijIf/ZI1fcBJg7 phiLl+9MsKOIvmGwNXd7gv0mmYemJ+fTbvK0l+/6483a8poIUXLousYy5rKFA9Y= X-Gm-Gg: ASbGnctdthe+PQNf6eLkz+tmetjnGdoVt/Zdwnc3JQrG/dkMUS7o6gdKoFD3Lc8ek2P rxR0pD4CF4NAT3sAqOpI6aWYE0mMh/rL4vhThEXKzvfn7nZ1GDzXwJ2Jp9+AxzdA1x+4tL5KqKO yYuCGX5clzfvOplkVpYqiPPDKDa7S3iVNZm4maSwC+NfX+4J3sTBPfD9bFSM19v6qVYibKA0H5v pQs2BE7s7uplimYOhuZZs5/2tl6nfBdHZSA8RtQqapf5OGlXalQIdRJnOuaIaquENzdGIchsgTD qSEiH+4N7FTWXXei9w== X-Google-Smtp-Source: AGHT+IGOlWVt9GgZaRqmv6W3yYmBmaFrcCt0q9TzaiC+ikBC6vIrRSHSVAlIO08rHLvVqQ4moswPFg== X-Received: by 2002:a05:6402:2392:b0:5de:4b81:d3fd with SMTP id 4fb4d7f45d1cf-5de4b81d4d7mr11286653a12.13.1739204100989; Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5de5fb0d738sm4925508a12.59.2025.02.10.08.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3A6825FD70; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Liu Zhiwei , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org (open list:sPAPR (pseries)), qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PULL 05/17] tests/qtest: rename qtest_send_prefix and roll-up into qtest_send Date: Mon, 10 Feb 2025 16:14:39 +0000 Message-Id: <20250210161451.3273284-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52b.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org qtest_send_prefix never actually sent something over the chardev, all it does is print the timestamp to the QTEST_LOG when enabled. So rename the function, make it static, remove the unused CharDev and simplify all the call sites by handling that directly with qtest_send (and qtest_log_send). Reviewed-by: Thomas Huth Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-6-alex.bennee@linaro.org> diff --git a/include/system/qtest.h b/include/system/qtest.h index c161d75165..6ddddc501b 100644 --- a/include/system/qtest.h +++ b/include/system/qtest.h @@ -24,7 +24,6 @@ static inline bool qtest_enabled(void) } #ifndef CONFIG_USER_ONLY -void qtest_send_prefix(CharBackend *chr); void G_GNUC_PRINTF(2, 3) qtest_sendf(CharBackend *chr, const char *fmt, ...); void qtest_set_command_cb(bool (*pc_cb)(CharBackend *chr, gchar **words)); bool qtest_driver(void); diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index df2e837632..503d441b48 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -565,7 +565,6 @@ static bool spapr_qtest_callback(CharBackend *chr, gchar **words) g_assert(rc == 0); res = qtest_rtas_call(words[1], nargs, args, nret, ret); - qtest_send_prefix(chr); qtest_sendf(chr, "OK %"PRIu64"\n", res); return true; diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c index ad67cd7645..a55d156668 100644 --- a/hw/riscv/riscv_hart.c +++ b/hw/riscv/riscv_hart.c @@ -94,7 +94,6 @@ static bool csr_qtest_callback(CharBackend *chr, gchar **words) g_assert(rc == 0); csr_call(words[1], cpu, csr, &val); - qtest_send_prefix(chr); qtest_sendf(chr, "OK 0 "TARGET_FMT_lx"\n", (target_ulong)val); return true; diff --git a/system/qtest.c b/system/qtest.c index bb1efba9fd..28b6fac37c 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -265,7 +265,7 @@ static int hex2nib(char ch) } } -void qtest_send_prefix(CharBackend *chr) +static void qtest_log_timestamp(void) { if (!qtest_log_fp || !qtest_opened) { return; @@ -282,7 +282,7 @@ static void G_GNUC_PRINTF(1, 2) qtest_log_send(const char *fmt, ...) return; } - qtest_send_prefix(NULL); + qtest_log_timestamp(); va_start(ap, fmt); vfprintf(qtest_log_fp, fmt, ap); @@ -301,6 +301,7 @@ static void qtest_server_char_be_send(void *opaque, const char *str) static void qtest_send(CharBackend *chr, const char *str) { + qtest_log_timestamp(); qtest_server_send(qtest_server_send_opaque, str); } @@ -324,7 +325,6 @@ static void qtest_irq_handler(void *opaque, int n, int level) if (irq_levels[n] != level) { CharBackend *chr = &qtest->qtest_chr; irq_levels[n] = level; - qtest_send_prefix(chr); qtest_sendf(chr, "IRQ %s %d\n", level ? "raise" : "lower", n); } @@ -380,19 +380,16 @@ static void qtest_process_command(CharBackend *chr, gchar **words) is_outbound = words[0][14] == 'o'; dev = DEVICE(object_resolve_path(words[1], NULL)); if (!dev) { - qtest_send_prefix(chr); qtest_send(chr, "FAIL Unknown device\n"); return; } if (is_named && !is_outbound) { - qtest_send_prefix(chr); qtest_send(chr, "FAIL Interception of named in-GPIOs not yet supported\n"); return; } if (irq_intercept_dev) { - qtest_send_prefix(chr); if (irq_intercept_dev != dev) { qtest_send(chr, "FAIL IRQ intercept already enabled\n"); } else { @@ -419,7 +416,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) } } - qtest_send_prefix(chr); if (interception_succeeded) { irq_intercept_dev = dev; qtest_send(chr, "OK\n"); @@ -438,7 +434,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) dev = DEVICE(object_resolve_path(words[1], NULL)); if (!dev) { - qtest_send_prefix(chr); qtest_send(chr, "FAIL Unknown device\n"); return; } @@ -457,7 +452,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) irq = qdev_get_gpio_in_named(dev, name, num); qemu_set_irq(irq, level); - qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "outb") == 0 || strcmp(words[0], "outw") == 0 || @@ -480,7 +474,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) } else if (words[0][3] == 'l') { cpu_outl(addr, value); } - qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "inb") == 0 || strcmp(words[0], "inw") == 0 || @@ -501,7 +494,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) } else if (words[0][2] == 'l') { value = cpu_inl(addr); } - qtest_send_prefix(chr); qtest_sendf(chr, "OK 0x%04x\n", value); } else if (strcmp(words[0], "writeb") == 0 || strcmp(words[0], "writew") == 0 || @@ -537,7 +529,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, &data, 8); } - qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "readb") == 0 || strcmp(words[0], "readw") == 0 || @@ -571,7 +562,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) &value, 8); tswap64s(&value); } - qtest_send_prefix(chr); qtest_sendf(chr, "OK 0x%016" PRIx64 "\n", value); } else if (strcmp(words[0], "read") == 0) { g_autoptr(GString) enc = NULL; @@ -593,7 +583,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) enc = qemu_hexdump_line(NULL, data, len, 0, 0); - qtest_send_prefix(chr); qtest_sendf(chr, "OK 0x%s\n", enc->str); g_free(data); @@ -613,7 +602,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, len); b64_data = g_base64_encode(data, len); - qtest_send_prefix(chr); qtest_sendf(chr, "OK %s\n", b64_data); g_free(data); @@ -649,7 +637,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) len); g_free(data); - qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "memset") == 0) { uint64_t addr, len; @@ -673,7 +660,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) g_free(data); } - qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "b64write") == 0) { uint64_t addr, len; @@ -705,10 +691,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words) address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data, len); - qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "endianness") == 0) { - qtest_send_prefix(chr); if (target_words_bigendian()) { qtest_sendf(chr, "OK big\n"); } else { @@ -726,7 +710,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) QEMU_TIMER_ATTR_ALL); } new_ns = qemu_clock_advance_virtual_time(old_ns + ns); - qtest_send_prefix(chr); qtest_sendf(chr, "%s %"PRIi64"\n", new_ns > old_ns ? "OK" : "FAIL", new_ns); } else if (strcmp(words[0], "module_load") == 0) { @@ -734,7 +717,6 @@ static void qtest_process_command(CharBackend *chr, gchar **words) int rv; g_assert(words[1] && words[2]); - qtest_send_prefix(chr); rv = module_load(words[1], words[2], &local_err); if (rv > 0) { qtest_sendf(chr, "OK\n"); @@ -752,13 +734,11 @@ static void qtest_process_command(CharBackend *chr, gchar **words) ret = qemu_strtoi64(words[1], NULL, 0, &ns); g_assert(ret == 0); new_ns = qemu_clock_advance_virtual_time(ns); - qtest_send_prefix(chr); qtest_sendf(chr, "%s %"PRIi64"\n", new_ns == ns ? "OK" : "FAIL", new_ns); } else if (process_command_cb && process_command_cb(chr, words)) { /* Command got consumed by the callback handler */ } else { - qtest_send_prefix(chr); qtest_sendf(chr, "FAIL Unknown command '%s'\n", words[0]); } } From patchwork Mon Feb 10 16:14:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968202 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 05D06C0219B for ; Mon, 10 Feb 2025 16:22:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWS4-0006Q3-Hw; Mon, 10 Feb 2025 11:16:04 -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 1thWR3-0004AA-Us for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:04 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR2-0001V4-0r for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:01 -0500 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5de5e3729ecso4169367a12.0 for ; Mon, 10 Feb 2025 08:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204098; x=1739808898; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WRjcWYmrZaZWP3MsASwgK8gyMjNh7g5UJb6gwrhevyU=; b=c6ZcAJK66VbfCY6B+jVgLqvrh7BMFb3Xiz1anoDDwwAHpBgUUf/Njgh8NZZUK15ks/ RyQoLESOBFnhK4GVL5y+qhxnG/EcpPUojgHzezgwHIf76kDROGzLCoAjy0fRmHGqIXar mWFj2qDkwdoPohp7TeTWOwdkyuomlVV8sPQdtqqxmzA/GLADMwGw+Vggk2gTTGoSxB6d QTwosm0VQlL5RkFF36KaE8Cs+YStji/w4U6veZKKcVWX1hKk6UtQ52TPuXmLKrjSHbHR LJpqhJrCgSRdxNy55QU216VFLW6wlNgVBKvYsRyCqYQB5f4topumDRHMosM1YH2j+Ygt QWNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204098; x=1739808898; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WRjcWYmrZaZWP3MsASwgK8gyMjNh7g5UJb6gwrhevyU=; b=gAnz9Cn6ECbaEHvWLgdcO+dFUbRz6dMNOmzWs69+MLd0o5w6eLZDUanEPFNGfcNcrb bNdyUs0xmi8TRZEzANJFP0hWsVkN0GiHz0RJOU/Ih1pySA7/zxlMJZtwJJNKVjgx+B5V aAqz7hlGNRHyHan0FOsxBjmB0RsMN9D480V6JyQ5tEx+AmDjXtZtdiuO86uIygJTOTqf N1UgCyYBComResU27AoiDcXFArQR5CVAo9iwVJadb2xrpem+klokzPfbAsssK2kPxEn8 bsHFUCWZ5sqd5A6X5FMuvhx2gqABhLwePFWJl0sQOg7ClrPdXnD3r0Tf3h0HMIUHSA1W i6JQ== X-Gm-Message-State: AOJu0YyxvB0pVkULzVosvqKFXtqzXUOk/rC+P117hZdomoqoonUCnGLi yk4iFAgPtJ5BRxCEhUkGFdmdelD62r5V+md3mrMAnOHotp+9a23JH2dZ2UnjwVk= X-Gm-Gg: ASbGncsc6h1F+acmAq5p5IQm0cbAuHW0pHtGLNQ5xLDn/sWjuSy6qbs5Fke85V+5chc RNQlqOBqEFy3XhVA8xjaCBoLScoCg9X6nYUQmVosuqM6YCpsjPnQEM6Xd/ZZFKQGKTrYJ98hIEp SvDf6HbfoK+e+lx7JesHw0cFuqgz8XT7B+Lo0P/rBDFJkq9QUwu0R+hZRQkoXrbLhUEebmPS17F +vAXPf9jxzJ9MhExeYelTidx/t477TtFq8U4lc/qWPSGCOamAD4i1kzYTYTb3hMCE1CkfusLLyH JtpJXBeo+0r2Y6+jIA== X-Google-Smtp-Source: AGHT+IGG/iTBzn7g9jQIRnszoJrFH5Y7WXqXc8PvmoXMmR0/8NIPg9gbEnuuse2l6YVANgv9SC+a6g== X-Received: by 2002:a05:6402:2189:b0:5dc:c869:da4f with SMTP id 4fb4d7f45d1cf-5de9a4645f9mr244118a12.24.1739204098169; Mon, 10 Feb 2025 08:14:58 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dcf1b734e5sm8303006a12.5.2025.02.10.08.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:56 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4D87C601E0; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL 06/17] tests/qtest: tighten up the checks on clock_step Date: Mon, 10 Feb 2025 16:14:40 +0000 Message-Id: <20250210161451.3273284-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52d.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org It is invalid to call clock_step with an implied time to step forward as if no timers are running we won't be able to advance. Reviewed-by: Peter Maydell Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-7-alex.bennee@linaro.org> diff --git a/system/qtest.c b/system/qtest.c index 28b6fac37c..12152efbcd 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -708,10 +708,19 @@ static void qtest_process_command(CharBackend *chr, gchar **words) } else { ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, QEMU_TIMER_ATTR_ALL); + if (ns < 0) { + qtest_send(chr, "FAIL " + "cannot advance clock to the next deadline " + "because there is no pending deadline\n"); + return; + } } new_ns = qemu_clock_advance_virtual_time(old_ns + ns); - qtest_sendf(chr, "%s %"PRIi64"\n", - new_ns > old_ns ? "OK" : "FAIL", new_ns); + if (new_ns > old_ns) { + qtest_sendf(chr, "OK %"PRIi64"\n", new_ns); + } else { + qtest_sendf(chr, "FAIL could not advance time\n"); + } } else if (strcmp(words[0], "module_load") == 0) { Error *local_err = NULL; int rv; From patchwork Mon Feb 10 16:14:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8792C0219B for ; Mon, 10 Feb 2025 16:21:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWRx-0005o0-RA; Mon, 10 Feb 2025 11:15:58 -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 1thWR5-0004AV-4P for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:04 -0500 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR2-0001VL-Cf for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:02 -0500 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-ab7a342ef4eso446512166b.0 for ; Mon, 10 Feb 2025 08:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204099; x=1739808899; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5De79NWbhkU5BW07foJEsOJqUNxurUAkpHc9PcGIKnc=; b=upjZqEADPBeOw6gl4+8dckuQGvoAhVOo+Glup/H6aaXWGgkzNkOWgNsuL6jP9yr71J YOvTzjxWejXZ1T++uOdHPKKpY4p/tBjRLhqGpG1rNubu5sfQpdhr0N7P1pbG3DFQeR2t 1SXugAQQeRLLD9dZU53xcYNlhO+fAPAijf3SCJcBA4dczfYorvZ6vgPOhzjEdJgyABcb XrNh/5lrxUg/CmnncrUtvMLJzs8gaHcP5aOmBELDoL39nWsznNZjc5zm6DZa1e0FyqMo u2y8CzSKze603aovms96i8L5QUOP35iD7vHV/IpA5OxWfpVcqx1G+oP4uo5jr1W+5pXw Z7JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204099; x=1739808899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5De79NWbhkU5BW07foJEsOJqUNxurUAkpHc9PcGIKnc=; b=e6hhx4VzXxcNgRFR3wf+mdtOCzcArnKPOAtq9+n0jaO2886GGeVYx8pYufGJbPHF9F BZaKq09EWF3YLpLot4N4+wUbM1RzKocTGP073950qoc6hWCQDN5tIPocSXSYy2w//e/8 ixxrCpaL1Rv9ZfwnImJOtPd8rkAt7Eecn0M5JZpn9KkZtHV94FA7mNuysUhnvtnBe1we ze8IDMAYGJXkbsRkF9G8EuR9cUkmQ2An08jvIclKgMMVJ8eN+u/WSO79RhhW/IitX29u xEyeqz+RUcdPf9gbzDRh2EGWNotrtDGxVuMmbNcYWM0Pd8ODV47iBC4xJtD9VbtX95v0 tohQ== X-Gm-Message-State: AOJu0YxVZbBxAXFmgsDNdMNumJGMS5nNaTFxBUuSmfXVxXqKtcVDLGga iphj3jMU/JKV91/7OD+WUF8E9otbHHSS0mAXE3gJDl7JFfmdMHQAusspn+zBjvM= X-Gm-Gg: ASbGnctOR6NW2r0+KrzjiNK862reM2EZnbOILV5DH01uPc7uJuQeKSu04kRBOD94lpG 2i6hYDh7evBZnwu42Frb6tjRURr0yKr2vlByFJC4tefOm4ARma0+I+J2fD4lSymSKJNz5l0UXZI NHREreaD75/PzMfHVl611j1TtXiGJXUgQSe6dpxUStv6K31fI5JlPvBf0SxGE1R4NMHA5bKJI4m aZ3ZvOM71oJPQw233TD2fv4eYMIpoQcbybmY218SS4x/Okj9xDrr57gSULbQqGnm2l0XtnygP4F p6pGnzWmD/dM9L5Ubw== X-Google-Smtp-Source: AGHT+IGsLT8DOAIv7Tr2e6mhHhqjUvXua6nW6MZkTLnr8ts3Va56wgaujNw0fPOHkao88QsD/lGijw== X-Received: by 2002:a17:907:948a:b0:aac:29a:2817 with SMTP id a640c23a62f3a-ab789b22c1dmr1355930766b.26.1739204098809; Mon, 10 Feb 2025 08:14:58 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7845d8810sm792990466b.72.2025.02.10.08.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 601866022C; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , Paolo Bonzini Subject: [PULL 07/17] Revert "util/timer: avoid deadlock when shutting down" Date: Mon, 10 Feb 2025 16:14:41 +0000 Message-Id: <20250210161451.3273284-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62b.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This reverts commit bc02be4508d8753d1f6071b77d10f4661587df6f. Now we catch attempts to clock_step to the next timer when none are enabled we can revert the previous attempt to prevent deadlock. As long as a new target time is given we will move time forward even if no timers will fire. This is desirable for tests which are checking that nothing changes when things are disabled. Previously most tests got away with it because --enable-slirp always has a timer running while the test is active. Reviewed-by: Peter Maydell Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-8-alex.bennee@linaro.org> diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 0e8a453eaa..3243d2c515 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -675,17 +675,10 @@ int64_t qemu_clock_advance_virtual_time(int64_t dest) { int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); AioContext *aio_context; - int64_t deadline; - aio_context = qemu_get_aio_context(); - - deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, - QEMU_TIMER_ATTR_ALL); - /* - * A deadline of < 0 indicates this timer is not enabled, so we - * won't get far trying to run it forward. - */ - while (deadline >= 0 && clock < dest) { + while (clock < dest) { + int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); int64_t warp = qemu_soonest_timeout(dest - clock, deadline); qemu_virtual_clock_set_ns(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + warp); @@ -693,9 +686,6 @@ int64_t qemu_clock_advance_virtual_time(int64_t dest) qemu_clock_run_timers(QEMU_CLOCK_VIRTUAL); timerlist_run_timers(aio_context->tlg.tl[QEMU_CLOCK_VIRTUAL]); clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - - deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, - QEMU_TIMER_ATTR_ALL); } qemu_clock_notify(QEMU_CLOCK_VIRTUAL); From patchwork Mon Feb 10 16:14:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B8D7C0219E for ; Mon, 10 Feb 2025 16:23:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWRp-0005Gl-Ox; Mon, 10 Feb 2025 11:15:50 -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 1thWR5-0004C2-P9 for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:05 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR2-0001VH-7R for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:02 -0500 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-ab7cc0c1a37so142657466b.0 for ; Mon, 10 Feb 2025 08:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204098; x=1739808898; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VG//uhabKjRFgO3Unu/weU5aBAHUld/kAOriyLnP5SU=; b=B2pwEjDVJEEsCqLic+YxOAHak0TY1ynLSh+63rmafVhsukwMrNsHCDpBQtInbPo2C2 YSd5+H6+k9yZ2AAq1VUBZqnd/4WP7KVGkbzkGDiWbruhBT/NXoWPk+SwPh+xUvRRMr0t BoE+ndQu6VfsocGoZzkzzQRTcFW0Oqx9TsUf7ZC1UtSrrNVdOuJ6dnnE9S5AYMbrSGKx mfKW/epWb2DiNcz6S8vYuwJWWSI4iOa3/v04YgTLqm+GpU33gnWtqXRzmqlXPADlVpwx 0qht4AQPyojy9uCPVZk6VcQWRH/dMJnMnrfuSajKB3C/1TPDDNsS9Z7aYb78l/zE9cy8 3WFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204098; x=1739808898; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VG//uhabKjRFgO3Unu/weU5aBAHUld/kAOriyLnP5SU=; b=MLvu5XZICUcyM+s224kSz/p98aZ099+1lzhVUdaxlaalHRjEnYgiV4Vftth9qkHQZ2 ZcUVVQU5uYW1CfjrfvG3iuP0ieVTh9BqIJyTr9lnvmL9auWBMVs5isjnuYOgdl/hRnUy vKtEXkiJmWz8UFebUNkSL38lD/bP0VNqm+LXPNS3GQWNm7Pt6b0LtSg/2EmE4UeYY4HF SMRFL85Zxstm7Q0IspLoQ5Mz357uKR4QowuY0ehdlPXsc4Guxj/74MCbwYvp4PFonclX wb/owRJSaskgvVVJB1uBXfz9WPNK4JKAk5eFGSmmAN9XPbpS0OeHfDXUMDkUxwxYiuAK z6BA== X-Gm-Message-State: AOJu0YyhNAbzzcY6qzCri4Nykp+ujTHJDuFAGXinxDTmGr1S5gtHJd63 P1rsgYCnEQ+foxJDnbww32QJFUwMXJDO/plnTH30/4e+/01p1/+QNcBwLfbuDVBNSpIXugSmz4u vWlY= X-Gm-Gg: ASbGnctORLh6z/gSD4ecD1n+Z6NgDkFqkHKtxY3PpJh6LzkDfSGBfPn6Mm4yJHHIpUE xRF9lIAA4nexx8YeWicM/UI85flSK3zanRIB9vklfPdG0VE0JP6YxUZKeIbnZw8I5DbytbuSkgn XW1Ms7fZmxA5ZKJQuMGfZk3HXUNwseTpj1eHHZu6iUIs0pQfGeX42YElAjo7Q5UHDObE55iQX58 WLmbhieKWHlxH/o4koa9klSJ8TH3K0RN83Jq/vexciNPd8BVWc8PItWxbiypzuAt0AyY7hc2hfk BOZEX2xCQPLDxxCTrg== X-Google-Smtp-Source: AGHT+IGkG762GIprzXT0Tcs53sVwjaLZe1qhPWjnQnjdOdaa7Zwe8m/QlWgGhKSPeIo5W2/Mj5o0fw== X-Received: by 2002:a17:907:da6:b0:ab7:877d:ec47 with SMTP id a640c23a62f3a-ab789bf95e3mr1310677566b.41.1739204098518; Mon, 10 Feb 2025 08:14:58 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7c01cba8asm252173766b.0.2025.02.10.08.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7EA5D60335; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier , Paolo Bonzini Subject: [PULL 08/17] tests/qtest/migration: Add --full option Date: Mon, 10 Feb 2025 16:14:42 +0000 Message-Id: <20250210161451.3273284-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fabiano Rosas Add a new command line option to allow selecting between running the full set of tests or a smaller set of tests. The default will be to run the small set (i.e. no comand line option provided) so we can reduce the amount of tests run by default. Only hosts which support KVM for the target architecture being tested will run the complete set of tests. Adjust the meson.build file to pass in the --full option when appropriate. (for now, set the option unconditionally until the next patch actually creates the small set) Use cases: configure --target-list=aarch64-softmmu,ppc64-softmmu,s390x-softmmu,x86_64-softmmu | before - 615s/244 tests | after - 244s/100 tests ------------------------+--------------------------+----------------------------- make check | full set for all archs | full set for the KVM arch, make check-qtest | | small set for the rest | | qemu-system-$ARCH | full set for $ARCH | small set for $ARCH, KVM or ./migration-test | | TCG automatically chosen | | qemu-system-$ARCH | N/A | full set for $ARCH, KVM or ./migration-test --full | | TCG automatically chosen | | migration-compat-x86_64 | full set for x86_64 | small set for x86_64 CI job | | ------------------------+--------------------------+----------------------------- Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu Message-Id: <20250130184012.5711-2-farosas@suse.de> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-9-alex.bennee@linaro.org> diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/framework.h index cb4a984700..e4a11870f6 100644 --- a/tests/qtest/migration/framework.h +++ b/tests/qtest/migration/framework.h @@ -24,6 +24,7 @@ typedef struct MigrationTestEnv { bool uffd_feature_thread_id; bool has_dirty_ring; bool is_x86; + bool full_set; const char *arch; const char *qemu_src; const char *qemu_dst; diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 5cad5060b3..61180fcbd5 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -14,13 +14,39 @@ #include "migration/framework.h" #include "qemu/module.h" +static void parse_args(int *argc_p, char ***argv_p, bool *full_set) +{ + int argc = *argc_p; + char **argv = *argv_p; + int i, j; + + j = 1; + for (i = 1; i < argc; i++) { + if (g_str_equal(argv[i], "--full")) { + *full_set = true; + continue; + } + argv[j++] = argv[i]; + if (i >= j) { + argv[i] = NULL; + } + } + *argc_p = j; +} + int main(int argc, char **argv) { MigrationTestEnv *env; int ret; + bool full_set = false; + + /* strip the --full option if it's present */ + parse_args(&argc, &argv, &full_set); g_test_init(&argc, &argv, NULL); env = migration_get_env(); + env->full_set = full_set; + env->full_set = true; /* temporary */ module_call_init(MODULE_INIT_QOM); migration_test_add_tls(env); diff --git a/tests/qtest/migration/compression-tests.c b/tests/qtest/migration/compression-tests.c index d78f1f11f1..9d0a258d51 100644 --- a/tests/qtest/migration/compression-tests.c +++ b/tests/qtest/migration/compression-tests.c @@ -155,6 +155,10 @@ void migration_test_add_compression(MigrationTestEnv *env) { tmpfs = env->tmpfs; + if (!env->full_set) { + return; + } + #ifdef CONFIG_ZSTD migration_test_add("/migration/multifd/tcp/plain/zstd", test_multifd_tcp_zstd); diff --git a/tests/qtest/migration/cpr-tests.c b/tests/qtest/migration/cpr-tests.c index 215b0df8c0..b1651fe48c 100644 --- a/tests/qtest/migration/cpr-tests.c +++ b/tests/qtest/migration/cpr-tests.c @@ -104,6 +104,10 @@ void migration_test_add_cpr(MigrationTestEnv *env) { tmpfs = env->tmpfs; + if (!env->full_set) { + return; + } + /* * Our CI system has problems with shared memory. * Don't run this test until we find a workaround. diff --git a/tests/qtest/migration/file-tests.c b/tests/qtest/migration/file-tests.c index 84225c8c33..5b190853a5 100644 --- a/tests/qtest/migration/file-tests.c +++ b/tests/qtest/migration/file-tests.c @@ -304,6 +304,10 @@ void migration_test_add_file(MigrationTestEnv *env) { tmpfs = env->tmpfs; + if (!env->full_set) { + return; + } + migration_test_add("/migration/precopy/file", test_precopy_file); diff --git a/tests/qtest/migration/misc-tests.c b/tests/qtest/migration/misc-tests.c index dda3707cf3..996256ef87 100644 --- a/tests/qtest/migration/misc-tests.c +++ b/tests/qtest/migration/misc-tests.c @@ -262,6 +262,10 @@ void migration_test_add_misc(MigrationTestEnv *env) { tmpfs = env->tmpfs; + if (!env->full_set) { + return; + } + migration_test_add("/migration/bad_dest", test_baddest); #ifndef _WIN32 migration_test_add("/migration/analyze-script", test_analyze_script); diff --git a/tests/qtest/migration/postcopy-tests.c b/tests/qtest/migration/postcopy-tests.c index daf7449f2c..b08cde3270 100644 --- a/tests/qtest/migration/postcopy-tests.c +++ b/tests/qtest/migration/postcopy-tests.c @@ -81,6 +81,10 @@ static void test_postcopy_preempt_recovery(void) void migration_test_add_postcopy(MigrationTestEnv *env) { + if (!env->full_set) { + return; + } + if (env->has_uffd) { migration_test_add("/migration/postcopy/plain", test_postcopy); migration_test_add("/migration/postcopy/recovery/plain", diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/precopy-tests.c index 436dbd98e8..c99a487bf1 100644 --- a/tests/qtest/migration/precopy-tests.c +++ b/tests/qtest/migration/precopy-tests.c @@ -955,6 +955,10 @@ void migration_test_add_precopy(MigrationTestEnv *env) { tmpfs = env->tmpfs; + if (!env->full_set) { + return; + } + if (env->is_x86) { migration_test_add("/migration/precopy/unix/suspend/live", test_precopy_unix_suspend_live); diff --git a/tests/qtest/migration/tls-tests.c b/tests/qtest/migration/tls-tests.c index 5704a1f992..aee56930ac 100644 --- a/tests/qtest/migration/tls-tests.c +++ b/tests/qtest/migration/tls-tests.c @@ -726,6 +726,10 @@ void migration_test_add_tls(MigrationTestEnv *env) { tmpfs = env->tmpfs; + if (!env->full_set) { + return; + } + migration_test_add("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 5e062c752a..68316dbdc1 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -405,6 +405,8 @@ foreach dir : target_dirs target_base = dir.split('-')[0] qtest_emulator = emulators['qemu-system-' + target_base] target_qtests = get_variable('qtests_' + target_base, []) + qtests_generic + has_kvm = ('CONFIG_KVM' in config_all_accel and host_os == 'linux' + and cpu == target_base and fs.exists('/dev/kvm')) test_deps = roms qtest_env = environment() @@ -438,11 +440,18 @@ foreach dir : target_dirs test: executable(test, src, dependencies: deps) } endif + + test_args = ['--tap', '-k'] + + if test == 'migration-test' and has_kvm + test_args += ['--full'] + endif + test('qtest-@0@/@1@'.format(target_base, test), qtest_executables[test], depends: [test_deps, qtest_emulator, emulator_modules], env: qtest_env, - args: ['--tap', '-k'], + args: test_args, protocol: 'tap', timeout: slow_qtests.get(test, 60), priority: slow_qtests.get(test, 60), From patchwork Mon Feb 10 16:14:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB0F3C02198 for ; Mon, 10 Feb 2025 16:19:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWRv-0005f9-LO; Mon, 10 Feb 2025 11:15:56 -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 1thWR8-0004Eb-7P for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:06 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR4-0001W1-Ir for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:05 -0500 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5de4d3bbc76so5677339a12.3 for ; Mon, 10 Feb 2025 08:15:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204100; x=1739808900; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1wgsLERHHuZ71dnIxMpojeA2APBNTZ57iSA3i6scrhE=; b=CPCA7uUMLKrw7/qHknGYtgCPXWKI2UlABJfrfs/sZg9ILPE3BQFr7DNLMR1HZnll+Y 5EAcwj9BSf9e4PlIq/1CMchmTcIQcgbmVIRbgpWzWfCChM7F2/9K1l76OfSIV49YlkWP M4wfgQJ4IOvOuyYJE87TKL0NC8JI6fTNmsQxZzZUcLQ6OBpa4E0XSmT7s6icngsC7GtM dJNRPYOnchOvxc3sZuw/kEi3gAZRqzxPVWfpxEcTGaCjopgkoo2nTG2vprIrvvejQJ4I XztZHo127fU44InpsbXstjKRdy3SN1OpFNKYaIsqaI16G3uHc8zlpoE2WuJEq6NK8aD/ IV0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204100; x=1739808900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1wgsLERHHuZ71dnIxMpojeA2APBNTZ57iSA3i6scrhE=; b=Jj6Aa78NbvEApPcVfyaDjESaZDdfRmY6CuccLNgsjotAILZWqw1ll4q3f58pES/+v+ /zz7hXa82GlCXlwjYl+tH999D4DGvc8TCgNGMCobFxpm5580fVDiY4NtLEo9h1D266u7 iRNFhgHMS/s+tb3weydx1jJ3sokKbLkTzdoBiQJ2Beb6XCPPUTaKzEgVHpe5r2w9xdgO imvhxQ35raVCVKsQuAcwILERR+0Nm7iXbrnSGf2GZIl4nbcqET2QFHpD0kTvVkzPTfcp tQgTIIg4CoLCOkF7NRbcECAoJsf090vVxPKX2NFDvk9LwwGWRdvg1LYMOJhHTqK5tUjH CiDg== X-Gm-Message-State: AOJu0Yzm4MpkCQPdJmE0KZh7WukLPPMJQdwUsh3YpnwAiSaRyO4CYsue 6fyDDHp40DzxS9k9IMVwlj1dq0MMEwBb16I1MC+PPG41Rn42L6XcpwxutTxVKJw= X-Gm-Gg: ASbGncuPVuN9/VsPqGE6BxaZ/LVN8YMsKmSGf/WPYSbItVC/bm1GsW3XHv7nccH4R/y A4RTwpq7HK3kt5BInWUZnL9+pfoJU0uAtOI78uDoiKKiOtqwzoTT7hS0WmAWkiOsrTQtYTDeT6l vWLKKXjtV8MITL4bCdUgxqaF0ydqWR0ZUlYOhkjVdmrFSQGbMRaFao1vk9WJ3MgOxITCO/Mg0re kImh9eJUOzbi9RRa2fbXEfxKhowit97Dur/+NnJ0kHMYYK0n9Y4Ppxow599TypyDGvzOfr/ArKY Qd9cVLmivJozwMp3eg== X-Google-Smtp-Source: AGHT+IHufHOT4/sLut4/aGvd+LMrR6n4Df27MJDm0SR1Kw1CbhXcegjSeSQnjqsnF2X4OLHibScEZA== X-Received: by 2002:a05:6402:5409:b0:5dc:8ed9:6bc3 with SMTP id 4fb4d7f45d1cf-5de450734d3mr13539900a12.26.1739204100277; Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5de5b2e4497sm5385155a12.47.2025.02.10.08.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9BDB660342; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier , Paolo Bonzini Subject: [PULL 09/17] tests/qtest/migration: Pick smoke tests Date: Mon, 10 Feb 2025 16:14:43 +0000 Message-Id: <20250210161451.3273284-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x531.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fabiano Rosas Choose a few tests per group and move them from the full set to the smoke set. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu Message-Id: <20250130184012.5711-3-farosas@suse.de> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-10-alex.bennee@linaro.org> diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 61180fcbd5..0893687174 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -46,7 +46,6 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); env = migration_get_env(); env->full_set = full_set; - env->full_set = true; /* temporary */ module_call_init(MODULE_INIT_QOM); migration_test_add_tls(env); diff --git a/tests/qtest/migration/compression-tests.c b/tests/qtest/migration/compression-tests.c index 9d0a258d51..8b58401b84 100644 --- a/tests/qtest/migration/compression-tests.c +++ b/tests/qtest/migration/compression-tests.c @@ -151,10 +151,18 @@ static void test_multifd_tcp_zlib(void) test_precopy_common(&args); } +static void migration_test_add_compression_smoke(MigrationTestEnv *env) +{ + migration_test_add("/migration/multifd/tcp/plain/zlib", + test_multifd_tcp_zlib); +} + void migration_test_add_compression(MigrationTestEnv *env) { tmpfs = env->tmpfs; + migration_test_add_compression_smoke(env); + if (!env->full_set) { return; } @@ -183,7 +191,4 @@ void migration_test_add_compression(MigrationTestEnv *env) migration_test_add("/migration/precopy/unix/xbzrle", test_precopy_unix_xbzrle); } - - migration_test_add("/migration/multifd/tcp/plain/zlib", - test_multifd_tcp_zlib); } diff --git a/tests/qtest/migration/cpr-tests.c b/tests/qtest/migration/cpr-tests.c index b1651fe48c..4758841824 100644 --- a/tests/qtest/migration/cpr-tests.c +++ b/tests/qtest/migration/cpr-tests.c @@ -104,6 +104,8 @@ void migration_test_add_cpr(MigrationTestEnv *env) { tmpfs = env->tmpfs; + /* no tests in the smoke set for now */ + if (!env->full_set) { return; } diff --git a/tests/qtest/migration/file-tests.c b/tests/qtest/migration/file-tests.c index 5b190853a5..f474b3590a 100644 --- a/tests/qtest/migration/file-tests.c +++ b/tests/qtest/migration/file-tests.c @@ -300,17 +300,25 @@ static void test_multifd_file_mapped_ram_fdset_dio(void) } #endif /* !_WIN32 */ +static void migration_test_add_file_smoke(MigrationTestEnv *env) +{ + migration_test_add("/migration/precopy/file", + test_precopy_file); + + migration_test_add("/migration/multifd/file/mapped-ram/dio", + test_multifd_file_mapped_ram_dio); +} + void migration_test_add_file(MigrationTestEnv *env) { tmpfs = env->tmpfs; + migration_test_add_file_smoke(env); + if (!env->full_set) { return; } - migration_test_add("/migration/precopy/file", - test_precopy_file); - migration_test_add("/migration/precopy/file/offset", test_precopy_file_offset); #ifndef _WIN32 @@ -330,9 +338,6 @@ void migration_test_add_file(MigrationTestEnv *env) migration_test_add("/migration/multifd/file/mapped-ram/live", test_multifd_file_mapped_ram_live); - migration_test_add("/migration/multifd/file/mapped-ram/dio", - test_multifd_file_mapped_ram_dio); - #ifndef _WIN32 migration_test_add("/migration/multifd/file/mapped-ram/fdset", test_multifd_file_mapped_ram_fdset); diff --git a/tests/qtest/migration/misc-tests.c b/tests/qtest/migration/misc-tests.c index 996256ef87..d03199f3c5 100644 --- a/tests/qtest/migration/misc-tests.c +++ b/tests/qtest/migration/misc-tests.c @@ -258,18 +258,24 @@ static void test_validate_uri_channels_none_set(void) do_test_validate_uri_channel(&args); } +static void migration_test_add_misc_smoke(MigrationTestEnv *env) +{ +#ifndef _WIN32 + migration_test_add("/migration/analyze-script", test_analyze_script); +#endif +} + void migration_test_add_misc(MigrationTestEnv *env) { tmpfs = env->tmpfs; + migration_test_add_misc_smoke(env); + if (!env->full_set) { return; } migration_test_add("/migration/bad_dest", test_baddest); -#ifndef _WIN32 - migration_test_add("/migration/analyze-script", test_analyze_script); -#endif /* * Our CI system has problems with shared memory. diff --git a/tests/qtest/migration/postcopy-tests.c b/tests/qtest/migration/postcopy-tests.c index b08cde3270..7e84e60fea 100644 --- a/tests/qtest/migration/postcopy-tests.c +++ b/tests/qtest/migration/postcopy-tests.c @@ -79,18 +79,26 @@ static void test_postcopy_preempt_recovery(void) test_postcopy_recovery_common(&args); } -void migration_test_add_postcopy(MigrationTestEnv *env) +static void migration_test_add_postcopy_smoke(MigrationTestEnv *env) { - if (!env->full_set) { - return; - } - if (env->has_uffd) { migration_test_add("/migration/postcopy/plain", test_postcopy); migration_test_add("/migration/postcopy/recovery/plain", test_postcopy_recovery); migration_test_add("/migration/postcopy/preempt/plain", test_postcopy_preempt); + } +} + +void migration_test_add_postcopy(MigrationTestEnv *env) +{ + migration_test_add_postcopy_smoke(env); + + if (!env->full_set) { + return; + } + + if (env->has_uffd) { migration_test_add("/migration/postcopy/preempt/recovery/plain", test_postcopy_preempt_recovery); diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/precopy-tests.c index c99a487bf1..b16f10e908 100644 --- a/tests/qtest/migration/precopy-tests.c +++ b/tests/qtest/migration/precopy-tests.c @@ -951,14 +951,8 @@ static void test_dirty_limit(void) migrate_end(from, to, true); } -void migration_test_add_precopy(MigrationTestEnv *env) +static void migration_test_add_precopy_smoke(MigrationTestEnv *env) { - tmpfs = env->tmpfs; - - if (!env->full_set) { - return; - } - if (env->is_x86) { migration_test_add("/migration/precopy/unix/suspend/live", test_precopy_unix_suspend_live); @@ -970,6 +964,21 @@ void migration_test_add_precopy(MigrationTestEnv *env) test_precopy_unix_plain); migration_test_add("/migration/precopy/tcp/plain", test_precopy_tcp_plain); + migration_test_add("/migration/multifd/tcp/uri/plain/none", + test_multifd_tcp_uri_none); + migration_test_add("/migration/multifd/tcp/plain/cancel", + test_multifd_tcp_cancel); +} + +void migration_test_add_precopy(MigrationTestEnv *env) +{ + tmpfs = env->tmpfs; + + migration_test_add_precopy_smoke(env); + + if (!env->full_set) { + return; + } migration_test_add("/migration/precopy/tcp/plain/switchover-ack", test_precopy_tcp_switchover_ack); @@ -993,16 +1002,12 @@ void migration_test_add_precopy(MigrationTestEnv *env) test_dirty_limit); } } - migration_test_add("/migration/multifd/tcp/uri/plain/none", - test_multifd_tcp_uri_none); migration_test_add("/migration/multifd/tcp/channels/plain/none", test_multifd_tcp_channels_none); migration_test_add("/migration/multifd/tcp/plain/zero-page/legacy", test_multifd_tcp_zero_page_legacy); migration_test_add("/migration/multifd/tcp/plain/zero-page/none", test_multifd_tcp_no_zero_page); - migration_test_add("/migration/multifd/tcp/plain/cancel", - test_multifd_tcp_cancel); if (g_str_equal(env->arch, "x86_64") && env->has_kvm && env->has_dirty_ring) { diff --git a/tests/qtest/migration/tls-tests.c b/tests/qtest/migration/tls-tests.c index aee56930ac..2cb4a44bcd 100644 --- a/tests/qtest/migration/tls-tests.c +++ b/tests/qtest/migration/tls-tests.c @@ -722,10 +722,18 @@ static void test_multifd_tcp_tls_x509_reject_anon_client(void) } #endif /* CONFIG_TASN1 */ +static void migration_test_add_tls_smoke(MigrationTestEnv *env) +{ + migration_test_add("/migration/precopy/tcp/tls/psk/match", + test_precopy_tcp_tls_psk_match); +} + void migration_test_add_tls(MigrationTestEnv *env) { tmpfs = env->tmpfs; + migration_test_add_tls_smoke(env); + if (!env->full_set) { return; } @@ -755,8 +763,6 @@ void migration_test_add_tls(MigrationTestEnv *env) test_precopy_unix_tls_x509_override_host); #endif /* CONFIG_TASN1 */ - migration_test_add("/migration/precopy/tcp/tls/psk/match", - test_precopy_tcp_tls_psk_match); migration_test_add("/migration/precopy/tcp/tls/psk/mismatch", test_precopy_tcp_tls_psk_mismatch); #ifdef CONFIG_TASN1 From patchwork Mon Feb 10 16:14:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5E04C0219B for ; Mon, 10 Feb 2025 16:23:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWS9-0006gZ-Cb; Mon, 10 Feb 2025 11:16:09 -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 1thWR9-0004Kg-6h for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:09 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR5-0001WB-Eb for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:06 -0500 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-ab7d451f7c4so58244866b.0 for ; Mon, 10 Feb 2025 08:15:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204100; x=1739808900; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=drUSqKJyol0KqcrQAykb+B2rcXTaSjubQI7HNVc4K6M=; b=EQ3NXv5LhYDpbgICW+p5kJoUpzNKnG4NOhmp7gN7dduhwfTPo9HztwYOMjeN9h0Mst orrgJw9BCxq0/peQ20/QX1kOpOLFajpmd+cUHF5hlboTWAS54uOebJu4fOZAO3URiQlG 8GRsyjQ2/4yRysLBdWqwGX1OIEkXNe97SKlF3IZk/u59nzJVF+OXt/NQK6lQMuq68toV woTQ4CBqrWttAc4ebeGE6SvVKL+CMsrLvWYH1tI7IC7kMhqT4Lk38gDEfFRcbO1IVhcw XMZwOodhMpeeDGBRahd9eh8KPbMuUPG6MA00JOTRNGV4WpzwzNjGUyh8LIGn3pLPfQsF YRwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204100; x=1739808900; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=drUSqKJyol0KqcrQAykb+B2rcXTaSjubQI7HNVc4K6M=; b=Qn8hd5j+mVxOcO3/xWPOZBhuZ8xaKjQnanTPQ9njE9LuC8EcToSIys/yM0SmaFC8fK qIgNJHcl3zyqe02c6VoqO1JAPy4S/e5R4HIftF1tjHerNeuZATlATKXGpAwGg+2wE9rk HpAyHlziMGUDMVLLz4E7JS1hcJo2E/zpj8fa6Q9V2g8noqDZm1i2hiaACGWSt+XcV3G4 Z8S5S2ueycNIIxSd+OK37lzuh3pQZjcs9fhlOdJL+C3+skO4NSG8b6Ze8O9ffWOEd0pv XJ9iHbPUM38CP50HnCVAsGV9AQ6+65yNYuYFxxzVDcdRxMIiHduKBOQ8vFSo6vXBVkt0 tmuA== X-Gm-Message-State: AOJu0Yzyr9MoTQabHqHew2Wszdg+XrvZW99QYDXmsGqpomeWx96RNgOz fMk/eiPdzmXrJKQ36FBujTuyfdWInFVt/J+DIn2k5WA51cxZacTAwKrrtbhNZT8= X-Gm-Gg: ASbGnctGFQN5aqYxKe5xZO+WkpN/SogxLt6NqAUMJzxHeB0v86cBPWgIludHs1ba81p YoeGniIVVfGEgnG7l/g4SZa3b4VqFRAdedsqWb6KL2UE+XCuHqrV7J4kzP18EluG4HR8s5P4AnS PHaly7R8sOYNmDiOAlJERolAtp15rHuQgH0kSMkQxRqowouZ7gpQnDItQCvk7i8YVBMb1EcEI+Y 0C7Ehi2Nczjs3+jjppFwoZy10tM8jVzjD67Z5AsgWXkXggsMog0P7VtwRbPOFyQMc6OFn3Ra5Dx 8wvq3zxUxOwmiM5F6w== X-Google-Smtp-Source: AGHT+IHb5RndRI06xl37JMWMbMARZvkmIYowTjDXqIdy4SANlVpPE0LB6SOC8VryYlW8/4iTdNv2TQ== X-Received: by 2002:a17:906:7955:b0:ab7:cedc:4b13 with SMTP id a640c23a62f3a-ab7cedc4c5bmr271617666b.34.1739204100593; Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7d243bb58sm81258066b.141.2025.02.10.08.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:14:57 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B0E9B60353; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Warner Losh , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 10/17] gdbstub: Allow the %d placeholder in the socket path Date: Mon, 10 Feb 2025 16:14:44 +0000 Message-Id: <20250210161451.3273284-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x629.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich Just like for QEMU_LOG_FILENAME, replace %d with PID in the GDB socket path. This allows running multi-process applications with, e.g., export QEMU_GDB=/tmp/qemu-%d.sock. Currently this is not possible, since the first process will cause the subsequent ones to fail due to not being able to bind() the GDB socket. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich Message-Id: <20250117001542.8290-2-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-11-alex.bennee@linaro.org> diff --git a/gdbstub/user.c b/gdbstub/user.c index c2bdfc3d49..fd29d595f4 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -317,9 +317,19 @@ static bool gdb_accept_socket(int gdb_fd) static int gdbserver_open_socket(const char *path) { + g_autoptr(GString) buf = g_string_new(""); struct sockaddr_un sockaddr = {}; + char *pid_placeholder; int fd, ret; + pid_placeholder = strstr(path, "%d"); + if (pid_placeholder != NULL) { + g_string_append_len(buf, path, pid_placeholder - path); + g_string_append_printf(buf, "%d", qemu_get_thread_id()); + g_string_append(buf, pid_placeholder + 2); + path = buf->str; + } + fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) { perror("create socket"); From patchwork Mon Feb 10 16:14:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D65B1C02198 for ; Mon, 10 Feb 2025 16:17:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWSD-0006wV-EL; Mon, 10 Feb 2025 11:16: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 1thWRB-0004NX-Cy for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:09 -0500 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR6-0001XJ-PJ for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:08 -0500 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-ab7b80326cdso238870466b.3 for ; Mon, 10 Feb 2025 08:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204103; x=1739808903; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YT3MtmnSLkBKcOVyMB0JztX76L81nkooZxZXsqcklIs=; b=Ct6YfJaKa2Ka+A34mWwgmMA+wEpIwQ4BUKa6BNZFJeUrC6J1TX9AwuFAgCbs3ZlPzj LlTtmRZguks4MXGkHuIWsDX7czsGfjZjEDp6qewwqW0RKLjZ92/iRuMz2ppu30pyW++P pMqrdE9cFuQKgxVEnWWKekRBQhL7DReHuvIGv6j92gksid+gW53LYPn6eKnYorXjc39I DLqMY4ELq+uaYm+TKdGH+v8puMYrZhUVeNF2RZTgBKMQ1q97lqQ8tA4hpV+PfaunLtHQ x8TMbr4pjJGlGPmX1krY8kWJsySiVQmpyzuoxsOqoMZ4uIiKqfv/OsdivE29TPi97G29 VExg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204103; x=1739808903; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YT3MtmnSLkBKcOVyMB0JztX76L81nkooZxZXsqcklIs=; b=VVSlTx5IHT0S3q8byaxdJw+KSFqOIpMTSpm26RL7QsgAhRSeBJ2yDvW8hxXjF3tmF2 X3hhqLeNIS2+/apWZOs0Gte2ohP+PB/6h/KaqIP8VlzzUkhtiPNw7tXCy/94cdpB+D5B XZPdH39ubT2gfZS0Y+0+BSVUKQgZGj6Hp5F5IXmvAPBDQTCM2ZNj5ZNYkdhLZcM5Jipj lHxCWA2C5/1dvlDLDJ6DedHek+qG9CKATu9xbAfjw/RzZ2Cv+kB+a/DwMARELVNDJcZn 5goazC5/JgfxuKkKVmBqS3G11rn25skdL9+ZUm/L5d7hMCJIf3FS6ubs2ScvktrrBQgN /dGQ== X-Gm-Message-State: AOJu0YwzHQdZzwFmA7zo44znOW/ZLvTaXKiRCV7qOsd/bT2xgTglWS2c lB4/4pCKerxch4g5TwAtQfCmdewJB8wpfuews4hcJy4ZsLuGQat5ka47bPCUHr8= X-Gm-Gg: ASbGncso+SUnY8t0oTxhCeymgXtU238aWMEc/oUwQLZgtIJHDc05k2+l31PZYNyLrd4 J3k+PYYN5fnDr1erSqXokiIU9wfgqHFI9Wau4bsSKtTPYolbNh8yGiZTUmVFliX5oZF06AX9Z8f 63obx0pewKFBvNptqCx6aQgyqe6FteDCP4A/DOVLmJ+k+fXsGMOnEqePFB9phHpFEQmpOKqoMM9 Or4IX6uZQnD/0vw5f2498R4920VULzwy4811SQKaZNw/Zr/TaCTworfPcNDx4rL9591G0zPx501 sVpD4d1vix3H1DZZyw== X-Google-Smtp-Source: AGHT+IG7BXxMQc+AY0CbJDer036tQ93MEsDG2oNxFJ6I5mNOrN8SCnNKi9SGXVyjFfhevbbjqNB7Bg== X-Received: by 2002:a17:907:d92:b0:ab7:b068:c7b9 with SMTP id a640c23a62f3a-ab7b068c7d9mr696240266b.13.1739204103126; Mon, 10 Feb 2025 08:15:03 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7bbf40b2bsm291680466b.23.2025.02.10.08.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id C773960354; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Paolo Bonzini Subject: [PULL 11/17] gdbstub: Try unlinking the unix socket before binding Date: Mon, 10 Feb 2025 16:14:45 +0000 Message-Id: <20250210161451.3273284-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62b.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich In case an emulated process execve()s another emulated process, bind() will fail, because the socket already exists. So try deleting it. Use the existing unix_listen() function which does this. Link qemu-user with qemu-sockets.c and add the monitor_get_fd() stub. Note that it is not possible to handle this in do_execv(): deleting gdbserver_user_state.socket_path before safe_execve() is not correct, because the latter may fail, and afterwards we may lose control. Signed-off-by: Ilya Leoshkevich Reviewed-by: Alex Bennée Message-Id: <20250117001542.8290-3-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-12-alex.bennee@linaro.org> diff --git a/gdbstub/user.c b/gdbstub/user.c index fd29d595f4..8225b70280 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -315,12 +315,10 @@ static bool gdb_accept_socket(int gdb_fd) return true; } -static int gdbserver_open_socket(const char *path) +static int gdbserver_open_socket(const char *path, Error **errp) { g_autoptr(GString) buf = g_string_new(""); - struct sockaddr_un sockaddr = {}; char *pid_placeholder; - int fd, ret; pid_placeholder = strstr(path, "%d"); if (pid_placeholder != NULL) { @@ -330,28 +328,7 @@ static int gdbserver_open_socket(const char *path) path = buf->str; } - fd = socket(AF_UNIX, SOCK_STREAM, 0); - if (fd < 0) { - perror("create socket"); - return -1; - } - - sockaddr.sun_family = AF_UNIX; - pstrcpy(sockaddr.sun_path, sizeof(sockaddr.sun_path) - 1, path); - ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); - if (ret < 0) { - perror("bind socket"); - close(fd); - return -1; - } - ret = listen(fd, 1); - if (ret < 0) { - perror("listen socket"); - close(fd); - return -1; - } - - return fd; + return unix_listen(path, errp); } static bool gdb_accept_tcp(int gdb_fd) @@ -424,7 +401,7 @@ bool gdbserver_start(const char *port_or_path, Error **errp) if (port > 0) { gdb_fd = gdbserver_open_port(port, errp); } else { - gdb_fd = gdbserver_open_socket(port_or_path); + gdb_fd = gdbserver_open_socket(port_or_path, errp); } if (gdb_fd < 0) { diff --git a/stubs/monitor-fd.c b/stubs/monitor-fd.c new file mode 100644 index 0000000000..9bb6749885 --- /dev/null +++ b/stubs/monitor-fd.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "monitor/monitor.h" + +int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp) +{ + abort(); +} diff --git a/stubs/meson.build b/stubs/meson.build index a8b3aeb564..b0fee37e05 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -61,6 +61,8 @@ if have_user if not have_system stub_ss.add(files('qdev.c')) endif + + stub_ss.add(files('monitor-fd.c')) endif if have_system diff --git a/util/meson.build b/util/meson.build index 5d8bef9891..780b5977a8 100644 --- a/util/meson.build +++ b/util/meson.build @@ -84,6 +84,8 @@ if have_block or have_ga util_ss.add(files('qemu-coroutine.c', 'qemu-coroutine-lock.c', 'qemu-coroutine-io.c')) util_ss.add(files(f'coroutine-@coroutine_backend@.c')) util_ss.add(files('thread-pool.c', 'qemu-timer.c')) +endif +if have_block or have_ga or have_user util_ss.add(files('qemu-sockets.c')) endif if have_block From patchwork Mon Feb 10 16:14:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6A6EC0219B for ; Mon, 10 Feb 2025 16:19:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWSc-0008N2-JB; Mon, 10 Feb 2025 11:16:39 -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 1thWRD-0004U9-AG for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:14 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWRB-0001YO-6y for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:10 -0500 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5de47cf9329so5406379a12.3 for ; Mon, 10 Feb 2025 08:15:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204106; x=1739808906; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2LwehABNpz+elHyUtu6V8SdPZXAtvSq5keb1F8SzdXM=; b=D2d6BZ7hD6gYCrk/Cz+T6xy3mO5H1wOofwV5xkMyuZUi7fhPUg0MD23H3fOo4BowTb 7nIBdHC5D+PkISjymsKThnELhJpwnA9Hyw6lUcqWXWfclJKPM0tibaIdoOneySzF6VYL D99jEMAEci3RREB8TEwhKusB/QJnjj4gC4dtugjMIW34XfeFmttQsyk3IMNyJobkPXNB LnZU6EUoqE52iT8kf9x12knGQSPeVGer1E/UwlPOkLHjbtT8BkxiUH34wC6tf+VJrqxJ o0RfLD5CkcJ/IpQYbfwBHCSJro6LMHQ+qOyNihjr0Ul/7jpxwUjPm6/Fc0khVbFtfA5J 1q9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204106; x=1739808906; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2LwehABNpz+elHyUtu6V8SdPZXAtvSq5keb1F8SzdXM=; b=ThfanZYauaOFLPO2NYormwuWeEZSBaF2NjIxnHJ/3koTw7XuG5AI6wY3UMDVb7FGu0 FISh/IzjpHlgimB9+zjbcGsucn6UR9aGSOFv8qxE94VUi9zjvpAUDX+BEfVE7n1yiHjQ TklMp6VWsnPmvgsbzaT9fejvYzHCba3/2wn0gFkUABLeZzucmqjZtJhkX8LIBvkT1vUO G201kn8XLKReetZpf7DBg9T9jb6bmRDHGgN/wHP3ki9WJCO6htQovplGk85tljJvdyiF ReVX7EsJ74AuvqvebhUUPDI9BF/KV6KhWkRU5jYxRjF6uRF3KkwU8pNcb1HT6L6Gl1So KNjw== X-Gm-Message-State: AOJu0Yzn9w/uxL1Juh1oJMED/5dMUl2vIG8OocLEUnrECvjAESN8Elme +/SLqqKOhGbDTeiulBeA1xgFbH619Jeyvv44t1pvysKxeDmlCiZLn/TY8AFgxo4= X-Gm-Gg: ASbGncufk4dPE9g3btMt2GQpuE6JrcLOTHtSu5NrMMhNhgRroyMmf5wHNlWxz0gUdpw AM/vAVmYQRVOg4n3iIaENzpvNPCL0Ur3xRxRfe0aa9Xupf0j4Xw4wo6DXpjxcCSQmmPEmqbZ07/ w143YjswF1YkddgY1l0Y4iV96e9HsVbGzWtW9i1PGIBEaxv/1zlRVFMlcmRdquKIsTcUiVJv2Qe dAnJc37GxIc3itjUl3eifTi0FivACn0XAgnHPtCdGc9UmfS/NwiKVlRbpPpxdTV2E4YgSjwBgbt J4pqksfBxApz6YE0zg== X-Google-Smtp-Source: AGHT+IFOwSSx7A2I4US7tcl8+SmC6mwVYsew2ms96Muhvxz4xciy4wJngym67uJ3E2Mr17d6Tu5RtQ== X-Received: by 2002:a05:6402:358e:b0:5db:731d:4456 with SMTP id 4fb4d7f45d1cf-5de9a4c86cbmr248743a12.28.1739204106312; Mon, 10 Feb 2025 08:15:06 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5de5ef7029asm4934287a12.58.2025.02.10.08.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E0D096037E; Mon, 10 Feb 2025 16:14:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Warner Losh , =?utf-8?q?Alex_Benn=C3=A9e?= , Kyle Evans , Riku Voipio , Laurent Vivier Subject: [PULL 12/17] user: Introduce user/signal.h Date: Mon, 10 Feb 2025 16:14:46 +0000 Message-Id: <20250210161451.3273284-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x536.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich gdbstub needs target_to_host_signal(), so move its declaration to a public header. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich Message-Id: <20250117001542.8290-4-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-13-alex.bennee@linaro.org> diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h index 77d7c7a78b..4e634e04a3 100644 --- a/bsd-user/signal-common.h +++ b/bsd-user/signal-common.h @@ -42,7 +42,6 @@ void process_pending_signals(CPUArchState *env); void queue_signal(CPUArchState *env, int sig, int si_type, target_siginfo_t *info); void signal_init(void); -int target_to_host_signal(int sig); void target_to_host_sigset(sigset_t *d, const target_sigset_t *s); /* diff --git a/include/user/signal.h b/include/user/signal.h new file mode 100644 index 0000000000..19b6b9e5dd --- /dev/null +++ b/include/user/signal.h @@ -0,0 +1,23 @@ +/* + * Signal-related declarations. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef USER_SIGNAL_H +#define USER_SIGNAL_H + +#ifndef CONFIG_USER_ONLY +#error Cannot include this header from system emulation +#endif + +/** + * target_to_host_signal: + * @sig: target signal. + * + * On success, return the host signal between 0 (inclusive) and NSIG + * (exclusive) corresponding to the target signal @sig. Return any other value + * on failure. + */ +int target_to_host_signal(int sig); + +#endif diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 8584d9ecc2..196d2406f8 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -61,7 +61,6 @@ void queue_signal(CPUArchState *env, int sig, int si_type, target_siginfo_t *info); void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info); void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo); -int target_to_host_signal(int sig); int host_to_target_signal(int sig); long do_sigreturn(CPUArchState *env); long do_rt_sigreturn(CPUArchState *env); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index b4e1458237..8c51f6ce65 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -24,6 +24,7 @@ #include "user/cpu_loop.h" #include "exec/page-protection.h" #include "user/page-protection.h" +#include "user/signal.h" #include "user/tswap-target.h" #include "gdbstub/user.h" #include "signal-common.h" diff --git a/linux-user/signal.c b/linux-user/signal.c index 087c4d270e..bffbef235c 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -36,6 +36,7 @@ #include "user/cpu_loop.h" #include "user/page-protection.h" #include "user/safe-syscall.h" +#include "user/signal.h" #include "tcg/tcg.h" /* target_siginfo_t must fit in gdbstub's siginfo save area. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6ee02383da..90afaa4426 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -138,6 +138,7 @@ #include "user-mmap.h" #include "user/page-protection.h" #include "user/safe-syscall.h" +#include "user/signal.h" #include "qemu/guest-random.h" #include "qemu/selfmap.h" #include "user/syscall-trace.h" From patchwork Mon Feb 10 16:14:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F489C02198 for ; Mon, 10 Feb 2025 16:21:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWS4-0006Q4-GP; Mon, 10 Feb 2025 11:16:04 -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 1thWRB-0004NW-Cb for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:09 -0500 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR6-0001X8-Ne for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:07 -0500 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-ab7cc0c1a37so142672066b.0 for ; Mon, 10 Feb 2025 08:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204102; x=1739808902; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4YSWMGdWl+8666egd7dZYOBYPozxtU1KxGkBOuAirDQ=; b=Nyyh2ewhHyN1icQhR2BAO/wC2g2q48u2Qmsdvni7XlPIdkEPCESX3tl3viRNyfuaEY b8KMqSP1YAcjj1Gh4Ws4ykZRgZlQFde8zEtClZGzVe4WazvYaZB2ZX+bmsY12Yil8rwQ cWnwIFyXaSuno1RujisJluO2iPl5QpSAh+dW/ZgkhJt0Z4GDukJ9X0hdC3X0L3Xlz/Rv F9L6uQI+w6mTRASKLTkMIrJI1hcSXXpl95ZsT/4UkUBLJcth+QMOROvEleWpEL/R3x3Z sP8BGDuNTReDIuHODgfE/7QRLbFP5kaoCYzhgUpw9uyM40cbEGQl/2ecotk7vEM678eg OT6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204102; x=1739808902; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4YSWMGdWl+8666egd7dZYOBYPozxtU1KxGkBOuAirDQ=; b=PhOggnl60QbHB/sBsBtuPcNS2bn/GaoaHb9/YSeI/dGENbOdllWWwjnpucwDuVO2rj rWYsLBwgkgAI7a3KUZPrs/ZwM/t1ZFpwD1WPYfgbIFM7uRSizg1yiwCSfg9qulmUjAz1 QfBg1tXmTk2KqMqVkkAZ1gOWNROEunfmf1Fo71khqBmLEntyqVG2XH5t5EwPO72M9ldg Ea4GEzrhVTNqwxhlxMhAkqAj6TP0NSEt+pF9UQ0VO6yopzfqecpnQyJagD/DCVzT/9w+ c8HAz4tPdRCBx99Dk+vhtFnI3S0TXUtqiMHvk6RwnXBXZIGBOciQCS/cQ+xTnsmd2qed y9Sg== X-Gm-Message-State: AOJu0Yx6XbN5EwgxpAAYKWblCmylKKbcZ2/YYM/5FN1LGbCqTVvbmzNe y/B8f7CyFq2KEFPsUJKfX2dOLOVkzQ3BRJXSG/HzaGpkwTgeumUd/WEoZpelsN8= X-Gm-Gg: ASbGnctWGTF5Alnm0TJUVuBFZQDaYCG4LKlQPGNk0RJR47JFEU+ig1M9XZINqs9tQVi 6CJPeijutYlMorcHjnWwuZ0IK4jjzJpTRRIwCJBGP4xzHPiJiPgElzLT2YmDG17q1c2w3af5og8 I+eVhVZ7k0FJD+imTK4AJ88rWv8p9wVqpmHwc8eeHAc/AQQGxwCj9ZdHy8PeRvv+7gagSPPH9zv 7rItaNWlYQEBfKY2BsTm7VM5rvQKfcGgavjrODxy33Frvtd24JgEVYvUx3nBByjuHOglCtlah3m zdOpq/LGt0OCJA3Wyw== X-Google-Smtp-Source: AGHT+IFvWeP7Cc/rgbQ2LL18D+kQ0m3lplavqv9M9F0opj5SfDa/12SdXHVq4EqfHgkS/9AAVGWKaQ== X-Received: by 2002:a17:907:948f:b0:aa6:5d30:d971 with SMTP id a640c23a62f3a-ab789a688b5mr1460165866b.11.1739204102396; Mon, 10 Feb 2025 08:15:02 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7d4d291bdsm55686866b.17.2025.02.10.08.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 0200060384; Mon, 10 Feb 2025 16:14:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Warner Losh , =?utf-8?q?Alex_Benn=C3=A9e?= , Kyle Evans , Riku Voipio , Laurent Vivier Subject: [PULL 13/17] user: Introduce host_interrupt_signal Date: Mon, 10 Feb 2025 16:14:47 +0000 Message-Id: <20250210161451.3273284-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x636.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich Attaching to the gdbstub of a running process requires stopping its threads. For threads that run on a CPU, cpu_exit() is enough, but the only way to grab attention of a thread that is stuck in a long-running syscall is to interrupt it with a signal. Reserve a host realtime signal for this, just like it's already done for TARGET_SIGABRT on Linux. This may reduce the number of available guest realtime signals by one, but this is acceptable, since there are quite a lot of them, and it's unlikely that there are apps that need them all. Set signal_pending for the safe_sycall machinery to prevent invoking the syscall. This is a lie, since we don't queue a guest signal, but process_pending_signals() can handle the absence of pending signals. The syscall returns with QEMU_ERESTARTSYS errno, which arranges for the automatic restart. This is important, because it helps avoiding disturbing poorly written guests. Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich Message-Id: <20250117001542.8290-5-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-14-alex.bennee@linaro.org> diff --git a/include/user/signal.h b/include/user/signal.h index 19b6b9e5dd..7fa33b05d9 100644 --- a/include/user/signal.h +++ b/include/user/signal.h @@ -20,4 +20,6 @@ */ int target_to_host_signal(int sig); +extern int host_interrupt_signal; + #endif diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 8c51f6ce65..ff2ccbbf60 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -51,6 +51,8 @@ static inline int sas_ss_flags(TaskState *ts, unsigned long sp) on_sig_stack(ts, sp) ? SS_ONSTACK : 0; } +int host_interrupt_signal = SIGRTMAX; + /* * The BSD ABIs use the same signal numbers across all the CPU architectures, so * (unlike Linux) these functions are just the identity mapping. This might not @@ -491,6 +493,12 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) uintptr_t pc = 0; bool sync_sig = false; + if (host_sig == host_interrupt_signal) { + ts->signal_pending = 1; + cpu_exit(thread_cpu); + return; + } + /* * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special * handling wrt signal blocking and unwinding. @@ -854,6 +862,9 @@ void signal_init(void) for (i = 1; i <= TARGET_NSIG; i++) { host_sig = target_to_host_signal(i); + if (host_sig == host_interrupt_signal) { + continue; + } sigaction(host_sig, NULL, &oact); if (oact.sa_sigaction == (void *)SIG_IGN) { sigact_table[i - 1]._sa_handler = TARGET_SIG_IGN; @@ -872,6 +883,7 @@ void signal_init(void) sigaction(host_sig, &act, NULL); } } + sigaction(host_interrupt_signal, &act, NULL); } static void handle_pending_signal(CPUArchState *env, int sig, diff --git a/linux-user/signal.c b/linux-user/signal.c index bffbef235c..81a98c6d02 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -517,6 +517,8 @@ static int core_dump_signal(int sig) } } +int host_interrupt_signal; + static void signal_table_init(const char *rtsig_map) { int hsig, tsig, count; @@ -580,10 +582,10 @@ static void signal_table_init(const char *rtsig_map) * Attempts for configure "missing" signals via sigaction will be * silently ignored. * - * Reserve one signal for internal usage (see below). + * Reserve two signals for internal usage (see below). */ - hsig = SIGRTMIN + 1; + hsig = SIGRTMIN + 2; for (tsig = TARGET_SIGRTMIN; hsig <= SIGRTMAX && tsig <= TARGET_NSIG; hsig++, tsig++) { @@ -604,12 +606,17 @@ static void signal_table_init(const char *rtsig_map) host_to_target_signal_table[SIGABRT] = 0; for (hsig = SIGRTMIN; hsig <= SIGRTMAX; hsig++) { if (!host_to_target_signal_table[hsig]) { - host_to_target_signal_table[hsig] = TARGET_SIGABRT; - break; + if (host_interrupt_signal) { + host_to_target_signal_table[hsig] = TARGET_SIGABRT; + break; + } else { + host_interrupt_signal = hsig; + } } } if (hsig > SIGRTMAX) { - fprintf(stderr, "No rt signals left for SIGABRT mapping\n"); + fprintf(stderr, + "No rt signals left for interrupt and SIGABRT mapping\n"); exit(EXIT_FAILURE); } @@ -689,6 +696,8 @@ void signal_init(const char *rtsig_map) } sigact_table[tsig - 1]._sa_handler = thand; } + + sigaction(host_interrupt_signal, &act, NULL); } /* Force a synchronously taken signal. The kernel force_sig() function @@ -1036,6 +1045,12 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) bool sync_sig = false; void *sigmask; + if (host_sig == host_interrupt_signal) { + ts->signal_pending = 1; + cpu_exit(thread_cpu); + return; + } + /* * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special * handling wrt signal blocking and unwinding. Non-spoofed SIGILL, From patchwork Mon Feb 10 16:14:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6F407C02198 for ; Mon, 10 Feb 2025 16:20:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWS2-0006G2-K1; Mon, 10 Feb 2025 11:16: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 1thWR9-0004Ki-7k for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:09 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR5-0001Wp-M6 for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:06 -0500 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-aaf0f1adef8so851613566b.3 for ; Mon, 10 Feb 2025 08:15:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204102; x=1739808902; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ayP8EMcB4Qo24WwN/jtc5LLSaKf0jilqA/YV1+mpnK0=; b=JRQGeReuSpfteDx0HCnwAoKkKJ+kiRQlqx60X8rIXtHcUzEb/0GtDw+9AOCuK77bWO +7QsXxyFlBj+sO58mUTArzdOKt7fb6aDX90rsfbyZOf992ogvrKBsw7GIH4RipU7kMZW cUBjrALDSOvxuru0GwJDDk2y4YjvP4XxsyPZeGajLafvZUHW4hl4MLqUAeaEW2uyJKev AvzeHV3rHFx/5EIzg9FWFzyvAKJ+weQUXFjgzAmE77qzqHzx3yRPcdP1SwbCytUM9cpD VqbiZMzNMol7Czu7KUHfufBZgjK3A3pbbIMEuBNCo+OSPQZxzMh4Db7rAOMcBX953owb iWvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204102; x=1739808902; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ayP8EMcB4Qo24WwN/jtc5LLSaKf0jilqA/YV1+mpnK0=; b=VVppUA4kNCY0D+GtbWKTkGgXj3IyZtxbtAIhhjzfe2mQUBtxCmnhC7Q6sIn9sbIjwB 6DyW42T7nMWibiwlpsIB+l/fJVOPVW0yjsQGMZ25R7QMB4C+fG8bCWdKeULaQhh/SD9t y+Eha0u/gvgFCqVjxOR9z9TDxyvSouO4B+gjg3h9s52BthYERiX6Vit/FbjJusas2wnB 52qxw5JS7JNXs61f4mZGMw1oZ9M/ZH4pkc1Pkf9hJqfWqT3r+Yc105jM6lxeh5axCCRB 9ElB/NWD7cGyfNi4sbBQsnAjQERPw9msh5eXKOFaQME1HiIYdn3B7jNP1u2lnUzSckTv Yyvg== X-Gm-Message-State: AOJu0YyaqOa+/DVRJ5EAb9h7oIJz1RvYpD27KdddP/WI0nFt+0SjqPrh Q8a1x3IdMbNeSKJSHH2ZrVBPsDyXQZRpeFbevt+YvOFPNlTjXSUL3rCOuoNnbB4= X-Gm-Gg: ASbGnctMi4gQ9gckWGy9K7ftp7/gMGQ4tCdQiTv6ilLWxqTpAqes4doPEvl8/K5lThh e6tC9Sf3X41KH9aeV9ilro+Rru0Bb+WSs4IUDx4gyMfWK/opIP4VS+BbJGIdy18/Zc19IJsYytt Nn925SPcTw38vVoywu8Y9FO2xTBocHMeZfmo2mByOww+KKQYMN9gpY+xuJfXMBaQPWXoluxkbxf 0XEiQwxqRKC2o4mlPlkDN6+hmbSEMna/FIsrfQfDaEZ293/Ye3PZO7uia8SZSxr+0tx5F+2DnOY UEdzA1FYZ7ouQXFZwg== X-Google-Smtp-Source: AGHT+IGnlyu5ebeRHeiaLSsB375w2OCuIlG6sB8aKp3v/B0FTzN5Reo34uQ+XFkLNiFLzM8QQQP3NQ== X-Received: by 2002:a17:907:1c95:b0:ab7:c94f:af7c with SMTP id a640c23a62f3a-ab7c94fb325mr332235466b.14.1739204101880; Mon, 10 Feb 2025 08:15:01 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7d3b9d85asm67650866b.53.2025.02.10.08.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 14A0260387; Mon, 10 Feb 2025 16:14:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Richard Henderson , Warner Losh , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini Subject: [PULL 14/17] osdep: Introduce qemu_kill_thread() Date: Mon, 10 Feb 2025 16:14:48 +0000 Message-Id: <20250210161451.3273284-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62a.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich Add a function for sending signals to individual threads. It does not make sense on Windows, so do not provide an implementation, so that if someone uses it by accident, they will get a linker error. Reviewed-by: Richard Henderson Reviewed-by: Warner Losh Signed-off-by: Ilya Leoshkevich Message-Id: <20250117001542.8290-6-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-15-alex.bennee@linaro.org> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 112ebdff21..4397a90680 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -631,6 +631,15 @@ bool qemu_write_pidfile(const char *pidfile, Error **errp); int qemu_get_thread_id(void); +/** + * qemu_kill_thread: + * @tid: thread id. + * @sig: host signal. + * + * Send @sig to one of QEMU's own threads with identifier @tid. + */ +int qemu_kill_thread(int tid, int sig); + #ifndef CONFIG_IOVEC struct iovec { void *iov_base; diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 2bb34dade3..a697c602c6 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -111,6 +111,21 @@ int qemu_get_thread_id(void) #endif } +int qemu_kill_thread(int tid, int sig) +{ +#if defined(__linux__) + return syscall(__NR_tgkill, getpid(), tid, sig); +#elif defined(__FreeBSD__) + return thr_kill2(getpid(), tid, sig); +#elif defined(__NetBSD__) + return _lwp_kill(tid, sig); +#elif defined(__OpenBSD__) + return thrkill(tid, sig, NULL); +#else + return kill(tid, sig); +#endif +} + int qemu_daemon(int nochdir, int noclose) { return daemon(nochdir, noclose); From patchwork Mon Feb 10 16:14:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF6C5C02198 for ; Mon, 10 Feb 2025 16:25:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWSK-0007aL-Jt; Mon, 10 Feb 2025 11:16:21 -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 1thWRB-0004Na-DO for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:09 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR8-0001Xi-Eb for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:08 -0500 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-aaec111762bso1104726866b.2 for ; Mon, 10 Feb 2025 08:15:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204105; x=1739808905; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cv/0HiWib5mVBaxSrAfp5Uz9fY8LMI2bjBnu/BWf/Z8=; b=YixDZ3bIvRxfnxLxzhKcXQK6rfbvkF63/ysNvMdc9VK5yvxoY4MT+jVDuSuZOgl+VV hvWGnex+SERc8l2Fcf9nQn3GOmLO1DYIWlKmf/nouDix5/yMLDU6/M7T+3mA1HCAS6Q4 M6zAnAaU5p5fDvBIeOT8ciI57sjva9eyFgKLTTRkYLOEwnbxqtNSu0AXOl7t/OJv1lmc XX1NL8u0t7rnIyEpiWL7djiSDR6cc2sQp+SlJTpACgHbBg8jm54rseIjU+RmIVZw0Ns6 FAvT2V98bmKRiuaAhqG2Bqay4ThXQM7aZFRm4mwIhmPHOsDx+ZWMeefcD/ZtNCJh7CD1 WzCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204105; x=1739808905; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cv/0HiWib5mVBaxSrAfp5Uz9fY8LMI2bjBnu/BWf/Z8=; b=Bpm5sQblTiYdUUg9mlBBGdFD6JwBYMhIxnnWiBvAmuIHWAF7I7VpLjfXQ3cspX2ejA ooFbHZrNhIe1D4u8ieIkF2t6AvIwVe2gM0jtbmeWp3W1fkPqN+JDqElecRZJP+qNT5rk RvDlAkVW/3qKtHiCKF8ZsJlKmjyPnfpMRLNie//VDqZI8zO4O5h/P1r/fhGyQEKlcuPK 5pbp+3Ngg9RE5Q9FcWRmgYcIF7nb0L+DvvomXpCC9X1Ah9A+pzS0M5U+9hMjckRRhDO4 dZlBLxLN4kSPuzVmsg0EHoe+MWW+8fSYIXSGEhg0Oeybi8LkIrvEiDqU2SHmI4oyB/jl Fg1g== X-Gm-Message-State: AOJu0YzGCu8uXgCmffyxx5eDwSgo7TizbISzmqG9iEQOwSVD7HptqJVH 4soBN7Dzv1wCB7LjcLIo+z8T3qT+UILXqHi7tHJNf6s+QRgJktUlrIrMwyl7gfM= X-Gm-Gg: ASbGncs3vfpGQoqxtzp3kIjSwP1mKUFpczokcY8ggN9mTLwS2VwxjmF3T1WF9zB/Gdq 3E39VmbKcIRy9UHH5Pdt4HZ9HYDar6wQyG/x4ehYAxjBlJdl3JfJhtDGYQFbsmmMzbzfeSCeWUF 65MFB7Ok/X6zrPPSfuDCO3+8fD/UrNgSe1ImznuWXVmcv9ov/hp4jLiKLpqtWooe5emTPkmNJB0 G3cvqnvVwoaFTPTCQAhhHkvRVuQpDYEa9A6o2QmAfwVXIeEKxgPHE4BROvKzWtiqRvfIHhJoN8g cM+F2ViEVOm3OnQpnA== X-Google-Smtp-Source: AGHT+IG2heHBIAuPYtOq6oHYP7Gc7zQLEOhC9SQlFm5Sgjs2KpUsmbBmclKn7yuY7kED9tkRfp2fnQ== X-Received: by 2002:a17:906:ef0b:b0:ab7:6c4b:796a with SMTP id a640c23a62f3a-ab789c629f3mr1715751766b.39.1739204104476; Mon, 10 Feb 2025 08:15:04 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7d4d291bdsm55689266b.17.2025.02.10.08.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2A4466038D; Mon, 10 Feb 2025 16:14:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= , Warner Losh , Kyle Evans , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 15/17] gdbstub: Allow late attachment Date: Mon, 10 Feb 2025 16:14:49 +0000 Message-Id: <20250210161451.3273284-16-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x633.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich Allow debugging individual processes in multi-process applications by starting them with export QEMU_GDB=/tmp/qemu-%d.sock,suspend=n. Currently one would have to attach to every process to ensure the app makes progress. In case suspend=n is not specified, the flow remains unchanged. If it is specified, then accepting the client connection is delegated to a thread. In the future this machinery may be reused for handling reconnections and interruptions. On accepting a connection, the thread schedules gdb_handlesig() on the first CPU and wakes it up with host_interrupt_signal. Note that the result of this gdb_handlesig() invocation is handled, as opposed to many other existing call sites. These other call sites probably need to be fixed separately. Signed-off-by: Ilya Leoshkevich Message-Id: <20250117001542.8290-7-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-16-alex.bennee@linaro.org> diff --git a/bsd-user/main.c b/bsd-user/main.c index b2f6a9be2f..fdb160bed0 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -629,7 +629,6 @@ int main(int argc, char **argv) if (gdbstub) { gdbserver_start(gdbstub, &error_fatal); - gdb_handlesig(cpu, 0, NULL, NULL, 0); } cpu_loop(env); /* never exits */ diff --git a/gdbstub/user.c b/gdbstub/user.c index 8225b70280..3730f32c41 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -22,6 +22,7 @@ #include "gdbstub/user.h" #include "gdbstub/enums.h" #include "hw/core/cpu.h" +#include "user/signal.h" #include "trace.h" #include "internals.h" @@ -393,32 +394,122 @@ static int gdbserver_open_port(int port, Error **errp) return fd; } -bool gdbserver_start(const char *port_or_path, Error **errp) +static bool gdbserver_accept(int port, int gdb_fd, const char *path) { - int port = g_ascii_strtoull(port_or_path, NULL, 10); + bool ret; + + if (port > 0) { + ret = gdb_accept_tcp(gdb_fd); + } else { + ret = gdb_accept_socket(gdb_fd); + if (ret) { + gdbserver_user_state.socket_path = g_strdup(path); + } + } + + if (!ret) { + close(gdb_fd); + } + + return ret; +} + +struct { + int port; int gdb_fd; + char *path; +} gdbserver_args; + +static void do_gdb_handlesig(CPUState *cs, run_on_cpu_data arg) +{ + int sig; + + sig = target_to_host_signal(gdb_handlesig(cs, 0, NULL, NULL, 0)); + if (sig >= 1 && sig < NSIG) { + qemu_kill_thread(gdb_get_cpu_index(cs), sig); + } +} + +static void *gdbserver_accept_thread(void *arg) +{ + if (gdbserver_accept(gdbserver_args.port, gdbserver_args.gdb_fd, + gdbserver_args.path)) { + CPUState *cs = first_cpu; + + async_safe_run_on_cpu(cs, do_gdb_handlesig, RUN_ON_CPU_NULL); + qemu_kill_thread(gdb_get_cpu_index(cs), host_interrupt_signal); + } + + g_free(gdbserver_args.path); + gdbserver_args.path = NULL; + + return NULL; +} +#define USAGE "\nUsage: -g {port|path}[,suspend={y|n}]" + +bool gdbserver_start(const char *args, Error **errp) +{ + g_auto(GStrv) argv = g_strsplit(args, ",", 0); + const char *port_or_path = NULL; + bool suspend = true; + int gdb_fd, port; + GStrv arg; + + for (arg = argv; *arg; arg++) { + g_auto(GStrv) tokens = g_strsplit(*arg, "=", 2); + + if (g_strcmp0(tokens[0], "suspend") == 0) { + if (tokens[1] == NULL) { + error_setg(errp, + "gdbstub: missing \"suspend\" option value" USAGE); + return false; + } else if (!qapi_bool_parse(tokens[0], tokens[1], + &suspend, errp)) { + return false; + } + } else { + if (port_or_path) { + error_setg(errp, "gdbstub: unknown option \"%s\"" USAGE, *arg); + return false; + } + port_or_path = *arg; + } + } + if (!port_or_path) { + error_setg(errp, "gdbstub: port or path not specified" USAGE); + return false; + } + + port = g_ascii_strtoull(port_or_path, NULL, 10); if (port > 0) { gdb_fd = gdbserver_open_port(port, errp); } else { gdb_fd = gdbserver_open_socket(port_or_path, errp); } - if (gdb_fd < 0) { return false; } - if (port > 0 && gdb_accept_tcp(gdb_fd)) { - return true; - } else if (gdb_accept_socket(gdb_fd)) { - gdbserver_user_state.socket_path = g_strdup(port_or_path); + if (suspend) { + if (gdbserver_accept(port, gdb_fd, port_or_path)) { + gdb_handlesig(first_cpu, 0, NULL, NULL, 0); + return true; + } else { + error_setg(errp, "gdbstub: failed to accept connection"); + return false; + } + } else { + QemuThread thread; + + gdbserver_args.port = port; + gdbserver_args.gdb_fd = gdb_fd; + gdbserver_args.path = g_strdup(port_or_path); + qemu_thread_create(&thread, "gdb-accept", + &gdbserver_accept_thread, NULL, + QEMU_THREAD_DETACHED); return true; } - - /* gone wrong */ - close(gdb_fd); - error_setg(errp, "gdbstub: failed to accept connection"); - return false; } void gdbserver_fork_start(void) diff --git a/linux-user/main.c b/linux-user/main.c index 7198fa0986..5c74c52cc5 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1024,7 +1024,6 @@ int main(int argc, char **argv, char **envp) if (gdbstub) { gdbserver_start(gdbstub, &error_fatal); - gdb_handlesig(cpu, 0, NULL, NULL, 0); } #ifdef CONFIG_SEMIHOSTING From patchwork Mon Feb 10 16:14:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968188 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1AE9C02198 for ; Mon, 10 Feb 2025 16:16:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWSU-00080t-H5; Mon, 10 Feb 2025 11:16:31 -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 1thWRB-0004NY-DX for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:09 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR7-0001XS-Rb for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:08 -0500 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-aaee2c5ee6eso739898866b.1 for ; Mon, 10 Feb 2025 08:15:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204104; x=1739808904; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PVPkeSXe9XeKHyg9wdlTOD67ZqgGK5EiAy24Z30yFIk=; b=wvxefPFKtCS/oI8OqzPgBFaLlHtkNoPu2uJH1VtWeDOLlQ4m9vufcBidroYiPxU7YX Pz82cpC12dW0A+lJ+F2YRAIn0voXa6MHAWm7FE2RxwXcVIEKp+LGB8VPgWlPBuljpcds 6bqwm+GBpO3tcTlgYqx3WP7YXj4ejxb/p/ZnWR6M8os61kQ1fTufjKbO1rHJQNqpWxyo ifUAh0azpYWXibrg8THPPi5PH4dJ1k7aCvS/lW9Q92GpINHFW/N4n0Chml6V9g5Vs3DC PV9eSWiu9rnSg47d/mKedB6Ia6KW0KgF9aAUhlMcejcAeZK2jCkY+1rEkox7Z4u7NKhL 6L7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204104; x=1739808904; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PVPkeSXe9XeKHyg9wdlTOD67ZqgGK5EiAy24Z30yFIk=; b=XcBKr410ptHCEd87ETxA3HJefDRHhwBGwDBoodjrdYZOYMy3R624+q3Py4DK2rsLXK 9AABakUzi4KsXt7XyHe8cUvre1yOvDIphEUMJUJbEZ9+L10TZ7TQIlQ3EU93XRoM3JUJ GXtRUS7iF0DC4gdB+L66Fu8FzNDfvwHFJV9behcuLc6xv4J0DobMQJ+gUej8YHtzc3D8 TkdbaZzjcq9WRUgCeZS5ZLzsZUcKQdUp/4MGAeI7tGme/6JPLW7MqeN2gFqGSy9WVRWx JPELoenQ8fUzlSgsiE7gLXho1fyEpISKSLaahFb+7ESAUxlNdgO1Hf3hLq9nDAr0Fdek 7nAg== X-Gm-Message-State: AOJu0YypN3WeAWgN5fa/LtuhXbj+6iSnR03J7HV+8o2b3duTEe7w5mn1 lhzaa18Xb0JiNBgV1kC9xporkVDvG2mPxo9yCb++QiARmUiKYop3MweBn7a73iQQfYaFogux/um bXAY= X-Gm-Gg: ASbGncvN7Meyhsyr0Zb6tr0jajuhig1AnPsh2BVOHg1GAz+AOwVXYH6eYiXUPZKDcbl yRaIUqVVt/dVsjePVr2ZKmrNHL8ikZDEl44Q1f+mZGwhMfhdFo9VUugyFsb6S9QVqeD72JQR7M2 q8n7fZcdofghigOgeRpPYl8AdIo2ohvxZBqRkcgu4YK8MYkXAfyyV2vkjiCFWEkEh2INp8jtD7L WuDLC32qD/T/fccavxNsZ1qSKBF2TGDG5yWQYLIbNpyX5nO4y/ACI6hfTR7yPyZ8NDxOPmiZwQm 6oLCQ8RiOFENvHdqVg== X-Google-Smtp-Source: AGHT+IEwC5FYTYdS5o+XGmQrIWD/cmvBq++0wmQBDEA1nxPyuFOIJSZA5TQZd6HCkgdF8nzGgC9oPw== X-Received: by 2002:a17:907:7fac:b0:ab7:bcc0:9067 with SMTP id a640c23a62f3a-ab7bcc09563mr588449566b.40.1739204103842; Mon, 10 Feb 2025 08:15:03 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7b1a981cesm395120066b.118.2025.02.10.08.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:15:00 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3CC4B603A1; Mon, 10 Feb 2025 16:14:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 16/17] docs/user: Document the %d placeholder and suspend=n QEMU_GDB features Date: Mon, 10 Feb 2025 16:14:50 +0000 Message-Id: <20250210161451.3273284-17-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62f.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich Message-Id: <20250117001542.8290-8-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-17-alex.bennee@linaro.org> diff --git a/docs/user/main.rst b/docs/user/main.rst index 80a77f0a0c..9a1c60448c 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -54,7 +54,7 @@ Command line options :: - qemu-i386 [-h] [-d] [-L path] [-s size] [-cpu model] [-g port] [-B offset] [-R size] program [arguments...] + qemu-i386 [-h] [-d] [-L path] [-s size] [-cpu model] [-g endpoint] [-B offset] [-R size] program [arguments...] ``-h`` Print the help @@ -91,8 +91,18 @@ Debug options: Activate logging of the specified items (use '-d help' for a list of log items) -``-g port`` - Wait gdb connection to port +``-g endpoint`` + Wait gdb connection to a port (e.g., ``1234``) or a unix socket (e.g., + ``/tmp/qemu.sock``). + + If a unix socket path contains single ``%d`` placeholder (e.g., + ``/tmp/qemu-%d.sock``), it is replaced by the emulator PID, which is useful + when passing this option via the ``QEMU_GDB`` environment variable to a + multi-process application. + + If the endpoint address is followed by ``,suspend=n`` (e.g., + ``1234,suspend=n``), then the emulated program starts without waiting for a + connection, which can be established at any later point in time. ``-one-insn-per-tb`` Run the emulation with one guest instruction per translation block. From patchwork Mon Feb 10 16:14:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13968203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11612C0219E for ; Mon, 10 Feb 2025 16:22:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1thWSi-0000Ke-Fi; Mon, 10 Feb 2025 11:16:44 -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 1thWRD-0004U8-9v for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:15 -0500 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1thWR8-0001Xl-TE for qemu-devel@nongnu.org; Mon, 10 Feb 2025 11:15:10 -0500 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5de64873d18so3488465a12.2 for ; Mon, 10 Feb 2025 08:15:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1739204105; x=1739808905; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=irCLni2uqvi4DVHX26aA8cLaSUYGRaTtdMKZFKQjhYQ=; b=eeIWCLIbZYZP7VANEE6D9i1FIplfioH7SMGxJ8GsArRqBRi0xTbWYakxX4qr2GdBwh 5t6IZ9r1viGxlFKpKtOsA7ATM4BvLYiAYyW/KzR+4nDhKZgXkfSTJpKnzfvUnAweHnU0 uoG5abpsr6lFXlI9wzmDLnikkKAxn8XjmhApYmQBmpEovetRAeZ4a7C4Ax+Ty5jzX0Jf 7gGYIXffu/c9vm3b0dKViZ4UgcwaFgYCchYwAiixX9odSFllFn5xj0BYwClLfXl+ndRV qrNUwGXDTJR2SLc3H1VnJU8Wcd5h/PWriVagkF9k4qKmanq+T4cOG6Ci4+d4pIwYW8vP SYTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739204105; x=1739808905; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=irCLni2uqvi4DVHX26aA8cLaSUYGRaTtdMKZFKQjhYQ=; b=v0OLZVryB+I0XmpiQckC0Db/w2xqepIPCgxYGUwHJ3GCQrCDJoooh+tWzdNUZJQ2q1 UIebIppYZYfRW+AFC8g/ay1ytAdMyglX1WvlLX5hsUX2M5f/Xc3uADV0esekatjJUt7p s3P42CRi0i+lMt/vq6OFad0PQuoxOe0Ghq1gpeaI3HLryA0KDaQGfx9XkJtN8GAt0XS/ JJPrjUXRuGnRusurvGxYaiNLXdK3Bfn7/kgtrszCFGtdbsTK1P/M8qhj92mARLVv1iDj 7Y8+ayHWzLxDoRuG75DghSgu67fHEpZh7koFJJYq6WH5NGbI0KUiMgdL9pi3RrAYs+if bj1A== X-Gm-Message-State: AOJu0YxYVAPcDhsj1/OWBnFdhNHly+G4+BFmAu1Kvv3Y6TVDWbY/v6AA B5H9GzCNJKSLYuvDZA+z+10JfB71KqFZBfwCPnE9F0QdnYHg+yrUcbNJ+X0xr/k= X-Gm-Gg: ASbGncuH2mzkzvdr1Fbb5pYhLj+QxsRz2Nzl6QIkLdXfgEUbA71Tw41vEBFfoLaVBJh ZkkOkBrQNkIwtZZmbZE82UeWbQwQ0ossYc0UrQ+Fthjux2ge69TC61KfyaZWEhjKUufqQ1C73Ng +KSm5F6cGft0Yp3K7m6yDpC9HU4SWqxyEwNBwGan1rGlTVQv7yyA8PTDkpghUpW49R3tPEOumi/ BlnR/ZVaLraLuNkrF3dpC7Eh2s0Q87EV5CnxbcRM2Ey+Z2XEGtp+Du4xWqirtCz6eny/ThiVglO cj5xNp9vnK0UFs8Kpw== X-Google-Smtp-Source: AGHT+IFvx53ntGlE8W/NwcXg0rZrU26Q/07wvwxvEPAnvMwFILOHEzCnEz2mtgKbo9yeVlVCzkXItQ== X-Received: by 2002:a17:907:360c:b0:ab7:63fa:e4a8 with SMTP id a640c23a62f3a-ab7897b37ffmr1280999766b.0.1739204105176; Mon, 10 Feb 2025 08:15:05 -0800 (PST) Received: from draig.lan ([185.126.160.109]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab7bb9cc85esm298532266b.67.2025.02.10.08.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 08:15:01 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 539DB603A4; Mon, 10 Feb 2025 16:14:53 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 17/17] tests/tcg: Add late gdbstub attach test Date: Mon, 10 Feb 2025 16:14:51 +0000 Message-Id: <20250210161451.3273284-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250210161451.3273284-1-alex.bennee@linaro.org> References: <20250210161451.3273284-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x533.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ilya Leoshkevich Add a small test to prevent regressions. Make sure that host_interrupt_signal is not visible to the guest. Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich Message-Id: <20250117001542.8290-9-iii@linux.ibm.com> Signed-off-by: Alex Bennée Message-Id: <20250207153112.3939799-18-alex.bennee@linaro.org> diff --git a/tests/tcg/multiarch/late-attach.c b/tests/tcg/multiarch/late-attach.c new file mode 100644 index 0000000000..20a364034b --- /dev/null +++ b/tests/tcg/multiarch/late-attach.c @@ -0,0 +1,41 @@ +/* + * Test attaching GDB to a running process. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include + +static const char *phase = "start"; + +int main(void) +{ + sigset_t set; + int sig; + + assert(sigfillset(&set) == 0); + assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0); + + /* Let GDB know it can send SIGUSR1. */ + phase = "sigwait"; + if (getenv("LATE_ATTACH_PY")) { + assert(sigwait(&set, &sig) == 0); + if (sig != SIGUSR1) { + fprintf(stderr, "Unexpected signal %d\n", sig); + return EXIT_FAILURE; + } + } + + /* Check that the guest does not see host_interrupt_signal. */ + assert(sigpending(&set) == 0); + for (sig = 1; sig < NSIG; sig++) { + if (sigismember(&set, sig)) { + fprintf(stderr, "Unexpected signal %d\n", sig); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; +} diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index 5a091db8be..75e9c92e03 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -36,6 +36,8 @@ def get_args(): parser.add_argument("--gdb-args", help="Additional gdb arguments") parser.add_argument("--output", help="A file to redirect output to") parser.add_argument("--stderr", help="A file to redirect stderr to") + parser.add_argument("--no-suspend", action="store_true", + help="Ask the binary to not wait for GDB connection") return parser.parse_args() @@ -73,10 +75,19 @@ def log(output, msg): # Launch QEMU with binary if "system" in args.qemu: + if args.no_suspend: + suspend = '' + else: + suspend = ' -S' cmd = f'{args.qemu} {args.qargs} {args.binary}' \ - f' -S -gdb unix:path={socket_name},server=on' + f'{suspend} -gdb unix:path={socket_name},server=on' else: - cmd = f'{args.qemu} {args.qargs} -g {socket_name} {args.binary}' + if args.no_suspend: + suspend = ',suspend=n' + else: + suspend = '' + cmd = f'{args.qemu} {args.qargs} -g {socket_name}{suspend}' \ + f' {args.binary}' log(output, "QEMU CMD: %s" % (cmd)) inferior = subprocess.Popen(shlex.split(cmd)) diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index 18d3cf4ae0..688a6be203 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -130,6 +130,13 @@ run-gdbstub-follow-fork-mode-parent: follow-fork-mode --bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-parent.py, \ following parents on fork) +run-gdbstub-late-attach: late-attach + $(call run-test, $@, env LATE_ATTACH_PY=1 $(GDB_SCRIPT) \ + --gdb $(GDB) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" --no-suspend \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/late-attach.py, \ + attaching to a running process) + else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support") @@ -139,7 +146,7 @@ EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \ run-gdbstub-registers run-gdbstub-prot-none \ run-gdbstub-catch-syscalls run-gdbstub-follow-fork-mode-child \ run-gdbstub-follow-fork-mode-parent \ - run-gdbstub-qxfer-siginfo-read + run-gdbstub-qxfer-siginfo-read run-gdbstub-late-attach # ARM Compatible Semi Hosting Tests # diff --git a/tests/tcg/multiarch/gdbstub/late-attach.py b/tests/tcg/multiarch/gdbstub/late-attach.py new file mode 100644 index 0000000000..1d40efb5ec --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/late-attach.py @@ -0,0 +1,28 @@ +"""Test attaching GDB to a running process. + +SPDX-License-Identifier: GPL-2.0-or-later +""" +from test_gdbstub import main, report + + +def run_test(): + """Run through the tests one by one""" + try: + phase = gdb.parse_and_eval("phase").string() + except gdb.error: + # Assume the guest did not reach main(). + phase = "start" + + if phase == "start": + gdb.execute("break sigwait") + gdb.execute("continue") + phase = gdb.parse_and_eval("phase").string() + report(phase == "sigwait", "{} == \"sigwait\"".format(phase)) + + gdb.execute("signal SIGUSR1") + + exitcode = int(gdb.parse_and_eval("$_exitcode")) + report(exitcode == 0, "{} == 0".format(exitcode)) + + +main(run_test)