From nobody Mon Feb 9 08:15:22 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=1768994772; cv=none; d=zohomail.com; s=zohoarc; b=UJSwcR4J1GdOoHBWKbnQ5OvVWLpSR1zjGzNfuVt9ifykEZwfiU5SKbPie0n2QzWyY7vfBvcLd2rfiODBPz8Xr17Uxzzt9T+luyu7rNOf+nYUyr9AEd5p0sUXyVbI6umPB1jaUbuQLV9f1YZ0ijiLbyPMAze9Uhm1RebLKmoi7FA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768994772; 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=qJgghm1I/u47AvRlxLoJmH1D0eOqQCR8JS/ZYdo22GU=; b=P6U7OYiV336EFkicB3KAPVj7OtYaca66WifD0sBh+qW6Yws6JgBa3nh2rwcZYkiR95StdgDLpdf4S/CT5tp0H5vJvF3Btk0YlYJLVuABOE4C4VwjWevoB9sndrivOFFlMJj+3DoL6he4wJnFJQRdA5hnDKlsXsC8RBmtrIOOF+U= 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 1768994772532670.0875615025071; Wed, 21 Jan 2026 03:26:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viWLJ-0002wp-9Y; Wed, 21 Jan 2026 06:25:47 -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 1viWLF-0002rJ-9o for qemu-devel@nongnu.org; Wed, 21 Jan 2026 06:25:42 -0500 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1viWLA-0007n6-N2 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 06:25:40 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 5A38E600AE; Wed, 21 Jan 2026 11:25:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3796C4AF0B; Wed, 21 Jan 2026 11:25:24 +0000 (UTC) Received: from mchehab by mail.kernel.org with local (Exim 4.99) (envelope-from ) id 1viWKx-00000003gJe-0aL4; Wed, 21 Jan 2026 12:25:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768994724; bh=IoP6UNuVlYspWDh1PMyMvKQhO54WgyTdoBbrxGt6IDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RaE+MEkZVzzaGHogAv/Z04qA1jYZdEBkMgW1VPiRJAWy2puU3Y4YO+xlzaf0rqw85 0f+1r3qTFJY1Bt6x8ByBKI/RRHgS+oWA5wScP0YulezofELv+dagOS4AcibSIch9nm BmeqLVtUAuTZOWb1g7qP3Oj1fwn2BxxVT2Rz49iGyXlOglDPg1HcSRvYp3zh3ceF9s vKH2eFg5Ge2IQ69Ciyo6OzJFFBexqWotuU2GauT0b/Cd75pvsKnZiLyosLvhL5wrcn hi9B1OO+IbyuYc7blWwgiA1w1LAhmycTJwzBUNmwQ5yYVDBCmIJ8jTWtQtZk1nJpKO uEtrU/jFZTcvQ== From: Mauro Carvalho Chehab To: Michael S Tsirkin Cc: Jonathan Cameron , Shiju Jose , qemu-devel@nongnu.org, Igor Mammedov , Mauro Carvalho Chehab , Cleber Rosa , John Snow Subject: [PATCH 06/13] scripts/qmp_helper: add support for a timeout logic Date: Wed, 21 Jan 2026 12:25:14 +0100 Message-ID: <2539e524dd467af51f8286bd1b201feaad06c81e.1768993993.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 (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=2600:3c04:e001:324:0:1991:8:25; 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.087, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1768994773898154100 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 40059cd105f6..63f3df2d75c3 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