Commit 0153d2f5 authored by Kevin Wolf's avatar Kevin Wolf
Browse files

block: Remove "options" indirection from blockdev-add



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: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarFam Zheng <famz@redhat.com>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: default avatarMax Reitz <mreitz@redhat.com>
parent 170f4b2e
Loading
Loading
Loading
Loading
+39 −45
Original line number Diff line number Diff line
@@ -1090,11 +1090,11 @@ Arguments:
Example:

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

<- { "return": {} }

@@ -3130,23 +3130,20 @@ 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",
    "arguments": { "driver": "qcow2",
                   "file": { "driver": "file",
                                           "filename": "test.qcow2" } } } }
                             "filename": "test.qcow2" } } }
<- { "return": {} }

Example (2):

-> { "execute": "blockdev-add",
     "arguments": {
         "options": {
         "driver": "qcow2",
         "node-name": "my_disk",
         "discard": "unmap",
@@ -3167,7 +3164,6 @@ Example (2):
         }
       }
     }
     }

<- { "return": {} }

@@ -3191,7 +3187,6 @@ Example:

-> { "execute": "blockdev-add",
     "arguments": {
         "options": {
         "driver": "qcow2",
         "node-name": "node0",
         "file": {
@@ -3200,7 +3195,6 @@ Example:
         }
     }
   }
   }

<- { "return": {} }

@@ -3342,10 +3336,10 @@ Arguments:
Example:

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

<- { "return": {} }

@@ -3383,10 +3377,10 @@ Example:

Add a new node to a quorum
-> { "execute": "blockdev-add",
     "arguments": { "options": { "driver": "raw",
     "arguments": { "driver": "raw",
                    "node-name": "new_node",
                    "file": { "driver": "file",
                                           "filename": "test.raw" } } } }
                              "filename": "test.raw" } } }
<- { "return": {} }
-> { "execute": "x-blockdev-change",
     "arguments": { "parent": "disk1",
+2 −2
Original line number Diff line number Diff line
@@ -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:
+5 −6
Original line number Diff line number Diff line
@@ -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,
        args = {'driver': iotests.imgfmt,
                'node-name': self.qmp_target,
                     'file': { 'filename': target_img, 'driver': 'file' } } }
                'file': { 'filename': target_img, 'driver': 'file' } }
        result = self.vm.qmp("blockdev-add", **args)
        self.assert_qmp(result, 'return', {})

@@ -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', {})
+5 −7
Original line number Diff line number Diff line
@@ -119,7 +119,6 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
  "arguments": {
      "options": {
      "driver": "$IMGFMT",
      "node-name": "disk",
      "file": {
@@ -128,7 +127,6 @@ run_qemu <<EOF
      }
    }
  }
  }
{ "execute": "query-named-block-nodes" }
{ "execute": "device_add",
   "arguments": { "driver": "virtio-blk", "drive": "disk",
+51 −67
Original line number Diff line number Diff line
@@ -107,16 +107,13 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
    "arguments": {
        "options": {
        "node-name": "drive0",
        "driver": "file",
        "filename": "$TEST_IMG"
    }
}
}
{ "execute": "blockdev-add",
    "arguments": {
        "options": {
        "driver": "$IMGFMT",
        "node-name": "drive0-debug",
        "file": {
@@ -128,7 +125,6 @@ run_qemu <<EOF
        }
    }
}
}
{ "execute": "human-monitor-command",
    "arguments": {
        "command-line": 'qemu-io drive0-debug "read 0 512"'
@@ -145,7 +141,6 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
    "arguments": {
        "options": {
        "node-name": "drive0",
        "driver": "$IMGFMT",
        "file": {
@@ -154,10 +149,8 @@ run_qemu <<EOF
        }
    }
}
}
{ "execute": "blockdev-add",
    "arguments": {
        "options": {
        "driver": "blkverify",
        "node-name": "drive0-verify",
        "test": "drive0",
@@ -167,7 +160,6 @@ run_qemu <<EOF
        }
    }
}
}
{ "execute": "human-monitor-command",
    "arguments": {
        "command-line": 'qemu-io drive0-verify "read 0 512"'
@@ -184,16 +176,13 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
    "arguments": {
        "options": {
        "node-name": "drive0",
        "driver": "file",
        "filename": "$TEST_IMG.base"
    }
}
}
{ "execute": "blockdev-add",
    "arguments": {
        "options": {
        "driver": "blkverify",
        "node-name": "drive0-verify",
        "test": {
@@ -206,7 +195,6 @@ run_qemu <<EOF
        "raw": "drive0"
    }
}
}
{ "execute": "human-monitor-command",
    "arguments": {
        "command-line": 'qemu-io drive0-verify "read 0 512"'
@@ -223,16 +211,13 @@ run_qemu <<EOF
{ "execute": "qmp_capabilities" }
{ "execute": "blockdev-add",
    "arguments": {
        "options": {
        "node-name": "drive0",
        "driver": "file",
        "filename": "$TEST_IMG"
    }
}
}
{ "execute": "blockdev-add",
    "arguments": {
        "options": {
        "driver": "$IMGFMT",
        "node-name": "drive0-debug",
        "file": {
@@ -249,7 +234,6 @@ run_qemu <<EOF
        }
    }
}
}
{ "execute": "human-monitor-command",
    "arguments": {
        "command-line": 'qemu-io drive0-debug "read 0 512"'
Loading