aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-04-19 17:01:43 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-05-04 08:27:53 +0200
commitcb3e7f08aeaab0ab13e629ce8496dca150a449ba (patch)
tree189830b93bea625aac19f86f26dc4b04cd99f5a3 /block
parent3d3eacaeccaab718ea0e2ddaa578bfae9e311c59 (diff)
qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF
Now that we can safely call QOBJECT() on QObject * as well as its subtypes, we can have macros qobject_ref() / qobject_unref() that work everywhere instead of having to use QINCREF() / QDECREF() for QObject and qobject_incref() / qobject_decref() for its subtypes. The replacement is mechanical, except I broke a long line, and added a cast in monitor_qmp_cleanup_req_queue_locked(). Unlike qobject_decref(), qobject_unref() doesn't accept void *. Note that the new macros evaluate their argument exactly once, thus no need to shout them. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180419150145.24795-4-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Rebased, semantic conflict resolved, commit message improved] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/blkdebug.c4
-rw-r--r--block/blkverify.c4
-rw-r--r--block/crypto.c4
-rw-r--r--block/gluster.c4
-rw-r--r--block/iscsi.c2
-rw-r--r--block/nbd.c4
-rw-r--r--block/nfs.c4
-rw-r--r--block/null.c2
-rw-r--r--block/nvme.c2
-rw-r--r--block/parallels.c4
-rw-r--r--block/qapi.c2
-rw-r--r--block/qcow.c8
-rw-r--r--block/qcow2.c8
-rw-r--r--block/qed.c4
-rw-r--r--block/quorum.c2
-rw-r--r--block/rbd.c14
-rw-r--r--block/sheepdog.c12
-rw-r--r--block/snapshot.c4
-rw-r--r--block/ssh.c4
-rw-r--r--block/vdi.c2
-rw-r--r--block/vhdx.c4
-rw-r--r--block/vpc.c4
-rw-r--r--block/vvfat.c2
-rw-r--r--block/vxhs.c2
24 files changed, 53 insertions, 53 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 589712475a..689703d386 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -845,12 +845,12 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
opts = qdict_new();
qdict_put_str(opts, "driver", "blkdebug");
- QINCREF(bs->file->bs->full_open_options);
+ qobject_ref(bs->file->bs->full_open_options);
qdict_put(opts, "image", bs->file->bs->full_open_options);
for (e = qdict_first(options); e; e = qdict_next(options, e)) {
if (strcmp(qdict_entry_key(e), "x-image")) {
- qobject_incref(qdict_entry_value(e));
+ qobject_ref(qdict_entry_value(e));
qdict_put_obj(opts, qdict_entry_key(e), qdict_entry_value(e));
}
}
diff --git a/block/blkverify.c b/block/blkverify.c
index 331365be33..3cffcb1ca6 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -291,9 +291,9 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options)
QDict *opts = qdict_new();
qdict_put_str(opts, "driver", "blkverify");
- QINCREF(bs->file->bs->full_open_options);
+ qobject_ref(bs->file->bs->full_open_options);
qdict_put(opts, "raw", bs->file->bs->full_open_options);
- QINCREF(s->test_file->bs->full_open_options);
+ qobject_ref(s->test_file->bs->full_open_options);
qdict_put(opts, "test", s->test_file->bs->full_open_options);
bs->full_open_options = opts;
diff --git a/block/crypto.c b/block/crypto.c
index bc6c7e3795..7e7ad2d2a6 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -305,7 +305,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
ret = 0;
cleanup:
- QDECREF(cryptoopts);
+ qobject_unref(cryptoopts);
qapi_free_QCryptoBlockOpenOptions(open_opts);
return ret;
}
@@ -635,7 +635,7 @@ static int coroutine_fn block_crypto_co_create_opts_luks(const char *filename,
fail:
bdrv_unref(bs);
qapi_free_QCryptoBlockCreateOptions(create_opts);
- QDECREF(cryptoopts);
+ qobject_unref(cryptoopts);
return ret;
}
diff --git a/block/gluster.c b/block/gluster.c
index 4adc1a875b..55be566f6d 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -650,7 +650,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
}
gsconf = NULL;
- QDECREF(backing_options);
+ qobject_unref(backing_options);
backing_options = NULL;
g_free(str);
str = NULL;
@@ -663,7 +663,7 @@ out:
qapi_free_SocketAddress(gsconf);
qemu_opts_del(opts);
g_free(str);
- QDECREF(backing_options);
+ qobject_unref(backing_options);
errno = EINVAL;
return -errno;
}
diff --git a/block/iscsi.c b/block/iscsi.c
index f5aecfc883..d19ae0e398 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -2143,7 +2143,7 @@ static int coroutine_fn iscsi_co_create_opts(const char *filename, QemuOpts *opt
} else {
ret = iscsi_open(bs, bs_options, 0, NULL);
}
- QDECREF(bs_options);
+ qobject_unref(bs_options);
if (ret != 0) {
goto out;
diff --git a/block/nbd.c b/block/nbd.c
index 1e2b3ba2d3..3e1693cc55 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -293,8 +293,8 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
}
done:
- QDECREF(addr);
- qobject_decref(crumpled_addr);
+ qobject_unref(addr);
+ qobject_unref(crumpled_addr);
visit_free(iv);
return saddr;
}
diff --git a/block/nfs.c b/block/nfs.c
index 2577df4b26..66fddf12d4 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -567,7 +567,7 @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options,
v = qobject_input_visitor_new_keyval(crumpled);
visit_type_BlockdevOptionsNfs(v, NULL, &opts, &local_err);
visit_free(v);
- qobject_decref(crumpled);
+ qobject_unref(crumpled);
if (local_err) {
return NULL;
@@ -683,7 +683,7 @@ static int coroutine_fn nfs_file_co_create_opts(const char *url, QemuOpts *opts,
ret = 0;
out:
- QDECREF(options);
+ qobject_unref(options);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
}
diff --git a/block/null.c b/block/null.c
index 806a8631e4..700a2d0857 100644
--- a/block/null.c
+++ b/block/null.c
@@ -244,7 +244,7 @@ static int coroutine_fn null_co_block_status(BlockDriverState *bs,
static void null_refresh_filename(BlockDriverState *bs, QDict *opts)
{
- QINCREF(opts);
+ qobject_ref(opts);
qdict_del(opts, "filename");
if (!qdict_size(opts)) {
diff --git a/block/nvme.c b/block/nvme.c
index c4f3a7bc94..e192da9ee1 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -1073,7 +1073,7 @@ static int nvme_reopen_prepare(BDRVReopenState *reopen_state,
static void nvme_refresh_filename(BlockDriverState *bs, QDict *opts)
{
- QINCREF(opts);
+ qobject_ref(opts);
qdict_del(opts, "filename");
if (!qdict_size(opts)) {
diff --git a/block/parallels.c b/block/parallels.c
index 799215e079..045810d00f 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -651,7 +651,7 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
qdict_put_str(qdict, "file", bs->node_name);
qobj = qdict_crumple(qdict, errp);
- QDECREF(qdict);
+ qobject_unref(qdict);
qdict = qobject_to(QDict, qobj);
if (qdict == NULL) {
ret = -EINVAL;
@@ -682,7 +682,7 @@ static int coroutine_fn parallels_co_create_opts(const char *filename,
ret = 0;
done:
- QDECREF(qdict);
+ qobject_unref(qdict);
bdrv_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
diff --git a/block/qapi.c b/block/qapi.c
index 04c6fc69b9..e12968fec8 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -773,7 +773,7 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f,
visit_complete(v, &obj);
data = qdict_get(qobject_to(QDict, obj), "data");
dump_qobject(func_fprintf, f, 1, data);
- qobject_decref(obj);
+ qobject_unref(obj);
visit_free(v);
}
diff --git a/block/qcow.c b/block/qcow.c
index f92891676c..4b2f7db74c 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -315,7 +315,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
- QDECREF(encryptopts);
+ qobject_unref(encryptopts);
qapi_free_QCryptoBlockOpenOptions(crypto_opts);
qemu_co_mutex_init(&s->lock);
return 0;
@@ -326,7 +326,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
g_free(s->cluster_cache);
g_free(s->cluster_data);
qcrypto_block_free(s->crypto);
- QDECREF(encryptopts);
+ qobject_unref(encryptopts);
qapi_free_QCryptoBlockOpenOptions(crypto_opts);
return ret;
}
@@ -995,7 +995,7 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
qdict_put_str(qdict, "file", bs->node_name);
qobj = qdict_crumple(qdict, errp);
- QDECREF(qdict);
+ qobject_unref(qdict);
qdict = qobject_to(QDict, qobj);
if (qdict == NULL) {
ret = -EINVAL;
@@ -1025,7 +1025,7 @@ static int coroutine_fn qcow_co_create_opts(const char *filename,
ret = 0;
fail:
- QDECREF(qdict);
+ qobject_unref(qdict);
bdrv_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
diff --git a/block/qcow2.c b/block/qcow2.c
index ef68772aca..2f36e632f9 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1063,7 +1063,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
ret = 0;
fail:
- QDECREF(encryptopts);
+ qobject_unref(encryptopts);
qemu_opts_del(opts);
opts = NULL;
return ret;
@@ -2183,7 +2183,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
qemu_co_mutex_lock(&s->lock);
ret = qcow2_do_open(bs, options, flags, &local_err);
qemu_co_mutex_unlock(&s->lock);
- QDECREF(options);
+ qobject_unref(options);
if (local_err) {
error_propagate(errp, local_err);
error_prepend(errp, "Could not reopen qcow2 layer: ");
@@ -3139,7 +3139,7 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
/* Now get the QAPI type BlockdevCreateOptions */
qobj = qdict_crumple(qdict, errp);
- QDECREF(qdict);
+ qobject_unref(qdict);
qdict = qobject_to(QDict, qobj);
if (qdict == NULL) {
ret = -EINVAL;
@@ -3168,7 +3168,7 @@ static int coroutine_fn qcow2_co_create_opts(const char *filename, QemuOpts *opt
ret = 0;
finish:
- QDECREF(qdict);
+ qobject_unref(qdict);
bdrv_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
diff --git a/block/qed.c b/block/qed.c
index 35ff505066..1db8eaf241 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -763,7 +763,7 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
qdict_put_str(qdict, "file", bs->node_name);
qobj = qdict_crumple(qdict, errp);
- QDECREF(qdict);
+ qobject_unref(qdict);
qdict = qobject_to(QDict, qobj);
if (qdict == NULL) {
ret = -EINVAL;
@@ -789,7 +789,7 @@ static int coroutine_fn bdrv_qed_co_create_opts(const char *filename,
ret = bdrv_qed_co_create(create_options, errp);
fail:
- QDECREF(qdict);
+ qobject_unref(qdict);
bdrv_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
diff --git a/block/quorum.c b/block/quorum.c
index cfe484a945..862cea366d 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1082,7 +1082,7 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options)
children = qlist_new();
for (i = 0; i < s->num_children; i++) {
- QINCREF(s->children[i]->bs->full_open_options);
+ qobject_ref(s->children[i]->bs->full_open_options);
qlist_append(children, s->children[i]->bs->full_open_options);
}
diff --git a/block/rbd.c b/block/rbd.c
index c9359d0ad8..a14b42fcde 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -226,7 +226,7 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,
done:
g_free(buf);
- QDECREF(keypairs);
+ qobject_unref(keypairs);
return;
}
@@ -275,17 +275,17 @@ static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json,
key = qstring_get_str(name);
ret = rados_conf_set(cluster, key, qstring_get_str(value));
- QDECREF(value);
+ qobject_unref(value);
if (ret < 0) {
error_setg_errno(errp, -ret, "invalid conf option %s", key);
- QDECREF(name);
+ qobject_unref(name);
ret = -EINVAL;
break;
}
- QDECREF(name);
+ qobject_unref(name);
}
- QDECREF(keypairs);
+ qobject_unref(keypairs);
return ret;
}
@@ -449,7 +449,7 @@ static int coroutine_fn qemu_rbd_co_create_opts(const char *filename,
}
exit:
- QDECREF(options);
+ qobject_unref(options);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
}
@@ -664,7 +664,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
v = qobject_input_visitor_new_keyval(crumpled);
visit_type_BlockdevOptionsRbd(v, NULL, &opts, &local_err);
visit_free(v);
- qobject_decref(crumpled);
+ qobject_unref(crumpled);
if (local_err) {
error_propagate(errp, local_err);
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 387f59c8aa..07529f4b1b 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -567,8 +567,8 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp)
done:
visit_free(iv);
- qobject_decref(crumpled_server);
- QDECREF(server);
+ qobject_unref(crumpled_server);
+ qobject_unref(server);
return saddr;
}
@@ -1883,7 +1883,7 @@ static int sd_create_prealloc(BlockdevOptionsSheepdog *location, int64_t size,
if (local_err) {
error_propagate(errp, local_err);
- qobject_decref(obj);
+ qobject_unref(obj);
return -EINVAL;
}
@@ -1901,7 +1901,7 @@ static int sd_create_prealloc(BlockdevOptionsSheepdog *location, int64_t size,
ret = sd_prealloc(bs, 0, size, errp);
fail:
bdrv_unref(bs);
- QDECREF(qdict);
+ qobject_unref(qdict);
return ret;
}
@@ -2226,7 +2226,7 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
v = qobject_input_visitor_new_keyval(crumpled);
visit_type_BlockdevCreateOptions(v, NULL, &create_options, &local_err);
visit_free(v);
- qobject_decref(crumpled);
+ qobject_unref(crumpled);
if (local_err) {
error_propagate(errp, local_err);
@@ -2252,7 +2252,7 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts,
ret = sd_co_create(create_options, errp);
fail:
qapi_free_BlockdevCreateOptions(create_options);
- QDECREF(qdict);
+ qobject_unref(qdict);
return ret;
}
diff --git a/block/snapshot.c b/block/snapshot.c
index eacc1f19a2..2953d96c06 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -214,7 +214,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
bdrv_ref(file);
qdict_extract_subqdict(options, &file_options, "file.");
- QDECREF(file_options);
+ qobject_unref(file_options);
qdict_put_str(options, "file", bdrv_get_node_name(file));
drv->bdrv_close(bs);
@@ -223,7 +223,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
ret = bdrv_snapshot_goto(file, snapshot_id, errp);
open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err);
- QDECREF(options);
+ qobject_unref(options);
if (open_ret < 0) {
bdrv_unref(file);
bs->drv = NULL;
diff --git a/block/ssh.c b/block/ssh.c
index ab3acf0c22..412a1bfc17 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -638,7 +638,7 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp)
v = qobject_input_visitor_new(crumpled);
visit_type_BlockdevOptionsSsh(v, NULL, &result, &local_err);
visit_free(v);
- qobject_decref(crumpled);
+ qobject_unref(crumpled);
if (local_err) {
error_propagate(errp, local_err);
@@ -917,7 +917,7 @@ static int coroutine_fn ssh_co_create_opts(const char *filename, QemuOpts *opts,
ret = ssh_co_create(create_options, errp);
out:
- QDECREF(uri_options);
+ qobject_unref(uri_options);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
}
diff --git a/block/vdi.c b/block/vdi.c
index 4a2d1ff88d..96a22b8e83 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -951,7 +951,7 @@ static int coroutine_fn vdi_co_create_opts(const char *filename, QemuOpts *opts,
/* Create the vdi image (format layer) */
ret = vdi_co_do_create(create_options, block_size, errp);
done:
- QDECREF(qdict);
+ qobject_unref(qdict);
qapi_free_BlockdevCreateOptions(create_options);
bdrv_unref(bs_file);
return ret;
diff --git a/block/vhdx.c b/block/vhdx.c
index 6ac0424f61..c3a4220a35 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -2003,7 +2003,7 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
qdict_put_str(qdict, "file", bs->node_name);
qobj = qdict_crumple(qdict, errp);
- QDECREF(qdict);
+ qobject_unref(qdict);
qdict = qobject_to(QDict, qobj);
if (qdict == NULL) {
ret = -EINVAL;
@@ -2049,7 +2049,7 @@ static int coroutine_fn vhdx_co_create_opts(const char *filename,
ret = vhdx_co_create(create_options, errp);
fail:
- QDECREF(qdict);
+ qobject_unref(qdict);
bdrv_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
diff --git a/block/vpc.c b/block/vpc.c
index 44f99a4d1b..0ebfcd3cc8 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -1119,7 +1119,7 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
qdict_put_str(qdict, "file", bs->node_name);
qobj = qdict_crumple(qdict, errp);
- QDECREF(qdict);
+ qobject_unref(qdict);
qdict = qobject_to(QDict, qobj);
if (qdict == NULL) {
ret = -EINVAL;
@@ -1157,7 +1157,7 @@ static int coroutine_fn vpc_co_create_opts(const char *filename,
ret = vpc_co_create(create_options, errp);
fail:
- QDECREF(qdict);
+ qobject_unref(qdict);
bdrv_unref(bs);
qapi_free_BlockdevCreateOptions(create_options);
return ret;
diff --git a/block/vvfat.c b/block/vvfat.c
index 1569783b0f..662dca0114 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -3179,7 +3179,7 @@ static int enable_write_target(BlockDriverState *bs, Error **errp)
qdict_put_str(options, "write-target.driver", "qcow");
s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs,
&child_vvfat_qcow, false, errp);
- QDECREF(options);
+ qobject_unref(options);
if (!s->qcow) {
ret = -EINVAL;
goto err;
diff --git a/block/vxhs.c b/block/vxhs.c
index 75cc6c8672..55ae1a666e 100644
--- a/block/vxhs.c
+++ b/block/vxhs.c
@@ -396,7 +396,7 @@ static int vxhs_open(BlockDriverState *bs, QDict *options,
out:
g_free(of_vsa_addr);
- QDECREF(backing_options);
+ qobject_unref(backing_options);
qemu_opts_del(tcp_opts);
qemu_opts_del(opts);
g_free(cacert);