Adding an overlay with 'blockdev-add' fails with: "Parameter 'driver' is missing"
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,nowaitWith 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?
Signature · 1 line
/kashyap
Quoted 3 lines · Kashyap Chamarthy
TL;DR: Using
blockdev-addto 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 <[email protected]> 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.
Sorry for the confusion! Early adopters always have the most fun ;)
[...]
Quoted 11 lines · Markus Armbruster
Quoted 3 lines · Kashyap Chamarthy
TL;DR: Using
blockdev-addto 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
0153d2f50bc2ad3f41810d838fcf66acbf10f07aAuthor: Kevin Wolf <[email protected]> Date: Fri Oct 7 17:05:04 2016 +0200block: Remove "options" indirection from blockdev-add
[...]
Quoted 1 line
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> Signature · 1 line
/kashyap
Quoted 23 lines · Kashyap Chamarthy
Quoted 11 lines · Markus Armbruster
Quoted 3 lines · Kashyap Chamarthy
TL;DR: Using
blockdev-addto 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
0153d2f50bc2ad3f41810d838fcf66acbf10f07aAuthor: Kevin Wolf <[email protected]> Date: Fri Oct 7 17:05:04 2016 +0200block: Remove "options" indirection from blockdev-add
[...]
Quoted 1 line
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:
Quoted 8 lines
$ 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.
Quoted 5 lines
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".
Quoted 9 lines
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"
}
}
}
}Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 1 line · Eric Blake
On 02/23/2017 10:33 AM, Kashyap Chamarthy wrote:
[...]
Quoted 13 lines
Quoted 4 lines
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:Quoted 8 lines
$ 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> },
Quoted 1 line
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).
Quoted 8 lines
Quoted 5 lines
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.
[...]
Quoted 15 lines
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 greping in the Git history):
{"error": {"class": "GenericError", "desc": "QMP input object member 'id' is unexpected"}}
Quoted 6 lines
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
Quoted 5 lines
"file":{
"driver":"file",
"filename":"/export/target.qcow2"
},
"backing":{Quoted 8 lines
"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"
}
} }
}
--------------------------------------------
Signature · 1 line
/kashyap
On Fri, Feb 24, 2017 at 11:53:12AM +0100, Kashyap Chamarthy wrote:
[...]
Quoted 4 lines
However, bizzarely enough, when I ran
query-blockafterblockdev-addsucceeded (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.
[...]
Signature · 1 line
/kashyap