[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-4.2 09/13] qcow2: Fix overly long snapshot t
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH for-4.2 09/13] qcow2: Fix overly long snapshot tables |
Date: |
Tue, 30 Jul 2019 14:08:37 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 7/30/19 12:25 PM, Max Reitz wrote:
> We currently refuse to open qcow2 images with overly long snapshot
> tables. This patch makes qemu-img check -r all drop all offending
> entries past what we deem acceptable.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/qcow2-snapshot.c | 89 +++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 79 insertions(+), 10 deletions(-)
I'm less sure about this one. 8/13 should have no semantic effect (if
the user _depended_ on that much extra data, they should have set an
incompatible feature flag bit, at which point we'd leave their data
alone because we don't recognize the feature bit; so it is safe to
assume the user did not depend on the data and that we can thus nuke it
with impunity). But here, we are throwing away the user's internal
snapshots, and not even giving them a say in which ones to throw away
(more likely, by trimming from the end, we are destroying the most
recent snapshots in favor of the older ones - but I could argue that
throwing away the oldest also has its uses).
> @@ -417,7 +461,32 @@ int coroutine_fn
> qcow2_check_read_snapshot_table(BlockDriverState *bs,
>
> return ret;
> }
> - result->corruptions += extra_data_dropped;
> + result->corruptions += nb_clusters_reduced + extra_data_dropped;
> +
> + if (nb_clusters_reduced) {
> + /*
> + * Update image header now, because:
> + * (1) qcow2_check_refcounts() relies on s->nb_snapshots to be
> + * the same as what the image header says,
> + * (2) this leaks clusters, but qcow2_check_refcounts() will
> + * fix that.
> + */
> + assert(fix & BDRV_FIX_ERRORS);
> +
> + snapshot_table_pointer.nb_snapshots = cpu_to_be32(s->nb_snapshots);
> + ret = bdrv_pwrite_sync(bs->file, 60,
That '60' needs a name; it keeps popping up.
If we like the patch, I didn't spot major coding problems. But because
I'm not sure we want this patch, I'll skip R-b for now.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH for-4.2 06/13] qcow2: Separate qcow2_check_read_snapshot_table(), (continued)
- [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, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 09/13] qcow2: Fix overly long snapshot tables, Max Reitz, 2019/07/30
- Re: [Qemu-devel] [PATCH for-4.2 09/13] qcow2: Fix overly long snapshot tables,
Eric Blake <=
- [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
- [Qemu-devel] [PATCH for-4.2 13/13] iotests: Test qcow2's snapshot table handling, Max Reitz, 2019/07/30
- Re: [Qemu-devel] [PATCH for-4.2 00/13] qcow2: Let check -r all repair some snapshot bits, Eric Blake, 2019/07/30