From nobody Sat Nov 29 10:15:25 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1764172268; cv=none; d=zohomail.com; s=zohoarc; b=W/DmpAcnD4vj/c2vrmkhNOFD48jCLMuqghhGkQ4ZyBMyL+DYTh44csiBrCDqrCCX+F+ZHpm7ixwIbqhtcKUUGcvgCgPQlzqmXdSrxpKruKBqpYaRTmwzBw/ecy1pQiJ1v4gzUP/Lrw7MJdBVw4IFgQOxd+NIjRBDwQG4x6owVxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764172268; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OnYA1X95KyQj+3iDTUiFgqfXlpUaFheDZtHSW65r120=; b=PB60YC3uSGSLo+BPIfDn4fneU/BWFliO2B7dviGhlDq495Vnkf9QwI8cJ5sgk2wpvYLISS3OjmPgzyBaRa8jCbMap3iuDnqWEiKbzh7EL4Z26JHhzAeo+t6f2MfONvGionmN75R3whcnn7Gm+IFYp745hhE2nNyt5NBV0Y7PO1s= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1764172268244136.39487447535566; Wed, 26 Nov 2025 07:51:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vOHmv-0001K9-NL; Wed, 26 Nov 2025 10:50:37 -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 1vOHmg-0000eo-5t for qemu-devel@nongnu.org; Wed, 26 Nov 2025 10:50:30 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vOHmc-0000vp-CH for qemu-devel@nongnu.org; Wed, 26 Nov 2025 10:50:21 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso73497175e9.3 for ; Wed, 26 Nov 2025 07:50:17 -0800 (PST) Received: from localhost ([109.76.183.78]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-479040c5f89sm48504525e9.2.2025.11.26.07.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 07:50:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764172216; x=1764777016; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OnYA1X95KyQj+3iDTUiFgqfXlpUaFheDZtHSW65r120=; b=H02RJbDKKGVVxKsLuyL4I6JDeYVZ3XnJ/jCXb4ONlWYw6Aq7etoMaqi6cgpfo+VJS+ vKkXQ3+rCxZ2Dd90+K7dqi0WeGg0qKHmH9Mr8sp4upGguG6z3IZpT84Ts22Ee8uhCxlD oHbaB8FgqMDQL8WSmgMordvCDrjxK7n/10724obCQy21GExmEPgvtIjEBfkA5QQB0eBZ rVrTSSDpOttSIKtbcB2geeDJX91FiDHtmfX4rBJoMygwbhy8uWrg6nqIclAUfs4bsGqF F43q6ADrfioDSd2hzZk1ZDpz4dlXljEir8Z57IdDvfEmZ6C66/G/cOpwWdsB9X8DOiKv Mp5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764172216; x=1764777016; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OnYA1X95KyQj+3iDTUiFgqfXlpUaFheDZtHSW65r120=; b=aw1ffAzWjdVMXz4xEQhNEBA8yQNjdA5At1g/UY4XY6SN+T1nqajqr1lsn54XyGXWh9 C+nvFD5fWK4qThs1fJ55OZE826vmB3FgFY33gUWJhO22OTTYg0IoR4oEpN8G22j+3Fxy 6NNkpdv+Qlw1aL89PfvMonci8yNAxok5hCqOfwYpOPkl7Pj7ZhjJHB+fc8x7GodRmWL4 3Sy2gA/StAWpAdRpGHQindRGb6RonH+zS9b8btx1oMsfYulup4BKGxG92GA+hNG+V4xU XGnzs4My7Ka+N/7j8Ddo8rPWZ8ZHOVVfYhC6taUX1SyIHmSUtTTmLa4QhQrRBL6Rgm1B 5jlA== X-Gm-Message-State: AOJu0Yw+XC4pkWDpCtjHWX7lY0g8BlL1IbVBLxBKPoI1Jv/Gji5zVx/m A0+2mImatxGg/tivS0pTrOIyu2JptFnE7662TCz1gZFa1AQLCdk2OchdTsdh2/e4QOo= X-Gm-Gg: ASbGnct4TZf5ILDpNZC4A/RsObUUzfn/UBwTGJ89a2VionEkIZffbtc+LWRUMZuI1Dd 0BiMDwR+JBL7dgRfye32oWQ39YqpQFo7uR2iLb4H4fQ4MLpPq6NLr/X9PVYWFTY47UZVevvKFG7 wufoRQXFZW1DJFeGzJCp18kb7o3aUc+u3Wn4nzj9IPjdoaPXa0ZJcXS2Y7yU1Ev1pE3pHCCEH0U WfKv665Puc0Mf0o5+p5+5JXsWiGfRCDfSuC8rPrcnODiji+chP9JoBgUR6pIec79JySlbKThRhL GTartf4BErTt4Jltl5yKhCU+0V3+cjKXq5h6hnloy49m0LBTiGY4CRGU1Jfyxzmgtdg6pG9Ewfg CwGfnNC/L9U/cUw1s+eC7WxTbnHK20UJSAOsQetjjgnHjLEqsfY3Q3kikyl4hBMXlz5w/kiDXaJ 0nF7+8A3KgUrIelNo7Wg== X-Google-Smtp-Source: AGHT+IE7DUgFjwWjluQAHGDdI8gADleYB4sWACIBSDGGH04dQFxBvuOvU8SXd81J9l8WV60Uv6+aew== X-Received: by 2002:a05:600c:350e:b0:477:ae31:1311 with SMTP id 5b1f17b1804b1-477c10e2a64mr174739785e9.13.1764172216304; Wed, 26 Nov 2025 07:50:16 -0800 (PST) From: Pawel Zmarzly To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de Subject: [PATCH v2] scripts/analyze-migration: Support mapped-ram snapshot format Date: Wed, 26 Nov 2025 15:50:15 +0000 Message-ID: <20251126155015.941129-1-pzmarzly0@gmail.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 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=2a00:1450:4864:20::32e; envelope-from=pzmarzly0@gmail.com; helo=mail-wm1-x32e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1764172269862019200 Content-Type: text/plain; charset="utf-8" The script has not been updated to read mapped-ram snapshots and is current= ly crashing when trying to read such a file. With this commit, it can now read a snapshot created with: (qemu) migrate_set_capability x-ignore-shared on (qemu) migrate_set_capability mapped-ram on (qemu) migrate -d file:vm.state Signed-off-by: Pawel Zmarzly --- V2: Added support for format change in my other patch "migration: Fix writi= ng mapped_ram + ignore_shared snapshots". You can see whole stack at https://gitlab.com/pzmarzly/qemu/-/commits/pzmarzly?ref_type=3Dheads --- scripts/analyze-migration.py | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py index 3303c05358..b6694bbd23 100755 --- a/scripts/analyze-migration.py +++ b/scripts/analyze-migration.py @@ -19,6 +19,7 @@ =20 import json import os +import math import argparse import collections import struct @@ -127,6 +128,7 @@ def __init__(self, file, version_id, ramargs, section_k= ey): self.dump_memory =3D ramargs['dump_memory'] self.write_memory =3D ramargs['write_memory'] self.ignore_shared =3D ramargs['ignore_shared'] + self.mapped_ram =3D ramargs['mapped_ram'] self.sizeinfo =3D collections.OrderedDict() self.data =3D collections.OrderedDict() self.data['section sizes'] =3D self.sizeinfo @@ -170,6 +172,50 @@ def read(self): self.files[self.name] =3D f if self.ignore_shared: mr_addr =3D self.file.read64() + if self.mapped_ram: + version =3D self.file.read32() + if version !=3D 1: + raise Exception("Unsupported MappedRamHeader v= ersion %s" % version) + =20 + page_size =3D self.file.read64() + if page_size !=3D self.TARGET_PAGE_SIZE: + raise Exception("Page size mismatch in MappedR= amHeader") + + bitmap_offset =3D self.file.read64() + pages_offset =3D self.file.read64() + =20 + if self.ignore_shared and bitmap_offset =3D=3D 0 a= nd pages_offset =3D=3D 0: + continue + + if self.dump_memory or self.write_memory: + num_pages =3D len // page_size + + self.file.seek(bitmap_offset, os.SEEK_SET) + bitmap_len =3D int(math.ceil(num_pages / 8)) + bitmap =3D self.file.readvar(size=3Dbitmap_len) + + self.file.seek(pages_offset, os.SEEK_SET) + for page_num in range(num_pages): + page_addr =3D page_num * page_size + + is_filled =3D (bitmap[page_num // 8] >> pa= ge_num % 8) & 1 + if is_filled: + data =3D self.file.readvar(size=3Dself= .TARGET_PAGE_SIZE) + if self.write_memory: + self.files[self.name].seek(page_ad= dr, os.SEEK_SET) + self.files[self.name].write(data) + if self.dump_memory: + hexdata =3D " ".join("{0:02x}".for= mat(c) for c in data) + self.memory['%s (0x%016x)' % (self= .name, page_addr)] =3D hexdata + else: + self.file.seek(self.TARGET_PAGE_SIZE, = os.SEEK_CUR) + if self.write_memory: + self.files[self.name].seek(page_ad= dr, os.SEEK_SET) + self.files[self.name].write(b'\x00= ' * self.TARGET_PAGE_SIZE) + if self.dump_memory: + self.memory['%s (0x%016x)' % (self= .name, page_addr)] =3D 'Filled with 0x00' + + self.file.seek(pages_offset + len, os.SEEK_SET) flags &=3D ~self.RAM_SAVE_FLAG_MEM_SIZE =20 if flags & self.RAM_SAVE_FLAG_COMPRESS: @@ -663,6 +709,7 @@ def read(self, desc_only =3D False, dump_memory =3D Fal= se, ramargs['dump_memory'] =3D dump_memory ramargs['write_memory'] =3D write_memory ramargs['ignore_shared'] =3D False + ramargs['mapped_ram'] =3D False self.section_classes[('ram',0)][1] =3D ramargs =20 while True: @@ -674,6 +721,7 @@ def read(self, desc_only =3D False, dump_memory =3D Fal= se, section =3D ConfigurationSection(file, config_desc) section.read() ramargs['ignore_shared'] =3D section.has_capability('x-ign= ore-shared') + ramargs['mapped_ram'] =3D section.has_capability('mapped-r= am') elif section_type =3D=3D self.QEMU_VM_SECTION_START or section= _type =3D=3D self.QEMU_VM_SECTION_FULL: section_id =3D file.read32() name =3D file.readstr() --=20 2.52.0