summaryrefslogtreecommitdiffstats
path: root/block/export
diff options
context:
space:
mode:
authorKevin Wolf2020-09-24 17:26:59 +0200
committerKevin Wolf2020-10-02 15:46:40 +0200
commitc69de1bef59ba0d824cd9d5e9da602cb23c29e4b (patch)
tree44c0095a1f47006da6297c23f3b0a372fb715dab /block/export
parentnbd/server: Simplify export shutdown (diff)
downloadqemu-c69de1bef59ba0d824cd9d5e9da602cb23c29e4b.tar.gz
qemu-c69de1bef59ba0d824cd9d5e9da602cb23c29e4b.tar.xz
qemu-c69de1bef59ba0d824cd9d5e9da602cb23c29e4b.zip
block/export: Move refcount from NBDExport to BlockExport
Having a refcount makes sense for all types of block exports. It is also a prerequisite for keeping a list of all exports at the BlockExport level. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200924152717.287415-14-kwolf@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/export')
-rw-r--r--block/export/export.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/block/export/export.c b/block/export/export.c
index 05bc5e3744..baba4e94ff 100644
--- a/block/export/export.c
+++ b/block/export/export.c
@@ -49,6 +49,20 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
return drv->create(export, errp);
}
+void blk_exp_ref(BlockExport *exp)
+{
+ assert(exp->refcount > 0);
+ exp->refcount++;
+}
+
+void blk_exp_unref(BlockExport *exp)
+{
+ assert(exp->refcount > 0);
+ if (--exp->refcount == 0) {
+ exp->drv->delete(exp);
+ }
+}
+
void qmp_block_export_add(BlockExportOptions *export, Error **errp)
{
blk_exp_add(export, errp);