From nobody Mon Feb 9 05:43:27 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=1768994832; cv=none; d=zohomail.com; s=zohoarc; b=VfuvUeb2ohgtexLo1hoWdyVMf/wndk8ZCMo9qiqe4uwdu/osONPJM1xq2qajug/roVkCvy/8nD0p4orAemNIF9irUHGRaJs64dul0G6YmyPxHubp5E+fuHSDiZ08s/0LU/JIi1e3SoWOXv1FA/sZjRYRxcQ5cYPM7l8L5yt9R0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768994832; 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=YrBlTge7d5IsHKXDS61i70rTZhM/EuMa2plXNBXxDDs=; b=IYZe5X/nLohRJBeWRidFvdpH9/7TBkpTK3uVKqoRATE4l2yhjGXFLqMvyjhuv6927pRhaGYsXefRKUmyxEnTP0M+xWWX+WKcOAlHKdTe0Dt1+zFH0ivhVBUJld0kGef26K4K+SbFnipCWXMx0DkYw5NIUrRvMpSlve0eFD4c4YE= 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 1768994832521363.5501953428509; Wed, 21 Jan 2026 03:27:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1viWLX-00037c-Bj; Wed, 21 Jan 2026 06:25:59 -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 1viWLE-0002qD-4N for qemu-devel@nongnu.org; Wed, 21 Jan 2026 06:25:40 -0500 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e: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-0007mx-P0 for qemu-devel@nongnu.org; Wed, 21 Jan 2026 06:25:39 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 386F444175; Wed, 21 Jan 2026 11:25:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E55FAC19424; 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-00000003gJW-0McM; 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=2JILPJ6jI/HfWZUXE4cKdBtggHc0n6EAmY9XXq4NC5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TPShCNPAS1uSlESGFBntKR3QY4jF7Qg3ZbDJAUOVAczg32uTKQHdfDi5hPk/cgKDZ aGIVaxg5So+70s8NEgeLKfVE3/G3aNBrg0SXw9/vbPENrP6BWmdbsYRWKNxs505cdL gsdG7cEfx9Apdeyqhq55QPn73aLtBIw7pRuWVICk2BeNwFHvvTsTkJRh9NEAud5iNW kqrMQWr8R+x40WWrzoT6D6z9X26UNY/TGycXjr5gDl0X/9kpF++CwqQ0omyy7oDVZ2 qtRbUb7IWJRFEbVBFMb1Io+O9zbyghWCsZxWc0Nql7xF3RaAOWlXpqxRzqrI9N6ni5 bl2BgF/GOSkkQ== 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 04/13] scripts/qmp_helper: make send_cper() more generic Date: Wed, 21 Jan 2026 12:25:12 +0100 Message-ID: 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:3c0a:e001:78e:0:1991:8:25; envelope-from=mchehab+huawei@kernel.org; helo=sea.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: 1768994834398158500 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 19bf641a13ce..51c8ad92a39d 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