Adding an overlay with 'blockdev-add' fails with: "Parameter 'driver' is missing"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding an overlay with 'blockdev-add' fails with: "Parameter 'driver' is missing"

Kashyap Chamarthy-2
TL;DR: Using `blockdev-add` to create an overlay file succeeds with QEMU
       2.7.0, however the *same* test fails with QEMU from Git (plus a
       couple of patch series from mailing list).  Details below.

QEMU invocation:

  $ qemu-system-x86_64 -display none \
     -nodefconfig -nodefaults -m 512 -device virtio-scsi-pci,id=scsi \
     -device virtio-serial-pci \
     -drive file=./base.qcow2,format=qcow2,if=virtio \
     -monitor stdio -qmp unix:./qmp-sock,server,nowait

With QEMU 2.7.0
---------------

$ qemu-system-x86_64 --version
QEMU emulator version 2.7.0(qemu-2.7.0-8.fc24) [...]

Create the overlay file:

    $ qemu-img create -f qcow2 /export/target.qcow2 1G

$ ./qmp-shell -v -p /export/qmp-sock

(QEMU) blockdev-add options={"id":"virtio1","driver":"qcow2","file":{"driver":"file","filename":"/export/target.qcow2"},"backing":"virtio0"}
{
    "execute": "blockdev-add",
    "arguments": {
        "options": {
            "backing": "virtio0",
            "driver": "qcow2",
            "id": "virtio1",
            "file": {
                "driver": "file",
                "filename": "/export/target.qcow2"
            }
        }
    }
}
{
    "return": {}
}
(QEMU)

* * *

With Git Master (v2.8.0-1462-g612bb5d-dirty)
--------------------------------------------

Note: I applied these three patch series:

  - [PATCH v2 00/24] QemuOpts util/cutils: Fix and clean up number
    conversions"
  - [PATCH 00/14] qobject: Cleanups, mostly in tests
  - [PATCH 0/2] qapi: Improve qobject input visitor error reporting

So, I'm here:

  $ git describe
        pull-block-2017-02-21-81-g612bb5d

The same test as above (but with the QEMU from Git + above patch
series):

- Stop system QEMU
- Start QEMU built from Git (with the above patches)
- Try to add 'target.qcow2' block device via `blockdev-add`, it now
  fails as below:

  [...]
  (QEMU)
  {
      "execute": "blockdev-add",
      "arguments": {
          "options": {
              "backing": "virtio0",
              "driver": "qcow2",
              "id": "virtio1",
              "file": {
                  "driver": "file",
                  "filename": "/export/target.qcow2"
              }
          }
      }
  }
  {
      "error": {
          "class": "GenericError",
          "desc": "Parameter 'driver' is missing"
      }
  }
  (QEMU)

* * *

Is this a regression or am I missing something?

--
/kashyap

Reply | Threaded
Open this post in threaded view
|

Re: Adding an overlay with 'blockdev-add' fails with: "Parameter 'driver' is missing"

Markus Armbruster
Kashyap Chamarthy <[hidden email]> writes:

> TL;DR: Using `blockdev-add` to create an overlay file succeeds with QEMU
>        2.7.0, however the *same* test fails with QEMU from Git (plus a
>        couple of patch series from mailing list).  Details below.

commit 0153d2f50bc2ad3f41810d838fcf66acbf10f07a
Author: Kevin Wolf <[hidden email]>
Date:   Fri Oct 7 17:05:04 2016 +0200

    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: Kevin Wolf <[hidden email]>

Sorry for the confusion!  Early adopters always have the most fun ;)

[...]

Reply | Threaded
Open this post in threaded view
|

Re: Adding an overlay with 'blockdev-add' fails with: "Parameter 'driver' is missing"

Kashyap Chamarthy-2
On Thu, Feb 23, 2017 at 04:11:21PM +0100, Markus Armbruster wrote:

> Kashyap Chamarthy <[hidden email]> writes:
>
> > TL;DR: Using `blockdev-add` to create an overlay file succeeds with QEMU
> >        2.7.0, however the *same* test fails with QEMU from Git (plus a
> >        couple of patch series from mailing list).  Details below.
>
> commit 0153d2f50bc2ad3f41810d838fcf66acbf10f07a
> Author: Kevin Wolf <[hidden email]>
> Date:   Fri Oct 7 17:05:04 2016 +0200
>
>     block: Remove "options" indirection from blockdev-add

