Stefan Hajnoczi recently posted a patchset to avoid exit() when a virtio device enters invalid states:
<1474473146-19337-1-git-send-email-stefa...@redhat.com> The above patchset provides the ability to deactivate a virtio device if it encounters an unrecoverable issue, with the introduction of a broken state. It also converts the core virtio code to do that, instead of terminating QEMU. The patchset is now in the virtio maintainer tree, and is expected to be merged soon into QEMU master. Stefan also sent another patchset to detach VirtQueueElements freed by reset: <1474291685-24226-1-git-send-email-stefa...@redhat.com> Patch 1/3 of this patchset brings a new virtio_detach_element() function which should be called when a VirtQueueElement isn't needed anymore. It was originally introduced to be used on outstanding requests when a device is reset. But it turns out that it is also needed if a device moves to the broken state. This series leverages the above to address all exit() call sites in the virtio blk, net and scsi device code, where the error is about a missing or malformed in/out header sent by the guest. They are converted to use virtio_error(), detach and free any queued VirtQueueElement and stop any processing, instead of forcing QEMU to exit. The 9P code currently calls assert() instead of exit(), but it also about malformed or missing headers, so it gets converted the same way. The remaining exit() call sites are related to a host misconfiguration or a migration stream issue, and thus shouldn't be converted. Next work will be to check all assert() call sites in the device code, in case some of them actually refer to a bug in the guest, and should be converted to use virtio_error() as well. This series is based on the virtio maintainer tree: https://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git fb9f592623b0 and the "virtio: add virtio_detach_element()" patch: <1474291685-24226-2-git-send-email-stefa...@redhat.com> Please review. --- Greg Kurz (9): virtio-9p: add parentheses to sizeof operator virtio-blk: make some functions static virtio-9p: handle handle_9p_output() error virtio-blk: handle virtio_blk_handle_request() errors virtio-net: handle virtio_net_handle_ctrl() error virtio-net: handle virtio_net_receive() errors virtio-net: handle virtio_net_flush_tx() errors virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error() virtio-scsi: handle virtio_scsi_set_config() error hw/9pfs/virtio-9p-device.c | 30 +++++++++++++++----- hw/block/virtio-blk.c | 46 +++++++++++++++++++++---------- hw/net/virtio-net.c | 60 +++++++++++++++++++++++++--------------- hw/scsi/virtio-scsi.c | 49 +++++++++++++++++++++++---------- include/hw/virtio/virtio-blk.h | 8 ----- 5 files changed, 127 insertions(+), 66 deletions(-) -- Greg