summaryrefslogtreecommitdiffstats
path: root/include/block
diff options
context:
space:
mode:
authorKevin Wolf2020-09-24 17:27:02 +0200
committerKevin Wolf2020-10-02 15:46:40 +0200
commita6ff7989662d659aed0888670e77e68cb8c9bd81 (patch)
tree67af6fa4a55dce3eb78a40f53433ffc49a38e59b /include/block
parentblock/export: Add node-name to BlockExportOptions (diff)
downloadqemu-a6ff7989662d659aed0888670e77e68cb8c9bd81.tar.gz
qemu-a6ff7989662d659aed0888670e77e68cb8c9bd81.tar.xz
qemu-a6ff7989662d659aed0888670e77e68cb8c9bd81.zip
block/export: Allocate BlockExport in blk_exp_add()
Instead of letting the driver allocate and return the BlockExport object, allocate it already in blk_exp_add() and pass it. This allows us to initialise the generic part before calling into the driver so that the driver can just use these values instead of having to parse the options a second time. For symmetry, move freeing the BlockExport to blk_exp_unref(). Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200924152717.287415-17-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.h8
-rw-r--r--include/block/nbd.h11
2 files changed, 13 insertions, 6 deletions
diff --git a/include/block/export.h b/include/block/export.h
index e6f96f4e1e..cf9b1c9dad 100644
--- a/include/block/export.h
+++ b/include/block/export.h
@@ -22,8 +22,14 @@ typedef struct BlockExportDriver {
/* The export type that this driver services */
BlockExportType type;
+ /*
+ * The size of the driver-specific state that contains BlockExport as its
+ * first field.
+ */
+ size_t instance_size;
+
/* Creates and starts a new block export */
- BlockExport *(*create)(BlockExportOptions *, Error **);
+ int (*create)(BlockExport *, BlockExportOptions *, Error **);
/*
* Frees a removed block export. This function is only called after all
diff --git a/include/block/nbd.h b/include/block/nbd.h
index e3bd112227..fc2c153d5b 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -330,11 +330,12 @@ int nbd_errno_to_system_errno(int err);
typedef struct NBDExport NBDExport;
typedef struct NBDClient NBDClient;
-BlockExport *nbd_export_create(BlockExportOptions *exp_args, Error **errp);
-NBDExport *nbd_export_new(BlockDriverState *bs,
- const char *name, const char *desc,
- const char *bitmap, bool readonly, bool shared,
- bool writethrough, Error **errp);
+int nbd_export_create(BlockExport *exp, BlockExportOptions *exp_args,
+ Error **errp);
+int nbd_export_new(BlockExport *blk_exp, BlockDriverState *bs,
+ const char *name, const char *desc,
+ const char *bitmap, bool readonly, bool shared,
+ bool writethrough, Error **errp);
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);