how to dynamically add a block device using qmp?
I also tried to add a virt io device to the frontend but still no disc in the VM. Am I missing anything else?
{"QMP": {"version": {"qemu": {"micro": 0, "minor": 0, "major": 2}, "package": " (Debian 2.0.0+dfsg-2ubuntu1.2)"}, "capabilities": []}} {"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add",
"arguments": { "options" : {
"id": "tc1",
"driver": "qcow2",
"file": { "driver": "file",
"filename": "test.qc2" } } } }{"return": {}}
{ "execute": "device_add", "arguments": {
"driver": "virtio-blk-pci", "id": "vda", "drive": "tc1" } }{"return": {}}
Thanks!
Ken
Markus,
Nevermind my previous question, I see now that you add a scsi bus prior to adding the scsi disk.
However, I did this and qmp returned {[]} in both cases and I am still not seeing the disk in the vm.
here's the qmp session:
{"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add",
"arguments": { "options" : {
"id": "tc1",
"driver": "qcow2",
"file": { "driver": "file",
"filename": "/home/kchiang/kvmimages/xpsp2_b-02222012.qc2" } } } }
{"return": {}}
{ "execute": "device_add", "arguments": {
"driver": "virtio-scsi-pci", "id": "vs-hba" } }
{"return": {}}
{ "execute": "device_add", "arguments": {
"driver": "scsi-disk", "id": "sdb", "drive": "tc1",
"bus": "vs-hba.0" } }{"return": {}}
{ "execute": "query-block" }
{"return": [{"io-status": "ok", "device": "ide0-hd0", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 5999951872, "filename": "kvmimages/vts-6g-u12-inetsim.image", "format": "raw", "actual-size": 5999955968, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "raw", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "kvmimages/vts-6g-u12-inetsim.image", "encryption_key_missing": false}, "type": "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"io-status": "ok", "device": "tc1", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 5368709120, "filename": "/home/kchiang/kvmimages/xpsp2_b-02222012.qc2", "cluster-size": 65536, "format": "qcow2", "actual-size": 1550454784, "format-specific": {"type": "qcow2", "data": {"compat": "0.10"}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "/home/kchiang/kvmimages/xpsp2_b-02222012.qc2", "encryption_key_missing": false}, "type": "unknown"}]}
am I missing anything else?
I've also tried rebooting the VM and running rescan-scsi-bus to no avail.
Ken
Quoted 54 lines · Markus Armbruster
Quoted 8 lines · Ken Chiang
Hello,
I am trying to add a block device dynamically using qmp and are having some issues.
After successfully adding the block device using "blockdev-add" and verifying that it has been added using "query-block", I am unable to see the block device in the VM under
/dev/sdXXBlock devices consist of a frontend (a.k.a. device model) and a backend. You added only a backend. To add the frontend, use
device_add.Quoted 17 lines
I am using ubuntu14.04LTS: qmp version:
{"QMP": {"version": {"qemu": {"micro": 0, "minor": 0, "major": 2}, "package": " (Debian 2.0.0+dfsg-2ubuntu1.2)"}, "capabilities": []}}Here's what I am doing:
1./usr/bin/kvm-spice-hda kvmimages/ubuntu.image -m 768 -usbdevice tablet -vnc :5 -qmp tcp:localhost:4444,server,nowait2. telnet localhost 4444
3. In the telnet session run:
{"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add","arguments": { "options" : { "id": "disk1", "driver": "qcow2", "file": { "driver": "file", "filename": "testvm.qc2" } } } }Quoted 8 lines
{"return": {}}
{ "execute": "query-block" }
4. query-block returns the device "disk1", but when I check the vm:
# vncviewer :5there are no new devices.
For a virtio-blk disk, try:
{ "execute": "device_add", "arguments": { "driver": "virtio-blk-pci", "id": "vda", "drive": "disk1" } }For a SCSI disk, try:
{ "execute": "device_add", "arguments": { "driver": "virtio-scsi-pci", "id": "vs-hba" } } { "execute": "device_add", "arguments": { "driver": "scsi-disk", "id": "sda", "drive": "disk1", "bus": "vs-hba.0" } }[...]
Signature · 4 lines
Ken Chiang Information Assurance Sandia National Labs - CA 925-294-2018
Quoted 13 lines · Ken Chiang
I also tried to add a virt io device to the frontend but still no disc in the VM. Am I missing anything else?
{"QMP": {"version": {"qemu": {"micro": 0, "minor": 0, "major": 2}, "package": " (Debian 2.0.0+dfsg-2ubuntu1.2)"}, "capabilities": []}} {"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add","arguments": { "options" : { "id": "tc1", "driver": "qcow2", "file": { "driver": "file", "filename": "test.qc2" } } } }
Quoted 6 lines
{"return": {}}
{ "execute": "device_add", "arguments": { "driver": "virtio-blk-pci", "id": "vda", "drive": "tc1" } }{"return": {}}
Thanks!
Maybe try
for m in acpiphp pci_hotplug; do sudo modprobe ${m}; done in the guest before adding the pci device.
Best regards
Benoît
Quoted 110 lines
Ken
Date: Mon, 13 Oct 2014 12:28:51 -0700
From: Ken Chiang <[email protected]>
To: Markus Armbruster <[email protected]>
Subject: Re: [EXTERNAL] Re: [Qemu-devel] how to dynamically add a block
device using qmp?
Message-ID: <[email protected]>
In-Reply-To: <[email protected]>
User-Agent: Mutt/1.5.18 (2008-05-17)Markus,
Nevermind my previous question, I see now that you add a scsi bus prior to adding the scsi disk.
However, I did this and qmp returned {[]} in both cases and I am still not seeing the disk in the vm.
here's the qmp session:
{"execute":"qmp_capabilities"} {"return": {}}
{ "execute": "blockdev-add","arguments": { "options" : { "id": "tc1", "driver": "qcow2", "file": { "driver": "file", "filename": "/home/kchiang/kvmimages/xpsp2_b-02222012.qc2" } } } } {"return": {}} { "execute": "device_add", "arguments": { "driver": "virtio-scsi-pci", "id": "vs-hba" } } {"return": {}} { "execute": "device_add", "arguments": { "driver": "scsi-disk", "id": "sdb", "drive": "tc1", "bus": "vs-hba.0" } }{"return": {}}
{ "execute": "query-block" }
{"return": [{"io-status": "ok", "device": "ide0-hd0", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 5999951872, "filename": "kvmimages/vts-6g-u12-inetsim.image", "format": "raw", "actual-size": 5999955968, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "raw", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "kvmimages/vts-6g-u12-inetsim.image", "encryption_key_missing": false}, "type": "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"io-status": "ok", "device": "tc1", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "image": {"virtual-size": 5368709120, "filename": "/home/kchiang/kvmimages/xpsp2_b-02222012.qc2", "cluster-size": 65536, "format": "qcow2", "actual-size": 1550454784, "format-specific": {"type": "qcow2", "data": {"compat": "0.10"}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "/home/kchiang/kvmimages/xpsp2_b-02222012.qc2", "encryption_key_missing": false}, "type": "unknown"}]}am I missing anything else?
I've also tried rebooting the VM and running rescan-scsi-bus to no avail.
Ken
Quoted 54 lines · Markus Armbruster
Quoted 8 lines · Ken Chiang
Hello,
I am trying to add a block device dynamically using qmp and are having some issues.
After successfully adding the block device using "blockdev-add" and verifying that it has been added using "query-block", I am unable to see the block device in the VM under
/dev/sdXXBlock devices consist of a frontend (a.k.a. device model) and a backend. You added only a backend. To add the frontend, use
device_add.Quoted 17 lines
I am using ubuntu14.04LTS: qmp version:
{"QMP": {"version": {"qemu": {"micro": 0, "minor": 0, "major": 2}, "package": " (Debian 2.0.0+dfsg-2ubuntu1.2)"}, "capabilities": []}}Here's what I am doing:
1./usr/bin/kvm-spice-hda kvmimages/ubuntu.image -m 768 -usbdevice tablet -vnc :5 -qmp tcp:localhost:4444,server,nowait2. telnet localhost 4444
3. In the telnet session run:
{"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add","arguments": { "options" : { "id": "disk1", "driver": "qcow2", "file": { "driver": "file", "filename": "testvm.qc2" } } } }Quoted 8 lines
{"return": {}}
{ "execute": "query-block" }
4. query-block returns the device "disk1", but when I check the vm:
# vncviewer :5there are no new devices.
For a virtio-blk disk, try:
{ "execute": "device_add", "arguments": { "driver": "virtio-blk-pci", "id": "vda", "drive": "disk1" } }For a SCSI disk, try:
{ "execute": "device_add", "arguments": { "driver": "virtio-scsi-pci", "id": "vs-hba" } } { "execute": "device_add", "arguments": { "driver": "scsi-disk", "id": "sda", "drive": "disk1", "bus": "vs-hba.0" } }[...]
Signature · 4 lines
Ken Chiang Information Assurance Sandia National Labs - CA 925-294-2018
Thanks! That did it!
-----Original Message-----
From: Benoît Canet [mailto:[email protected]]
Sent: Tuesday, October 14, 2014 12:20 PM
To: Chiang, Ken
Cc: [email protected]
Subject: Re: [Qemu-devel] [EXTERNAL] Re: how to dynamically add a block device using qmp?
Quoted 14 lines · Ken Chiang
I also tried to add a virt io device to the frontend but still no disc in the VM. Am I missing anything else?
{"QMP": {"version": {"qemu": {"micro": 0, "minor": 0, "major": 2}, "package": " (Debian 2.0.0+dfsg-2ubuntu1.2)"}, "capabilities": []}} {"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add","arguments": { "options" : { "id": "tc1", "driver": "qcow2", "file": { "driver": "file", "filename": "test.qc2" } } } }
Quoted 6 lines
{"return": {}}
{ "execute": "device_add", "arguments": { "driver": "virtio-blk-pci", "id": "vda", "drive": "tc1" } }{"return": {}}
Thanks!
Maybe try
for m in acpiphp pci_hotplug; do sudo modprobe ${m}; done in the guest before adding the pci device.
Best regards
Benoît
Quoted 137 lines
Ken
Date: Mon, 13 Oct 2014 12:28:51 -0700
From: Ken Chiang <[email protected]>
To: Markus Armbruster <[email protected]>
Subject: Re: [EXTERNAL] Re: [Qemu-devel] how to dynamically add a block device using qmp?
Message-ID: <[email protected]>
In-Reply-To: <[email protected]>
User-Agent: Mutt/1.5.18 (2008-05-17)Markus,
Nevermind my previous question, I see now that you add a scsi bus prior to adding the scsi disk.
However, I did this and qmp returned {[]} in both cases and I am still not seeing the disk in the vm.
here's the qmp session:
{"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add","arguments": { "options" : { "id": "tc1", "driver": "qcow2", "file": { "driver": "file", "filename": "/home/kchiang/kvmimages/xpsp2_b-02222012.qc2" } } } } {"return": {}} { "execute": "device_add", "arguments": { "driver": "virtio-scsi-pci", "id": "vs-hba" } } {"return": {}} { "execute": "device_add", "arguments": { "driver": "scsi-disk", "id": "sdb", "drive": "tc1", "bus": "vs-hba.0" } }{"return": {}}
{ "execute": "query-block" }
{"return": [{"io-status": "ok", "device": "ide0-hd0", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "image":
{"virtual-size": 5999951872, "filename":
"kvmimages/vts-6g-u12-inetsim.image", "format": "raw", "actual-size":
5999955968, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "raw", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file":
"kvmimages/vts-6g-u12-inetsim.image", "encryption_key_missing":
false}, "type": "unknown"}, {"io-status": "ok", "device": "ide1-cd0", "locked": false, "removable": true, "tray_open": false, "type":
"unknown"}, {"device": "floppy0", "locked": false, "removable": true, "tray_open": false, "type": "unknown"}, {"device": "sd0", "locked":
false, "removable": true, "tray_open": false, "type": "unknown"}, {"io-status": "ok", "device": "tc1", "locked": false, "removable":
false, "inserted": {"iops_rd": 0, "image": {"virtual-size":
5368709120, "filename":
"/home/kchiang/kvmimages/xpsp2_b-02222012.qc2", "cluster-size": 65536, "format": "qcow2", "actual-size": 1550454784, "format-specific":
{"type": "qcow2", "data": {"compat": "0.10"}}, "dirty-flag": false}, "iops_wr": 0, "ro": false, "backing_file_depth": 0, "drv": "qcow2", "iops": 0, "bps_wr": 0, "encrypted": false, "bps": 0, "bps_rd": 0, "file": "/home/kchiang/kvmimages/xpsp2_b-02222012.qc2", "encryption_key_missing": false}, "type": "unknown"}]}am I missing anything else?
I've also tried rebooting the VM and running rescan-scsi-bus to no avail.
Ken
Quoted 51 lines · Markus Armbruster
Quoted 8 lines · Ken Chiang
Hello,
I am trying to add a block device dynamically using qmp and are having some issues.
After successfully adding the block device using "blockdev-add" and verifying that it has been added using "query-block", I am unable to see the block device in the VM under
/dev/sdXXBlock devices consist of a frontend (a.k.a. device model) and a backend. You added only a backend. To add the frontend, use
device_add.Quoted 20 lines
I am using ubuntu14.04LTS: qmp version:
{"QMP": {"version": {"qemu": {"micro": 0, "minor": 0, "major": 2}, "package": " (Debian 2.0.0+dfsg-2ubuntu1.2)"}, "capabilities":
[]}}Here's what I am doing:
1./usr/bin/kvm-spice-hda kvmimages/ubuntu.image -m 768 -usbdevice tablet -vnc :5 -qmp tcp:localhost:4444,server,nowait2. telnet localhost 4444
3. In the telnet session run:
{"execute":"qmp_capabilities"}
{"return": {}}
{ "execute": "blockdev-add","arguments": { "options" : { "id": "disk1", "driver": "qcow2", "file": { "driver": "file", "filename": "testvm.qc2" } } } }Quoted 8 lines
{"return": {}}
{ "execute": "query-block" }
4. query-block returns the device "disk1", but when I check the vm:
# vncviewer :5there are no new devices.
For a virtio-blk disk, try:
{ "execute": "device_add", "arguments": { "driver": "virtio-blk-pci", "id": "vda", "drive": "disk1" } }For a SCSI disk, try:
Quoted 7 lines
{ "execute": "device_add", "arguments": { "driver": "virtio-scsi-pci", "id": "vs-hba" } } { "execute": "device_add", "arguments": { "driver": "scsi-disk", "id": "sda", "drive": "disk1", "bus": "vs-hba.0" } }[...]
--
Ken Chiang
Information Assurance
Sandia National Labs - CA
925-294-2018