dataplane: support viostor virtio-pci status bit setting
PATCH 1/1 dataplane: support viostor virtio-pci status bit setting
The viostor virtio-blk driver for Windows does not use the VIRTIO_CONFIG_S_DRIVER bit. It only sets the VIRTIO_CONFIG_S_DRIVER_OK bit.
The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret 0x4 (VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since 0x2 (VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.
--- hw/virtio-blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio-blk.c +2 -1
@@ -571,7 +571,8 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)uint32_t features;#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE -if (s->dataplane && !(status &VIRTIO_CONFIG_S_DRIVER )) { +if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER | +VIRTIO_CONFIG_S_DRIVER_OK ))) {virtio_blk_data_plane_stop (s->dataplane); }#endif
Signature · 1 line
1.8.0.2
Quoted 11 lines · Stefan Hajnoczi
The viostor virtio-blk driver for Windows does not use the
VIRTIO_CONFIG_S_DRIVERbit. It only sets theVIRTIO_CONFIG_S_DRIVER_OKbit.The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret
0x4(VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since0x2(VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.Signed-off-by Stefan Hajnoczi <[email protected]>
I think you actually want
if (s->dataplane && !(status & VIRTIO_CONFIG_S_DRIVER_OK)))
so stop on any error.
This is also consistent with what vhost-net does.
Quoted 20 lines
--- hw/virtio-blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/virtio-blk.c +2
-1@@ -571,7 +571,8 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)uint32_t features;#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE -if (s->dataplane && !(status &VIRTIO_CONFIG_S_DRIVER )) { +if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER | +VIRTIO_CONFIG_S_DRIVER_OK ))) {virtio_blk_data_plane_stop (s->dataplane); }#endif Signature · 1 line
1.8.0.2
Quoted 13 lines · Michael S. Tsirkin
Quoted 11 lines · Stefan Hajnoczi
The viostor virtio-blk driver for Windows does not use the
VIRTIO_CONFIG_S_DRIVERbit. It only sets theVIRTIO_CONFIG_S_DRIVER_OKbit.The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret
0x4(VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since0x2(VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 7 lines
I think you actually want
if (s->dataplane && !(status & VIRTIO_CONFIG_S_DRIVER_OK)))so stop on any error.
This is also consistent with what vhost-net does.
We can't do that because of the Linux virtio quirk where it begins using virtqueues before VIRTIO_CONFIG_S_DRIVER_OK. I original checked VIRTIO_CONFIG_S_DRIVER_OK but I'm pretty sure I hit a situation where the status would still be set ~DRIVER_OK after the first kick - this would stop data plane and the vring last indices would no longer be in sync when it started again.
So I think it's most robust to check both DRIVER and DRIVER_OK.
Stefan
Stefan Hajnoczi
AppliedQuoted 10 lines · Stefan Hajnoczi
The viostor virtio-blk driver for Windows does not use the
VIRTIO_CONFIG_S_DRIVERbit. It only sets theVIRTIO_CONFIG_S_DRIVER_OKbit.The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret
0x4(VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since0x2(VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.
Quoted 4 lines
Signed-off-by Stefan Hajnoczi <[email protected]>--- hw/virtio-blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
Quoted 4 lines · Stefan Hajnoczi
Quoted 3 lines · Stefan Hajnoczi
The viostor virtio-blk driver for Windows does not use the
VIRTIO_CONFIG_S_DRIVERbit. It only sets theVIRTIO_CONFIG_S_DRIVER_OKbit.
Will be added in the next build.
Thank you,
Vadim.
Quoted 17 lines
Quoted 7 lines
The viostor driver refreshes the virtio-pci status byte sometimes while the guest is running. We misinterpret
0x4(VIRTIO_CONFIG_S_DRIVER_OK) as an indication that virtio-blk-data-plane should be stopped since0x2(VIRTIO_CONFIG_S_DRIVER) is missing. The result is that the device becomes unresponsive.Quoted 5 lines
Signed-off-by Stefan Hajnoczi <[email protected]>---
hw/virtio-blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Applied to my block tree:
https://github.com/stefanha/qemu/commits/blockStefan
Quoted 6 lines · Vadim Rozenfeld
Quoted 4 lines · Stefan Hajnoczi
Quoted 3 lines · Stefan Hajnoczi
The viostor virtio-blk driver for Windows does not use the
VIRTIO_CONFIG_S_DRIVERbit. It only sets theVIRTIO_CONFIG_S_DRIVER_OKbit.Will be added in the next build.
Nice, thanks. For compatibility with existing viostor drivers QEMU will carry this patch.
Stefan
Quoted 6 lines · Stefan Hajnoczi
Quoted 5 lines · Vadim Rozenfeld
Quoted 4 lines · Stefan Hajnoczi
Quoted 3 lines · Stefan Hajnoczi
The viostor virtio-blk driver for Windows does not use the
VIRTIO_CONFIG_S_DRIVERbit. It only sets theVIRTIO_CONFIG_S_DRIVER_OKbit.
Quoted 6 lines
Quoted 1 line
Will be added in the next build.
Nice, thanks. For compatibility with existing viostor drivers QEMU will carry this patch.
Stefan
I still think it's wrong: when DRIVER_OK is cleared you should stop device I think even if DRIVER is set.
This patch keeps dataplane running if DRIVER is set.