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);
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;
# besides their data source and an optional backing file.
#
# @backing: reference to or definition of the backing file block
-# device (if missing, taken from the image file content). It is
-# allowed to pass an empty string here in order to disable the
-# default backing file.
+# device, null disables the backing file entirely.
+# Defaults to the backing file stored the image file.
#
# Since: 2.9
##
{ 'struct': 'BlockdevOptionsGenericCOWFormat',
'base': 'BlockdevOptionsGenericFormat',
- 'data': { '*backing': 'BlockdevRef' } }
+ 'data': { '*backing': 'BlockdevRefOrNull' } }
##
# @Qcow2OverlapCheckMode:
# Reference to a block device.
#
# @definition: defines a new block device inline
-# @reference: references the ID of an existing block device. An
-# empty string means that no block device should be
-# referenced.
+# @reference: references the ID of an existing block device
#
# Since: 2.9
##
'data': { 'definition': 'BlockdevOptions',
'reference': 'str' } }
+##
+# @BlockdevRefOrNull:
+#
+# Reference to a block device.
+#
+# @definition: defines a new block device inline
+# @reference: references the ID of an existing block device.
+# An empty string means that no block device should
+# be referenced. Deprecated; use null instead.
+# @null: No block device should be referenced (since 2.10)
+#
+# Since: 2.9
+##
+{ 'alternate': 'BlockdevRefOrNull',
+ 'data': { 'definition': 'BlockdevOptions',
+ 'reference': 'str',
+ 'null': 'null' } }
+
##
# @blockdev-add:
#
snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}"
_make_test_img -u -b "${base_image}" "$size"
mv "${TEST_IMG}" "${snapshot_file}"
- do_blockdev_add "$1" "'backing': '', " "${snapshot_file}"
+ do_blockdev_add "$1" "'backing': null, " "${snapshot_file}"
}
# ${1}: unique identifier for the snapshot filename
'-b', base_img, new_img, '1M')
opts = {'driver': iotests.imgfmt,
'node-name': node,
- 'backing': '',
+ 'backing': None,
'file': {'driver': 'file',
'filename': new_img}}
result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)