From nobody Sat Sep 27 11:42:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547036395762319.85977833305174; Wed, 9 Jan 2019 04:19:55 -0800 (PST) Received: from localhost ([127.0.0.1]:48041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghCpu-00015a-Iz for importer@patchew.org; Wed, 09 Jan 2019 07:19:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghCiI-0003M1-3i for qemu-devel@nongnu.org; Wed, 09 Jan 2019 07:12:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghCiH-0001Yt-Cj for qemu-devel@nongnu.org; Wed, 09 Jan 2019 07:12:02 -0500 Received: from mail.ispras.ru ([83.149.199.45]:37128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghCiH-0001Yb-4v for qemu-devel@nongnu.org; Wed, 09 Jan 2019 07:12:01 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 2C5C054006A; Wed, 9 Jan 2019 15:12:00 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Wed, 09 Jan 2019 15:12:00 +0300 Message-ID: <154703592002.13472.15345101256444192021.stgit@pasha-VirtualBox> In-Reply-To: <154703587757.13472.3898702635363120794.stgit@pasha-VirtualBox> References: <154703587757.13472.3898702635363120794.stgit@pasha-VirtualBox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v9 07/21] qcow2: introduce icount field for snapshots X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, war2jordan@live.com, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, crosthwaite.peter@gmail.com, ciro.santilli@gmail.com, jasowang@redhat.com, quintela@redhat.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" This patch introduces the icount field for saving within the snapshot. It is required for navigation between the snapshots in record/replay mode. Signed-off-by: Pavel Dovgalyuk Acked-by: Kevin Wolf -- v2: - documented format changes in docs/interop/qcow2.txt (suggested by Eric Blake) --- block/qcow2-snapshot.c | 7 +++++++ block/qcow2.h | 2 ++ docs/interop/qcow2.txt | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index bb6a5b7..d682946 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -103,6 +103,12 @@ int qcow2_read_snapshots(BlockDriverState *bs) sn->disk_size =3D bs->total_sectors * BDRV_SECTOR_SIZE; } =20 + if (extra_data_size >=3D 24) { + sn->icount =3D be64_to_cpu(extra.icount); + } else { + sn->icount =3D -1ULL; + } + /* Read snapshot ID */ sn->id_str =3D g_malloc(id_str_size + 1); ret =3D bdrv_pread(bs->file, offset, sn->id_str, id_str_size); @@ -209,6 +215,7 @@ static int qcow2_write_snapshots(BlockDriverState *bs) memset(&extra, 0, sizeof(extra)); extra.vm_state_size_large =3D cpu_to_be64(sn->vm_state_size); extra.disk_size =3D cpu_to_be64(sn->disk_size); + extra.icount =3D cpu_to_be64(sn->icount); =20 id_str_size =3D strlen(sn->id_str); name_size =3D strlen(sn->name); diff --git a/block/qcow2.h b/block/qcow2.h index a98d245..8554629 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -159,6 +159,7 @@ typedef struct QEMU_PACKED QCowSnapshotHeader { typedef struct QEMU_PACKED QCowSnapshotExtraData { uint64_t vm_state_size_large; uint64_t disk_size; + uint64_t icount; } QCowSnapshotExtraData; =20 =20 @@ -172,6 +173,7 @@ typedef struct QCowSnapshot { uint32_t date_sec; uint32_t date_nsec; uint64_t vm_clock_nsec; + uint64_t icount; } QCowSnapshot; =20 struct Qcow2Cache; diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt index fb5cb47..c1edef7 100644 --- a/docs/interop/qcow2.txt +++ b/docs/interop/qcow2.txt @@ -540,6 +540,10 @@ Snapshot table entry: =20 Byte 48 - 55: Virtual disk size of the snapshot in b= ytes =20 + Byte 56 - 63: icount value which corresponds to + the record/replay step when the snapsh= ot + was taken + Version 3 images must include extra data at least up to byte 55. =20