mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
qapi block: Elide redundant has_FOO in generated C
The has_FOO for pointer-valued FOO are redundant, except for arrays. They are also a nuisance to work with. Recent commit "qapi: Start to elide redundant has_FOO in generated C" provided the means to elide them step by step. This is the step for qapi/block*.json. Said commit explains the transformation in more detail. There is one instance of the invariant violation mentioned there: qcow2_signal_corruption() passes false, "" when node_name is an empty string. Take care to pass NULL then. The previous two commits cleaned up two more. Additionally, helper bdrv_latency_histogram_stats() loses its output parameters and returns a value instead. Cc: Kevin Wolf <kwolf@redhat.com> Cc: Hanna Reitz <hreitz@redhat.com> Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20221104160712.3005652-11-armbru@redhat.com> [Fixes for #ifndef LIBRBD_SUPPORTS_ENCRYPTION and MacOS squashed in]
This commit is contained in:
parent
8461b4d601
commit
54fde4ff06
23 changed files with 173 additions and 281 deletions
|
@ -3508,7 +3508,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
|||
if (!qcow2_opts->has_preallocation) {
|
||||
qcow2_opts->preallocation = PREALLOC_MODE_OFF;
|
||||
}
|
||||
if (qcow2_opts->has_backing_file &&
|
||||
if (qcow2_opts->backing_file &&
|
||||
qcow2_opts->preallocation != PREALLOC_MODE_OFF &&
|
||||
!qcow2_opts->extended_l2)
|
||||
{
|
||||
|
@ -3517,7 +3517,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
|||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (qcow2_opts->has_backing_fmt && !qcow2_opts->has_backing_file) {
|
||||
if (qcow2_opts->has_backing_fmt && !qcow2_opts->backing_file) {
|
||||
error_setg(errp, "Backing format cannot be used without backing file");
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
|
@ -3558,7 +3558,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
|||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (qcow2_opts->data_file_raw && qcow2_opts->has_backing_file) {
|
||||
if (qcow2_opts->data_file_raw && qcow2_opts->backing_file) {
|
||||
error_setg(errp, "Backing file and data-file-raw cannot be used at "
|
||||
"the same time");
|
||||
ret = -EINVAL;
|
||||
|
@ -3584,7 +3584,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
|||
* backing file when specifying data_file_raw is an error
|
||||
* anyway.
|
||||
*/
|
||||
assert(!qcow2_opts->has_backing_file);
|
||||
assert(!qcow2_opts->backing_file);
|
||||
}
|
||||
|
||||
if (qcow2_opts->data_file) {
|
||||
|
@ -3752,7 +3752,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
|||
}
|
||||
|
||||
/* Want a backing file? There you go. */
|
||||
if (qcow2_opts->has_backing_file) {
|
||||
if (qcow2_opts->backing_file) {
|
||||
const char *backing_format = NULL;
|
||||
|
||||
if (qcow2_opts->has_backing_fmt) {
|
||||
|
@ -3770,7 +3770,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
|||
}
|
||||
|
||||
/* Want encryption? There you go. */
|
||||
if (qcow2_opts->has_encrypt) {
|
||||
if (qcow2_opts->encrypt) {
|
||||
ret = qcow2_set_up_encryption(blk_bs(blk), qcow2_opts->encrypt, errp);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
|
@ -5195,7 +5195,6 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
|
|||
.refcount_bits = s->refcount_bits,
|
||||
.has_bitmaps = !!bitmaps,
|
||||
.bitmaps = bitmaps,
|
||||
.has_data_file = !!s->image_data_file,
|
||||
.data_file = g_strdup(s->image_data_file),
|
||||
.has_data_file_raw = has_data_file(bs),
|
||||
.data_file_raw = data_file_is_raw(bs),
|
||||
|
@ -5226,7 +5225,6 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs,
|
|||
memset(&encrypt_info->u, 0, sizeof(encrypt_info->u));
|
||||
qapi_free_QCryptoBlockInfo(encrypt_info);
|
||||
|
||||
spec_info->u.qcow2.data->has_encrypt = true;
|
||||
spec_info->u.qcow2.data->encrypt = qencrypt;
|
||||
}
|
||||
|
||||
|
@ -5846,7 +5844,7 @@ static int coroutine_fn qcow2_co_amend(BlockDriverState *bs,
|
|||
BDRVQcow2State *s = bs->opaque;
|
||||
int ret = 0;
|
||||
|
||||
if (qopts->has_encrypt) {
|
||||
if (qopts->encrypt) {
|
||||
if (!s->crypto) {
|
||||
error_setg(errp, "image is not encrypted, can't amend");
|
||||
return -EOPNOTSUPP;
|
||||
|
@ -5911,7 +5909,7 @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,
|
|||
|
||||
node_name = bdrv_get_node_name(bs);
|
||||
qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs),
|
||||
*node_name != '\0', node_name,
|
||||
*node_name ? node_name : NULL,
|
||||
message, offset >= 0, offset,
|
||||
size >= 0, size,
|
||||
fatal);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue