{"id":2231418,"url":"http://patchwork.ozlabs.org/api/patches/2231418/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430172204.1006673-13-pbonzini@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260430172204.1006673-13-pbonzini@redhat.com>","list_archive_url":null,"date":"2026-04-30T17:21:18","name":"[PULL,12/58] minikconf: modernize handling of include chain","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6bec5897b495e311bb78a1ad6e024ad89e6a72df","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/?format=json","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430172204.1006673-13-pbonzini@redhat.com/mbox/","series":[{"id":502347,"url":"http://patchwork.ozlabs.org/api/series/502347/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502347","date":"2026-04-30T17:21:16","name":"[PULL,01/58] pythondeps: bump to meson 1.11.1","version":1,"mbox":"http://patchwork.ozlabs.org/series/502347/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231418/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231418/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=NA72SdiL;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=qdIfiPki;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g61Hz4dpJz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 03:24:31 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wIV6G-0004iF-D0; Thu, 30 Apr 2026 13:22:56 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pbonzini@redhat.com>)\n id 1wIV6E-0004hs-R5\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 13:22:54 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pbonzini@redhat.com>)\n id 1wIV6D-0004Jh-7f\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 13:22:54 -0400","from mail-qk1-f197.google.com (mail-qk1-f197.google.com\n [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-62-kLHjyBl9N5qJxAL1dDx-1g-1; Thu, 30 Apr 2026 13:22:50 -0400","by mail-qk1-f197.google.com with SMTP id\n af79cd13be357-8eb04352924so223839885a.1\n for <qemu-devel@nongnu.org>; Thu, 30 Apr 2026 10:22:50 -0700 (PDT)","from [192.168.10.48] ([151.49.85.67])\n by smtp.gmail.com with ESMTPSA id\n af79cd13be357-8fbb09fc96fsm27525985a.6.2026.04.30.10.22.46\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 30 Apr 2026 10:22:47 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1777569772;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=XGYB/Qea4Rw59yZSl456XX9o94gifzjhM+3vdt+q8MM=;\n b=NA72SdiLzmipohSt8+w2F6h8dgFqtRHIKC4xC+Z6HZce6UaUNa9VW8HZaWyLz+OafKKrCO\n BGVOJ9SPjQXBODNDOFO0TRiT2n3CXyEiWWHI0t2j6aa00rNcHJ8L1gCepgEdax6j+Wb9yJ\n L8BqKMSCkhwZh3EWbWW4q/oXU+sMnQk=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1777569769; x=1778174569; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=XGYB/Qea4Rw59yZSl456XX9o94gifzjhM+3vdt+q8MM=;\n b=qdIfiPkijnE/iWl372NCw4dRrXzORL77vNI/BFq3RLvpltyO9L2ozJsnAR42Cblb3Q\n 6KLARDXo4plFFA8trtmWNDA/+fOb6vA7U8NfvyXXaCMYr/LI7nbt1IXVfdfps05gPZ9s\n 2cHovP1HU2SLSSR6oJNElbaeGTmaVDeic+/nLX55E3oMr8/4EA1QmTUgni0z1N1jA6N2\n B21Whsk5ZBk/kWvfmaA8Asbd5wyWzTkverN56XS79QRiqFUhlcgWWTEAkIuEzxRXcLDd\n Etma2ypohZRaztvIVT5zpD3Xd6hVuozX1XBiw2AKDelul/H42Fa5CwtKT8ivdA2sHHlA\n DIKA=="],"X-MC-Unique":"kLHjyBl9N5qJxAL1dDx-1g-1","X-Mimecast-MFC-AGG-ID":"kLHjyBl9N5qJxAL1dDx-1g_1777569770","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777569769; x=1778174569;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=XGYB/Qea4Rw59yZSl456XX9o94gifzjhM+3vdt+q8MM=;\n b=CTSzlPe9OFllE8nIdKAG7YvzVRcagehhpKH1C8wRTwh/yLstwwJ+H9XTvOCWU2QO/g\n zkPS87V1LOOfDcNt/w+7fms4I9BsGZkOTlVOsFRCwFA2U4aIf0W7yIl0RMB1lStRDzpv\n Irnrjyaha8k8VbBPlCeCQy1VWOlnuxwPck1Wz1Fzk9wIRSnTWC5ckBaiPt1JaKbadhZn\n ad1NLvTFOCzCSEfUVTg9ylqO0mSpqy0bDfu6+Ld8hFKifdXL/QUmponIVkBXzMqueRLU\n /Z2vtrFOvAHWQ904+u8tavjv3UpGzAY8ZXy4ZYIGqH8TQgkOzMoXTb15kdZArrweDdZ+\n r7WA==","X-Gm-Message-State":"AOJu0YysWdUlig7AwO2Kio2Yf32qgCuK8/rf+Klv+6HscG9SkjJlerHT\n 68tizmfMSbN9CQL2CRXG8WS1OK8KjZOKQG9P07FQDrA/a+OXBnzw4fEjos3edb7e0BiZaWWYtTW\n j5qkRK9vqoPV3RKKhwBgVaDmX1BucjowTxDLVaNRV7SfdACzn4uVgKDDcLlfoJjY0MYQNTdtjWf\n DbPaaYtQ/R5UvNrgEFq0bQb6CLS37gbfiZT0lY9+uv","X-Gm-Gg":"AeBDiet99l1PBlE7zLvwyz6CaDFyclwaiE0fWJFQlM/hzzktDa5HdfyJYwt8kUHBq39\n cHAvR1dYMckJAxux9v81XTJMCREemyXOLxGj0JS8my+O8oooMhI6guvnX/fqecOD84W95Zqe7vj\n ysELt5ZzdxTw1dJUG4B2c4gcC8n4fvoAF0rXVrbwDH2TGwjDANqNOdiGfDYLhxLfXHrRvHbNqjp\n zZAYqg1CnfPg2HDW7K/qCm1HBrufI/vhvgLVQjZyQQWjhcOWJQl9xUOHP2zX/axjWDjnMg1UtGp\n Y7yQ3pVcdg80O27n3cCkoe51dPGdcYMbK1NW7pjTd2vmgPGnp22ODkBUxIpHXbnOP0JUKIwFQS0\n Nqzaau6aV/bsrheKvb5xkzk36eyO1Tq0KQjOrLI5LWvWAuo2juQwMUMWmFpo3BtJfhpnDribn+x\n NWdrwAQkRVBBB1tKY/ni4qw1l943SG2k/BGkg=","X-Received":["by 2002:a05:620a:bc7:b0:8ee:1073:320b with SMTP id\n af79cd13be357-8fa88847176mr596811885a.32.1777569769035;\n Thu, 30 Apr 2026 10:22:49 -0700 (PDT)","by 2002:a05:620a:bc7:b0:8ee:1073:320b with SMTP id\n af79cd13be357-8fa88847176mr596803685a.32.1777569768379;\n Thu, 30 Apr 2026 10:22:48 -0700 (PDT)"],"From":"Paolo Bonzini <pbonzini@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>","Subject":"[PULL 12/58] minikconf: modernize handling of include chain","Date":"Thu, 30 Apr 2026 19:21:18 +0200","Message-ID":"<20260430172204.1006673-13-pbonzini@redhat.com>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260430172204.1006673-1-pbonzini@redhat.com>","References":"<20260430172204.1006673-1-pbonzini@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.133.124;\n envelope-from=pbonzini@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_PASS=-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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Use a dataclass, and store it in the parser to avoid having to\nsave and restore it.\n\nReviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nSigned-off-by: Paolo Bonzini <pbonzini@redhat.com>\n---\n scripts/minikconf.py | 68 +++++++++++++++++++++++++-------------------\n 1 file changed, 39 insertions(+), 29 deletions(-)","diff":"diff --git a/scripts/minikconf.py b/scripts/minikconf.py\nindex 3d63cc6b21f..c46c73f82d9 100644\n--- a/scripts/minikconf.py\n+++ b/scripts/minikconf.py\n@@ -11,15 +11,36 @@\n # or, at your option, any later version.  See the COPYING file in\n # the top-level directory.\n \n+from __future__ import annotations\n+\n import os\n import random\n import re\n import sys\n+from dataclasses import dataclass\n \n __all__ = [ 'KconfigDataError', 'KconfigParserError',\n             'KconfigData', 'KconfigParser' ,\n             'defconfig', 'allyesconfig', 'allnoconfig', 'randconfig' ]\n \n+@dataclass\n+class IncludeInfo:\n+    file: str\n+    line: int\n+    parent: IncludeInfo | None\n+\n+    def __iter__(self):\n+        inf = self\n+        while inf is not None:\n+            yield \"%s:%d\" % (inf.file, inf.line)\n+            inf = inf.parent\n+\n+    def error_path(self):\n+        res = \"\"\n+        for loc in self:\n+            res = \"In file included from %s:\\n\" % loc + res\n+        return res\n+\n def debug_print(*args):\n     #print('# ' + (' '.join(str(x) for x in args)))\n     pass\n@@ -202,7 +223,6 @@ def process(self):\n     def __init__(self, value_mangler=defconfig):\n         self.value_mangler = value_mangler\n         self.previously_included = []\n-        self.incl_info = None\n         self.defined_vars = set()\n         self.referenced_vars = dict()\n         self.clauses = list()\n@@ -342,13 +362,12 @@ def __str__(self):\n class KconfigParser:\n \n     @classmethod\n-    def parse(cls, fp, data):\n-        cls(data).parse_file(fp)\n+    def parse(cls, fp, data, incl_info=None):\n+        cls(fp, data, incl_info).parse_config()\n \n-    def __init__(self, data):\n+    def __init__(self, fp, data, incl_info):\n         self.data = data\n-\n-    def parse_file(self, fp):\n+        self.incl_info = incl_info\n         self.abs_fname = os.path.abspath(fp.name)\n         self.fname = fp.name\n         self.data.previously_included.append(self.abs_fname)\n@@ -360,19 +379,9 @@ def parse_file(self, fp):\n         self.line = 1\n         self.line_pos = 0\n         self.get_token()\n-        self.parse_config()\n \n     # file management -----\n \n-    def error_path(self):\n-        inf = self.data.incl_info\n-        res = \"\"\n-        while inf:\n-            res = (\"In file included from %s:%d:\\n\" % (inf['file'],\n-                                                       inf['line'])) + res\n-            inf = inf['parent']\n-        return res\n-\n     def location(self):\n         col = 1\n         for ch in self.src[self.line_pos:self.pos]:\n@@ -380,33 +389,34 @@ def location(self):\n                 col += 8 - ((col - 1) % 8)\n             else:\n                 col += 1\n-        return '%s%s:%d:%d' %(self.error_path(), self.fname, self.line, col)\n+        inf = self.incl_info\n+        incl_chain = inf.error_path() if inf is not None else \"\"\n+        return '%s%s:%d:%d' % (incl_chain, self.fname, self.line, col)\n \n     def do_include(self, include):\n         incl_abs_fname = os.path.join(os.path.dirname(self.abs_fname),\n                                       include)\n         # catch inclusion cycle\n-        inf = self.data.incl_info\n+        inf = self.incl_info\n         while inf:\n-            if incl_abs_fname == os.path.abspath(inf['file']):\n+            if incl_abs_fname == os.path.abspath(inf.file):\n                 raise KconfigParserError(self, \"Inclusion loop for %s\"\n                                     % include)\n-            inf = inf['parent']\n+            inf = inf.parent\n \n         # skip multiple include of the same file\n         if incl_abs_fname in self.data.previously_included:\n             return\n         try:\n-            fp = open(incl_abs_fname, 'rt', encoding='utf-8')\n-        except IOError as e:\n-            raise KconfigParserError(self,\n-                                '%s: %s' % (e.strerror, include))\n+            try:\n+                fp = open(incl_abs_fname, 'rt', encoding='utf-8')\n+            except IOError as e:\n+                raise KconfigParserError(self, '%s: %s' % (e.strerror, include))\n \n-        inf = self.data.incl_info\n-        self.data.incl_info = { 'file': self.fname, 'line': self.line,\n-                'parent': inf }\n-        KconfigParser(self.data).parse_file(fp)\n-        self.data.incl_info = inf\n+            inner = IncludeInfo(file=self.fname, line=self.line, parent=self.incl_info)\n+            type(self).parse(fp, self.data, inner)\n+        finally:\n+            fp.close()\n \n     # recursive descent parser -----\n \n","prefixes":["PULL","12/58"]}