summaryrefslogtreecommitdiffstats
path: root/include/block
diff options
context:
space:
mode:
authorEric Blake2019-01-11 20:47:16 +0100
committerEric Blake2019-01-14 17:09:46 +0100
commit3fa4c76590569f9dc128beb3eee65aaefcb6321e (patch)
tree774c11eaf4ad51fd636e74b4cec75e6284848db9 /include/block
parentnbd: Only require disabled bitmap for read-only exports (diff)
downloadqemu-3fa4c76590569f9dc128beb3eee65aaefcb6321e.tar.gz
qemu-3fa4c76590569f9dc128beb3eee65aaefcb6321e.tar.xz
qemu-3fa4c76590569f9dc128beb3eee65aaefcb6321e.zip
nbd: Merge nbd_export_set_name into nbd_export_new
The existing NBD code had a weird split where nbd_export_new() created an export but did not add it to the list of exported names until a later nbd_export_set_name() came along and grabbed a second reference on the object; later, the first call to nbd_export_close() drops the second reference while removing the export from the list. This is in part because the QAPI NbdServerRemoveNode enum documents the possibility of adding a mode where we could do a soft disconnect: preventing new clients, but waiting for existing clients to gracefully quit, based on the mode used when calling nbd_export_close(). But in spite of all that, note that we never change the name of an NBD export while it is exposed, which means it is easier to just inline the process of setting the name as part of creating the export. Inline the contents of nbd_export_set_name() and nbd_export_set_description() into the two points in an export lifecycle where they matter, then adjust both callers to pass the name up front. Note that for creation, all callers pass a non-NULL name, (passing NULL at creation was for old style servers, but we removed support for that in commit 7f7dfe2a), so we can add an assert and do things unconditionally; but for cleanup, because of the dual nature of nbd_export_close(), we still have to be careful to avoid use-after-free. Along the way, add a comment reminding ourselves of the potential of adding a middle mode disconnect. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20190111194720.15671-5-eblake@redhat.com>
Diffstat (limited to 'include/block')
-rw-r--r--include/block/nbd.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 65402d3396..2f9a2aeb73 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -295,6 +295,7 @@ typedef struct NBDExport NBDExport;
typedef struct NBDClient NBDClient;
NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset, off_t size,
+ const char *name, const char *description,
uint16_t nbdflags, void (*close)(NBDExport *),
bool writethrough, BlockBackend *on_eject_blk,
Error **errp);
@@ -306,8 +307,6 @@ void nbd_export_put(NBDExport *exp);
BlockBackend *nbd_export_get_blockdev(NBDExport *exp);
NBDExport *nbd_export_find(const char *name);
-void nbd_export_set_name(NBDExport *exp, const char *name);
-void nbd_export_set_description(NBDExport *exp, const char *description);
void nbd_export_close_all(void);
void nbd_client_new(QIOChannelSocket *sioc,