Skip to content

Commit

Permalink
block: Remove "options" indirection from blockdev-add
Browse files Browse the repository at this point in the history
Now that QAPI supports boxed types, we can have unions at the top level
of a command, so let's put our real options directly there for
blockdev-add instead of having a single "options" dict that contains the
real arguments.

blockdev-add is still experimental and we already made substantial
changes to the API recently, so we're free to make changes like this
one, too.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
kevmw committed Oct 24, 2016
1 parent 170f4b2 commit 0153d2f
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 259 deletions.
84 changes: 39 additions & 45 deletions docs/qmp-commands.txt
Expand Up @@ -1090,11 +1090,11 @@ Arguments:
Example:

-> { "execute": "blockdev-add",
"arguments": { "options": { "driver": "qcow2",
"node-name": "node1534",
"file": { "driver": "file",
"filename": "hd1.qcow2" },
"backing": "" } } }
"arguments": { "driver": "qcow2",
"node-name": "node1534",
"file": { "driver": "file",
"filename": "hd1.qcow2" },
"backing": "" } }

<- { "return": {} }

Expand Down Expand Up @@ -3130,41 +3130,37 @@ This command is still a work in progress. It doesn't support all
block drivers among other things. Stay away from it unless you want
to help with its development.

Arguments:

- "options": block driver options
For the arguments, see the QAPI schema documentation of BlockdevOptions.

Example (1):

-> { "execute": "blockdev-add",
"arguments": { "options" : { "driver": "qcow2",
"file": { "driver": "file",
"filename": "test.qcow2" } } } }
"arguments": { "driver": "qcow2",
"file": { "driver": "file",
"filename": "test.qcow2" } } }
<- { "return": {} }

Example (2):

