From nobody Sun Jan 25 12:01:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1769175360; cv=none; d=zohomail.com; s=zohoarc; b=INI7PoUkoZUE7o2q2ULzWUDnoBxTWVtmzXsaqGIFA8LOBNsi2LbUFdLZwlZmvv5U1Q7ldY8ZmunQnW2oHFE+/OOjLXn2JY3cEQHjCxqTozOwQH5HrJ0u4jTcgYJqRw6IbRdV4P/jR7Yf7VA2ZUX2hlzP1mT66SqxquNr3BeTiVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769175360; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IDsY+53ym8RTShOjfT/4VvKLP3eWhIDRBlQhQbrO39k=; b=WMIkRLb3HFz2jnwmzDwunFTMvkwEXDja7ryfa6IvGfw4nCWaP2LlULoarrpGx4nfNEb0c4yJn8QfwROq3RGBhIn7PhpsBzjXhpsbcpWuSCiyWjsI5HugFtGyKzjBwPJP+ZEyDbhxiQBkSgVCnemL5Kf2t6d3CWYk/Tp7Pxebclo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769175360422523.4023207428696; Fri, 23 Jan 2026 05:36:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vjHKJ-0007Tr-0M; Fri, 23 Jan 2026 08:35:51 -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 1vjHKH-0007Sn-At for qemu-devel@nongnu.org; Fri, 23 Jan 2026 08:35:49 -0500 Received: from tor.source.kernel.org ([172.105.4.254]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vjHKF-0004cy-RM for qemu-devel@nongnu.org; Fri, 23 Jan 2026 08:35:49 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 3F5D360135; Fri, 23 Jan 2026 13:35:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E890BC4CEF1; Fri, 23 Jan 2026 13:35:46 +0000 (UTC) Received: from localhost ([::1]) by mail.kernel.org with esmtp (Exim 4.99.1) (envelope-from ) id 1vjHKC-000000063Jt-2soT; Fri, 23 Jan 2026 14:35:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769175346; bh=rKSrF85OxrtAnXi0vbTWc5mB5I2n992k0TGKaluhwVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UJsrezdYIAJazp4E8Lja1sLcL/A93noEiab3saYC2KNk2/Iy9uYGq6CGVXbYdl8wu 2JM3jt0sauPaFL6firABjRs8QMsStou1fwZI7HsEj1t4TkL7DvORAB/PgELsK4StPF ahysdcMw5nJ1zsQtGg70HHCEtGAfK9eglbTLFQxEksVqNdL9wEOfyjvf1EkxTGLd68 CGsU2hxemzB3e/fl12kJrLq2TFmFcitpeM0DrxNVMJB5GQCQxtg+3fkYrCNFiXoRrf WVbmD7+9U5yvFC9R19gfzb3TXSjhdu6W+CWvJKPxjSXjLnDwkhFlxcgLQLxqeFf4VD AdgXdbvWQKuxA== From: Mauro Carvalho Chehab To: "Michael S. Tsirkin" Cc: Mauro Carvalho Chehab , qemu-devel@nongnu.org, Cleber Rosa , John Snow , Jonathan Cameron Subject: [PATCH v2 06/13] scripts/qmp_helper: add support for a timeout logic Date: Fri, 23 Jan 2026 14:35:20 +0100 Message-ID: <3633cf168519ef0ad02c7e493865b0a20257b695.1769175069.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=172.105.4.254; envelope-from=mchehab+huawei@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.079, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1769175362580154100 We can't inject a new GHES record to the same source before it has been acked. There is an async mechanism to verify when the Kernel is ready, which is implemented at QEMU's ghes driver. If error inject is too fast, QEMU may return an error. When such errors occur, implement a retry mechanism, based on a maximum timeout. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- scripts/qmp_helper.py | 47 +++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/scripts/qmp_helper.py b/scripts/qmp_helper.py index 1587492807fe..d5ffd51f161e 100755 --- a/scripts/qmp_helper.py +++ b/scripts/qmp_helper.py @@ -14,6 +14,7 @@ =20 from datetime import datetime from os import path as os_path +from time import sleep =20 try: qemu_dir =3D os_path.abspath(os_path.dirname(os_path.dirname(__file__)= )) @@ -324,7 +325,8 @@ class qmp: Opens a connection and send/receive QMP commands. """ =20 - def send_cmd(self, command, args=3DNone, may_open=3DFalse, return_erro= r=3DTrue): + def send_cmd(self, command, args=3DNone, may_open=3DFalse, return_erro= r=3DTrue, + timeout=3DNone): """Send a command to QMP, optinally opening a connection""" =20 if may_open: @@ -336,12 +338,31 @@ def send_cmd(self, command, args=3DNone, may_open=3DF= alse, return_error=3DTrue): if args: msg['arguments'] =3D args =20 - try: - obj =3D self.qmp_monitor.cmd_obj(msg) - # Can we use some other exception class here? - except Exception as e: # pylint: disable= =3DW0718 - print(f"Command: {command}") - print(f"Failed to inject error: {e}.") + if timeout and timeout > 0: + attempts =3D int(timeout * 10) + else: + attempts =3D 1 + + # Try up to attempts + for i in range(0, attempts): + try: + obj =3D self.qmp_monitor.cmd_obj(msg) + + if obj and "return" in obj and not obj["return"]: + break + + except Exception as e: # pylint: disable= =3DW0718 + print(f"Command: {command}") + print(f"Failed to inject error: {e}.") + obj =3D None + + if attempts > 1: + print(f"Error inject attempt {i + 1}/{attempts} failed.") + + if i + 1 < attempts: + sleep(0.1) + + if not obj: return None =20 if "return" in obj: @@ -531,7 +552,7 @@ def __init__(self, host, port, debug=3DFalse): # # Socket QMP send command # - def send_cper_raw(self, cper_data): + def send_cper_raw(self, cper_data, timeout=3DNone): """ Send a raw CPER data to QEMU though QMP TCP socket. =20 @@ -546,11 +567,11 @@ def send_cper_raw(self, cper_data): =20 self._connect() =20 - if self.send_cmd("inject-ghes-v2-error", cmd_arg): + ret =3D self.send_cmd("inject-ghes-v2-error", cmd_arg, timeout=3Dt= imeout) + if ret: print("Error injected.") - return True =20 - return False + return ret =20 def get_gede(self, notif_type, payload_length): """ @@ -597,7 +618,7 @@ def get_gebs(self, payload_length): return gebs =20 def send_cper(self, notif_type, payload, - gede=3DNone, gebs=3DNone, raw_data=3DNone): + gede=3DNone, gebs=3DNone, raw_data=3DNone, timeout=3DNon= e): """ Send commands to QEMU though QMP TCP socket. =20 @@ -656,7 +677,7 @@ def send_cper(self, notif_type, payload, =20 util.dump_bytearray("Payload", payload) =20 - return self.send_cper_raw(cper_data) + return self.send_cper_raw(cper_data, timeout=3Dtimeout) =20 def search_qom(self, path, prop, regex): """ --=20 2.52.0