From nobody Thu Nov 13 06:10:02 2025 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1577094613; cv=none; d=zohomail.com; s=zohoarc; b=Zo3HW0USjr55zgQaq3NlOT7TIJ0HDA31W6bKEZNdCAAWrUlTT1KTBZJBTNKPR+kKx/HAgFOFbYMu38z3/5ZN/ND7mLoT2329q/JN0EikhW2HzSk4tzh0V+r4UAB5eBAoedw85mIAMh6DP3ZeRVKv69jLOIpsL2bj5WNEC530uV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577094613; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CxABCsXyUueoqmxWmHcs+KYoTwVq/UjrZK5qGtwlJlI=; b=WpSMXMeomW3+5FboUI++MRsMvUHBxsWXNqsnYK+3VEWO4r3iWrQPOIOae0FMJ2Vkp6cG8sJDTt2/pV+VfQElqQhq9qe/YKz2Xj1+Gt2emlgy4Oyx4CUBFr/uznqMwvIAK7G7mmmcOHJ2/+LIUCYajYxtuPEPQUPqpiiVHHM5pBc= ARC-Authentication-Results: i=1; mx.zohomail.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1577094613582243.48797826675457; Mon, 23 Dec 2019 01:50:13 -0800 (PST) Received: from localhost ([::1]:55222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijKLs-000627-Hi for importer@patchew.org; Mon, 23 Dec 2019 04:50:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45333) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijKIk-00034c-Ig for qemu-devel@nongnu.org; Mon, 23 Dec 2019 04:46:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ijKIj-0006qK-C0 for qemu-devel@nongnu.org; Mon, 23 Dec 2019 04:46:58 -0500 Received: from mail.ispras.ru ([83.149.199.45]:50722) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ijKIi-0006kG-TP for qemu-devel@nongnu.org; Mon, 23 Dec 2019 04:46:57 -0500 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id DBC3154006B; Mon, 23 Dec 2019 12:46:38 +0300 (MSK) Subject: [for-5.0 PATCH 02/11] qcow2: introduce icount field for snapshots From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Mon, 23 Dec 2019 12:46:38 +0300 Message-ID: <157709439859.12933.3023824005902199560.stgit@pasha-Precision-3630-Tower> In-Reply-To: <157709434917.12933.4351155074716553976.stgit@pasha-Precision-3630-Tower> References: <157709434917.12933.4351155074716553976.stgit@pasha-Precision-3630-Tower> 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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.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" From: Pavel Dovgalyuk 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) v10: - updated the documentation --- block/qcow2-snapshot.c | 7 +++++++ block/qcow2.h | 3 +++ docs/interop/qcow2.txt | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 5ab64da1ec..b04b3e1634 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -163,6 +163,12 @@ static int qcow2_do_read_snapshots(BlockDriverState *b= s, bool repair, sn->disk_size =3D bs->total_sectors * BDRV_SECTOR_SIZE; } =20 + if (sn->extra_data_size >=3D endof(QCowSnapshotExtraData, icount))= { + sn->icount =3D be64_to_cpu(extra.icount); + } else { + sn->icount =3D -1ULL; + } + if (sn->extra_data_size > sizeof(extra)) { uint64_t extra_data_end; size_t unknown_extra_data_size; @@ -332,6 +338,7 @@ 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 0942126232..f3e0d9aa56 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -171,6 +171,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 @@ -184,6 +185,8 @@ typedef struct QCowSnapshot { uint32_t date_sec; uint32_t date_nsec; uint64_t vm_clock_nsec; + /* icount value for the moment when snapshot was taken */ + uint64_t icount; /* Size of all extra data, including QCowSnapshotExtraData if availabl= e */ uint32_t extra_data_size; /* Data beyond QCowSnapshotExtraData, if any */ diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt index af5711e533..aa9d447cda 100644 --- a/docs/interop/qcow2.txt +++ b/docs/interop/qcow2.txt @@ -584,6 +584,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 instruction count + when the snapshot was taken + Version 3 images must include extra data at least up to byte 55. =20