diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-03-07 17:06:48 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-03-07 17:06:48 +0000 |
commit | 87467097f8811258cd91d42c141a7bd8492ed08a (patch) | |
tree | 4c9f130fca163f66038c12af9b3416860bad6338 /vl.c | |
parent | 43c227f9dd7945bb4a895f841ecdb957bd8a12da (diff) | |
parent | 0b2c1beea4358e40d1049b8ee019408ce96b37ce (diff) |
Merge remote-tracking branch 'remotes/armbru/tags/pull-block-2017-02-28-v4' into staging
block: Command line option -blockdev
# gpg: Signature made Tue 07 Mar 2017 15:07:59 GMT
# gpg: using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg: aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-block-2017-02-28-v4: (24 commits)
keyval: Support lists
docs/qapi-code-gen.txt: Clarify naming rules
qapi: Improve how keyval input visitor reports unexpected dicts
block: Initial implementation of -blockdev
qapi: New qobject_input_visitor_new_str() for convenience
keyval: Restrict key components to valid QAPI names
qapi: New parse_qapi_name()
test-qapi-util: New, covering qapi/qapi-util.c
monitor: Assert qmp_schema_json[] is sane
test-visitor-serialization: Pass &error_abort to qobject_from_json()
check-qjson: Test errors from qobject_from_json()
block: More detailed syntax error reporting for JSON filenames
qobject: Propagate parse errors through qobject_from_json()
test-qobject-input-visitor: Abort earlier on bad test input
qjson: Abort earlier on qobject_from_jsonf() misuse
libqtest: Fix qmp() & friends to abort on JSON parse errors
qobject: Propagate parse errors through qobject_from_jsonv()
qapi: Factor out common qobject_input_get_keyval()
qapi: Factor out common part of qobject input visitor creation
test-keyval: Cover use with qobject input visitor
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'vl.c')
-rw-r--r-- | vl.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -95,6 +95,9 @@ int main(int argc, char **argv) #include "migration/colo.h" #include "sysemu/kvm.h" #include "sysemu/hax.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi-visit.h" #include "qapi/qmp/qjson.h" #include "qemu/option.h" #include "qemu/config-file.h" @@ -2976,6 +2979,13 @@ int main(int argc, char **argv, char **envp) Error *main_loop_err = NULL; Error *err = NULL; bool list_data_dirs = false; + typedef struct BlockdevOptions_queue { + BlockdevOptions *bdo; + Location loc; + QSIMPLEQ_ENTRY(BlockdevOptions_queue) entry; + } BlockdevOptions_queue; + QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue + = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); module_call_init(MODULE_INIT_TRACE); @@ -3118,6 +3128,25 @@ int main(int argc, char **argv, char **envp) drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg, HD_OPTS); break; + case QEMU_OPTION_blockdev: + { + Visitor *v; + BlockdevOptions_queue *bdo; + + v = qobject_input_visitor_new_str(optarg, "driver", &err); + if (!v) { + error_report_err(err); + exit(1); + } + + bdo = g_new(BlockdevOptions_queue, 1); + visit_type_BlockdevOptions(v, NULL, &bdo->bdo, + &error_fatal); + visit_free(v); + loc_save(&bdo->loc); + QSIMPLEQ_INSERT_TAIL(&bdo_queue, bdo, entry); + break; + } case QEMU_OPTION_drive: if (drive_def(optarg) == NULL) { exit(1); @@ -4451,6 +4480,16 @@ int main(int argc, char **argv, char **envp) } /* open the virtual block devices */ + while (!QSIMPLEQ_EMPTY(&bdo_queue)) { + BlockdevOptions_queue *bdo = QSIMPLEQ_FIRST(&bdo_queue); + + QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry); + loc_push_restore(&bdo->loc); + qmp_blockdev_add(bdo->bdo, &error_fatal); + loc_pop(&bdo->loc); + qapi_free_BlockdevOptions(bdo->bdo); + g_free(bdo); + } if (snapshot || replay_mode != REPLAY_MODE_NONE) { qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, NULL); |