From patchwork Fri Jul 11 12:50:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 369157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6D6C3140092 for ; Fri, 11 Jul 2014 22:51:32 +1000 (EST) Received: from localhost ([::1]:44608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5aIU-0001Hc-Q1 for incoming@patchwork.ozlabs.org; Fri, 11 Jul 2014 08:51:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5aI6-0000rz-K5 for qemu-devel@nongnu.org; Fri, 11 Jul 2014 08:51:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X5aHx-0003T0-Ut for qemu-devel@nongnu.org; Fri, 11 Jul 2014 08:51:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X5aHx-0003So-MJ for qemu-devel@nongnu.org; Fri, 11 Jul 2014 08:50:57 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6BCos89027728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Jul 2014 08:50:55 -0400 Received: from localhost (ovpn-113-66.phx2.redhat.com [10.3.113.66]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6BCopJv015480; Fri, 11 Jul 2014 08:50:53 -0400 From: Amit Shah To: qemu list Date: Fri, 11 Jul 2014 18:20:28 +0530 Message-Id: <5ed3be986930cb422e5c14b72d247d014e1a0eea.1405083028.git.amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amit Shah , Peter Maydell , "Dr. David Alan Gilbert" Subject: [Qemu-devel] [PATCH for 2.1 1/1] vmstate static checker: detect section renames X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Commit 292b1634 changed the section name of "ICH9 LPC" to "ICH9-LPC", and that causes the static checker to flag this: Section "ICH9 LPC" does not exist in dest This patch introduces a function that checks for section renames and also a dictionary that maps those renames. Reported-by: "Dr. David Alan Gilbert" Signed-off-by: Amit Shah --- This is a small patch to a script; doesn't break qemu and helps with the static checker, so it's a very low-risk patch for 2.1. --- scripts/vmstate-static-checker.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/vmstate-static-checker.py b/scripts/vmstate-static-checker.py index 1604e68..3bae769 100755 --- a/scripts/vmstate-static-checker.py +++ b/scripts/vmstate-static-checker.py @@ -79,6 +79,18 @@ def check_fields_match(name, s_field, d_field): return False +def get_changed_sec_name(sec): + # Section names can change -- see commit 292b1634 for an example. + changes = { + "ICH9 LPC": "ICH9-LPC", + } + + for item in changes: + if item == sec: + return changes[item] + if changes[item] == sec: + return item + return "" def exists_in_substruct(fields, item): # Some QEMU versions moved a few fields inside a substruct. This @@ -314,13 +326,18 @@ def main(): dest_data = temp for sec in src_data: - if not sec in dest_data: - print "Section \"" + sec + "\" does not exist in dest" - bump_taint() - continue + dest_sec = sec + if not dest_sec in dest_data: + # Either the section name got changed, or the section + # doesn't exist in dest. + dest_sec = get_changed_sec_name(sec) + if not dest_sec in dest_data: + print "Section \"" + sec + "\" does not exist in dest" + bump_taint() + continue s = src_data[sec] - d = dest_data[sec] + d = dest_data[dest_sec] if sec == "vmschkmachine": check_machine_type(s, d)