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 committed 2020-02-05 17:22:13 -06:00
1 parent 7bd9d0a9e2
commit deb6ccb077
5 files changed
+21 -9

No files matched your search

+8 -1
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;