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: 863787 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1675649wrt; Mon, 10 Feb 2025 08:16:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWc3GWetZ4ML2iSWb+hn7JmsJqoOYFkn193l5fFx/R/KJNIL2hYD+3zSoale5Idxv5AIbEugQ==@linaro.org X-Google-Smtp-Source: AGHT+IFm48jsy/Iw5qsT8W3frLP+HOrI46e4jf88kSiSKScYR7++9X3F5miYWEuWiRSvaVp42Ydk X-Received: by 2002:a05:6102:50a6:b0:4b2:cc94:1881 with SMTP id ada2fe7eead31-4bbe054dc20mr366228137.21.1739204176289; Mon, 10 Feb 2025 08:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204176; cv=none; d=google.com; s=arc-20240605; b=gDe6gha20H0kgn8BtTZZ6DxS+1XsYz6IjHtrMSMUXOP1fqTfVVtomgPrYKux2yfFKN bXJO4GxdTjdAdUj55zjV/M+N/f5fSh6QEmScRhvp2wU2AA/tEMtYdru31V3XtXWOOiGx vaNLAzvvagOG+kdCdBFXUApf1OQ/qa9GpRo1dU+u5pIitexjz7noojamjJLWahS1BGU1 WNmfZi5CemJkBGhFfFQVY2dZGZhgiNPJNTsixlPt6M1ycoB9nSrIXb5ORpmY6Bng/EoW H38sFFr9dsDNfXt7wazGXLgvJKlnVKylICv0fzDUBAkLsDkgYVt0U0qF1y+8U6zkunNt /+wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s+bgwk18lKdsHzokGpBgI91DaZBecMvO8llhyl5xsWo=; fh=NGKL7EjXsVlLqsgiVJF8cw5y1vl5Mk38NA/Bpy/nmro=; b=P2vYi3U5MErbY2LmiU9no6ZaGpHO1CHKaxS0thxtLoziePLDQhVGuxp8D3sb9smkiR C9dv2JV5g7q7Pme8CYjWOTl24S70QbfGB790mGgTsebAr5jiY9TMaOKqoQm8ARP1srjP DiiXx4wJwQqgkosbGK0xviHn8NReHEN/ChfytlPvtb+pzXbKwOd96n4rXCGMh+5BzrNp /5o6q+819dx4i8sHVt8jwgLcKAZ2kye5G1vo+ePq83ukcBpPS1YKkpi+y5BR4m6uTUED n87uufFBd/vxp8EEtDb0GPopWGzGBkaEwugYrjtjMiK/bFPEXKVeK8SJpkurxhasiG36 KIOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YDRaIuP6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4bbe037ba45si72437137.239.2025.02.10.08.16.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:16:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YDRaIuP6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863812 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1680663wrt; Mon, 10 Feb 2025 08:26:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUTiyi0f1wcXLboz7DjW+k8Ld6WYuSowst1kPXEPlFFNgPuSRNQZVNth48b6ADkv+LktBnQRg==@linaro.org X-Google-Smtp-Source: AGHT+IGU4BXuY7xd0M7Sn4jXOHJf+qxODW1Jdr/jY7TauHqN/gx72BYvVnv9go3ibl1G4qdeyVFT X-Received: by 2002:adf:f109:0:b0:38d:b051:5a0e with SMTP id ffacd0b85a97d-38dc935ce11mr8815077f8f.49.1739204792171; Mon, 10 Feb 2025 08:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204792; cv=none; d=google.com; s=arc-20240605; b=QBm0XsxArFi0hWF+zgjlQeplzUI+af8LN6098s9K5kKKnHCsK7/ZsCFsY9daICD6kV YAx5KBoX1wB0PhIj7Ds9nAV5mA6/gXw//fMCCJc38fyREMUg2vPihtj1QfeqLasd/RIM vYN2yHOuhJlygLTX2BwlIoD2Uzor/eFW1F+7hJNzwVcBiQ5Qc71hxZAmCNgwYSCpI6A2 zdfAxXiu6PQnth1qKe06+yl+x6G8kNdSO17dKjjzCumpJvJ0KgYpcvfP7d2bCNNfe2wR Bsfrpul6T009Xo6XrajIR25vSSBSO/PrkMRWpnTkncoXBFdYmXSngoqzjiDwpOCvHDdD Co4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s99h8qs7nLU97pBsNxE2tPpHIjsUUYJGtsusMGsaa/8=; fh=Yjiq842v7N+FcFZr6Y+9xaweKWU+r6Vw0m9++HcCC70=; b=LUz9mthM4QA6wjTrEX4q3E+YLBYu4xAK8VoydhBNBeX5wB+tsDmhtyAf8ePKzCj7B8 045jcaxABk+ZUYyER6hEN6k3CoToFGJAfldh/lk2sETO9t38M7+LlBBvJ32kIyVvYZQn SBgkAx5QptAaJXnyl3oMenhKcxZOXgeEAbR6TKsjvA0Epll/MsrUox23lD9JCfZqhCbm ChluFlr1AfeUuZk4r+1U+4OFemd7+QlbzqJt7qGyq1ET6cG1khUWfUJ9O3UZqVFyJl+l a8C8oJI8E8vQXXieQjGNUSuXQf2GLp849UvvFmF2WTaQNWR/blI+y33T1PYNQ0OSvEW6 tIrw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BD5ea4PI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-38dc39f1471si5734783f8f.579.2025.02.10.08.26.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:26:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BD5ea4PI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863788 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1675712wrt; Mon, 10 Feb 2025 08:16:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV8dzrGDRaWmnJYeUtQ4QB65m10NCZpx/SaerGt1xahWzOmFcdO8VlyGLUts0pAYHSvINpciA==@linaro.org X-Google-Smtp-Source: AGHT+IHtnjI9llNIn+0RPJStrO4xczBXld+5ODEwCbB/QwzCqKSbXI0smiZBqtzx0d12L3btTh7h X-Received: by 2002:a05:6102:4b16:b0:4bb:db41:3b68 with SMTP id ada2fe7eead31-4bbdb414202mr1201044137.5.1739204180448; Mon, 10 Feb 2025 08:16:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204180; cv=none; d=google.com; s=arc-20240605; b=CoybvAecokbZRMI04KqHl3eUDoPEL39DKeFVMg/dXiqawAAafjYiA5WUMqwvVWnkEb cRmew94bWfnNYn77QM4UpQBq7KyQ2DwHKyVge3BLtaIT1wdaSvWk1YMQPpzDXzwGfEif 4vsu4/Q+0J1r97tsPT4SctwgDXlpBtUC2CEK4gOsbGBBSVnx00QAuAKWJVwt3XnfiEKp cSqORLM7K1HYTIC2I496pYHeXPC3AFAJfn8xYbSB53k4MvSa9IymvGwEaYxNflSnHH/b KwZ3Ubim+Iy4kl+b9RazR7V46ob3nlJU/Uz34efYEzJp3fsyPEvicUZFJzXNeerYav4j GX+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cgHEs4UjXEPONNRSfBLs6a+I9ub5T+ewhfrcjtrhUWQ=; fh=Y5NvAJ2x8KcTUrjiW4X/TF0OST2y6tvMlTGCoX2zaA0=; b=B27Aclu59xS6JIPnRJJCX8HC9uosJMmjAfA47rrIqAO7aw9lUoCn72BzK7ttExkYQ6 l3RCFRHlciGHqUhmEYvXcfItxGb73jL3DwAJdaOk9U4zvbRQMIWltl2c2GvxUTexyOSx W8FkaLvd9e5IP/i4KCgFhExRZor8T2Xb/ZpIMKyTkJSHIx8VkLVJ7jooYYQ4gMKNaMrv 2QU/+WST/d54o5oG6iNOqRSz7eM9RlFAoP22kfeDHzX4pqg6sjefm3DF0Npim+JfrZuU pdg1Y6jlQzcYf1fubqI2iTvleZ41IUcef5IT4fvdk1eXJfksjeu5iJh8qHQdV46T7nyg Fzhw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=La1vGC0d; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4bbc29474a5si631886137.354.2025.02.10.08.16.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=La1vGC0d; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863792 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1676056wrt; Mon, 10 Feb 2025 08:17:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVGqdr7LFp3HjlU5v0AA5mmTtOTF2+GZn+ya4aBGUSlZqvID4G4IRKZA9zpILW1wOe0UrTtrA==@linaro.org X-Google-Smtp-Source: AGHT+IEoILPRM5miHyK0X+wYJ8uRK6UjT+mAWAKL88Cnn+p57c4ShC8djYOGWtV1R5TQ1DvZEw0U X-Received: by 2002:a05:620a:25c6:b0:7bf:ff64:336a with SMTP id af79cd13be357-7c047c21327mr1847999385a.38.1739204223712; Mon, 10 Feb 2025 08:17:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204223; cv=none; d=google.com; s=arc-20240605; b=Gk2KNxHtDUe75xMCeljSW9M2PN5u+0MUnKXyfaEJQIvH+cGXhP0KPDn+u0FXzOLjDa 9F1AocQHhZO/9XbxfaWjOL9a8ckyXYMtqHyLykikM/j2H672qlwW391jToF9zF3RlQi/ uEfGV+cZWnbhJt+KNpjfXGVq3m+7Bz0rVlm5rtM1068KrCS7U95Gu1AI0TmTihXLtlgh BZQh05U4ctNdIquEmlVzwExJyEy84gDVBaIFwwYyUdepUjvHDwYqB+fgFIf/sfZARDCj NkTudQdNYv5m1UOhBY8NwevPoH+wuL/mZRAmwcFvb/LbvB8NJVzo9DwnoMkGeZQ/3yjl 3cKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ALPFRjqBCzN5IspKKvq+gGyQjhJlGV0zlBdiRI50u44=; fh=oOfLW5aFyOCTvB4Tv2DIh0IbhnYrPO4G9WjFchHv1NU=; b=FaXl008ETXGzabNPacZ1azzU5piqfcD65NDZdmCk8rqE4i0VNgzOsk6U57xGmGRCkt QIGpZIlzdziPfkY5mhkD93kOgtMxdCt3zBf/MzgXQA7EPF8GU7xOhzY22c2Uui5INnyz hSvbJTG3HF2tregm2ldsvEp5EJjcUvo4G4nt8WyWwyQt1UEJVaEmjNwM+2+YHIt/Q713 Zu+Zg7pUJyyKgb0AwvkRByk9d94PDEM81hbrpU5+sOALIzLLQcBUEO47g9VjU6KUXqO9 JmA8JZObEx0i0PFlTgIIrVulRz3hhHhPW47+G1lLPy1e5H2LxsCVtHZU0BtDnFPA1yvj 3fKA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qrWk3F7Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c041df5007si969327885a.17.2025.02.10.08.17.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:17:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qrWk3F7Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863791 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1676054wrt; Mon, 10 Feb 2025 08:17:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUkPmEM2501TXqJtcm9uXi4wf3sVZ7LP11PLmAYF7GCf93kBjqFO85rptR0Bd2qXGGKuTD6gg==@linaro.org X-Google-Smtp-Source: AGHT+IGIy9zHfhezOxkhvWZsuJME/9gIIUPJAPs45sMdAPFNvrBnamsr1wzSgEmF/qMsTjjeBZSR X-Received: by 2002:a05:622a:1a1a:b0:471:9a06:9732 with SMTP id d75a77b69052e-4719a0698f9mr30216401cf.4.1739204223546; Mon, 10 Feb 2025 08:17:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204223; cv=none; d=google.com; s=arc-20240605; b=Jnr4hsdGd3XCAl4DfLvx/jxC5zWfAdacfBE/9RQOCO14jWlHmsf4vMZrvHb72d2dwD kOXohhAH7hLTrCxa6REo92e9B96bYST54cHU3UH8VE4/svZghuR3+V2VuGXCxgoIUQvQ B1N16LXIN6s7onnpyKUVaOzwR/p7hPgMkZgIcFcTDBBMuGrKy2sgZk6R0VzVZj21Mo0W IgyRP/FEXxT10Pl5rF2rf3OqOvvT0Q7ENVwMwmIJ3XAWFfdbQHrc6HxbmRq9BE8qtvpJ 26u4G2PRlo2Hz1L0aCMQDSuj2tYZ/PE4GRwDdeGBItp93jFpa9SYDDdRB6J2G9MP7ojk qHmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Mdv6BlsMATdrpGMkUawzyb+JI/nA7/PsR2TQFJvlMrU=; fh=WfL5w8Mp1V9wMKhPWRSgS3yZU7eoqHdwwnjlS71aSTM=; b=CIAz27cBXxxueJ/ZNQZ3nhGAW1ZrThVKKyDbd2ZfLUGnDYWrSxy7Ls3ZXZF2sv84Ne 9XrtlVOri2rhtFYo7yjKuwvfIH0Bw7sd32rZEcdLH+oqI7IWF0bxXlDm86qjYIPKH64r ozy+XiWC3ZV6UMKWEWzKzU9ojBYaMgt3whhqVVXSapALqx9CsyoeLaMjy5T6a9WoKPSb Rno0FVNH77+QX2anToOkgF2N7COoY5XVgjxnwPGZu9IRGtcOg86I8aRGs2mmJYrZ766m uu5mAs13X+vtIpp4DLOUu5dfpVQ98cuKm/T8Y2G4OAJBpZIRjOO/k3uI48iApMdbp+8X csaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tOmD8Hck; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-866f9800e50si1859487241.150.2025.02.10.08.17.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:17:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tOmD8Hck; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863800 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1678921wrt; Mon, 10 Feb 2025 08:22:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUR+0sRDyT/g/S+il7FqrnhOf7zrTsOuPOChbSCfapH3ye1J24Wg6Buj1bu/7XW2Gz/oIdxhg==@linaro.org X-Google-Smtp-Source: AGHT+IE3fwP0bC7QdTIV/7aa/QdSFsZ7mgoW2fqZ9/IkL7+zLkUJO6Qv9fI323ryUNKROKp5Zztr X-Received: by 2002:a5d:6d04:0:b0:38d:a910:b4d5 with SMTP id ffacd0b85a97d-38de41c5b84mr177581f8f.54.1739204570211; Mon, 10 Feb 2025 08:22:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204570; cv=none; d=google.com; s=arc-20240605; b=G1OWnG0goFTQBzPxEx/OoRcQeXwPT6Phq5srULxylwt/7kNtQMnRNPJ9z/J/UJwsXj FcUi78WjJj3j7UN3myp5+dNXSVbpTuBIyJlwMLwo5KZn+1jmvSz1gh29e3Q63dzMVn34 ky3PieRf8v4YqwPmLPfwp2qkm7kYOAA5sGeVObZ5IxjBO+OGF53PMhwDnFzQEusbbXyA 2IPluHURDmCscB3eBvKkbKDUtyAmgdBRJY2XRohpnSJBCov6HngkmZqcMuqKuZ3VjKin 66SwJHwPZ39hyvqMKt8VOFQQveIJbyNnwfcQdL3TxJE42OP/YpvWUPbbG5SfyFNIeEhf XxyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WRjcWYmrZaZWP3MsASwgK8gyMjNh7g5UJb6gwrhevyU=; fh=oOfLW5aFyOCTvB4Tv2DIh0IbhnYrPO4G9WjFchHv1NU=; b=dRoIBzyVciB1KHGqttLypq7YSTgooYuh6m/t/AsTG238FlgkZ6F6EveHW18ABIhbbz q13amzfDfO58DtDwf9c5B/yYYV+/R+CUk6btLccr9cAu2f/JY1Xl00+qI6MlVTsZtcOW lhgIWgWjJeGhUAUJuhSt5ClBKTCrA5/14eo/1+R+nG2dFMWBBb25Hf5fU2+X8v/lzg93 NLEfTd+xgf8JdR8CbbcU+M2dbXf4Ynxy/f9MaN15a1rwL/uCcGjozxauReRads/1s3wd tEChL9I8I3CAzJKfLb/YaDBDDHXTyQFw/oP5v5TuqlQX7BYvRG1gGUq7qsRNFjO5l1e8 so1Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c6ZcAJK6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-38dca743744si5186296f8f.163.2025.02.10.08.22.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:22:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c6ZcAJK6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863799 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1678366wrt; Mon, 10 Feb 2025 08:21:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWMu4OsJFagp/8F05Bpjeaq6h60VQgKANQIFPDzQnAdzTV2qwpgBz10904Tnm0Nlpe9P7r5OA==@linaro.org X-Google-Smtp-Source: AGHT+IFO1IBDLw+hMgQCk3poNOIAV4+mVvYDVrpmaw6qSqgu0OojlOvXTDAnfWAMHIcCJSZAPqpE X-Received: by 2002:a05:600c:3384:b0:439:33db:b969 with SMTP id 5b1f17b1804b1-43933dbbb8fmr87318285e9.16.1739204503145; Mon, 10 Feb 2025 08:21:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204503; cv=none; d=google.com; s=arc-20240605; b=gT4aqlbEngYkVCsqVuG9xqxXlrZcVBtg04zEeiL+73vUATWWiQjp34nd5kqaBixkeU uXvM7xPuFRGLF5DbaOKHwbxuICkiFecOL+Cq4c9iaiWhVMtCSKWDXeiaI/OxbX8deovQ GS+Vb9OMd4gkOSHRLA83wuiNEq0ZpR+ay7xmropw0ZHxFrRojfqrfxR87A3fm7XhcqfP TOappTOZwS3+xIRnITmEpnRzqCJm/gv233wF8mIwv3HoSwLfLyrbTbHhJT+ChaJk1B0h CUergGcoWY/6L2AW9YBJb/F+kG9wQW5O6j1Jz84fL61zrV9bO7uA4dU45JZGMtxb3Dfe dF+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5De79NWbhkU5BW07foJEsOJqUNxurUAkpHc9PcGIKnc=; fh=FwYFY0aoHgJ8gQHRlqI5aSHs2bl34umB1Mxm+7g5/qk=; b=DNYubHUiXyG+ySkYFybbRF5YFp+AbTCHR58OT/Ksf5vCrVIPpGuHz3kIjVVoeqs1AR NBe+ps6VDKSI5B5euy0jOFucDe6aBnePI3ojOJnLFojlXeI9qIrpQUJiS/aQ/VrgrppP 0veT8klHAILK70sLhtukXT1CIJsRAPUoGnhYKCSLjTCFf5SPICOSDefigwRz5j8yliG+ pln7mXCLLz57hDhtLIcog1jinpZyZ12iuaURKcw5K/bO1mKDKOOQMId6f61E+MVdAwFM WC0ib4HqIGmfPjY7Stzb6xWwO89XQZ/HIKd7vdDhtzpxzqT7Y4pu7iB9iTPWDDSz4DfH CE2w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=upjZqEAD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 5b1f17b1804b1-4391dfc810asi65435235e9.99.2025.02.10.08.21.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:21:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=upjZqEAD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863803 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1679225wrt; Mon, 10 Feb 2025 08:23:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUOSQ1acXU8SXhBOn5oi8lhs7y2n1I8TRNVMpIU1Y2MppXDcFlg46YW3w5kgEvgCyA03ZFnlA==@linaro.org X-Google-Smtp-Source: AGHT+IHp6Sc/Y554LApI+MjrUMihjiFmjUxrJAZjAMvUcEZf15E61eDjdLo3yeiL/EP77HeHtZ4e X-Received: by 2002:a5d:6d87:0:b0:38d:d69e:1326 with SMTP id ffacd0b85a97d-38dd69e1b18mr5560577f8f.9.1739204616644; Mon, 10 Feb 2025 08:23:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204616; cv=none; d=google.com; s=arc-20240605; b=X+sBE/y3IDwnT/oMcRNA8dm8geSdgFL0hHF8VdeGXvpfR7jMULBb9J1G8ewbMZNxDN RLUn03UAXLeEZ/xeNX1+Q0GO/VGTGD24RqhBfIW3ouamWnm5a9vhikrIh/loUMkEk0mL byjnyoURNgsxRoo2inlVXckj5R/VxFNinhv+HhCvlkxqgqgUS1gii+2yyo3fZcnKVz6K sAhmstt87z1oh8rAdtC8E7zzc8ucIewQ/CqlNwmDKhOB/i72H/mS8j2/cG4b/1F8yQEr mahnA4pRNMIGsyO3OULtrh4I2bDlYYBnLth/jZEI/kPKLDWqpost066nzTslsZU6CxGh 8L9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VG//uhabKjRFgO3Unu/weU5aBAHUld/kAOriyLnP5SU=; fh=yOMeWqTPD+Vj5QEPrg9bdbJZfpFIFFCGV8qqv+mOGPQ=; b=FQ7GGueUaBkMhB+NUqcr0hu5UsB2W/KdyYDiS13XIDS8T9bdbfyQBkiaNIivky+pCz PetLaudg62c4TIpS1gi1m3+m8xa/yJ8WOo2TX8jWOVKhKB4PrJHJ543VX7FtofVZMIKL N4qqLHpHnoj39HzK2urrRCrxV0QJODlTO2wGwOGuCJz1/0qFJr63VJMWZ0BRhOTljk6T PptEMF1Gu4tL1B4OJk+HlSxc/FtC+WgR0b3bWa89Lc92g7LlV9jNn0RdCwDJFxwOd25a VKR1fTlGJcqL3v2qPaQ5fzLVD47JIwuv1aBFxeRVZnQXjUA6PqIMbLVVyrkmJ7n15H90 RkhQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B2pwEjDV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 5b1f17b1804b1-4391dca62d3si66297355e9.64.2025.02.10.08.23.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:23:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B2pwEjDV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863796 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1677302wrt; Mon, 10 Feb 2025 08:19:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWvqybPrQ8A2e5Kv+7PWJx+pNZI7O8ECRg2Aj+iTVqGfugEZ8dashQpDn5H22CqQPIHYXIFdg==@linaro.org X-Google-Smtp-Source: AGHT+IGc/i4L1IcmG6H/slKIGQvQyVMB4ZDhHkR/cAbhJOZgPpVAage6hjMusyOBJJUmHUAUsdjC X-Received: by 2002:a5d:5f87:0:b0:38d:d299:709f with SMTP id ffacd0b85a97d-38dd29973b3mr8652197f8f.48.1739204383550; Mon, 10 Feb 2025 08:19:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204383; cv=none; d=google.com; s=arc-20240605; b=Gm2LnzA98/pkY4biTD4brg0LwhPIMmtY+n/jm9pfx/UG7DFpcDtsEQTDlFligyjrVY DMi9ivJIR4eLIHEJ/GbJb09iPDy1d6z3kUZ5PISonloB8F5DY7blMi4P7V8p832V/47s ALEphXvmw0TYcxj1peFnEkam2XX4GkTxJ59aBWN7y/pziLuC5B77tg7TUe4Rwfvnpodp XtfxqFCq6f/SkDZCz1zhWo2Xwu8rqoR7N2XjtdePOYrqI4NUS6iBT5I8TW6j20eISL55 lllrnVCsMk+fzEvfJ2lXx6MVbK16rfiIG0A2TjJ79MCGx653U52cyFe5F3muaY0lKJJX i4Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1wgsLERHHuZ71dnIxMpojeA2APBNTZ57iSA3i6scrhE=; fh=yOMeWqTPD+Vj5QEPrg9bdbJZfpFIFFCGV8qqv+mOGPQ=; b=M7ApbTxMCkHceWtF4ngtqKVmGfjdcCPsgRi+9+smlcCNzfcb5H1uCqTG3PHY+sLlKi 2PKF08PzEHOCk9SSZenJ9b/WCxp3Q3YPO163s2oYWTULCg4ILfy7BhMwSJBQYhro6peG kXWwfw4EPz4Qts0BLQc3xoQcOZE0jJANqe/bO7WT2AbRTH3MRxb7UfLYY+XB82W+/U1n 2jOqT2ONAf3fv5zeWcCvrwSU0YUaVlTaKOJE9rKwEOvnfUogDBLhs09RPd5fcwGtpZuk pJD6Wt4J7Q6yLf9MISn18NuU7UAs3zMjuYHZU9iFuf60mEeRKQol35KOIo8RzVIG3UKI UuHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CPCA7uUM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-38dcdfb72dbsi4592483f8f.901.2025.02.10.08.19.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:19:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CPCA7uUM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863805 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1679289wrt; Mon, 10 Feb 2025 08:23:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXoYU1DD7Xdr1QRz2OvWNfSB02wMPyTRjv2M/kivCYmcyyAGOmQJarqkJmBPsLS1M/okRv9NQ==@linaro.org X-Google-Smtp-Source: AGHT+IGYpwE/2snXS9zoZpASbOL/dhl+BHXgBujM5IjO6d0F+zFJf2ufxIhZlhQdz18dePMTWqKV X-Received: by 2002:a05:6000:2cf:b0:38d:e02d:5f4e with SMTP id ffacd0b85a97d-38de02d5fdemr2207747f8f.5.1739204625286; Mon, 10 Feb 2025 08:23:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204625; cv=none; d=google.com; s=arc-20240605; b=HEQIb9k2aOOlkWGtHuCEzBpkx4LoTDhYIT7GRpuYVrqFSaNe1huWIuvNaMVZNzkVGT AC4o9MQci+l5N9gOsgvQ7/CjtJOyfw+GO4m4XBYk5A76gg0xU3+Zm5YiHRWddnx80G9a ZvdQlZptkbsSdOGdBeiQfFjTK8C1/gEcf9IqucJD4zu6GkNrjI+hVNgT9Uwmmx9I0z7f QB3/6UhMnlMjJzmmFjZWImyRCTCnzSGemcr0VqjiTAyZ5shMnsPYKjoBw8amt3jCqVb4 FRgtFD9XbIUV+nES82OUh8NvdQGfP4EXGr37xZxPjgnsZf9Jb5wnPMTl9mn11WygV2Ph I8Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=drUSqKJyol0KqcrQAykb+B2rcXTaSjubQI7HNVc4K6M=; fh=+Vs8Ps4xrCMI1qti6Ua1vW01vgc7IVSKoE3I+h1JGLs=; b=LS2tlLVFK1jLiTfrIQIUsFP1HWwfGHEo53WdNqZCJ4I+UtC1i4di8ogs7bNbtDMV0F HzcMD3XP8djHoYCtjLW/jOqCSASDkACgr4bSqxNdTgFkPAutxpugbIkFxCLp5PJpKujU l+FyjfeJt1Mzi8MMlZHlEDfh/vwJEfRiZ28+IUts4bAaH+aA2QslLETC5rjvOVzk5DjG /ajq/Ho4gvdBV+ZWjUv4DyxkcFqKZjW9pLkNyqfRa52p/ALxbmQfvcfwk40+7q215YDq E4n4YGz4OWXMpdvqsJXJFZhmGW/kdSku4uLWLZ7fYiTVOmrvKgKh0+qMdvoY0BiflxBK nAcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EQ3NXv5L; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-38dd1bdd9e6si3941259f8f.810.2025.02.10.08.23.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:23:45 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EQ3NXv5L; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863793 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1676387wrt; Mon, 10 Feb 2025 08:17:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW+kmzA4l8c4a+Pfd4yW+GqFXTAv5h30I+ErjymE18205OwJGSTLKoJH3Ybjt3mDpwYH9fd6w==@linaro.org X-Google-Smtp-Source: AGHT+IH3WnZheUGM3RDnRdnOyrSfLLVAhre+ITBjJrP1EYU+mr/O22BG+JWWiWn0vBoC4uhYw8wM X-Received: by 2002:ac8:5812:0:b0:467:681c:425c with SMTP id d75a77b69052e-471679a8fe8mr209671641cf.1.1739204267756; Mon, 10 Feb 2025 08:17:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204267; cv=none; d=google.com; s=arc-20240605; b=RIPHq7k5mRLzryE3IgQSg3vWU83AEgQ3gXZODz0cr5Div2iINox1+oqD3bv5rkP76E /EnYYWAA5iAzlSbJqExg0eGZRndXd0FSrnCmKtavpl5k98QM8WzBKoC6bdb5bZIZPAwV JiqPFo9KqrB6Ucr85PMxXVp0QHE7/1OyEkJXBqJveONPRPKpIF866UUWwQ1xuZoePB21 /AutRtP9ZOx7uW2D6VmwlUtaXLpj1a3LCoOgu//CViopT2K1BYqibVyAxfbBDBEYrley VDmgTlT4bnVvB73OaIZHB4pFiYzwaCGVoRZ6EWtW6Tl3pDoYzj9ac4My5yoCkTv1YSUN 51pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YT3MtmnSLkBKcOVyMB0JztX76L81nkooZxZXsqcklIs=; fh=zNcCrv0iORvx7Yv7ZHmrW/HP3e3F04qVdXctlpWMV5E=; b=CSJcGh7DytFVp6LNb257XhB/VcTZn7FUj88hqbAG4G05dYbuDYULuqZQrwKLL9SBVP ycSMK3akteSBJ13BMEUUVSioWIjyzjkCgNosqh19+/sk1PXeOu7+Ws0iI6T/TiboZ+8Z r4c+stNgOPTqRsPQaUlk9HC0KmaYzRb2QLUTtNiRQspr3EaVfjyCdB0VhQFBFdwTb1mB YfI5F+yKNBx5tExD9KpLs25lId21c3+5TYWDaF4fSthPgI0L1eB8HaNgTXQYR8AErPuq 5lDUdNGSPTt/jdQLwR/S66FDYqCDW5D+Z59WKrl0dpO1Mz5U/NsM0bLL36Prce3MF6iC gnJQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ct6YfJaK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c05837b43esi375727585a.369.2025.02.10.08.17.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:17:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ct6YfJaK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863795 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1677041wrt; Mon, 10 Feb 2025 08:19:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW97ngf+WMF+6R6TUbd02tKK+EkdPDnebsgxdyIWpScPSSDWK4nUMasU/bQ7MNNS2ZcRj0+PQ==@linaro.org X-Google-Smtp-Source: AGHT+IGJ7F3xkXu1uDtN2R3WwYwpxnAk7/tr2KtbMm0lzm+Wlne22ZXzaq7x0TtcEa+4ffOgtHi0 X-Received: by 2002:a05:620a:bd5:b0:7be:3d2f:16fc with SMTP id af79cd13be357-7c047c4ae9bmr1565824385a.51.1739204349572; Mon, 10 Feb 2025 08:19:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204349; cv=none; d=google.com; s=arc-20240605; b=ZVl01LghCmlHefC7CY0ofhKLdtvxKBBu1pRMAqlTbTB3ARqK10p1T1lzHZ4JEWaVzp j61OnRjgDiWByoWoRxzS9LvylviPa9kfjoK2Ofts+Tmqq4Um76yvZwB2oK+2ipsCL2Wo 1IQ3G3+V3UIZz7Mf8bp85d5KPIDMZN3Sa22tYaMp22u0yDd2K+68HuOl8ZlpihBNn7sm dd/tkKCCvrOEDPw/vgTcjcsrqczQnUWRifF3WfUXt+zk8C1II9HAetTjfGr/58Z3sT+N wcRuONlhwvP6HLj9zZMoCyrCNukkhut6o5iabz7uE/I1pLMHFiizrEuDusB2ClBGXs3T QvIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2LwehABNpz+elHyUtu6V8SdPZXAtvSq5keb1F8SzdXM=; fh=yDlbSgr8iA7rdHLClsrHGiwrdnGi8CotpDrRSxYiEB4=; b=MCLWd2t4mSanswyWB0IMuEb3CkUd2ZBuzD7O7XESkAPGp9i0fgyT6YDe8K5KdumcDQ nYe7elFM0ElJ8rVYmIh9AqO2Uh5HSP7Ft8I2PLSUbxV9BkrOtccJgO6bHiwUhp3UKNGM EliBzaSOTPTvFYIw2uhCjHpC8zKtKkI2EnjG95KpbDRY1Zzm13Sc9dY75daVGZsSEqzL qlu/TYz+/CAL4P0RjVTGouDpvnwanHBolJFJ7ek3Z37rfAz8Mdcof/1rM9sVKxLq4MqF vDOWkjUo+BjLCEsKNnrPnV784z+TVsGes7P+uyCnCJXPExmNnRsEGh3M7yR6iIoCHN+G F3og==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D2d6BZ7h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c068c7133fsi1932385a.437.2025.02.10.08.19.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:19:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D2d6BZ7h; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863798 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1678195wrt; Mon, 10 Feb 2025 08:21:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUqVhPQAhpx3aRq7vHZ7cgKAWFNZOaQQP6aQUnh8NTD/dZvQ+yoM4zSLvcQmW3Y0+luPBTRQQ==@linaro.org X-Google-Smtp-Source: AGHT+IF4t0uF+UE3t4lbmSIAgHyf0AXg8LHZF5qhiw7Xr8XUvb5fjq9/wcrQcf1yC9H7giU2Aq1V X-Received: by 2002:a5d:59ab:0:b0:385:fd07:8616 with SMTP id ffacd0b85a97d-38dc891ff80mr10977638f8f.0.1739204485279; Mon, 10 Feb 2025 08:21:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204485; cv=none; d=google.com; s=arc-20240605; b=N6lbYZ2+iwI7AkINC2NLQrBKBeuWgZn/WIAQz4P8U79pRcjYdu5HGLW78NEeoZRhKC lcxcdbKoIKzLrKoN6FKq2wS2R8cdXv7I51I92ts8KE1Iy07F23/t9xu6N3GEvxcMUw7T HNMMlIe6qxx+eRgbso9gTu+nktJgNAMTZnHLxND0CpC08ZQGw+6CjN7p6uni7Qat+Zcj e8DL+6mk1GBwbQ3+3cCDtbxnjqIU2MC7MLV93sGQaXGjVkP/w4wD5SfZiS7VtiJaZUHZ nXojKzL7fdRfy6NcsO0/OD0ihCNJauwCNkNqRZsXLBHefPSrwB7pGhlbTHICfilDx0OR PHfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4YSWMGdWl+8666egd7dZYOBYPozxtU1KxGkBOuAirDQ=; fh=u6N1UvhsqhcFAPs12vhNsj42USY6/Rwq/nG48mmOGo8=; b=QKTHw2ZP1CFpYAffFCL1m98cGE8wah/BfUNO2fWWaBh+5S2DWa0ECU9rkM3yfFszO7 sYPygDofFhLZInHTIJiLqEY2kZYXTFDX74aiXHy+6pL2osfekL55uGrT4VF7jzcdSwFN o0OnWxfATjib9oiOD7p0l2RplYD/uvA9mfKLNyFpMW0AYGyBw9cOWH3oCU3gExXysRad XPMtCJ6AX9UXlm3jqrTZF+JAe/7lJCRHwNVsXI7PsDKSAY/3C7BK8cU2UwkxlBtzmrbd d6Q8Yp7trrCfVK09COcM6adVw6JW0u86MOx+alJ38qiI9qk6qDv/oUkppkkv2mCASrbh dddg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nyyh2ewh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-38ddc8e4a22si2297687f8f.142.2025.02.10.08.21.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:21:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nyyh2ewh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863797 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1677455wrt; Mon, 10 Feb 2025 08:20:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV7rxWMKGHBAQwfKIGQMGhgB+baB0XP7ij53VxYD3iM/XpwWLXdgb0hc9LE8InUnkzyiszlFA==@linaro.org X-Google-Smtp-Source: AGHT+IE0LRE8xKNv4vdzCFBW7orkkWxFSlULtCUpXU5Kqd7cbMEufTtkMxYORYSAzqyVX/MKMYlN X-Received: by 2002:adf:fe86:0:b0:38d:b1ea:506a with SMTP id ffacd0b85a97d-38dc8fe4162mr9029561f8f.28.1739204403709; Mon, 10 Feb 2025 08:20:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204403; cv=none; d=google.com; s=arc-20240605; b=MRiRiMnchhiilhYtgvYyOGLwF2DeYHPmlRC/ia7TUKbd9VRqGup2KDc1qBO4rSX+xx 2Zl9CY0NvkMXWSintGdzdE26WIxjD66w/50SV+iV4j/ou6M03OQwgk86zWYbesLNBRa5 rqVjoClYkBKyO/L/TTuvTiWJH5IUxUuX6sf1GOhNCXsL2r1FL+CfChXma8yG12MGTb5x B9VCtr+rkz0SDi2npm0qdCOnZxh3vXu1QdTRS38KltkovkRPPXyK2QNhtWKLcWt4CRIu 3iDTJdT30CnxY8VNq8dyEQdAjFiELIgGqndQnLHIxvjO3+xpmn91pNqE20X3NwCGe+uX V11A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ayP8EMcB4Qo24WwN/jtc5LLSaKf0jilqA/YV1+mpnK0=; fh=A2Zo7aVQ/VtN4GAXw6aHQhTa0BuZcPyoTODjv0LIq78=; b=gkvTI55xAV4D5UcB5gOdaLaRxzjdKjaBHPXjhkldvr28YPP+0hCzK0c/DDkm1gZPj7 o+PefnjOoOla3xH0X8lgJsWRwg1nmH4GXiY0QNgLJeDx2VBAIUb8b1wPZArU1ORAdQVs dtIf9LPD2rTNxKR5eYRZczoOEd/SyP2OGLDdbIBk21TtN2LVsM34ifptK51qh61c8qfb CM7m09dgbdLY3SvdX3SMwBAfMRZGwMD1R/iq7O7Len0YoUbIJl0++5CCrYrOpfXoH/4D stTBcJ+OdcNLRkVB0JwzFALuJlYR0DKUc1EmasxVIyjFgHdtSfpWMZroiLoZUsgysuhL a/nA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JRQGeReu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-38dcef8d705si4457481f8f.755.2025.02.10.08.20.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:20:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JRQGeReu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863809 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1680055wrt; Mon, 10 Feb 2025 08:25:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWwh7yjxiO8yDBLyUXKx15OsfZNfpdQfpV2DEYKIEKT6BDrd7JS6OHhM0z7y270GOWx58ISUg==@linaro.org X-Google-Smtp-Source: AGHT+IGZkRZE/dJxVHUpQCKnUn3VwiW0/BodLg/Vmjci01pSX0+gOZi1C4s07SvYfvc9EHpY06BE X-Received: by 2002:a5d:64a2:0:b0:38d:e092:3d0b with SMTP id ffacd0b85a97d-38de0923f2bmr2773588f8f.39.1739204716089; Mon, 10 Feb 2025 08:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204716; cv=none; d=google.com; s=arc-20240605; b=Zaaknu3Wn4YvSQlWg9kb3gOUabygUkxe0Tj1Sapz7jX5dYiYL9sB5Cpdw9v8DwXrSZ q+RFtzKD9x1yBjcjA2M8MzPFYWmU6VJiRQz5LuVkNI1zkyrWiQ79IIJLGBMUzcdZibFn oQOxiverhk7PFsS7e4vqoNY+gASaXiRYbDei3Z7IeIJC93SWU3gAukfeobqNWEEKC4b/ NtO+4V2SwjN5dF/GHwM7KJVjLVVLd7I3YII1V+uAI2pa9R4j/rNyPijMG32/fCgKmO4G ii7cRf6f3mIcoNAz3bhDSduK22mB5/q01vOxFKuxAb/gfIEy/j6ktAr2UIsg9pJs4rEO O/0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cv/0HiWib5mVBaxSrAfp5Uz9fY8LMI2bjBnu/BWf/Z8=; fh=9NTumLZGpBx5jQEP29+z9TNsdwEhuX/5fSeD7t13FW8=; b=eg203XuwvSyO4RJWFBnTo+qaTRIaCwVrGJd2E76x19uCjyt3tGt2uaD0h81mWTxt7S Soz3tUuat54Q0RZHkiamHZWZLLhRxSqHuoNUHUIeCcjE9hz+aZ6ch68OmRcHbDMscgyP 9gAeZhTAFb1ATMjcnJ7v3yUsgd8n4I1sp4iBA2itZn/vTyIn6y8cwFUGn4rMPFcJ1oxj mLOxHwANnMGtUav2ACvAQhSBEuuNqARIAWOeR71+fUbDgfEqLqM7ig90ZLx40Af8bJRs pIf2jsWLI14RMkzI2ytrKIaEIqaLk52UHLEhT/agln3rF0+88LlW9lcbQZ4jUGRMtusd jrxQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YixDZ3bI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-38dc446a408si5662418f8f.842.2025.02.10.08.25.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:25:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YixDZ3bI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863790 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1676017wrt; Mon, 10 Feb 2025 08:16:59 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWaBbCu60ExtWupzNRmpNZ7C2v+/AYvxVGosJpsJvndldpxdHdlM+x4a9HGdaE6bydiKq5DqA==@linaro.org X-Google-Smtp-Source: AGHT+IHXa0lRzDRLH8gylsGDy2RpF4nc2fPaQNXNHF+7gOAHDstxpg9ZA0xF8Kfq/dffaBj95iXi X-Received: by 2002:a05:622a:c5:b0:466:9507:624d with SMTP id d75a77b69052e-47167a37ae7mr182936051cf.27.1739204218896; Mon, 10 Feb 2025 08:16:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204218; cv=none; d=google.com; s=arc-20240605; b=UottXmCa1Pb8Ru1gF7oSq9G0jSCpr3V381L6jQOl6Sa3v5LQZFyGfzYsePMGxheYEJ CXPVWlIumPAdJRJQd51CC3paGkD0XvpaVjf3KofDdKdhpOjgU7+jPitC5ruPhjgxw0H6 JDeg6+VYRk8SYo5TLbF0S4lh4GHkglBraGNj3ASMLxFK0cWuzvzD5rvAZ/LFFoZRHnkT TlZtqarb2/GguEJPW/yuLxRPsmrraiyepBIaHHhezAo/JIhCnkV0RA0WH8z/x3EpmhFA OsJclPiHDvyemJB6NqVXIREY6C/9iPoL6yw1KxtLd+ilclMGTX8fudAaWyfRWTxJ11NU gKXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PVPkeSXe9XeKHyg9wdlTOD67ZqgGK5EiAy24Z30yFIk=; fh=m3bIYSMZqCABEJVkIKLKf3tNf8TH8EKhZ9yqNwsZqDo=; b=CXLJ0ZLo+kjFkDt7Rd2nI8tkbk3z86zl8LFkY8SRcUa3yWzGru1/Fd0KUdYbdfl7E+ Gm0jWO7ZqxK+Tvj03vZfu/8PC1gw1k09gu43xZh1RgMz8yiRHuDnXc8SJ1xRp6XzhNcj vivnGcoKOBosLqXtf4IHL38DfI0QxnM7PmvkvFKxW2qvvDGW0eN5IpW/ZbFW0FG7Bp/d +S7eNQGY0mVHIlauaHjA/6FCSEAPYw/BHl+AvYPxR5QftFZYs6FskHWN55er7QQ+wRgw 1kRhPed+9VjmHAvE+13b49trDV1g7zCqL9yEw6xPluUDJZ5wV0n2u+7PmllDkFcGXqjb iN2Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wvxefPFK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-471a081fc68si848341cf.222.2025.02.10.08.16.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:16:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wvxefPFK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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: 863801 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e42:0:b0:385:e875:8a9e with SMTP id r2csp1678927wrt; Mon, 10 Feb 2025 08:22:51 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUAlZFKNSBbOQarNlUZOSBnJVJ5Levs4Zpg645OU9QvH2BjhxwTExVfJaZ15QHMpVnqpT5zSw==@linaro.org X-Google-Smtp-Source: AGHT+IE+neHDw4y1R4Kb9hb1+4oonhGvYIIFV1udjujy57mKuWGYhub14Sxprhtv1hJiWijKij44 X-Received: by 2002:adf:f3d0:0:b0:38d:b282:bbb2 with SMTP id ffacd0b85a97d-38dc9127c84mr9696499f8f.23.1739204571251; Mon, 10 Feb 2025 08:22:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1739204571; cv=none; d=google.com; s=arc-20240605; b=bH+/yzMHqSjseKqqHIjCuCo6dsk77WXztEWGV+lWd1hGIi3G1o5qveO9pCn4xPR5za 2P/yvzXwSXvCZxJU1tRHq5etGAYT0eTrduNottDsZOnVSjBUuVobVAk47FsQDFgWSY7l +QiJ/wDWnC5GynnILzKAVSJ5+cHam56s7EjbmGcOOhPQ5jBetyNRw3bdzuiz0rRgiAEj hzAWmEShMEgfjomHCvVuM1ijsQXjBWYFQnQbH5ZHaI/8zeSanLWda6yY2a6/KZd+nM95 meO0AYd8G093CLEcYeDDvlLXPZvlQn5xPjlrRh+n6n+59vqUT/ULGuB5XXHBDO1jPBfU 7QVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=irCLni2uqvi4DVHX26aA8cLaSUYGRaTtdMKZFKQjhYQ=; fh=U8v/Dtss/m4oPeJtZ17DHKEvZGyePY/+mu3CqtBX2ks=; b=lSIoF6f6DGKwuIMp0HYOxe5bc1BhCMywK9SqVBZTvOSBoSDKlkN7PPODHkrStUnaKw D9hsxB6QnqxKY6aqvz0Zs6RJNZZmVbtqwAxFJM8Qx2u9OE6d0uOvNvKerklfmIZBWhGI AZpjx5sx1syoAbKVTtSGQJUW5zKLDXflCitOo+dpTaHBhAJmCYnBla4JVp4BMpAHZI0p kRCNKQgGGQKBuF0yVyEzJ7VbpGqExE1OMC5/iqvcj2pIoCsRZyUU1WMEV5N+skvPkGdU E2El8/ReFKyoE0xpad+Pb97bt6INVw/msFgrYYkztIWxP3mzj5DhVh8hE2osshFm6I7e U3tQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eeIWCLIb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ffacd0b85a97d-38dd0f38ee7si4130067f8f.747.2025.02.10.08.22.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Feb 2025 08:22:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eeIWCLIb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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)