[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-4.2 10/13] qcow2: Repair snapshot table with too
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH for-4.2 10/13] qcow2: Repair snapshot table with too many entries |
Date: |
Tue, 30 Jul 2019 19:25:05 +0200 |
Signed-off-by: Max Reitz <address@hidden>
---
block/qcow2-snapshot.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index bd8e56a99e..9e8c7c1f7f 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -430,6 +430,14 @@ int coroutine_fn
qcow2_check_read_snapshot_table(BlockDriverState *bs,
s->snapshots_offset = be64_to_cpu(snapshot_table_pointer.snapshots_offset);
s->nb_snapshots = be32_to_cpu(snapshot_table_pointer.nb_snapshots);
+ if (s->nb_snapshots > QCOW_MAX_SNAPSHOTS && (fix & BDRV_FIX_ERRORS)) {
+ fprintf(stderr, "Discarding %u overhanging snapshots\n",
+ s->nb_snapshots - QCOW_MAX_SNAPSHOTS);
+
+ nb_clusters_reduced += s->nb_snapshots - QCOW_MAX_SNAPSHOTS;
+ s->nb_snapshots = QCOW_MAX_SNAPSHOTS;
+ }
+
ret = qcow2_validate_table(bs, s->snapshots_offset, s->nb_snapshots,
sizeof(QCowSnapshotHeader),
sizeof(QCowSnapshotHeader) * QCOW_MAX_SNAPSHOTS,
@@ -438,6 +446,12 @@ int coroutine_fn
qcow2_check_read_snapshot_table(BlockDriverState *bs,
result->check_errors++;
error_reportf_err(local_err, "ERROR ");
+ if (s->nb_snapshots > QCOW_MAX_SNAPSHOTS) {
+ fprintf(stderr, "You can force-remove all %u overhanging snapshots
"
+ "with qemu-img check -r all\n",
+ s->nb_snapshots - QCOW_MAX_SNAPSHOTS);
+ }
+
/* We did not read the snapshot table, so invalidate this information
*/
s->snapshots_offset = 0;
s->nb_snapshots = 0;
--
2.21.0
- Re: [Qemu-devel] [PATCH for-4.2 05/13] qcow2: Write v3-compliant snapshot list on upgrade, (continued)
- [Qemu-devel] [PATCH for-4.2 06/13] qcow2: Separate qcow2_check_read_snapshot_table(), Max Reitz, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 07/13] qcow2: Add qcow2_check_fix_snapshot_table(), Max Reitz, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 08/13] qcow2: Fix broken snapshot table entries, Max Reitz, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 10/13] qcow2: Repair snapshot table with too many entries,
Max Reitz <=
- [Qemu-devel] [PATCH for-4.2 09/13] qcow2: Fix overly long snapshot tables, Max Reitz, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 11/13] qcow2: Fix v3 snapshot table entry compliancy, Max Reitz, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 12/13] iotests: Add peek_file* functions, Max Reitz, 2019/07/30