dataplane: fix virtio_blk_data_plane_create() op blocker error path
PATCH 1/1 dataplane: fix virtio_blk_data_plane_create() op blocker error path
Commit 3718d8ab65f68de2acccbe6a315907805f54e3cc ("block: Replace in_use with operation blocker") broke the error path because it consumed local_err instead of propagating it.
The caller has no way to know that the function failed. This caused virtio-blk to start "successfully" even though there was a fatal dataplane error.
Steps to reproduce:
$ qemu-system-x86_64 -enable-kvm -object iothread,id=iothread0 \
-drive if=none,id=drive0,file=a.img \
(qemu) drive_mirror drive0 /tmp/foo.img
(qemu) device_add virtio-blk-pci,iothread=iothread0,drive=drive0Expected result:
Since the mirror block job is using drive0 it is not possible to start virtio-blk data-plane.
device_add fails and the PCI adapter is not added.
Actual result:
device_add completes and the PCI adapter is added.
--- hw/block/dataplane/virtio-blk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/block/dataplane/virtio-blk.c +2 -2
@@ -164,8 +164,8 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,* block jobs that can conflict. */ if (bdrv_op_is_blocked (blk->conf.bs,BLOCK_OP_TYPE_DATAPLANE , &local_err)) { -error_report ("cannot start dataplane thread: %s" , -error_get_pretty (local_err)); +error_setg (errp,"cannot start dataplane thread: %s" , +error_get_pretty (local_err));error_free (local_err);return ; }
Signature · 1 line
1.9.3
Quoted 4 lines · Stefan Hajnoczi
Commit
3718d8ab65f68de2acccbe6a315907805f54e3cc("block: Replacein_usewith operation blocker") broke the error path because it consumedlocal_errinstead of propagating it.
Quoted 8 lines
The caller has no way to know that the function failed. This caused virtio-blk to start "successfully" even though there was a fatal dataplane error.
--- hw/block/dataplane/virtio-blk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Kevin Wolf
AppliedAm 11.09.2014 um 14:49 hat Stefan Hajnoczi geschrieben:
Quoted 20 lines
Commit
3718d8ab65f68de2acccbe6a315907805f54e3cc("block: Replacein_usewith operation blocker") broke the error path because it consumedlocal_errinstead of propagating it.The caller has no way to know that the function failed. This caused virtio-blk to start "successfully" even though there was a fatal dataplane error.
Steps to reproduce:
$ qemu-system-x86_64 -enable-kvm -object iothread,id=iothread0 \ -drive if=none,id=drive0,file=a.img \ (qemu) drive_mirror drive0 /tmp/foo.img (qemu) device_add virtio-blk-pci,iothread=iothread0,drive=drive0Expected result:
Since the mirror block job is using drive0 it is not possible to start virtio-blk data-plane.
Quoted 8 lines
device_addfails and the PCI adapter is not added.Actual result:
device_addcompletes and the PCI adapter is added.Cc Fam Zheng <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Thanks, applied to the block branch.
Kevin