From patchwork Fri Nov 27 12:25:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 39627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3D4161007D2 for ; Fri, 27 Nov 2009 23:38:50 +1100 (EST) Received: from localhost ([127.0.0.1]:60224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NE063-0005o1-BB for incoming@patchwork.ozlabs.org; Fri, 27 Nov 2009 07:38:47 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDzue-0007yv-7r for qemu-devel@nongnu.org; Fri, 27 Nov 2009 07:27:00 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDzuZ-0007vg-JJ for qemu-devel@nongnu.org; Fri, 27 Nov 2009 07:26:59 -0500 Received: from [199.232.76.173] (port=41469 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDzuY-0007uq-SN for qemu-devel@nongnu.org; Fri, 27 Nov 2009 07:26:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26228) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDzuY-0007L4-Em for qemu-devel@nongnu.org; Fri, 27 Nov 2009 07:26:54 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nARCQr1k018932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 27 Nov 2009 07:26:53 -0500 Received: from localhost.localdomain (vpn2-8-149.ams2.redhat.com [10.36.8.149]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nARCQin7002824; Fri, 27 Nov 2009 07:26:52 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Fri, 27 Nov 2009 13:25:39 +0100 Message-Id: <1259324739-6805-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1259324739-6805-1-git-send-email-kwolf@redhat.com> References: <1259324739-6805-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Kevin Wolf Subject: [Qemu-devel] [PATCH 4/4] virtio-blk: Implement rerror option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Kevin Wolf --- hw/virtio-blk.c | 13 ++++++++----- vl.c | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index a93d20d..a2f0639 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -98,9 +98,11 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, int status) qemu_free(req); } -static int virtio_blk_handle_write_error(VirtIOBlockReq *req, int error) +static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, + int is_read) { - BlockInterfaceErrorAction action = drive_get_on_error(req->dev->bs, 0); + BlockInterfaceErrorAction action = + drive_get_on_error(req->dev->bs, is_read); VirtIOBlock *s = req->dev; if (action == BLOCK_ERR_IGNORE) @@ -122,12 +124,13 @@ static void virtio_blk_rw_complete(void *opaque, int ret) { VirtIOBlockReq *req = opaque; - if (ret && (req->out->type & VIRTIO_BLK_T_OUT)) { - if (virtio_blk_handle_write_error(req, -ret)) + if (ret) { + int is_read = !(req->out->type & VIRTIO_BLK_T_OUT); + if (virtio_blk_handle_rw_error(req, -ret, is_read)) return; } - virtio_blk_req_complete(req, ret ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK); + virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); } static void virtio_blk_flush_complete(void *opaque, int ret) diff --git a/vl.c b/vl.c index 0136d16..9f3962c 100644 --- a/vl.c +++ b/vl.c @@ -2199,7 +2199,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { - if (type != IF_IDE) { + if (type != IF_IDE && type != IF_VIRTIO) { fprintf(stderr, "rerror is no supported by this format\n"); return NULL; }