Received: from eggs.gnu.org ([2001:4830:134:3::10]:47575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boRMR-0001JA-Tb for qemu-devel@nongnu.org; Mon, 26 Sep 2016 04:34:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boRMM-0005wJ-SL for qemu-devel@nongnu.org; Mon, 26 Sep 2016 04:34:02 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55282 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boRMM-0005w3-Mt for qemu-devel@nongnu.org; Mon, 26 Sep 2016 04:33:58 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8Q8XSsv117021 for ; Mon, 26 Sep 2016 04:33:57 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 25p6mm8s4f-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 26 Sep 2016 04:33:57 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Sep 2016 02:33:56 -0600 From: Greg Kurz Date: Mon, 26 Sep 2016 10:33:47 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <147487882735.6679.8076815106195077844.stgit@bahia> Subject: [Qemu-devel] [PATCH v3 0/9] virtio: avoid inappropriate QEMU termination List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Jason Wang , Greg Kurz , Max Reitz , "Aneesh Kumar K.V" , Stefan Hajnoczi , Cornelia Huck , Paolo Bonzini Stefan Hajnoczi recently posted a patchset to avoid exit() when a virtio device enters invalid states: <1474473146-19337-1-git-send-email-stefanha@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-stefanha@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-stefanha@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