From nobody Sun Jan 25 12:00:06 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=1769175362; cv=none; d=zohomail.com; s=zohoarc; b=G5Vm41AuuiDyKTT5b8pJY/qg1PSSmqNCyaY3eXHpt2S8U2Ulb5TFjKOXdSWmGOpvgS/K1KNufzT/7N6laRPbs1MAg60OBwoqQZIV9emgvHV2hz18k3HC2aE4TIfqnsdbVPE/EirZijuBxRCD3558RczIPXsdToBW09nLTJS2H9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769175362; 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=TNfykULAYugK5y7/EgGpcRMmiorfVRc4IdQIghGhNe4=; b=OQahK5++osW/JRgjzM/Yt1QXhXwygJEOWKaPNOiFSwJLAzUMDxtWUzdmnokHi8Wouqs7lN5d2s0qIzyBV5HSQ7b5SkIPfm65E2qKNv/dGimnVB6dThKL5dErW0JSkS0wZGxVhRHp1YXJoUQpaDfpLdCHx8+lvbqMARC+ONDWGwU= 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 1769175362807579.7021667507687; Fri, 23 Jan 2026 05:36:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vjHKD-0007RC-IK; Fri, 23 Jan 2026 08:35:45 -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 1vjHKB-0007QS-RG for qemu-devel@nongnu.org; Fri, 23 Jan 2026 08:35:43 -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 1vjHKA-0004cA-79 for qemu-devel@nongnu.org; Fri, 23 Jan 2026 08:35:43 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 19AA460010; Fri, 23 Jan 2026 13:35:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5775C4CEF1; Fri, 23 Jan 2026 13:35:40 +0000 (UTC) Received: from localhost ([::1]) by mail.kernel.org with esmtp (Exim 4.99.1) (envelope-from ) id 1vjHK6-000000063Jj-21yc; Fri, 23 Jan 2026 14:35:39 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769175340; bh=cAn/uow26i6rYfHjiGm3Vhb9DNFN5wMSz3b13l7uzdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kvElkiPUnr6+LR3Fb/ljJOGNP6LYTeB6gDV61M4Jw1mb+SBrXPuGJWjSfVsWxvU/0 tymWzVLjfeb5mvf1KG08VOONtugMqNKb6m8nqaVakmQZM9o5NRJe34V/AAiI63OH/X rhQW4ihS+XiMnG7/jtjxD9r4rApfzPI05wO4mL6l56DymMG1rCAJ/kSrUxnqk6HsE4 0jU8xrWm34VZXNb83yAIKnb5aTlAWaqPWlJq1yNWISCvRO8rN5w+BFIGgL4FOEtdsr 6mZIQ1+yieqThbz//o/c/zlwZFuFyASOQPl8RHh5OcdYZGsxTM2pVx6AwUAJP82aFX 3iacmu5K2J/Ag== 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 04/13] scripts/qmp_helper: make send_cper() more generic Date: Fri, 23 Jan 2026 14:35:18 +0100 Message-ID: <6fe142b90bea9a8c8be43dc86f7750212be05809.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=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.079, 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: 1769175364574154100 Allow the caller to set GEDE, GEBS and raw data. This can be useful if one wants to replicate a CPER with the same parameters as the original one. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- scripts/qmp_helper.py | 69 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/scripts/qmp_helper.py b/scripts/qmp_helper.py index d37fb0ae11cc..ac3abc794c69 100755 --- a/scripts/qmp_helper.py +++ b/scripts/qmp_helper.py @@ -551,22 +551,11 @@ def send_cper_raw(self, cper_data): =20 return False =20 - def send_cper(self, notif_type, payload): + def get_gede(self, notif_type, cper_length): """ - Send commands to QEMU though QMP TCP socket. - - Return True on success, False otherwise. + Return a Generic Error Data Entry bytearray """ =20 - # Fill CPER record header - - # NOTE: bits 4 to 13 of block status contain the number of - # data entries in the data section. This is currently unsupported. - - cper_length =3D len(payload) - data_length =3D cper_length + len(self.raw_data) + self.GENERIC_DA= TA_SIZE - - # Generic Error Data Entry gede =3D bytearray() =20 gede.extend(notif_type.to_bytes()) @@ -579,7 +568,13 @@ def send_cper(self, notif_type, payload): gede.extend(self.fru_text) gede.extend(self.timestamp) =20 - # Generic Error Status Block + return gede + + def get_gebs(self, data_length): + """ + Return a Generic Error Status Block bytearray + """ + gebs =3D bytearray() =20 if self.raw_data: @@ -593,6 +588,52 @@ def send_cper(self, notif_type, payload): util.data_add(gebs, data_length, 4) util.data_add(gebs, self.error_severity, 4) =20 + return gebs + + def send_cper(self, notif_type, payload, + gede=3DNone, gebs=3DNone, raw_data=3DNone): + """ + Send commands to QEMU though QMP TCP socket. + + Return True on success, False otherwise. + + Arguments: + notif_type: Notification type (GUID) + payload: bytearray with the payload + gede: Generic Error Data Entry. If None, the code will generate + one using the defaults and generic error data arguments + gebs: Generic Error Status block. If None, the code will gener= ate + one using the defaults and generic error data arguments + raw_data: Raw data to be added after GEBS. If not specified, + the code will generate one if Generic Error Data + --raw-data parameter is specified. + """ + + # Fill CPER record header + + # NOTE: bits 4 to 13 of block status contain the number of + # data entries in the data section. This is currently unsupported. + + if raw_data: + self.raw_data =3D raw_data + + cper_length =3D len(payload) + data_length =3D cper_length + len(self.raw_data) + self.GENERIC_DA= TA_SIZE + + if gede and len(gede) !=3D 72: + print(f"Invalid Generic Error Data Entry length: {len(gede)}. = Ignoring it") + gede =3D None + + if gebs and len(gebs) !=3D 20: + print(f"Invalid Generic Error Status Block length: {len(gebs)}= . Ignoring it") + gebs =3D None + + if not gede: + gede =3D self.get_gede(notif_type, cper_length) + + if not gebs: + gebs =3D self.get_gebs(data_length) + cper_data =3D bytearray() cper_data.extend(gebs) cper_data.extend(gede) --=20 2.52.0