aboutsummaryrefslogtreecommitdiff
path: root/blockdev-nbd.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2018-01-19 16:57:15 +0300
committerEric Blake <eblake@redhat.com>2018-01-26 09:37:20 -0600
commit902a1f94bee2f5c633bb623baf2160c0a6da097c (patch)
tree172642330cb8ede5ad843ee82de7cc2179e5f754 /blockdev-nbd.c
parente607bbee553cfe73072870cef458cfa4e78133e2 (diff)
qapi: add name parameter to nbd-server-add
Allow user to specify name for new export, to not reuse internal node name and to not show it to clients. This also allows creating several exports per device. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180119135719.24745-2-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'blockdev-nbd.c')
-rw-r--r--blockdev-nbd.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 9e3c22109c..104789e521 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -140,8 +140,8 @@ void qmp_nbd_server_start(SocketAddressLegacy *addr,
qapi_free_SocketAddress(addr_flat);
}
-void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
- Error **errp)
+void qmp_nbd_server_add(const char *device, bool has_name, const char *name,
+ bool has_writable, bool writable, Error **errp)
{
BlockDriverState *bs = NULL;
BlockBackend *on_eject_blk;
@@ -152,8 +152,12 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
return;
}
- if (nbd_export_find(device)) {
- error_setg(errp, "NBD server already exporting device '%s'", device);
+ if (!has_name) {
+ name = device;
+ }
+
+ if (nbd_export_find(name)) {
+ error_setg(errp, "NBD server already has export named '%s'", name);
return;
}
@@ -177,7 +181,7 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
return;
}
- nbd_export_set_name(exp, device);
+ nbd_export_set_name(exp, name);
/* The list of named exports has a strong reference to this export now and
* our only way of accessing it is through nbd_export_find(), so we can drop