@@ -103,6 +103,12 @@ int qcow2_read_snapshots(BlockDriverState *bs)
sn->disk_size = bs->total_sectors * BDRV_SECTOR_SIZE;
}
+ if (extra_data_size >= 24) {
+ sn->icount = be64_to_cpu(extra.icount);
+ } else {
+ sn->icount = -1ULL;
+ }
+
/* Read snapshot ID */
sn->id_str = g_malloc(id_str_size + 1);
ret = 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 = 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);
@@ -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;
@@ -172,6 +173,7 @@ typedef struct QCowSnapshot {
uint32_t date_sec;
uint32_t date_nsec;
uint64_t vm_clock_nsec;
+ uint64_t icount;
} QCowSnapshot;
struct Qcow2Cache;
@@ -540,6 +540,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 step when the snapshot
+ was taken
+
Version 3 images must include extra data at least up to
byte 55.