[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[for-5.0 PATCH 02/11] qcow2: introduce icount field for snapshots
From: |
Pavel Dovgalyuk |
Subject: |
[for-5.0 PATCH 02/11] qcow2: introduce icount field for snapshots |
Date: |
Mon, 23 Dec 2019 12:46:38 +0300 |
User-agent: |
StGit/0.17.1-dirty |
From: Pavel Dovgalyuk <address@hidden>
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 <address@hidden>
Acked-by: Kevin Wolf <address@hidden>
--
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 *bs,
bool repair,
sn->disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
}
+ if (sn->extra_data_size >= endof(QCowSnapshotExtraData, icount)) {
+ sn->icount = be64_to_cpu(extra.icount);
+ } else {
+ sn->icount = -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 = cpu_to_be64(sn->vm_state_size);
extra.disk_size = cpu_to_be64(sn->disk_size);
+ extra.icount = cpu_to_be64(sn->icount);
id_str_size = strlen(sn->id_str);
name_size = 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;
@@ -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 available */
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:
Byte 48 - 55: Virtual disk size of the snapshot in bytes
+ 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.
- [for-5.0 PATCH 00/11] Support for reverse debugging with GDB, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 01/11] replay: provide an accessor for rr filename, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 02/11] qcow2: introduce icount field for snapshots,
Pavel Dovgalyuk <=
- [for-5.0 PATCH 03/11] migration: introduce icount field for snapshots, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 04/11] qapi: introduce replay.json for record/replay-related stuff, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 05/11] replay: introduce info hmp/qmp command, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 06/11] replay: introduce breakpoint at the specified step, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 07/11] replay: implement replay-seek command, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 08/11] replay: flush rr queue before loading the vmstate, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 09/11] gdbstub: add reverse step support in replay mode, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 10/11] gdbstub: add reverse continue support in replay mode, Pavel Dovgalyuk, 2019/12/23
- [for-5.0 PATCH 11/11] replay: describe reverse debugging in docs/replay.txt, Pavel Dovgalyuk, 2019/12/23