From patchwork Fri Nov 15 16:50:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 843506 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcc:0:b0:382:184f:390f with SMTP id e12csp946488wrc; Fri, 15 Nov 2024 08:51:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWUTMpFnqoK9BmOThS35oEYXpobUjwhQcWC4+KJ+4Vbrn4+ICnm5QZ52UaWNWXYyRsO6OKxeA==@linaro.org X-Google-Smtp-Source: AGHT+IGlxi/BM73yL6nRD1puaDHFPK9w1xgxtdKANtPuzAHiLztC4OTAyEsLqJPqBLYBcpUz7yyS X-Received: by 2002:a05:620a:371f:b0:7a9:b9dc:1b72 with SMTP id af79cd13be357-7b3622e6b31mr390847785a.23.1731689489069; Fri, 15 Nov 2024 08:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731689489; cv=none; d=google.com; s=arc-20240605; b=QLvNq+qX7N+tsdDUJFNtm1t60RUszU3yLLB6CUjQpSdub7XRGC06EDQ3OshGDGx9+S FxScKCMKXypg7iPfxB3Wu9/mptQesheWzV2SQ2EkDd8W7KtsI7RNZLXo9RxUM1M7tA0a u97vIlxZvSbu6S5Pwkz2y7m7MoL8Wkl3+k92KPHP5lgswsjczLNchGLY9NM+1sJpgtXw bBxicpJxorlRWW/nc703oXkRb8lqJTKQPJFVFma3y/eKQb7Al3ddXbhnkdhDsNCbE047 vwJ0KiO3HGEVmJnv8qc8Ms/BCMyXSptYYhgWZHD5M/Ofkb5ftheFLXgur2fwPUt2XxCp nAXA== 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=EKGJo6RL8JtSuOntPAnWTBPQ2/3pgYHRUszkLKiPvPw=; fh=L+F+imk7SNxd+VJgpUcpWeNwCxrzN2ZHmlwvyOYjkVU=; b=XOgXCA36coiNHGF9l1w3jkNytajrcAHbVdQ5I8n4EY+5mmDyfMRfPp6KB9tRTiAfGw KYEC71Rqy5PHfNXEsKnBUaKqZz7ykYEx7sp5F/K2DMjpYftEAmgwE1wC2AEAr85BO/2a nrFrTzuo1fboKcrzOnMQkXSSFuFIONf7UHQKGcF//Khmm0z6oz/cAUFDijKB9IofD0uS Gyou6oFKnBsmCEuuRiC2ganSy/Ax54rnx/HNN4CqgDjxQHdFlCPWDrjLlA/rQO17JTF9 TvkfOjUM1oG+yfccFdgXzA3r5UabF/W0GQZCHXYmuIAvhgzQL+CguuQ4i3adFG8EAJxz YxPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rjEaBllr; 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-7b35cae7c37si401435385a.605.2024.11.15.08.51.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 08:51:29 -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=rjEaBllr; 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 1tBzX0-0007vv-4y; Fri, 15 Nov 2024 11:50: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 1tBzWx-0007uv-MD for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:50:48 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBzWw-0003ai-1o for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:50:47 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4315baa51d8so7531785e9.0 for ; Fri, 15 Nov 2024 08:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731689444; x=1732294244; 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=EKGJo6RL8JtSuOntPAnWTBPQ2/3pgYHRUszkLKiPvPw=; b=rjEaBllrSSJmMJ+DLd7Y5lOdA9GXP2K97OKvoQsu4s8cl4kDZonuxkasr5ieGuVQ5p zNXtfUygGvBLPY/MVqWVMHnQ65neBcO3gZUXBOYQSIWiAdAlFPrUTSOzmvarmxwG+08P ws8/mn2bUrA5QnsmUpIt87D2tVSTPaBi/QaaKd8mtN1U0+2ZjAnKEAV/s8cf3QZerkXh m48HZcRfuOTfp3B0PVbMt9FEUTp004pR6YV3Yc0zxv5F5JiSUUZJ0aU97p8fp4OZYUqN 3+4cnkBFrvLxk7fihl43hWiFJkpVm48NHolbHKIvLVvsEkRFw5LKYVCOo/DHXi5LBc1l nkaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731689444; x=1732294244; 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=EKGJo6RL8JtSuOntPAnWTBPQ2/3pgYHRUszkLKiPvPw=; b=opfIdM/bBbumUb+yENdSsz4pyMS73+eQIkwS5Nti4UHd8+DNFQPcgsAbgusXlneEPh rxuzugyD1RDf3B06IjttKHUdB0KMw3xGSLRxerqZgWT8YHTXMwwWKOuIgJWn5t1FObWM GFvX8eJ1KQwVih1rnpsFNhzzK8THZNxhEu1xIbUcd9pOkhXDq2X4JUam2nSLVfcDp0vA OIP0Wauy+egVgllDrltgq0xXQMCohkz9f+vgXIrnl4e6dvNH2muonx8TxMu16spyiBor tG0gAs2ycJddtXZ9XazHAHcYnvcimuA3+DrL66Fd2XMxyYGZQeCTlM4I1UZGPRmuJxL/ jYoA== X-Gm-Message-State: AOJu0YyDEqgYxV2LSod+oJjgMyu6SFXTKDMBt6AWgQSRPR57fSvo9+US VbBVRr/axy+0aE5XqUuOgujvxO6iSN7K4wT/licgxTRj3coUpgqTtGiBqrgt56DHM9RJLEDuDL8 f X-Received: by 2002:a05:600c:1d0a:b0:42c:acb0:dda5 with SMTP id 5b1f17b1804b1-432df7179e0mr22855475e9.1.1731689443970; Fri, 15 Nov 2024 08:50:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm60386405e9.28.2024.11.15.08.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:50:43 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Roque Arcudia Hernandez Subject: [PATCH 1/3] tests/qtest: Add qtest_system_reset() utility function Date: Fri, 15 Nov 2024 16:50:39 +0000 Message-Id: <20241115165041.1148095-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115165041.1148095-1-peter.maydell@linaro.org> References: <20241115165041.1148095-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We have several qtest tests which want to reset the QEMU under test during the course of testing something. They currently generally have their own functions to do this, which work by sending a "system_reset" QMP command. However, "system_reset" only requests a reset, and many of the tests which send the QMP command forget the "and then wait for the QMP RESET event" part which is needed to ensure that the reset has completed. Provide a qtest_system_reset() function in libqtest so that we don't need to reimplement this in multiple different tests. A few tests (for example device hotplug related tests) want to perform the reset command and then wait for some other event that is produced during the reset sequence. For them we provide qtest_system_reset_nowait() so they can clearly indicate that they are deliberately not waiting for the RESET event. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- tests/qtest/libqtest.h | 25 +++++++++++++++++++++++++ tests/qtest/libqtest.c | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index beb96b18ebd..f23d80e9e5e 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -88,6 +88,31 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args); */ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd); +/** + * qtest_system_reset: + * @s: #QTestState instance to operate on. + * + * Send a "system_reset" command to the QEMU under test, and wait for + * the reset to complete before returning. + */ +void qtest_system_reset(QTestState *s); + +/** + * qtest_system_reset_nowait: + * @s: #QTestState instance to operate on. + * + * Send a "system_reset" command to the QEMU under test, but do not + * wait for the reset to complete before returning. The caller is + * responsible for waiting for either the RESET event or some other + * event of interest to them before proceeding. + * + * This function should only be used if you're specifically testing + * for some other event; in that case you can't use qtest_system_reset() + * because it will read and discard any other QMP events that arrive + * before the RESET event. + */ +void qtest_system_reset_nowait(QTestState *s); + /** * qtest_wait_qemu: * @s: #QTestState instance to operate on. diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 817fd7aac52..8de5f1fde30 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -215,6 +215,22 @@ static void qtest_check_status(QTestState *s) #endif } +void qtest_system_reset_nowait(QTestState *s) +{ + /* Request the system reset, but do not wait for it to complete */ + qtest_qmp_assert_success(s, "{'execute': 'system_reset' }"); +} + +void qtest_system_reset(QTestState *s) +{ + qtest_system_reset_nowait(s); + /* + * Wait for the RESET event, which is sent once the system reset + * has actually completed. + */ + qtest_qmp_eventwait(s, "RESET"); +} + void qtest_wait_qemu(QTestState *s) { if (s->qemu_pid != -1) {