From nobody Fri Apr 19 16:45:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642104042756894.0495835919147; Thu, 13 Jan 2022 12:00:42 -0800 (PST) Received: from localhost ([::1]:52396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n86H2-0001CA-Dz for importer@patchew.org; Thu, 13 Jan 2022 15:00:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8620-0007uN-LB for qemu-devel@nongnu.org; Thu, 13 Jan 2022 14:45:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37228) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n861y-0007Ly-HH for qemu-devel@nongnu.org; Thu, 13 Jan 2022 14:45:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-104-z-T7dFvyO2WqLsBfPQefXA-1; Thu, 13 Jan 2022 14:45:01 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D3BD31006AA7; Thu, 13 Jan 2022 19:45:00 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.39.195.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72A65100E125; Thu, 13 Jan 2022 19:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642103105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dJmfuVskT8yJsedM7Sx7cjdtjKigT5Qr7i/Bod/Tesk=; b=DkXciQpaxkor3eO+S2fdrdm6be/BJcVrY7LZddGrJjNjR9pqLfHAjGhLh9AJ/oNE3LkxBK 6lkupuYVE78zAfxlL4EFejKoC/EvDI7Mg8B28+iIop96Bf1B4NqVYRa7wdm50XZ2TsrAWR WtSkSM+gp4Bot9SJjzO4QmG/Sn3XCCo= X-MC-Unique: z-T7dFvyO2WqLsBfPQefXA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, peter.maydell@linaro.org, quintela@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v2 1/3] ppc: Fix vmstate_pbr403 subsection name Date: Thu, 13 Jan 2022 19:44:50 +0000 Message-Id: <20220113194452.254011-2-dgilbert@redhat.com> In-Reply-To: <20220113194452.254011-1-dgilbert@redhat.com> References: <20220113194452.254011-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=170.10.133.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.594, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lsoaresp@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1642104045111100003 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" The pbr403 subsection is part of the tlb6xx state, so I believe it's name needs to be: .name =3D "cpu/tlb6xx/pbr403", Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Maydell --- target/ppc/machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/ppc/machine.c b/target/ppc/machine.c index 756d8de5d8..e535edb7c4 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -718,7 +718,7 @@ static bool pbr403_needed(void *opaque) } =20 static const VMStateDescription vmstate_pbr403 =3D { - .name =3D "cpu/pbr403", + .name =3D "cpu/tlb6xx/pbr403", .version_id =3D 1, .minimum_version_id =3D 1, .needed =3D pbr403_needed, --=20 2.34.1 From nobody Fri Apr 19 16:45:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642104992164875.6887984653887; Thu, 13 Jan 2022 12:16:32 -0800 (PST) Received: from localhost ([::1]:51922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n86WN-0004t5-22 for importer@patchew.org; Thu, 13 Jan 2022 15:16:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n862B-0007y4-OL for qemu-devel@nongnu.org; Thu, 13 Jan 2022 14:45:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8622-0007Mk-5R for qemu-devel@nongnu.org; Thu, 13 Jan 2022 14:45:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-90-qCqMfhKfM4uiuNpPgU052Q-1; Thu, 13 Jan 2022 14:45:03 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1D041B2C980; Thu, 13 Jan 2022 19:45:02 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.39.195.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D271100E125; Thu, 13 Jan 2022 19:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642103108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D9Rtqv5nFetkw54FozTaz0/o98J4ZnuNV1oSCeEl7W8=; b=SXaDTGlPntpwJwEg3EnQNihKnPR6VxZpEiq+POnYVfzCKG3Atl7iz2DSk1quJRvDrPrrah kEiWCVu+NBAykmUDXmtlGpXG9sJD+EmjSv05fQPw7W0ipJVmNYursAyDOK2Mv2YjOE3Go/ jqTSefd8q+qJrkYvbG4q9EmooQvDecw= X-MC-Unique: qCqMfhKfM4uiuNpPgU052Q-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, peter.maydell@linaro.org, quintela@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v2 2/3] migration: Add canary to VMSTATE_END_OF_LIST Date: Thu, 13 Jan 2022 19:44:51 +0000 Message-Id: <20220113194452.254011-3-dgilbert@redhat.com> In-Reply-To: <20220113194452.254011-1-dgilbert@redhat.com> References: <20220113194452.254011-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=170.10.133.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.594, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lsoaresp@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1642104993208100001 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" We fairly regularly forget VMSTATE_END_OF_LIST markers off descriptions; given that the current check is only for ->name being NULL, sometimes we get unlucky and the code apparently works and no one spots the error. Explicitly add a flag, VMS_END that should be set, and assert it is set during the traversal. Note: This can't go in until we update the copy of vmstate.h in slirp. Suggested-by: Peter Maydell Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/migration/vmstate.h | 7 ++++++- migration/savevm.c | 1 + migration/vmstate.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 017c03675c..b50708e57a 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -147,6 +147,9 @@ enum VMStateFlags { * VMStateField.struct_version_id to tell which version of the * structure we are referencing to use. */ VMS_VSTRUCT =3D 0x8000, + + /* Marker for end of list */ + VMS_END =3D 0x10000 }; =20 typedef enum { @@ -1163,7 +1166,9 @@ extern const VMStateInfo vmstate_info_qlist; VMSTATE_UNUSED_BUFFER(_test, 0, _size) =20 #define VMSTATE_END_OF_LIST() \ - {} + { \ + .flags =3D VMS_END, \ + } =20 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id); diff --git a/migration/savevm.c b/migration/savevm.c index 0bef031acb..8077393d11 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -620,6 +620,7 @@ static void dump_vmstate_vmsd(FILE *out_file, field++; first =3D false; } + assert(field->flags =3D=3D VMS_END); fprintf(out_file, "\n%*s]", indent, ""); } if (vmsd->subsections !=3D NULL) { diff --git a/migration/vmstate.c b/migration/vmstate.c index 05f87cdddc..181ba08c7d 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -160,6 +160,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, } field++; } + assert(field->flags =3D=3D VMS_END); ret =3D vmstate_subsection_load(f, vmsd, opaque); if (ret !=3D 0) { return ret; @@ -413,6 +414,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDesc= ription *vmsd, } field++; } + assert(field->flags =3D=3D VMS_END); =20 if (vmdesc) { json_writer_end_array(vmdesc); --=20 2.34.1 From nobody Fri Apr 19 16:45:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642104794573930.1295333435405; Thu, 13 Jan 2022 12:13:14 -0800 (PST) Received: from localhost ([::1]:46572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n86TB-000140-3c for importer@patchew.org; Thu, 13 Jan 2022 15:13:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n862F-0007yd-Hf for qemu-devel@nongnu.org; Thu, 13 Jan 2022 14:45:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8624-0007Mv-LT for qemu-devel@nongnu.org; Thu, 13 Jan 2022 14:45:21 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-H6OGdCGPMeqVA7U5YVDXrw-1; Thu, 13 Jan 2022 14:45:05 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6559985B66D; Thu, 13 Jan 2022 19:45:04 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.39.195.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2851100E125; Thu, 13 Jan 2022 19:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642103110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KCTSU2dzLGocSacE7o3F9FqPrmgf/LE2Ac3aHtzm9qg=; b=iFUjmIpWdikxNo+InqTZUzZ0IdoM9J4hCNmUS/UkyhZGYcDiFHbJ8mRm15g3nNZDLJuykU AOVmlIp/7Y5yOVhR8Psog0Zj4Tk4R1nVNDB6pOpq808j4N2XzSOHZ/l8XUw6EqmVhivCbn AJe1EV/OYf8BS/dRToVL4qG1cjBB4tg= X-MC-Unique: H6OGdCGPMeqVA7U5YVDXrw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, peter.maydell@linaro.org, quintela@redhat.com, marcandre.lureau@gmail.com Subject: [PATCH v2 3/3] migration: Perform vmsd structure check during tests Date: Thu, 13 Jan 2022 19:44:52 +0000 Message-Id: <20220113194452.254011-4-dgilbert@redhat.com> In-Reply-To: <20220113194452.254011-1-dgilbert@redhat.com> References: <20220113194452.254011-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=170.10.133.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.594, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lsoaresp@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1642104796326100001 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Perform a check on vmsd structures during test runs in the hope of catching any missing terminators and other simple screwups. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Reviewed-by: Peter Maydell --- migration/savevm.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index 8077393d11..97a4471220 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -66,6 +66,7 @@ #include "net/announce.h" #include "qemu/yank.h" #include "yank_functions.h" +#include "sysemu/qtest.h" =20 const unsigned int postcopy_ram_discard_version; =20 @@ -839,6 +840,39 @@ void unregister_savevm(VMStateIf *obj, const char *ids= tr, void *opaque) } } =20 +/* + * Perform some basic checks on vmsd's at registration + * time. + */ +static void vmstate_check(const VMStateDescription *vmsd) +{ + const VMStateField *field =3D vmsd->fields; + const VMStateDescription **subsection =3D vmsd->subsections; + + if (field) { + while (field->name) { + if (field->flags & (VMS_STRUCT | VMS_VSTRUCT)) { + /* Recurse to sub structures */ + vmstate_check(field->vmsd); + } + /* Carry on */ + field++; + } + /* Check for the end of field list canary */ + assert(field->flags =3D=3D VMS_END); + } + + while (subsection && *subsection) { + /* + * The name of a subsection should start with the name of the + * current object. + */ + assert(!strncmp(vmsd->name, (*subsection)->name, strlen(vmsd->name= ))); + vmstate_check(*subsection); + subsection++; + } +} + int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id, const VMStateDescription *vmsd, void *opaque, int alias_id, @@ -884,6 +918,11 @@ int vmstate_register_with_alias_id(VMStateIf *obj, uin= t32_t instance_id, } else { se->instance_id =3D instance_id; } + + /* Perform a recursive sanity check during the test runs */ + if (qtest_enabled()) { + vmstate_check(vmsd); + } assert(!se->compat || se->instance_id =3D=3D 0); savevm_state_handler_insert(se); return 0; --=20 2.34.1