diff options
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c index 6469f161df..02cd69bc21 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3887,6 +3887,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp) QObject *obj; Visitor *v = qobject_output_visitor_new(&obj); QDict *qdict; + const QDictEntry *ent; Error *local_err = NULL; visit_type_BlockdevOptions(v, NULL, &options, &local_err); @@ -3900,6 +3901,19 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp) qdict_flatten(qdict); + /* + * Rewrite "backing": null to "backing": "" + * TODO Rewrite "" to null instead, and perhaps not even here + */ + for (ent = qdict_first(qdict); ent; ent = qdict_next(qdict, ent)) { + char *dot = strrchr(ent->key, '.'); + + if (!strcmp(dot ? dot + 1 : ent->key, "backing") + && qobject_type(ent->value) == QTYPE_QNULL) { + qdict_put(qdict, ent->key, qstring_new()); + } + } + if (!qdict_get_try_str(qdict, "node-name")) { error_setg(errp, "'node-name' must be specified for the root node"); goto fail; |