From nobody Fri Oct 10 13:10:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545132785507500.1010522351868; Tue, 18 Dec 2018 03:33:05 -0800 (PST) Received: from localhost ([::1]:53271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZDcV-0003Al-VX for importer@patchew.org; Tue, 18 Dec 2018 06:33:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZDRR-0002al-TU for qemu-devel@nongnu.org; Tue, 18 Dec 2018 06:21:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZDRQ-0005nO-6P for qemu-devel@nongnu.org; Tue, 18 Dec 2018 06:21:37 -0500 Received: from mail.ispras.ru ([83.149.199.45]:55446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZDRP-0005mg-Qn for qemu-devel@nongnu.org; Tue, 18 Dec 2018 06:21:36 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id CC1AA54006A; Tue, 18 Dec 2018 14:21:34 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 18 Dec 2018 14:21:37 +0300 Message-ID: <20181218112137.11727.3761.stgit@pasha-VirtualBox> In-Reply-To: <20181218112056.11727.96529.stgit@pasha-VirtualBox> References: <20181218112056.11727.96529.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 [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v8 07/20] 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