[...]

> Sorry for the confusion!  Early adopters always have the most fun ;)

Ah, I see, thanks for the pointer.

I tried to come up with the below JSON, after looking at the QAPI schema
documentation (from qemu/qapi/block-core.json), still I seem to be
tripping up somewhere.  Now it doesn't recognize the 'backing' option:

$ socat UNIX:./qmp-sock READLINE,history=$HOME/.qmp_history,prompt='QMP> '
[...]
QMP> {
QMP>   "execute":"blockdev-add",
QMP>   "arguments":{
QMP>     "driver":"qcow2",
QMP>     "node-name":"node1"
QMP>   },
QMP>   "file":{
QMP>     "driver":"file",
QMP>     "filename":"/export/target.qcow2"
QMP>   },
QMP>   "backing":{
QMP>     "driver":"qcow2",
QMP>     "file":{
QMP>       "driver":"file",
QMP>       "filename":"/export/base.qcow2"
QMP>     }
QMP>   }
QMP> }
{"error": {"class": "GenericError", "desc": "QMP input object member 'backing' is unexpected"}}
QMP>

--
/kashyap

Reply | Threaded
Open this post in threaded view
|

Re: Adding an overlay with 'blockdev-add' fails with: "Parameter 'driver' is missing"

Eric Blake
On 02/23/2017 10:33 AM, Kashyap Chamarthy wrote:

> On Thu, Feb 23, 2017 at 04:11:21PM +0100, Markus Armbruster wrote:
>> Kashyap Chamarthy <[hidden email]> writes:
>>
>>> TL;DR: Using `blockdev-add` to create an overlay file succeeds with QEMU
>>>        2.7.0, however the *same* test fails with QEMU from Git (plus a
>>>        couple of patch series from mailing list).  Details below.
>>
>> commit 0153d2f50bc2ad3f41810d838fcf66acbf10f07a
>> Author: Kevin Wolf <[hidden email]>
>> Date:   Fri Oct 7 17:05:04 2016 +0200
>>
>>     block: Remove "options" indirection from blockdev-add
>
> [...]
>
>> Sorry for the confusion!  Early adopters always have the most fun ;)
>
> Ah, I see, thanks for the pointer.
>
> I tried to come up with the below JSON, after looking at the QAPI schema
> documentation (from qemu/qapi/block-core.json), still I seem to be
> tripping up somewhere.  Now it doesn't recognize the 'backing' option:
>
> $ socat UNIX:./qmp-sock READLINE,history=$HOME/.qmp_history,prompt='QMP> '
> [...]
> QMP> {
> QMP>   "execute":"blockdev-add",
> QMP>   "arguments":{
> QMP>     "driver":"qcow2",
> QMP>     "node-name":"node1"
> QMP>   },
Oops, you ended your arguments too soon.

> QMP>   "file":{
> QMP>     "driver":"file",
> QMP>     "filename":"/export/target.qcow2"
> QMP>   },
> QMP>   "backing":{

Here, you passed "file" and "backing" as siblings of "execute", but they
should be children of "arguments".

> QMP>     "driver":"qcow2",
> QMP>     "file":{
> QMP>       "driver":"file",
> QMP>       "filename":"/export/base.qcow2"
> QMP>     }
> QMP>   }
> QMP> }
> {"error": {"class": "GenericError", "desc": "QMP input object member 'backing' is unexpected"}}
> QMP>

Try (untested on my end) this rewrite of your original post (just
removing the '"options":{' and corresponding '}' from that listing):

{
    "execute": "blockdev-add",
    "arguments": {
            "backing": "virtio0",
            "driver": "qcow2",
            "id": "virtio1",
            "file": {
                "driver": "file",
                "filename": "/export/target.qcow2"
            }
    }
}

or this attempt at your current post:

{   "execute":"blockdev-add",
    "arguments":{
     "driver":"qcow2",
     "node-name":"node1"
     "file":{
      "driver":"file",
      "filename":"/export/target.qcow2"
     },
     "backing":{
      "driver":"qcow2",
      "file":{
        "driver":"file",
        "filename":"/export/base.qcow2"
      }
     }
    }
}

