mirror_qemu/include/block
Eric Blake 3fa4c76590 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>
2019-01-14 10:09:46 -06:00
..
accounting.h block/accounting: introduce latency histogram 2018-03-19 14:58:37 -05:00
aio-wait.h block: Use a single global AioWait 2018-09-25 15:50:15 +02:00
aio.h qemu-timer: introduce timer attributes 2018-10-19 13:44:03 +02:00
block.h block: Remove flags parameter from bdrv_reopen_queue() 2018-12-14 11:55:02 +01:00
block_backup.h block/backup: drop unused synchronization interface 2018-12-14 11:52:40 +01:00
block_int.h dirty-bitmap: rename bdrv_undo_clear_dirty_bitmap 2018-10-29 16:23:14 -04:00
blockjob.h block: Use a single global AioWait 2018-09-25 15:50:15 +02:00
blockjob_int.h block: Really pause block jobs on drain 2018-06-18 15:03:25 +02:00
dirty-bitmap.h dirty-bitmaps: clean-up bitmaps loading and migration logic 2018-10-29 16:23:17 -04:00
nbd.h nbd: Merge nbd_export_set_name into nbd_export_new 2019-01-14 10:09:46 -06:00
nvme.h block: Move NVMe constants to a separate header 2018-02-08 09:22:03 +08:00
qapi.h Drop superfluous includes of qapi-types.h and test-qapi-types.h 2018-02-09 05:05:11 +01:00
qdict.h block: Factor out qobject_input_visitor_new_flat_confused() 2018-06-15 14:49:44 +02:00
raw-aio.h file-posix: Make .bdrv_co_truncate asynchronous 2018-06-29 14:20:56 +02:00
snapshot.h Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
thread-pool.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
throttle-groups.h block: add throttle block filter driver 2017-09-06 10:12:02 +02:00
write-threshold.h Use scripts/clean-includes to drop redundant qemu/typedefs.h 2016-03-22 22:20:16 +01:00