nbd: Allow description when creating NBD blockdev

Allow blockdevs to match the feature already present in qemu-nbd -D.
Enhance iotest 223 to cover it.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20191114024635.11363-5-eblake@redhat.com>
This commit is contained in:
Eric Blake
2019-11-13 20:46:35 -06:00
parent 7bd9d0a9e2
commit deb6ccb077
5 changed files with 21 additions and 9 deletions

View File

@ -144,6 +144,7 @@ void qmp_nbd_server_start(SocketAddressLegacy *addr,
}
void qmp_nbd_server_add(const char *device, bool has_name, const char *name,
bool has_description, const char *description,
bool has_writable, bool writable,
bool has_bitmap, const char *bitmap, Error **errp)
{
@ -167,6 +168,11 @@ void qmp_nbd_server_add(const char *device, bool has_name, const char *name,
return;
}
if (has_description && strlen(description) > NBD_MAX_STRING_SIZE) {
error_setg(errp, "description '%s' too long", description);
return;
}
if (nbd_export_find(name)) {
error_setg(errp, "NBD server already has export named '%s'", name);
return;
@ -195,7 +201,8 @@ void qmp_nbd_server_add(const char *device, bool has_name, const char *name,
writable = false;
}
exp = nbd_export_new(bs, 0, len, name, NULL, bitmap, !writable, !writable,
exp = nbd_export_new(bs, 0, len, name, description, bitmap,
!writable, !writable,
NULL, false, on_eject_blk, errp);
if (!exp) {
goto out;