diff options
author | Eric Blake <eblake@redhat.com> | 2019-11-13 20:46:35 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2020-02-05 17:22:13 -0600 |
commit | deb6ccb077238660080abe7e667bbf8ede5141c7 (patch) | |
tree | 9251a3aee8863567541d966115cff6643758607c /blockdev-nbd.c | |
parent | 7bd9d0a9e26c7a3c67c0f174f0009ba19969b158 (diff) |
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>
Diffstat (limited to 'blockdev-nbd.c')
-rw-r--r-- | blockdev-nbd.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 8c20baa4a4..de2f2ff713 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -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; |