[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-4.2 06/13] qcow2: Separate qcow2_check_read_
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH for-4.2 06/13] qcow2: Separate qcow2_check_read_snapshot_table() |
Date: |
Tue, 30 Jul 2019 13:53:04 -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:
> Reading the snapshot table can fail. That is a problem when we want to
> repair the image.
>
> Therefore, stop reading the snapshot table in qcow2_do_open() in check
> mode. Instead, add a new function qcow2_check_read_snapshot_table()
> that reads the snapshot table at a later point. In the future, we want
> to handle errors here and fix them.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/qcow2.h | 4 +++
> block/qcow2-snapshot.c | 58 ++++++++++++++++++++++++++++++++
> block/qcow2.c | 76 ++++++++++++++++++++++++++++++++----------
> 3 files changed, 120 insertions(+), 18 deletions(-)
>
> +++ b/block/qcow2-snapshot.c
> @@ -321,6 +321,64 @@ fail:
> return ret;
> }
>
> +int coroutine_fn qcow2_check_read_snapshot_table(BlockDriverState *bs,
> + BdrvCheckResult *result,
> + BdrvCheckMode fix)
> +{
> + BDRVQcow2State *s = bs->opaque;
> + Error *local_err = NULL;
> + int ret;
> + struct {
> + uint32_t nb_snapshots;
> + uint64_t snapshots_offset;
> + } QEMU_PACKED snapshot_table_pointer;
> +
> + /* qcow2_do_open() discards this information in check mode */
> + ret = bdrv_pread(bs->file, 60, &snapshot_table_pointer,
> + sizeof(snapshot_table_pointer));
Should that '60' be a named constant or offsetof() expression? (I know,
you just copied this instance from elsewhere)
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 for-4.2 02/13] qcow2: Keep unknown extra snapshot data, (continued)
- [Qemu-devel] [PATCH for-4.2 03/13] qcow2: Make qcow2_write_snapshots() public, Max Reitz, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 04/13] qcow2: Put qcow2_upgrade() into an own function, Max Reitz, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 05/13] qcow2: Write v3-compliant snapshot list on upgrade, Max Reitz, 2019/07/30
- [Qemu-devel] [PATCH for-4.2 06/13] qcow2: Separate qcow2_check_read_snapshot_table(), Max Reitz, 2019/07/30
- Re: [Qemu-devel] [PATCH for-4.2 06/13] qcow2: Separate qcow2_check_read_snapshot_table(),
Eric Blake <=
- [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