From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, stefanha@redhat.com,
lcapitulino@redhat.com
Subject: [Qemu-devel] [RFC PATCH 11/11] [WIP] block: Implement 'blockdev-add' QMP command
Date: Tue, 9 Jul 2013 11:53:37 +0200 [thread overview]
Message-ID: <1373363617-4723-12-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1373363617-4723-1-git-send-email-kwolf@redhat.com>
This is just a quick hack to test things
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
blockdev.c | 32 ++++++++++++++++++++++++++++++++
qapi-schema.json | 29 +++++++++++++++++++++++++++++
qmp-commands.hx | 6 ++++++
3 files changed, 67 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index e71c4ee..e3a4fb8 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1741,6 +1741,38 @@ void qmp_block_job_complete(const char *device, Error **errp)
block_job_complete(job, errp);
}
+#include "qapi-visit.h"
+#include "qapi/qmp-output-visitor.h"
+
+void qmp_blockdev_add(BlockOptions *options, Error **errp)
+{
+ QString *str;
+ QmpOutputVisitor *ov = qmp_output_visitor_new();
+ QObject *obj;
+ visit_type_BlockOptions(qmp_output_get_visitor(ov),
+ &options, NULL, errp);
+ obj = qmp_output_get_qobject(ov);
+ str = qobject_to_json_pretty(obj);
+ assert(str != NULL);
+ fprintf(stderr, "\n>>>>>>%s\n<<<<<<\n", qstring_get_str(str));
+ qdict_flatten(obj);
+ str = qobject_to_json_pretty(obj);
+ fprintf(stderr, "\n----->%s\n<-----\n", qstring_get_str(str));
+
+ Error *local_err = NULL;
+ QemuOpts *opts = qemu_opts_from_qdict(&qemu_drive_opts, qobject_to_qdict(obj), &local_err);
+ if (error_is_set(&local_err)) {
+ qerror_report_err(local_err);
+ error_free(local_err);
+ } else {
+ drive_init(opts, IF_NONE);
+ }
+
+ qobject_decref(obj);
+ qmp_output_visitor_cleanup(ov);
+ QDECREF(str);
+}
+
static void do_qmp_query_block_jobs_one(void *opaque, BlockDriverState *bs)
{
BlockJobInfoList **prev = opaque;
diff --git a/qapi-schema.json b/qapi-schema.json
index a90aeb1..9f1cc8d 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3702,3 +3702,32 @@
'*cpuid-input-ecx': 'int',
'cpuid-register': 'X86CPURegister32',
'features': 'int' } }
+
+
+{ 'type': 'BlockOptionsBase',
+ 'data': { 'driver': 'str', '*read-only': 'bool' } }
+
+{ 'type': 'BlockOptionsFile',
+ 'data': { 'filename': 'str' } }
+
+{ 'type': 'BlockOptionsRaw',
+ 'data': { 'file': 'BlockRef' } }
+
+{ 'type': 'BlockOptionsQcow2',
+ 'data': { '*lazy-refcounts': 'bool', 'file': 'BlockRef' } }
+
+{ 'union': 'BlockOptions',
+ 'base': 'BlockOptionsBase',
+ 'discriminator': 'driver',
+ 'data': {
+ 'file': 'BlockOptionsFile'
+ 'raw': 'BlockOptionsRaw'
+ 'qcow2': 'BlockOptionsQcow2'
+ } }
+
+{ 'union': 'BlockRef',
+ 'discriminator': {},
+ 'data': { 'definition': 'BlockOptions'
+ 'reference': 'str' } }
+
+{ 'command': 'blockdev-add', 'data': { 'options': 'BlockOptions' } }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 362f0e1..fe32ae7 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3043,3 +3043,9 @@ Example:
<- { "return": {} }
EQMP
+
+ {
+ .name = "blockdev-add",
+ .args_type = "options:q",
+ .mhandler.cmd_new = qmp_marshal_input_blockdev_add,
+ },
--
1.8.1.4
next prev parent reply other threads:[~2013-07-09 9:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-09 9:53 [Qemu-devel] [RFC PATCH 00/11] qapi changes in preparation for blockdev-add Kevin Wolf
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 01/11] qapi-types.py: Split off generate_struct_fields() Kevin Wolf
2013-07-11 11:45 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 02/11] qapi-types.py: Implement 'base' for unions Kevin Wolf
2013-07-11 11:57 ` Eric Blake
2013-07-11 12:46 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 03/11] qapi-visit.py: Split off generate_visit_struct_fields() Kevin Wolf
2013-07-11 12:18 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 04/11] qapi-visit.py: Implement 'base' for unions Kevin Wolf
2013-07-11 12:21 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 05/11] qapi: Add visitor for implicit structs Kevin Wolf
2013-07-11 12:41 ` Eric Blake
2013-07-11 12:51 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 06/11] qapi: Flat unions with arbitrary discriminator Kevin Wolf
2013-07-11 14:16 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 07/11] qapi: Add consume argument to qmp_input_get_object() Kevin Wolf
2013-07-11 19:17 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 08/11] qapi: Anonymous unions Kevin Wolf
2013-07-11 19:47 ` Eric Blake
2013-07-12 8:55 ` Kevin Wolf
2013-07-12 14:15 ` Eric Blake
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 09/11] Implement qdict_flatten() Kevin Wolf
2013-07-11 20:25 ` Eric Blake
2013-07-16 8:59 ` Kevin Wolf
2013-07-09 9:53 ` [Qemu-devel] [RFC PATCH 10/11] block: Allow "driver" option on the top level Kevin Wolf
2013-07-11 22:30 ` Eric Blake
2013-07-09 9:53 ` Kevin Wolf [this message]
2013-07-11 22:45 ` [Qemu-devel] [RFC PATCH 11/11] [WIP] block: Implement 'blockdev-add' QMP command Eric Blake
2013-07-12 9:40 ` Kevin Wolf
2013-07-12 14:27 ` Eric Blake
2013-07-12 9:55 ` [Qemu-devel] [RFC PATCH 00/11] qapi changes in preparation for blockdev-add Laszlo Ersek
2013-07-12 10:53 ` 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=1373363617-4723-12-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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.