[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 57/69] qcow2: Repair snapshot table with too many entries
From: |
Max Reitz |
Subject: |
[PULL 57/69] qcow2: Repair snapshot table with too many entries |
Date: |
Mon, 28 Oct 2019 13:14:49 +0100 |
The user cannot choose which snapshots are removed. This is fine
because we have chosen the maximum snapshot table size to be so large
(65536 entries) that it cannot be reasonably reached. If the snapshot
table exceeds this size, the image has probably been corrupted in some
way; in this case, it is most important to just make the image usable
such that the user can copy off at least the active layer.
(Also note that the snapshots will be removed only with "-r all", so a
plain "check" or "check -r leaks" will not delete any data.)
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-id: address@hidden
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 366d9f574c..dac8a778e4 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -444,6 +444,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,
@@ -452,6 +460,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
- [PULL 49/69] qcow2: Make qcow2_write_snapshots() public, (continued)
- [PULL 49/69] qcow2: Make qcow2_write_snapshots() public, Max Reitz, 2019/10/28
- [PULL 47/69] qcow2: Add Error ** to qcow2_read_snapshots(), Max Reitz, 2019/10/28
- [PULL 51/69] qcow2: Write v3-compliant snapshot list on upgrade, Max Reitz, 2019/10/28
- [PULL 50/69] qcow2: Put qcow2_upgrade() into its own function, Max Reitz, 2019/10/28
- [PULL 53/69] qcow2: Add qcow2_check_fix_snapshot_table(), Max Reitz, 2019/10/28
- [PULL 48/69] qcow2: Keep unknown extra snapshot data, Max Reitz, 2019/10/28
- [PULL 62/69] block/cor: Drop cor_co_truncate(), Max Reitz, 2019/10/28
- [PULL 59/69] iotests: Add peek_file* functions, Max Reitz, 2019/10/28
- [PULL 52/69] qcow2: Separate qcow2_check_read_snapshot_table(), Max Reitz, 2019/10/28
- [PULL 54/69] qcow2: Fix broken snapshot table entries, Max Reitz, 2019/10/28
- [PULL 57/69] qcow2: Repair snapshot table with too many entries,
Max Reitz <=
- [PULL 55/69] qcow2: Keep track of the snapshot table length, Max Reitz, 2019/10/28
- [PULL 58/69] qcow2: Fix v3 snapshot table entry compliancy, Max Reitz, 2019/10/28
- [PULL 61/69] block: Handle filter truncation like native impl., Max Reitz, 2019/10/28
- [PULL 63/69] block: Do not truncate file node when formatting, Max Reitz, 2019/10/28
- [PULL 56/69] qcow2: Fix overly long snapshot tables, Max Reitz, 2019/10/28
- [PULL 65/69] block: Evaluate @exact in protocol drivers, Max Reitz, 2019/10/28
- [PULL 60/69] iotests: Test qcow2's snapshot table handling, Max Reitz, 2019/10/28
- [PULL 64/69] block: Add @exact parameter to bdrv_co_truncate(), Max Reitz, 2019/10/28
- [PULL 67/69] block: Pass truncate exact=true where reasonable, Max Reitz, 2019/10/28
- [PULL 66/69] block: Let format drivers pass @exact, Max Reitz, 2019/10/28