block: Handle null backing link

Instead of converting all "backing": null instances into "backing": "",
handle a null value directly in bdrv_open_inherit().

This enables explicitly null backing links for json:{} filenames.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-Id: <20180224154033.29559-7-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: rebase to qobject_to() parameter order and qapi headers split]
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Max Reitz 2018-02-24 16:40:32 +01:00 committed by Eric Blake
parent 532fb53284
commit e59a0cf17b
4 changed files with 32 additions and 15 deletions

View file

@ -4045,7 +4045,6 @@ 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);
@ -4059,19 +4058,6 @@ 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;