|
|
7711c0 |
From d48c917f7bcc56fce488c129884abee39dbf0df4 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Wed, 20 Mar 2019 21:48:36 +0100
|
|
|
7711c0 |
Subject: [PATCH 043/163] bdrv_query_image_info Error parameter added
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190320214838.22027-9-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 85002
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 08/10] bdrv_query_image_info Error parameter added
|
|
|
7711c0 |
Bugzilla: 1691048
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Inform a user in case qcow2_get_specific_info fails to obtain
|
|
|
7711c0 |
QCOW2 image specific information. This patch is preliminary to
|
|
|
7711c0 |
the one "qcow2: Add list of bitmaps to ImageInfoSpecificQCow2".
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
|
|
|
7711c0 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Message-Id: <1549638368-530182-2-git-send-email-andrey.shinkevich@virtuozzo.com>
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 1bf6e9ca9234e1dbcaa18baa06eca9d55cc2dbbb)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
block.c | 5 +++--
|
|
|
7711c0 |
block/crypto.c | 9 +++------
|
|
|
7711c0 |
block/qapi.c | 7 ++++++-
|
|
|
7711c0 |
block/qcow2.c | 10 ++++++++--
|
|
|
7711c0 |
block/vmdk.c | 3 ++-
|
|
|
7711c0 |
include/block/block.h | 3 ++-
|
|
|
7711c0 |
include/block/block_int.h | 3 ++-
|
|
|
7711c0 |
qemu-io-cmds.c | 7 ++++++-
|
|
|
7711c0 |
8 files changed, 32 insertions(+), 15 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/block.c b/block.c
|
|
|
7711c0 |
index bcf277d..e3e0e34 100644
|
|
|
7711c0 |
--- a/block.c
|
|
|
7711c0 |
+++ b/block.c
|
|
|
7711c0 |
@@ -4204,11 +4204,12 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
|
|
7711c0 |
return drv->bdrv_get_info(bs, bdi);
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
-ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs)
|
|
|
7711c0 |
+ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs,
|
|
|
7711c0 |
+ Error **errp)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
BlockDriver *drv = bs->drv;
|
|
|
7711c0 |
if (drv && drv->bdrv_get_specific_info) {
|
|
|
7711c0 |
- return drv->bdrv_get_specific_info(bs);
|
|
|
7711c0 |
+ return drv->bdrv_get_specific_info(bs, errp);
|
|
|
7711c0 |
}
|
|
|
7711c0 |
return NULL;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
diff --git a/block/crypto.c b/block/crypto.c
|
|
|
7711c0 |
index 0bb0db6..fd88782 100644
|
|
|
7711c0 |
--- a/block/crypto.c
|
|
|
7711c0 |
+++ b/block/crypto.c
|
|
|
7711c0 |
@@ -664,20 +664,17 @@ static int block_crypto_get_info_luks(BlockDriverState *bs,
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
static ImageInfoSpecific *
|
|
|
7711c0 |
-block_crypto_get_specific_info_luks(BlockDriverState *bs)
|
|
|
7711c0 |
+block_crypto_get_specific_info_luks(BlockDriverState *bs, Error **errp)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
BlockCrypto *crypto = bs->opaque;
|
|
|
7711c0 |
ImageInfoSpecific *spec_info;
|
|
|
7711c0 |
QCryptoBlockInfo *info;
|
|
|
7711c0 |
|
|
|
7711c0 |
- info = qcrypto_block_get_info(crypto->block, NULL);
|
|
|
7711c0 |
+ info = qcrypto_block_get_info(crypto->block, errp);
|
|
|
7711c0 |
if (!info) {
|
|
|
7711c0 |
return NULL;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
- if (info->format != Q_CRYPTO_BLOCK_FORMAT_LUKS) {
|
|
|
7711c0 |
- qapi_free_QCryptoBlockInfo(info);
|
|
|
7711c0 |
- return NULL;
|
|
|
7711c0 |
- }
|
|
|
7711c0 |
+ assert(info->format == Q_CRYPTO_BLOCK_FORMAT_LUKS);
|
|
|
7711c0 |
|
|
|
7711c0 |
spec_info = g_new(ImageInfoSpecific, 1);
|
|
|
7711c0 |
spec_info->type = IMAGE_INFO_SPECIFIC_KIND_LUKS;
|
|
|
7711c0 |
diff --git a/block/qapi.c b/block/qapi.c
|
|
|
7711c0 |
index 339727f..42ce4a3 100644
|
|
|
7711c0 |
--- a/block/qapi.c
|
|
|
7711c0 |
+++ b/block/qapi.c
|
|
|
7711c0 |
@@ -282,7 +282,12 @@ void bdrv_query_image_info(BlockDriverState *bs,
|
|
|
7711c0 |
info->dirty_flag = bdi.is_dirty;
|
|
|
7711c0 |
info->has_dirty_flag = true;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
- info->format_specific = bdrv_get_specific_info(bs);
|
|
|
7711c0 |
+ info->format_specific = bdrv_get_specific_info(bs, &err;;
|
|
|
7711c0 |
+ if (err) {
|
|
|
7711c0 |
+ error_propagate(errp, err);
|
|
|
7711c0 |
+ qapi_free_ImageInfo(info);
|
|
|
7711c0 |
+ goto out;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
info->has_format_specific = info->format_specific != NULL;
|
|
|
7711c0 |
|
|
|
7711c0 |
backing_filename = bs->backing_file;
|
|
|
7711c0 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
7711c0 |
index 114dcdd..de9872f 100644
|
|
|
7711c0 |
--- a/block/qcow2.c
|
|
|
7711c0 |
+++ b/block/qcow2.c
|
|
|
7711c0 |
@@ -4166,14 +4166,20 @@ static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
|
|
|
7711c0 |
return 0;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
-static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
|
|
|
7711c0 |
+static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
|
|
|
7711c0 |
+ Error **errp)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
BDRVQcow2State *s = bs->opaque;
|
|
|
7711c0 |
ImageInfoSpecific *spec_info;
|
|
|
7711c0 |
QCryptoBlockInfo *encrypt_info = NULL;
|
|
|
7711c0 |
+ Error *local_err = NULL;
|
|
|
7711c0 |
|
|
|
7711c0 |
if (s->crypto != NULL) {
|
|
|
7711c0 |
- encrypt_info = qcrypto_block_get_info(s->crypto, &error_abort);
|
|
|
7711c0 |
+ encrypt_info = qcrypto_block_get_info(s->crypto, &local_err);
|
|
|
7711c0 |
+ if (local_err) {
|
|
|
7711c0 |
+ error_propagate(errp, local_err);
|
|
|
7711c0 |
+ return NULL;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
spec_info = g_new(ImageInfoSpecific, 1);
|
|
|
7711c0 |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
7711c0 |
index 84f8bbe..f52f291 100644
|
|
|
7711c0 |
--- a/block/vmdk.c
|
|
|
7711c0 |
+++ b/block/vmdk.c
|
|
|
7711c0 |
@@ -2287,7 +2287,8 @@ static int coroutine_fn vmdk_co_check(BlockDriverState *bs,
|
|
|
7711c0 |
return ret;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
-static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)
|
|
|
7711c0 |
+static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs,
|
|
|
7711c0 |
+ Error **errp)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
int i;
|
|
|
7711c0 |
BDRVVmdkState *s = bs->opaque;
|
|
|
7711c0 |
diff --git a/include/block/block.h b/include/block/block.h
|
|
|
7711c0 |
index 36a702c..5f40140 100644
|
|
|
7711c0 |
--- a/include/block/block.h
|
|
|
7711c0 |
+++ b/include/block/block.h
|
|
|
7711c0 |
@@ -472,7 +472,8 @@ const char *bdrv_get_device_name(const BlockDriverState *bs);
|
|
|
7711c0 |
const char *bdrv_get_device_or_node_name(const BlockDriverState *bs);
|
|
|
7711c0 |
int bdrv_get_flags(BlockDriverState *bs);
|
|
|
7711c0 |
int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
|
|
|
7711c0 |
-ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs);
|
|
|
7711c0 |
+ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs,
|
|
|
7711c0 |
+ Error **errp);
|
|
|
7711c0 |
void bdrv_round_to_clusters(BlockDriverState *bs,
|
|
|
7711c0 |
int64_t offset, int64_t bytes,
|
|
|
7711c0 |
int64_t *cluster_offset,
|
|
|
7711c0 |
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
|
7711c0 |
index f457acb..f241bd9 100644
|
|
|
7711c0 |
--- a/include/block/block_int.h
|
|
|
7711c0 |
+++ b/include/block/block_int.h
|
|
|
7711c0 |
@@ -321,7 +321,8 @@ struct BlockDriver {
|
|
|
7711c0 |
const char *name,
|
|
|
7711c0 |
Error **errp);
|
|
|
7711c0 |
int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
|
|
|
7711c0 |
- ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs);
|
|
|
7711c0 |
+ ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs,
|
|
|
7711c0 |
+ Error **errp);
|
|
|
7711c0 |
|
|
|
7711c0 |
int coroutine_fn (*bdrv_save_vmstate)(BlockDriverState *bs,
|
|
|
7711c0 |
QEMUIOVector *qiov,
|
|
|
7711c0 |
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
|
|
|
7711c0 |
index 5bf5f28..9c51e57 100644
|
|
|
7711c0 |
--- a/qemu-io-cmds.c
|
|
|
7711c0 |
+++ b/qemu-io-cmds.c
|
|
|
7711c0 |
@@ -1660,6 +1660,7 @@ static int info_f(BlockBackend *blk, int argc, char **argv)
|
|
|
7711c0 |
BlockDriverState *bs = blk_bs(blk);
|
|
|
7711c0 |
BlockDriverInfo bdi;
|
|
|
7711c0 |
ImageInfoSpecific *spec_info;
|
|
|
7711c0 |
+ Error *local_err = NULL;
|
|
|
7711c0 |
char s1[64], s2[64];
|
|
|
7711c0 |
int ret;
|
|
|
7711c0 |
|
|
|
7711c0 |
@@ -1681,7 +1682,11 @@ static int info_f(BlockBackend *blk, int argc, char **argv)
|
|
|
7711c0 |
printf("cluster size: %s\n", s1);
|
|
|
7711c0 |
printf("vm state offset: %s\n", s2);
|
|
|
7711c0 |
|
|
|
7711c0 |
- spec_info = bdrv_get_specific_info(bs);
|
|
|
7711c0 |
+ spec_info = bdrv_get_specific_info(bs, &local_err);
|
|
|
7711c0 |
+ if (local_err) {
|
|
|
7711c0 |
+ error_report_err(local_err);
|
|
|
7711c0 |
+ return -EIO;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
if (spec_info) {
|
|
|
7711c0 |
printf("Format specific information:\n");
|
|
|
7711c0 |
bdrv_image_info_specific_dump(fprintf, stdout, spec_info);
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|