-> { "execute": "blockdev-add",
"arguments": {
"options": {
"driver": "qcow2",
"node-name": "my_disk",
"discard": "unmap",
"cache": {
"direct": true,
"writeback": true
},
"file": {
"driver": "file",
"filename": "/tmp/test.qcow2"
},
"backing": {
"driver": "raw",
"file": {
"driver": "file",
"filename": "/dev/fdset/4"
}
}
"driver": "qcow2",
"node-name": "my_disk",
"discard": "unmap",
"cache": {
"direct": true,
"writeback": true
},
"file": {
"driver": "file",
"filename": "/tmp/test.qcow2"
},
"backing": {
"driver": "raw",
"file": {
"driver": "file",
"filename": "/dev/fdset/4"
}
}
}
}
Expand All @@ -3191,13 +3187,11 @@ Example:

-> { "execute": "blockdev-add",
"arguments": {
"options": {
"driver": "qcow2",
"node-name": "node0",
"file": {
"driver": "file",
"filename": "test.qcow2"
}
"driver": "qcow2",
"node-name": "node0",
"file": {
"driver": "file",
"filename": "test.qcow2"
}
}
}
Expand Down Expand Up @@ -3342,10 +3336,10 @@ Arguments:
Example:

-> { "execute": "blockdev-add",
"arguments": { "options": { "node-name": "node0",
"driver": "raw",
"file": { "driver": "file",
"filename": "fedora.iso" } } } }
"arguments": { { "node-name": "node0",
"driver": "raw",
"file": { "driver": "file",
"filename": "fedora.iso" } } }

<- { "return": {} }

Expand Down Expand Up @@ -3383,10 +3377,10 @@ Example:

Add a new node to a quorum
-> { "execute": "blockdev-add",
"arguments": { "options": { "driver": "raw",
"node-name": "new_node",
"file": { "driver": "file",
"filename": "test.raw" } } } }
"arguments": { "driver": "raw",
"node-name": "new_node",
"file": { "driver": "file",
"filename": "test.raw" } } }
<- { "return": {} }
-> { "execute": "x-blockdev-change",
"arguments": { "parent": "disk1",
Expand Down
4 changes: 2 additions & 2 deletions qapi/block-core.json
Expand Up @@ -2312,11 +2312,11 @@
# block drivers among other things. Stay away from it unless you want
# to help with its development.
#
# @options: block device options for the new device
# For the arguments, see the documentation of BlockdevOptions.
#
# Since: 1.7
##
{ 'command': 'blockdev-add', 'data': { 'options': 'BlockdevOptions' } }
{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true }

##
# @x-blockdev-del:
Expand Down
11 changes: 5 additions & 6 deletions tests/qemu-iotests/041
Expand Up @@ -194,10 +194,9 @@ class TestSingleBlockdev(TestSingleDrive):
def setUp(self):
TestSingleDrive.setUp(self)
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, target_img)
args = {'options':
{'driver': iotests.imgfmt,
'node-name': self.qmp_target,
'file': { 'filename': target_img, 'driver': 'file' } } }
args = {'driver': iotests.imgfmt,
'node-name': self.qmp_target,
'file': { 'filename': target_img, 'driver': 'file' } }
result = self.vm.qmp("blockdev-add", **args)
self.assert_qmp(result, 'return', {})

Expand Down Expand Up @@ -782,8 +781,8 @@ class TestRepairQuorum(iotests.QMPTestCase):
self.vm.launch()

#assemble the quorum block device from the individual files
args = { "options" : { "driver": "quorum", "node-name": "quorum0",
"vote-threshold": 2, "children": [ "img0", "img1", "img2" ] } }
args = { "driver": "quorum", "node-name": "quorum0",
"vote-threshold": 2, "children": [ "img0", "img1", "img2" ] }
if self.has_quorum():
result = self.vm.qmp("blockdev-add", **args)
self.assert_qmp(result, 'return', {})
Expand Down
12 changes: 5 additions & 7 deletions tests/qemu-iotests/067
Expand Up @@ -119,13 +119,11 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
"arguments": {
"options": {
"driver": "$IMGFMT",
"node-name": "disk",
"file": {
"driver": "file",
"filename": "$TEST_IMG"
}
"driver": "$IMGFMT",
"node-name": "disk",
"file": {
"driver": "file",
"filename": "$TEST_IMG"
}
}
}
Expand Down
118 changes: 51 additions & 67 deletions tests/qemu-iotests/071
Expand Up @@ -107,25 +107,21 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
"arguments": {
"options": {
"node-name": "drive0",
"driver": "file",
"filename": "$TEST_IMG"
}
"node-name": "drive0",
"driver": "file",
"filename": "$TEST_IMG"
}
}
{ "execute": "blockdev-add",
"arguments": {
"options": {
"driver": "$IMGFMT",
"node-name": "drive0-debug",
"file": {
"driver": "blkdebug",
"image": "drive0",
"inject-error": [{
"event": "l2_load"
}]
}
"driver": "$IMGFMT",
"node-name": "drive0-debug",
"file": {
"driver": "blkdebug",
"image": "drive0",
"inject-error": [{
"event": "l2_load"
}]
}
}
}
Expand All @@ -145,26 +141,22 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
"arguments": {
"options": {
"node-name": "drive0",
"driver": "$IMGFMT",
"file": {
"driver": "file",
"filename": "$TEST_IMG"
}
"node-name": "drive0",
"driver": "$IMGFMT",
"file": {
"driver": "file",
"filename": "$TEST_IMG"
}
}
}
{ "execute": "blockdev-add",
"arguments": {
"options": {
"driver": "blkverify",
"node-name": "drive0-verify",
"test": "drive0",
"raw": {
"driver": "file",
"filename": "$TEST_IMG.base"
}
"driver": "blkverify",
"node-name": "drive0-verify",
"test": "drive0",
"raw": {
"driver": "file",
"filename": "$TEST_IMG.base"
}
}
}
Expand All @@ -184,27 +176,23 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
"arguments": {
"options": {
"node-name": "drive0",
"driver": "file",
"filename": "$TEST_IMG.base"
}
"node-name": "drive0",
"driver": "file",
"filename": "$TEST_IMG.base"
}
}
{ "execute": "blockdev-add",
"arguments": {
"options": {
"driver": "blkverify",
"node-name": "drive0-verify",
"test": {
"driver": "$IMGFMT",
"file": {
"driver": "file",
"filename": "$TEST_IMG"
}
},
"raw": "drive0"
}
"driver": "blkverify",
"node-name": "drive0-verify",
"test": {
"driver": "$IMGFMT",
"file": {
"driver": "file",
"filename": "$TEST_IMG"
}
},
"raw": "drive0"
}
}
{ "execute": "human-monitor-command",
Expand All @@ -223,30 +211,26 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
"arguments": {
"options": {
"node-name": "drive0",
"driver": "file",
"filename": "$TEST_IMG"
}
"node-name": "drive0",
"driver": "file",
"filename": "$TEST_IMG"
}
}
{ "execute": "blockdev-add",
"arguments": {
"options": {
"driver": "$IMGFMT",
"node-name": "drive0-debug",
"file": {
"driver": "blkdebug",
"image": "drive0",
"inject-error": [{
"event": "read_aio",
"state": 42
}],
"set-state": [{
"event": "write_aio",
"new_state": 42
}]
}
"driver": "$IMGFMT",
"node-name": "drive0-debug",
"file": {
"driver": "blkdebug",
"image": "drive0",
"inject-error": [{
"event": "read_aio",
"state": 42
}],
"set-state": [{
"event": "write_aio",
"new_state": 42
}]
}
}
}
Expand Down

0 comments on commit 0153d2f

Please sign in to comment.