From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org,
armbru@redhat.com, mreitz@redhat.com
Subject: [RFC PATCH 08/18] qemu-storage-daemon: Add --export option
Date: Thu, 17 Oct 2019 15:01:54 +0200 [thread overview]
Message-ID: <20191017130204.16131-9-kwolf@redhat.com> (raw)
In-Reply-To: <20191017130204.16131-1-kwolf@redhat.com>
Add a --export option to qemu-storage-daemon to export a block node. For
now, only NBD exports are implemented. Apart from the 'type' option
(which is the implied key), it maps the arguments for nbd-server-add to
the command line. Example:
--export nbd,device=disk,name=test-export,writable=on
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qapi/block.json | 27 +++++++++++++++++++++++++++
qemu-storage-daemon.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/qapi/block.json b/qapi/block.json
index 567f116875..d9b1f16fbf 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -481,3 +481,30 @@
{ 'event': 'QUORUM_REPORT_BAD',
'data': { 'type': 'QuorumOpType', '*error': 'str', 'node-name': 'str',
'sector-num': 'int', 'sectors-count': 'int' } }
+
+##
+# @BlockExportType:
+#
+# An enumeration of block export types
+#
+# @nbd: NBD export
+#
+# Since: 4.2
+##
+{ 'enum': 'BlockExportType',
+ 'data': [ 'nbd' ] }
+
+##
+# @BlockExport:
+#
+# Describes a block export, i.e. how single node should be exported on an
+# external interface.
+#
+# Since: 4.2
+##
+{ 'union': 'BlockExport',
+ 'base': { 'type': 'BlockExportType' },
+ 'discriminator': 'type',
+ 'data': {
+ 'nbd': 'BlockExportNbd'
+ } }
diff --git a/qemu-storage-daemon.c b/qemu-storage-daemon.c
index 51882452f3..9e5f474fd0 100644
--- a/qemu-storage-daemon.c
+++ b/qemu-storage-daemon.c
@@ -67,6 +67,11 @@ static void help(void)
" [,driver specific parameters...]\n"
" configure a block backend\n"
"\n"
+" --export [type=]nbd,device=<node-name>[,name=<export-name>]\n"
+" [,writable=on|off][,bitmap=<name>]\n"
+" export the specified block node over NBD\n"
+" (requires --nbd-server)\n"
+"\n"
" --nbd-server addr.type=inet,addr.host=<host>,addr.port=<port>\n"
" [,tls-creds=<id>][,tls-authz=<id>]\n"
" --nbd-server addr.type=unix,addr.path=<path>\n"
@@ -84,6 +89,7 @@ enum {
OPTION_OBJECT = 256,
OPTION_BLOCKDEV,
OPTION_NBD_SERVER,
+ OPTION_EXPORT,
};
static QemuOptsList qemu_object_opts = {
@@ -95,6 +101,17 @@ static QemuOptsList qemu_object_opts = {
},
};
+static void init_export(BlockExport *export, Error **errp)
+{
+ switch (export->type) {
+ case BLOCK_EXPORT_TYPE_NBD:
+ qmp_nbd_server_add(&export->u.nbd, errp);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
static int process_options(int argc, char *argv[], Error **errp)
{
int c;
@@ -106,6 +123,7 @@ static int process_options(int argc, char *argv[], Error **errp)
{"object", required_argument, 0, OPTION_OBJECT},
{"blockdev", required_argument, 0, OPTION_BLOCKDEV},
{"nbd-server", required_argument, 0, OPTION_NBD_SERVER},
+ {"export", required_argument, 0, OPTION_EXPORT},
{"version", no_argument, 0, 'V'},
{"trace", required_argument, NULL, 'T'},
{0, 0, 0, 0}
@@ -176,6 +194,19 @@ static int process_options(int argc, char *argv[], Error **errp)
qapi_free_NbdServerOptions(options);
break;
}
+ case OPTION_EXPORT:
+ {
+ Visitor *v;
+ BlockExport *export;
+
+ v = qobject_input_visitor_new_str(optarg, "type", &error_fatal);
+ visit_type_BlockExport(v, NULL, &export, &error_fatal);
+ visit_free(v);
+
+ init_export(export, &error_fatal);
+ qapi_free_BlockExport(export);
+ break;
+ }
}
}
if (optind != argc) {
--
2.20.1
next prev parent reply other threads:[~2019-10-17 13:10 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-17 13:01 [RFC PATCH 00/18] Add qemu-storage-daemon Kevin Wolf
2019-10-17 13:01 ` [RFC PATCH 01/18] qemu-storage-daemon: Add barebone tool Kevin Wolf
2019-10-24 13:50 ` Eric Blake
2019-11-13 14:12 ` Kevin Wolf
2019-11-06 12:11 ` Max Reitz
2019-11-07 16:21 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 02/18] qemu-storage-daemon: Add --object option Kevin Wolf
2019-11-07 20:36 ` Markus Armbruster
2019-11-14 12:05 ` Kevin Wolf
2019-11-18 9:10 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 03/18] stubs: Add arch_type Kevin Wolf
2019-10-17 13:01 ` [RFC PATCH 04/18] stubs: Add blk_by_qdev_id() Kevin Wolf
2019-11-08 9:03 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 05/18] qemu-storage-daemon: Add --blockdev option Kevin Wolf
2019-11-08 13:29 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 06/18] qemu-storage-daemon: Add --nbd-server option Kevin Wolf
2019-11-06 12:51 ` Max Reitz
2019-11-06 19:25 ` Eric Blake
2019-11-07 8:33 ` Kevin Wolf
2019-11-07 13:45 ` Eric Blake
2019-11-07 15:27 ` Kevin Wolf
2019-11-07 15:36 ` Eric Blake
2019-11-08 15:36 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 07/18] blockdev-nbd: Boxed argument type for nbd-server-add Kevin Wolf
2019-10-17 13:01 ` Kevin Wolf [this message]
2019-11-06 13:11 ` [RFC PATCH 08/18] qemu-storage-daemon: Add --export option Max Reitz
2019-11-06 13:34 ` Kevin Wolf
2019-11-06 13:39 ` Max Reitz
2019-11-08 15:57 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 09/18] qemu-storage-daemon: Add main loop Kevin Wolf
2019-11-08 16:02 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 10/18] qemu-storage-daemon: Add --chardev option Kevin Wolf
2019-11-08 16:27 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 11/18] monitor: Move monitor option parsing to monitor/monitor.c Kevin Wolf
2019-10-17 13:01 ` [RFC PATCH 12/18] stubs: Update monitor stubs for qemu-storage-daemon Kevin Wolf
2019-11-08 16:45 ` Markus Armbruster
2019-10-17 13:01 ` [RFC PATCH 13/18] qapi: Create module 'monitor' Kevin Wolf
2019-11-11 9:36 ` Markus Armbruster
2019-10-17 13:02 ` [RFC PATCH 14/18] monitor: Create monitor/qmp-cmds-monitor.c Kevin Wolf
2019-10-17 13:02 ` [RFC PATCH 15/18] qapi: Support empty modules Kevin Wolf
2019-11-12 8:29 ` Markus Armbruster
2019-10-17 13:02 ` [RFC PATCH 16/18] qapi: Create 'pragma' module Kevin Wolf
2019-11-12 9:41 ` Markus Armbruster
2019-10-17 13:02 ` [RFC PATCH 17/18] monitor: Move qmp_query_qmp_schema to qmp-cmds-monitor.c Kevin Wolf
2019-10-17 13:02 ` [RFC PATCH 18/18] qemu-storage-daemon: Add --monitor option Kevin Wolf
2019-11-06 14:32 ` Max Reitz
2019-11-07 10:12 ` Kevin Wolf
2019-11-07 10:44 ` Max Reitz
2019-11-08 8:59 ` Markus Armbruster
2019-11-12 14:25 ` Markus Armbruster
2019-11-13 10:58 ` Kevin Wolf
2019-11-13 13:53 ` Markus Armbruster
2019-10-24 11:33 ` [RFC PATCH 00/18] Add qemu-storage-daemon Kevin Wolf
2019-10-24 13:55 ` Vladimir Sementsov-Ogievskiy
2019-11-14 10:44 ` Kevin Wolf
2019-11-05 15:52 ` Stefan Hajnoczi
2019-11-06 14:37 ` Max Reitz
2019-11-06 14:58 ` Kevin Wolf
2019-11-06 15:35 ` Max Reitz
2019-11-06 17:13 ` Eric Blake
2019-11-21 10:32 ` Stefan Hajnoczi
2019-11-21 11:08 ` Kevin Wolf
2019-12-12 11:16 ` Stefan Hajnoczi
2019-11-07 10:33 ` Daniel P. Berrangé
2019-11-07 12:03 ` Kevin Wolf
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=20191017130204.16131-9-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=mreitz@redhat.com \
--cc=pkrempa@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).