[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 07/16] qcow2: Write v3-compliant snapshot lis
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 07/16] qcow2: Write v3-compliant snapshot list on upgrade |
Date: |
Mon, 19 Aug 2019 14:25:59 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
On 8/19/19 1:55 PM, Max Reitz wrote:
> qcow2 v3 requires every snapshot table entry to have two extra data
> fields: The 64-bit VM state size, and the virtual disk size. Both are
> optional for v2 images, so they may not be present.
>
> qcow2_upgrade() therefore should update the snapshot table to ensure all
> entries have these extra data fields.
>
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1727347
> Reported-by: Eric Blake <address@hidden>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/qcow2.c | 32 ++++++++++++++++++++++++++++++--
> 1 file changed, 30 insertions(+), 2 deletions(-)
>
> @@ -4768,7 +4770,33 @@ static int qcow2_upgrade(BlockDriverState *bs, int
> target_version,
> /* There are no other versions (yet) that you can upgrade to */
> assert(target_version == 3);
>
> - status_cb(bs, 0, 1, cb_opaque);
> + status_cb(bs, 0, 2, cb_opaque);
> +
> + /*
> + * In v2, snapshots do not need to have extra data. v3 requires
> + * the 64-bit VM state size and the virtual disk size to be
> + * present.
> + * qcow2_write_snapshots() will always write the list in the
> + * v3-compliant format.
> + */
> + need_snapshot_update = false;
> + for (i = 0; i < s->nb_snapshots; i++) {
> + if (s->snapshots[i].extra_data_size <
> + sizeof_field(QCowSnapshotExtraData, vm_state_size_large) +
> + sizeof_field(QCowSnapshotExtraData, disk_size))
sizeof(extra) would be more concise than two sizeof_field() added
together, but might cause problems if we later expand the size of extra
for other reasons, but don't revisit this code. So I actually like what
you did here.
Reviewed-by: Eric Blake <address@hidden>
--
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 v2 02/16] qcow2: Use endof(), (continued)
- [Qemu-devel] [PATCH v2 03/16] qcow2: Add Error ** to qcow2_read_snapshots(), Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 04/16] qcow2: Keep unknown extra snapshot data, Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 05/16] qcow2: Make qcow2_write_snapshots() public, Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 06/16] qcow2: Put qcow2_upgrade() into its own function, Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 07/16] qcow2: Write v3-compliant snapshot list on upgrade, Max Reitz, 2019/08/19
- Re: [Qemu-devel] [PATCH v2 07/16] qcow2: Write v3-compliant snapshot list on upgrade,
Eric Blake <=
- [Qemu-devel] [PATCH v2 08/16] qcow2: Separate qcow2_check_read_snapshot_table(), Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 09/16] qcow2: Add qcow2_check_fix_snapshot_table(), Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 11/16] qcow2: Keep track of the snapshot table length, Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 10/16] qcow2: Fix broken snapshot table entries, Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 12/16] qcow2: Fix overly long snapshot tables, Max Reitz, 2019/08/19