mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -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
17
block/rbd.c
17
block/rbd.c
|
@ -536,13 +536,13 @@ static int qemu_rbd_do_create(BlockdevCreateOptions *options,
|
|||
int ret;
|
||||
|
||||
assert(options->driver == BLOCKDEV_DRIVER_RBD);
|
||||
if (opts->location->has_snapshot) {
|
||||
if (opts->location->snapshot) {
|
||||
error_setg(errp, "Can't use snapshot name for image creation");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#ifndef LIBRBD_SUPPORTS_ENCRYPTION
|
||||
if (opts->has_encrypt) {
|
||||
if (opts->encrypt) {
|
||||
error_setg(errp, "RBD library does not support image encryption");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ static int qemu_rbd_do_create(BlockdevCreateOptions *options,
|
|||
}
|
||||
|
||||
#ifdef LIBRBD_SUPPORTS_ENCRYPTION
|
||||
if (opts->has_encrypt) {
|
||||
if (opts->encrypt) {
|
||||
rbd_image_t image;
|
||||
|
||||
ret = rbd_open(io_ctx, opts->location->image, &image, NULL);
|
||||
|
@ -686,7 +686,6 @@ static int coroutine_fn qemu_rbd_co_create_opts(BlockDriver *drv,
|
|||
goto exit;
|
||||
}
|
||||
rbd_opts->encrypt = encrypt;
|
||||
rbd_opts->has_encrypt = !!encrypt;
|
||||
|
||||
/*
|
||||
* Caution: while qdict_get_try_str() is fine, getting non-string
|
||||
|
@ -697,11 +696,8 @@ static int coroutine_fn qemu_rbd_co_create_opts(BlockDriver *drv,
|
|||
loc = rbd_opts->location;
|
||||
loc->pool = g_strdup(qdict_get_try_str(options, "pool"));
|
||||
loc->conf = g_strdup(qdict_get_try_str(options, "conf"));
|
||||
loc->has_conf = !!loc->conf;
|
||||
loc->user = g_strdup(qdict_get_try_str(options, "user"));
|
||||
loc->has_user = !!loc->user;
|
||||
loc->q_namespace = g_strdup(qdict_get_try_str(options, "namespace"));
|
||||
loc->has_q_namespace = !!loc->q_namespace;
|
||||
loc->image = g_strdup(qdict_get_try_str(options, "image"));
|
||||
keypairs = qdict_get_try_str(options, "=keyvalue-pairs");
|
||||
|
||||
|
@ -767,7 +763,6 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
|||
return -EINVAL;
|
||||
}
|
||||
opts->key_secret = g_strdup(secretid);
|
||||
opts->has_key_secret = true;
|
||||
}
|
||||
|
||||
mon_host = qemu_rbd_mon_host(opts, &local_err);
|
||||
|
@ -785,7 +780,7 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
|||
|
||||
/* try default location when conf=NULL, but ignore failure */
|
||||
r = rados_conf_read_file(*cluster, opts->conf);
|
||||
if (opts->has_conf && r < 0) {
|
||||
if (opts->conf && r < 0) {
|
||||
error_setg_errno(errp, -r, "error reading conf file %s", opts->conf);
|
||||
goto failed_shutdown;
|
||||
}
|
||||
|
@ -833,7 +828,7 @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx,
|
|||
}
|
||||
|
||||
#ifdef HAVE_RBD_NAMESPACE_EXISTS
|
||||
if (opts->has_q_namespace && strlen(opts->q_namespace) > 0) {
|
||||
if (opts->q_namespace && strlen(opts->q_namespace) > 0) {
|
||||
bool exists;
|
||||
|
||||
r = rbd_namespace_exists(*io_ctx, opts->q_namespace, &exists);
|
||||
|
@ -991,7 +986,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
|
|||
goto failed_open;
|
||||
}
|
||||
|
||||
if (opts->has_encrypt) {
|
||||
if (opts->encrypt) {
|
||||
#ifdef LIBRBD_SUPPORTS_ENCRYPTION
|
||||
r = qemu_rbd_encryption_load(s->image, opts->encrypt, errp);
|
||||
if (r < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue