From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: armbru@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com,
eblake@redhat.com, mreitz@redhat.com, kwolf@redhat.com,
vsementsov@virtuozzo.com, den@openvz.org
Subject: [Qemu-devel] [PATCH v2 2/6] qapi: add name parameter to nbd-server-add
Date: Thu, 7 Dec 2017 18:50:58 +0300 [thread overview]
Message-ID: <20171207155102.66622-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20171207155102.66622-1-vsementsov@virtuozzo.com>
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>
---
qapi/block.json | 9 +++++++--
blockdev-nbd.c | 14 +++++++++-----
hmp.c | 5 +++--
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/qapi/block.json b/qapi/block.json
index f093fa3f27..503d4b287b 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -213,14 +213,19 @@
#
# @device: The device name or node name of the node to be exported
#
+# @name: Export name. If unspecified @device parameter used as export name.
+# (Since 2.12)
+#
# @writable: Whether clients should be able to write to the device via the
# NBD connection (default false).
#
-# Returns: error if the device is already marked for export.
+# Returns: error if the server is not running, or export with the same name
+# already exists.
#
# Since: 1.3.0
##
-{ 'command': 'nbd-server-add', 'data': {'device': 'str', '*writable': 'bool'} }
+{ 'command': 'nbd-server-add',
+ 'data': {'device': 'str', '*name': 'str', '*writable': 'bool'} }
##
# @nbd-server-stop:
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 28f551a7b0..46c885aa35 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -158,8 +158,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;
@@ -170,8 +170,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;
}
@@ -195,7 +199,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
diff --git a/hmp.c b/hmp.c
index 35a7041824..0ea9c09b58 100644
--- a/hmp.c
+++ b/hmp.c
@@ -2203,7 +2203,8 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
continue;
}
- qmp_nbd_server_add(info->value->device, true, writable, &local_err);
+ qmp_nbd_server_add(info->value->device, false, NULL,
+ true, writable, &local_err);
if (local_err != NULL) {
qmp_nbd_server_stop(NULL);
@@ -2223,7 +2224,7 @@ void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
bool writable = qdict_get_try_bool(qdict, "writable", false);
Error *local_err = NULL;
- qmp_nbd_server_add(device, true, writable, &local_err);
+ qmp_nbd_server_add(device, false, NULL, true, writable, &local_err);
if (local_err != NULL) {
hmp_handle_error(mon, &local_err);
--
2.11.1
next prev parent reply other threads:[~2017-12-07 15:51 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 15:50 [Qemu-devel] [PATCH v2 0/6] nbd export qmp interface Vladimir Sementsov-Ogievskiy
2017-12-07 15:50 ` [Qemu-devel] [PATCH v2 1/6] nbd/server: add additional assert to nbd_export_put Vladimir Sementsov-Ogievskiy
2018-01-10 16:33 ` Eric Blake
2017-12-07 15:50 ` Vladimir Sementsov-Ogievskiy [this message]
2017-12-08 17:33 ` [Qemu-devel] [PATCH v2 2/6] qapi: add name parameter to nbd-server-add Dr. David Alan Gilbert
2017-12-09 9:28 ` Vladimir Sementsov-Ogievskiy
2018-01-09 19:06 ` Eric Blake
2018-01-10 16:01 ` Dr. David Alan Gilbert
2018-01-09 19:28 ` [Qemu-devel] [PATCH v2 2.5/6] hmp: Add name parameter to nbd_server_add Eric Blake
2018-01-11 17:59 ` Dr. David Alan Gilbert
2018-01-11 19:50 ` Eric Blake
2018-01-11 20:11 ` Dr. David Alan Gilbert
2018-01-09 19:05 ` [Qemu-devel] [PATCH v2 2/6] qapi: add name parameter to nbd-server-add Eric Blake
2017-12-07 15:50 ` [Qemu-devel] [PATCH v2 3/6] qapi: add nbd-server-remove Vladimir Sementsov-Ogievskiy
2018-01-09 19:52 ` Eric Blake
2018-01-12 9:47 ` Vladimir Sementsov-Ogievskiy
2018-01-15 15:09 ` Eric Blake
2018-01-15 17:47 ` Vladimir Sementsov-Ogievskiy
2018-01-17 13:36 ` Vladimir Sementsov-Ogievskiy
2018-01-17 15:23 ` Eric Blake
2018-01-17 15:51 ` Vladimir Sementsov-Ogievskiy
2018-01-17 16:03 ` Eric Blake
2018-01-17 16:39 ` Vladimir Sementsov-Ogievskiy
2018-01-26 15:05 ` Dr. David Alan Gilbert
2018-02-06 15:29 ` Vladimir Sementsov-Ogievskiy
2018-02-06 16:06 ` Eric Blake
2018-02-06 17:54 ` Vladimir Sementsov-Ogievskiy
2018-02-06 18:38 ` Dr. David Alan Gilbert
2018-02-07 7:14 ` Markus Armbruster
2017-12-07 15:51 ` [Qemu-devel] [PATCH v2 4/6] iotest 147: add cases to test new @name parameter of nbd-server-add Vladimir Sementsov-Ogievskiy
2018-01-09 20:21 ` Eric Blake
2017-12-07 15:51 ` [Qemu-devel] [PATCH v2 5/6] iotests: implement QemuIoInteractive class Vladimir Sementsov-Ogievskiy
2018-01-09 20:34 ` Eric Blake
2018-01-12 11:56 ` Vladimir Sementsov-Ogievskiy
2018-01-12 16:48 ` Eric Blake
2017-12-07 15:51 ` [Qemu-devel] [PATCH v2 6/6] iotest 201: new test for qmp nbd-server-remove Vladimir Sementsov-Ogievskiy
2018-01-09 20:49 ` Eric Blake
2018-01-12 11:43 ` Vladimir Sementsov-Ogievskiy
2018-01-12 16:54 ` Eric Blake
2018-01-15 14:40 ` Vladimir Sementsov-Ogievskiy
2018-01-15 15:05 ` Eric Blake
2018-01-15 18:28 ` Vladimir Sementsov-Ogievskiy
2017-12-21 11:52 ` [Qemu-devel] ping Re: [PATCH v2 0/6] nbd export qmp interface Vladimir Sementsov-Ogievskiy
2017-12-21 15:28 ` [Qemu-devel] " Markus Armbruster
2017-12-21 18:32 ` Eric Blake
2017-12-22 8:53 ` Vladimir Sementsov-Ogievskiy
2017-12-22 15:47 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171207155102.66622-3-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.