summaryrefslogtreecommitdiff
path: root/tests/qemu-iotests
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-07-18 08:54:00 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-07-24 13:35:11 +0200
commitc42e8742f527476839bcc5f91c3d2ea456ca6a45 (patch)
tree89fcb3d94e71834ce42ab56a2544d52212a69412 /tests/qemu-iotests
parent06f80154b2ada1d58ac504e98ff6e943b069b96c (diff)
downloadqemu-c42e8742f527476839bcc5f91c3d2ea456ca6a45.tar.gz
block: Use JSON null instead of "" to disable backing file
BlockdevRef is an alternate of BlockdevOptions (inline definition) and str (reference to an existing block device by name). BlockdevRef value "" is special: "no block device should be referenced." It's actually interpreted that way in just one place: optional member @backing of COW formats. Semantics: * Present means "use this block device" as backing storage * Absent means "default to the one stored in the image" * Except "" means "don't use backing storage at all" The first two are perfectly normal: when the parameter is absent, it defaults to an implied value, but the value's meaning is the same. The third one overloads the parameter with a second meaning. The overloading is *implicit*, i.e. it's not visible in the types. Works here, because "" is not a value block device ID. Pressing argument values the schema accepts, but are semantically invalid, into service to mean "do something else entirely" is not general, as suitable invalid values need not exist. I also find it ugly. To clean this up, we could add a separate flag argument to suppress @backing, or add a distinct value to @backing. This commit implements the latter: add JSON null to the values of @backing, deprecate "". Because we're so close to the 2.10 freeze, implement it in the stupidest way possible: have qmp_blockdev_add() rewrite null to "" before anything else can see the null. Works, because BlockdevRef occurs only within arguments of blockdev-add. The proper way to do it would be rewriting "" to null, preferably in a cleaner way, but that requires fixing up code to work with null. Add a TODO comment for that. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'tests/qemu-iotests')
-rwxr-xr-xtests/qemu-iotests/0852
-rw-r--r--tests/qemu-iotests/1392
2 files changed, 2 insertions, 2 deletions
diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085
index 71efe50d34..5c7668cf9b 100755
--- a/tests/qemu-iotests/085
+++ b/tests/qemu-iotests/085
@@ -106,7 +106,7 @@ function add_snapshot_image()
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
diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
index 9ff51d9647..50cf40fbd5 100644
--- a/tests/qemu-iotests/139
+++ b/tests/qemu-iotests/139
@@ -69,7 +69,7 @@ class TestBlockdevDel(iotests.QMPTestCase):
'-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)