--
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


signature.asc (617 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Adding an overlay with 'blockdev-add' fails with: "Parameter 'driver' is missing"

Kashyap Chamarthy-2
On Thu, Feb 23, 2017 at 10:51:38AM -0600, Eric Blake wrote:
> On 02/23/2017 10:33 AM, Kashyap Chamarthy wrote:

[...]

> > I tried to come up with the below JSON, after looking at the QAPI schema
> > documentation (from qemu/qapi/block-core.json), still I seem to be
> > tripping up somewhere.  Now it doesn't recognize the 'backing' option:
> >
> > $ socat UNIX:./qmp-sock READLINE,history=$HOME/.qmp_history,prompt='QMP> '
> > [...]
> > QMP> {
> > QMP>   "execute":"blockdev-add",
> > QMP>   "arguments":{
> > QMP>     "driver":"qcow2",
> > QMP>     "node-name":"node1"
> > QMP>   },
>
> Oops, you ended your arguments too soon.

Sigh, that was a stray closing bracket that I didn't clean up (it was
part of the "cache" section that I borrowed from the schema docs).

> > QMP>   "file":{
> > QMP>     "driver":"file",
> > QMP>     "filename":"/export/target.qcow2"
> > QMP>   },
> > QMP>   "backing":{
>
> Here, you passed "file" and "backing" as siblings of "execute", but they
> should be children of "arguments".

Oops, you're right.

[...]

> Try (untested on my end) this rewrite of your original post (just
> removing the '"options":{' and corresponding '}' from that listing):
>
> {
>     "execute": "blockdev-add",
>     "arguments": {
>             "backing": "virtio0",
>             "driver": "qcow2",
>             "id": "virtio1",
>             "file": {
>                 "driver": "file",
>                 "filename": "/export/target.qcow2"
>             }
>     }
> }

This does not work (tested), because my current QEMU build from Git,
will reject the "id" key (Kevin mentioned so on IRC, but I couldn't
find the relevant Git commit from my `grep`ing in the Git history):

{"error": {"class": "GenericError", "desc": "QMP input object member 'id' is unexpected"}}
 
> or this attempt at your current post:
>
> {   "execute":"blockdev-add",
>     "arguments":{
>      "driver":"qcow2",
>      "node-name":"node1"

A comma missing here :-)  With that fixed, it returns success.  

However, bizzarely enough, when I ran `query-block` after `blockdev-add`
succeeded (well, at least after it returned success), I don't see the
new node ('target.qcow2') reflected in the return output.  Me
investigates.

https://kashyapc.fedorapeople.org/virt/temp/blockdev-add-followed-by-buggy-query-block.txt

>      "file":{
>       "driver":"file",
>       "filename":"/export/target.qcow2"
>      },
>      "backing":{
>       "driver":"qcow2",
>       "file":{
>         "driver":"file",
>         "filename":"/export/base.qcow2"
>       }
>      }
>     }
> }

Just for completeness, the new working incantation (that removes the
need for "options" indirection, and the "id" key) that takes
'node-name':

--------------------------------------------
{
  "execute":"blockdev-add",
  "arguments":{
    "driver":"qcow2",
    "node-name":"node1",
    "file":{
      "driver":"file",
      "filename":"/export/target.qcow2"
    },
    "backing":{
      "driver":"qcow2",
      "file":{
        "driver":"file",
        "filename":"/export/base.qcow2"
      }
    }
  }
}
--------------------------------------------

--
/kashyap

Reply | Threaded
Open this post in threaded view
|

Re: Adding an overlay with 'blockdev-add' fails with: "Parameter 'driver' is missing"

Kashyap Chamarthy-2
On Fri, Feb 24, 2017 at 11:53:12AM +0100, Kashyap Chamarthy wrote:

[...]

> However, bizzarely enough, when I ran `query-block` after `blockdev-add`
> succeeded (well, at least after it returned success), I don't see the
> new node ('target.qcow2') reflected in the return output.  Me
> investigates.

Okay, Kevin educated me IRC that I should rather use
`query-named-block-nodes`.  That gives the intended output.

[...]

--
/kashyap