Skip to content

RFC virtio: fix hang(loop) after hot-unplug vlan

Heinz Graalfs virtualization 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 RFC Latest9 patches 3 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9virtio_ring: change host notification APIdrivers/lguest/lguest_device.c drivers/remoteproc/remoteproc_virtio.c drivers/s390/kvm/kvm_virtio.c +7 more+32 -151 reply
2/9virtio_ring: let virtqueue_{kick()/notify()} return a booldrivers/virtio/virtio_ring.c include/linux/virtio.h+18 -60 replies
3/9virtio_net: verify if virtqueue_kick() succeededdrivers/net/virtio_net.c+5 -40 replies
4/9virtio_test: verify if virtqueue_kick() succeededtools/virtio/virtio_test.c+2 -10 replies
5/9virtio_ring: add new function virtqueue_is_broken()drivers/virtio/virtio_ring.c include/linux/virtio.h+10 -00 replies
6/9virtio_blk: verify if queue is broken after virtqueue_get_buf()drivers/block/virtio_blk.c+2 -00 replies
7/9virtio_console: verify if queue is broken after virtqueue_get_buf()drivers/char/virtio_console.c+4 -20 replies
8/9virtio_net: verify if queue is broken after virtqueue_get_buf()drivers/net/virtio_net.c+2 -10 replies
9/9virtio_scsi: verify if queue is broken after virtqueue_get_buf()drivers/scsi/virtio_scsi.c+2 -12 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH V2 RFC 0/9] virtio: fix hang(loop) after hot-unplug vlan

Hi,

this patch-set solves a hang situation when a vlan network device is hot-unplugged from a KVM guest.

On System z there exists no handshake mechanism between host and guest when a device is hot-unplugged. The device is removed and no further I/O is possible.

The guest is notified about the hard removal with a CRW machine check. As per architecture, the host must repond to any I/O operation for the removed device with an error condition as if the device had never been there.

During machine check handling in the guest, virtio exit functions try to perform cleanup operations by triggering final I/O, including appropriate host kicks. These operations fail, or do not complete, and lead to several kinds of hang situations. In particular, virtio-ccw guest->host notification on an unplugged device will receive an error; this is, however, not reflected back to the affected virtqueues.

Here are the details of the error.

A hang (loop) occurs when a machine check is handled on System z due to a vlan device removal. A loop spinning for a response for final IO in virtnet_send_command() will never complete successfully because of a previous unsuccessfull host kick operation (virtqueue_kick()).

Patch [1] changes the guest->host notification API. A potential error returned by the host during notify() should not be ignored, but used in order to reflect the error back to the affected virtqueue.

Patch [2] changes virtqueue_kick() and virtqueue_notify() to return a bool depending on the result of the host notification operation. If the host kick failed the current virtqueue is now flagged as 'broken'.

Patches [3,4] add code to verify host kicks by testing the return value of virtqueue_kick() in order to avoid potential loops.

Patch [5] adds a new function virtqueue_is_broken(). This function should be used to verify the state of a virtqueue when a previous virtqueue_get_buf() returned a NULL pointer.

Patch [6,7,8,9] add virtqueue_is_broken() calls to handle potential errors when a virtqueue_bet_buf() doesn't deliver any more buffers.

Heinz Graalfs (9):
virtio_ring: change host notification API
virtio_ring: let virtqueue_{kick()/notify()} return a bool
virtio_net: verify if virtqueue_kick() succeeded
virtio_test: verify if virtqueue_kick() succeeded
virtio_ring: add new function virtqueue_is_broken()
virtio_blk: verify if queue is broken after virtqueue_get_buf()
virtio_console: verify if queue is broken after virtqueue_get_buf()
virtio_net: verify if queue is broken after virtqueue_get_buf()
virtio_scsi: verify if queue is broken after virtqueue_get_buf()

 drivers/block/virtio_blk.c             |  2 ++
 drivers/char/virtio_console.c          |  6 ++++--
 drivers/lguest/lguest_device.c         |  3 ++-
 drivers/net/virtio_net.c               | 12 +++++++-----
 drivers/remoteproc/remoteproc_virtio.c |  3 ++-
 drivers/s390/kvm/kvm_virtio.c          |  8 ++++++--
 drivers/s390/kvm/virtio_ccw.c          |  5 ++++-
 drivers/scsi/virtio_scsi.c             |  3 ++-
 drivers/virtio/virtio_mmio.c           |  3 ++-
 drivers/virtio/virtio_pci.c            |  3 ++-
 drivers/virtio/virtio_ring.c           | 32 ++++++++++++++++++++++++++------
 include/linux/virtio.h                 |  6 ++++--
 include/linux/virtio_ring.h            |  2 +-
 tools/virtio/virtio_test.c             |  6 ++++--
 tools/virtio/vringh_test.c             | 13 +++++++++----
 15 files changed, 77 insertions(+), 30 deletions(-)
Signature · 1 line
1.8.3.1