diff options
author | Kevin Wolf <kwolf@redhat.com> | 2020-09-24 17:26:59 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2020-10-02 15:46:40 +0200 |
commit | c69de1bef59ba0d824cd9d5e9da602cb23c29e4b (patch) | |
tree | 44c0095a1f47006da6297c23f3b0a372fb715dab /block/export | |
parent | dbc9e94a23dfdebe3bd610165d25ca080e705455 (diff) |
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.c | 14 |
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); |