[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 47/69] qcow2: Add Error ** to qcow2_read_snapshots()
From: |
Max Reitz |
Subject: |
[PULL 47/69] qcow2: Add Error ** to qcow2_read_snapshots() |
Date: |
Mon, 28 Oct 2019 13:14:39 +0100 |
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.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 5cccd87162..cc0d5eadd0 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 0bc69e6996..60ed084e5c 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
- [PULL 35/69] iotests: Drop TEST_DIR filter from _filter_nbd, (continued)
- [PULL 35/69] iotests: Drop TEST_DIR filter from _filter_nbd, Max Reitz, 2019/10/28
- [PULL 37/69] block/block-copy: limit copy_range_size to 16 MiB, Max Reitz, 2019/10/28
- [PULL 40/69] block/block-copy: add memory limit, Max Reitz, 2019/10/28
- [PULL 38/69] block/block-copy: refactor copying, Max Reitz, 2019/10/28
- [PULL 39/69] util: introduce SharedResource, Max Reitz, 2019/10/28
- [PULL 41/69] block/block-copy: increase buffered copy request, Max Reitz, 2019/10/28
- [PULL 43/69] block/nvme: add support for discard, Max Reitz, 2019/10/28
- [PULL 42/69] block/nvme: add support for write zeros, Max Reitz, 2019/10/28
- [PULL 44/69] mirror: Do not dereference invalid pointers, Max Reitz, 2019/10/28
- [PULL 50/69] qcow2: Put qcow2_upgrade() into its own function, Max Reitz, 2019/10/28
- [PULL 47/69] qcow2: Add Error ** to qcow2_read_snapshots(),
Max Reitz <=
- [PULL 45/69] include: Move endof() up from hw/virtio/virtio.h, Max Reitz, 2019/10/28
- [PULL 48/69] qcow2: Keep unknown extra snapshot data, Max Reitz, 2019/10/28
- [PULL 51/69] qcow2: Write v3-compliant snapshot list on upgrade, Max Reitz, 2019/10/28
- [PULL 46/69] qcow2: Use endof(), Max Reitz, 2019/10/28
- [PULL 53/69] qcow2: Add qcow2_check_fix_snapshot_table(), Max Reitz, 2019/10/28
- [PULL 56/69] qcow2: Fix overly long snapshot tables, Max Reitz, 2019/10/28
- [PULL 59/69] iotests: Add peek_file* functions, Max Reitz, 2019/10/28
- [PULL 54/69] qcow2: Fix broken snapshot table entries, Max Reitz, 2019/10/28
- [PULL 49/69] qcow2: Make qcow2_write_snapshots() public, Max Reitz, 2019/10/28
- [PULL 52/69] qcow2: Separate qcow2_check_read_snapshot_table(), Max Reitz, 2019/10/28