summaryrefslogtreecommitdiffstats
path: root/include/block
diff options
context:
space:
mode:
authorKevin Wolf2020-09-24 17:26:59 +0200
committerKevin Wolf2020-10-02 15:46:40 +0200
commitc69de1bef59ba0d824cd9d5e9da602cb23c29e4b (patch)
tree44c0095a1f47006da6297c23f3b0a372fb715dab /include/block
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 'include/block')
-rw-r--r--include/block/export.h15
-rw-r--r--include/block/nbd.h2
2 files changed, 15 insertions, 2 deletions
diff --git a/include/block/export.h b/include/block/export.h
index e7af2c7687..5236a35e12 100644
--- a/include/block/export.h
+++ b/include/block/export.h
@@ -24,12 +24,27 @@ typedef struct BlockExportDriver {
/* Creates and starts a new block export */
BlockExport *(*create)(BlockExportOptions *, Error **);
+
+ /*
+ * Frees a removed block export. This function is only called after all
+ * references have been dropped.
+ */
+ void (*delete)(BlockExport *);
} BlockExportDriver;
struct BlockExport {
const BlockExportDriver *drv;
+
+ /*
+ * Reference count for this block export. This includes strong references
+ * both from the owner (qemu-nbd or the monitor) and clients connected to
+ * the export.
+ */
+ int refcount;
};
BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp);
+void blk_exp_ref(BlockExport *exp);
+void blk_exp_unref(BlockExport *exp);
#endif
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 1dafe70615..e3bd112227 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -338,8 +338,6 @@ NBDExport *nbd_export_new(BlockDriverState *bs,
void nbd_export_set_on_eject_blk(BlockExport *exp, BlockBackend *blk);
void nbd_export_close(NBDExport *exp);
void nbd_export_remove(NBDExport *exp, NbdServerRemoveMode mode, Error **errp);
-void nbd_export_get(NBDExport *exp);
-void nbd_export_put(NBDExport *exp);
AioContext *nbd_export_aio_context(NBDExport *exp);
NBDExport *nbd_export_find(const char *name);