From patchwork Mon Nov 25 15:20:54 2024 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: 845348 Delivered-To: patch@linaro.org Received: by 2002:a5d:688e:0:b0:382:43a8:7b94 with SMTP id h14csp1248033wru; Mon, 25 Nov 2024 07:27:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUPWXpfT1Y9zGSYWh7JYql9LjVxH5H7XirVirR8By+rTlVvDBeDtGypwRdYVNl5H3bBTwDNZQ==@linaro.org X-Google-Smtp-Source: AGHT+IFj+JAow3sc8MCMN9G+m5hOeJV91Okobm2Tzt1aj1T2dstLdQP2rYZdUVOgjI0IfvahHYsq X-Received: by 2002:ad4:5bcf:0:b0:6d3:f741:3518 with SMTP id 6a1803df08f44-6d451342c62mr206183686d6.30.1732548440962; Mon, 25 Nov 2024 07:27:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732548440; cv=none; d=google.com; s=arc-20240605; b=iAiYPfH3IVqSklrob8DXwiygY6wU6SxUAXVbb4F+Y7zNQ1xeREMa70tboOQDv5icOT GBPVZjQHwdZIlLZO8SX2ZuMhZVWiuoGo3aKs7vG+xGt1w6B6X9G8/yFY7HGStp9qJEa1 5D4DDvJ8DMAn/JdAPdaLc8dQCF2pCebEGWUSrIgbWIVq+r4otF4TYUnz1FjjtjMeZrjB dKXZ6GJ7yGSFzK8t8dJCDF5h2rk0aiodifnZ7oDgdv0klBtddth+gxPg22y2Vs6H0ZC/ +wLV0SXbwKPNrXNfjH3/JCfDjnyHbGEpFi5z0FeIQJdek+JPa3RMw1L4u843O7qBpo0/ f7Og== 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=vAncWUHXyfA57+KSZY1P9qzVPf7uUwxapVn6zYWCi3g=; fh=6mDKvW8kWNqSgMRXstCIjuE/wvBsxXt+CmnWPweyKjQ=; b=T6+Lq/THvmWVQ1u8prIykmiV8X2M4JQQRES/adJ/7NODRUUXhoEmfTECDdbS0UKcIC yK7oRjrb0h5ZWH82WGEw7C+PY68U68xcy0yrWUbBS8PfVTFSJN46KvereRR8Q8P1GaRW 9zdCk3qwp7B25NQi/I+hzQ9eyLsiWmQHpfYmsoXQ2Qw2+Tjr908ugEDF1MjUHaYactH9 hbo16DHjeDapG2p8OPEOy+TgLqZoDd6r0lPtqGLfomQei97VGxctuXt/kNeSZTz15PDB 2d6Bf5tb9LpCnVMs1NMgVWrjDBW85URQBwnomx/5ch72cFKEBKeIxCNPKXhQHyxYeFUq e7tw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yQEdAk89; 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 6a1803df08f44-6d451b6c42esi93905596d6.441.2024.11.25.07.27.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Nov 2024 07:27: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=yQEdAk89; 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 1tFayn-0006yd-6n; Mon, 25 Nov 2024 10:26:25 -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 1tFayg-0006uU-O0 for qemu-devel@nongnu.org; Mon, 25 Nov 2024 10:26:18 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFaye-0002Xp-VJ for qemu-devel@nongnu.org; Mon, 25 Nov 2024 10:26:18 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-38242abf421so3065614f8f.2 for ; Mon, 25 Nov 2024 07:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732548375; x=1733153175; 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=vAncWUHXyfA57+KSZY1P9qzVPf7uUwxapVn6zYWCi3g=; b=yQEdAk89NP8AEo2nC1uVIh69LDfMQxOV9pyc1Exte2dSd2QGiTr21d+QOXLrIDMSnX RBOB4pJAtVhOXHjej9ycU2GAVXaH7VCSKZKaTjBGX859qxziKEjRH/Zp9uYNdf2Jikd1 bTEbX7Ouq3k6zTL5itcPPiRsG/XxuVjBhTEjfNLpiv5bpPZNlBwZJf2eAuJXHFohXFVs h71CD/J7GifLcyevlrG+WbynUC2KhQ23BW8dBunb7yqtxktS7UNN7S904ETiDhXokq5b n523cXt8sdBeoDMMGADNjnHR2Z/Gk9t3DI+a6C8dFYJwpl7QkkPyPlxOz6yG4qh+aiAP czQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732548375; x=1733153175; 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=vAncWUHXyfA57+KSZY1P9qzVPf7uUwxapVn6zYWCi3g=; b=oll3GyuIrL/oNVwf/iIT+KbubrIjcWW6XkttfgbXw6vV4atTbHLFx4alCzuC1djfq1 oh2wsb3fUe5MkoSX0jWyf2jwADsLHeDkxYHXNiP3nVsiGTDrGcFjdUFz7SqNTjs/BUks B3IeEvcIDl6jPmnLMfMnsmGhhRDOByCXcEKYlRfeMpPiek+v8OPNn9E54acDdVtN+qYc eZFMSgaAxezgHhuDBfgY3d91PfR9RK644JA8ovDReD+c+Xhd0m2J2QMD4qv+WLISiz/2 ccWmZiHHgSLcHvmxkfsocipIDJiTdqQFBYGuC2LoGMIhnh65QxnpYD53UaBKeP5fFog+ 5DMA== X-Gm-Message-State: AOJu0Yxv+3TjRvw9j9253xDBiI1iYNz4U7ApU/+umZV6m7mL1RP5K5dq Hoj7gv0ZtqvdhrpseErGKvqi5KIkGia7uv3aco9GUzGWrc/dt4QPAhaQj3BLGDE= X-Gm-Gg: ASbGncu9gv4HPaBVVcUUjrQI5/Ea6ycmovz65oArR0q99twLDvbVJO4NVTVOeBG+XA+ RnclEqTL9PFwHum7tgR25JZFcJREG2BP7gTZ4cQULTwElB69lBgFU3xFqxkEeh2TKRlc9Nh93J1 LqQR2G2ffw7ozuxejOFR9YnvJ/QkhKQFnnkzkYfC32ZWazOg3QF2VfJc/p4LcNUGQReDX3sIv9e Z6iA43Qrb7Il3lx79Eq8v9GRzLpK9SjFGNa+DyxEeWtLqR1 X-Received: by 2002:a05:6000:18ae:b0:374:c847:852 with SMTP id ffacd0b85a97d-38260b806f8mr11899215f8f.29.1732548374880; Mon, 25 Nov 2024 07:26:14 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fafe98asm10565203f8f.39.2024.11.25.07.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 07:26:14 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 5786D5F8B7; Mon, 25 Nov 2024 15:21:07 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 17/28] tests/functional: add a QMP backdoor for debugging stalled tests Date: Mon, 25 Nov 2024 15:20:54 +0000 Message-Id: <20241125152105.2100395-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241125152105.2100395-1-alex.bennee@linaro.org> References: <20241125152105.2100395-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x431.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 From: Daniel P. Berrangé Support the QEMU_TEST_QMP_BACKDOOR=backdoor.sock env variable as a way to get a QMP backdoor for debugging a stalled QEMU test. Most typically this would be used if running the tests directly: $ QEMU_TEST_QMP_BACKDOOR=backdoor.sock \ QEMU_TEST_QEMU_BINARY=./build/qemu-system-arm \ PYTHONPATH=./python \ ./tests/functional/test_arm_tuxrun.py And then, when the test stalls, in a second shell run: $ ./scripts/qmp/qmp-shell backdoor.sock Signed-off-by: Daniel P. Berrangé Message-Id: <20241121154218.1423005-18-berrange@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Alex Bennée Message-Id: <20241121165806.476008-18-alex.bennee@linaro.org> diff --git a/docs/devel/testing/functional.rst b/docs/devel/testing/functional.rst index 6b5d0c5b98..b8ad7b0bf7 100644 --- a/docs/devel/testing/functional.rst +++ b/docs/devel/testing/functional.rst @@ -176,6 +176,16 @@ primarily depend on the value of the ``qemu_bin`` class attribute. If it is not explicitly set by the test code, its default value will be the result the QEMU_TEST_QEMU_BINARY environment variable. +Debugging hung QEMU +^^^^^^^^^^^^^^^^^^^ + +When test cases go wrong it may be helpful to debug a stalled QEMU +process. While the QEMUMachine class owns the primary QMP monitor +socket, it is possible to request a second QMP monitor be created +by setting the ``QEMU_TEST_QMP_BACKDOOR`` env variable to refer +to a UNIX socket name. The ``qmp-shell`` command can then be +attached to the stalled QEMU to examine its live state. + Attribute reference ------------------- diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py index e2a329c3e5..fceafb32b0 100644 --- a/tests/functional/qemu_test/testcase.py +++ b/tests/functional/qemu_test/testcase.py @@ -175,6 +175,13 @@ def _new_vm(self, name, *args): log_dir=self.logdir) self.log.debug('QEMUMachine "%s" created', name) self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir) + + sockpath = os.environ.get("QEMU_TEST_QMP_BACKDOOR", None) + if sockpath is not None: + vm.add_args("-chardev", + f"socket,id=backdoor,path={sockpath},server=on,wait=off", + "-mon", "chardev=backdoor,mode=control") + if args: vm.add_args(*args) return vm