All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [PATCH v3 03/16] qcow2: Add Error ** to qcow2_read_snapshots()
Date: Fri, 11 Oct 2019 17:28:01 +0200	[thread overview]
Message-ID: <20191011152814.14791-4-mreitz@redhat.com> (raw)
In-Reply-To: <20191011152814.14791-1-mreitz@redhat.com>

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/qcow2.h          | 2 +-
 block/qcow2-snapshot.c | 7 ++++++-
 block/qcow2.c          | 3 +--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/block/qcow2.h b/block/qcow2.h
index f51f478e34..8da1ad11d9 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -708,7 +708,7 @@ int qcow2_snapshot_load_tmp(BlockDriverState *bs,
                             Error **errp);
 
 void qcow2_free_snapshots(BlockDriverState *bs);
-int qcow2_read_snapshots(BlockDriverState *bs);
+int qcow2_read_snapshots(BlockDriverState *bs, Error **errp);
 
 /* qcow2-cache.c functions */
 Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables,
diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c
index 752883e5c3..80d32e4504 100644
--- a/block/qcow2-snapshot.c
+++ b/block/qcow2-snapshot.c
@@ -43,7 +43,7 @@ void qcow2_free_snapshots(BlockDriverState *bs)
     s->nb_snapshots = 0;
 }
 
-int qcow2_read_snapshots(BlockDriverState *bs)
+int qcow2_read_snapshots(BlockDriverState *bs, Error **errp)
 {
     BDRVQcow2State *s = bs->opaque;
     QCowSnapshotHeader h;
@@ -68,6 +68,7 @@ int qcow2_read_snapshots(BlockDriverState *bs)
         offset = ROUND_UP(offset, 8);
         ret = bdrv_pread(bs->file, offset, &h, sizeof(h));
         if (ret < 0) {
+            error_setg_errno(errp, -ret, "Failed to read snapshot table");
             goto fail;
         }
 
@@ -88,6 +89,7 @@ int qcow2_read_snapshots(BlockDriverState *bs)
         ret = bdrv_pread(bs->file, offset, &extra,
                          MIN(sizeof(extra), extra_data_size));
         if (ret < 0) {
+            error_setg_errno(errp, -ret, "Failed to read snapshot table");
             goto fail;
         }
         offset += extra_data_size;
@@ -107,6 +109,7 @@ int qcow2_read_snapshots(BlockDriverState *bs)
         sn->id_str = g_malloc(id_str_size + 1);
         ret = bdrv_pread(bs->file, offset, sn->id_str, id_str_size);
         if (ret < 0) {
+            error_setg_errno(errp, -ret, "Failed to read snapshot table");
             goto fail;
         }
         offset += id_str_size;
@@ -116,6 +119,7 @@ int qcow2_read_snapshots(BlockDriverState *bs)
         sn->name = g_malloc(name_size + 1);
         ret = bdrv_pread(bs->file, offset, sn->name, name_size);
         if (ret < 0) {
+            error_setg_errno(errp, -ret, "Failed to read snapshot table");
             goto fail;
         }
         offset += name_size;
@@ -123,6 +127,7 @@ int qcow2_read_snapshots(BlockDriverState *bs)
 
         if (offset - s->snapshots_offset > QCOW_MAX_SNAPSHOTS_SIZE) {
             ret = -EFBIG;
+            error_setg(errp, "Snapshot table is too big");
             goto fail;
         }
     }
diff --git a/block/qcow2.c b/block/qcow2.c
index 7961c05783..d0135912d0 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1584,9 +1584,8 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
     s->snapshots_offset = header.snapshots_offset;
     s->nb_snapshots = header.nb_snapshots;
 
-    ret = qcow2_read_snapshots(bs);
+    ret = qcow2_read_snapshots(bs, errp);
     if (ret < 0) {
-        error_setg_errno(errp, -ret, "Could not read snapshots");
         goto fail;
     }
 
-- 
2.21.0



  parent reply	other threads:[~2019-10-11 15:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 15:27 [PATCH v3 00/16] qcow2: Let check -r all repair some snapshot bits Max Reitz
2019-10-11 15:27 ` [PATCH v3 01/16] include: Move endof() up from hw/virtio/virtio.h Max Reitz
2019-10-11 15:28 ` [PATCH v3 02/16] qcow2: Use endof() Max Reitz
2019-10-11 15:28 ` Max Reitz [this message]
2019-10-11 15:28 ` [PATCH v3 04/16] qcow2: Keep unknown extra snapshot data Max Reitz
2019-10-11 16:20   ` Eric Blake
2019-10-14  8:46     ` Max Reitz
2019-10-11 15:28 ` [PATCH v3 05/16] qcow2: Make qcow2_write_snapshots() public Max Reitz
2019-10-11 15:28 ` [PATCH v3 06/16] qcow2: Put qcow2_upgrade() into its own function Max Reitz
2019-10-11 15:28 ` [PATCH v3 07/16] qcow2: Write v3-compliant snapshot list on upgrade Max Reitz
2019-10-11 16:23   ` Eric Blake
2019-10-14  8:45     ` Max Reitz
2019-10-14 13:53       ` Eric Blake
2019-10-14 14:09         ` Max Reitz
2019-10-11 15:28 ` [PATCH v3 08/16] qcow2: Separate qcow2_check_read_snapshot_table() Max Reitz
2019-10-11 15:28 ` [PATCH v3 09/16] qcow2: Add qcow2_check_fix_snapshot_table() Max Reitz
2019-10-11 15:28 ` [PATCH v3 10/16] qcow2: Fix broken snapshot table entries Max Reitz
2019-10-11 15:28 ` [PATCH v3 11/16] qcow2: Keep track of the snapshot table length Max Reitz
2019-10-11 15:28 ` [PATCH v3 12/16] qcow2: Fix overly long snapshot tables Max Reitz
2019-10-11 15:28 ` [PATCH v3 13/16] qcow2: Repair snapshot table with too many entries Max Reitz
2019-10-11 16:31   ` Eric Blake
2019-10-11 15:28 ` [PATCH v3 14/16] qcow2: Fix v3 snapshot table entry compliancy Max Reitz
2019-10-11 16:32   ` Eric Blake
2019-10-11 15:28 ` [PATCH v3 15/16] iotests: Add peek_file* functions Max Reitz
2019-10-11 15:28 ` [PATCH v3 16/16] iotests: Test qcow2's snapshot table handling Max Reitz
2019-10-28 10:55 ` [PATCH v3 00/16] qcow2: Let check -r all repair some snapshot bits Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191011152814.14791-4-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.