From patchwork Tue Jul 19 07:33:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 105399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4DEAAB6F80 for ; Tue, 19 Jul 2011 17:36:36 +1000 (EST) Received: from localhost ([::1]:42683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qj4r2-0002pU-9n for incoming@patchwork.ozlabs.org; Tue, 19 Jul 2011 03:36:32 -0400 Received: from eggs.gnu.org ([140.186.70.92]:56918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qj4o0-0002od-CS for qemu-devel@nongnu.org; Tue, 19 Jul 2011 03:33:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qj4ny-00022Y-Eb for qemu-devel@nongnu.org; Tue, 19 Jul 2011 03:33:23 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:61692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qj4ny-00022L-71 for qemu-devel@nongnu.org; Tue, 19 Jul 2011 03:33:22 -0400 Received: by yxt3 with SMTP id 3so1890899yxt.4 for ; Tue, 19 Jul 2011 00:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=Bf5Q2bWDOflRajV10zf+A2w7JVtuU+Y523t39VnJMBQ=; b=rGJLYDZvaYT7L7/Hq7fOFTvKH0BZeMFKOBThq3PJGOYtVyKWSgFDjNZzNBFHH4JLsR T+AADQ6ORVa7Y8euhFH4FFEjA3gznAFdAfMVkz6isU0uTDRQWXaDzc+CEtv1mhwYS9Be hOUE1jBEsd9ugRVjsnxnYrY7zZ53yv11qK1Wg= MIME-Version: 1.0 Received: by 10.100.20.34 with SMTP id 34mr5072577ant.41.1311060800845; Tue, 19 Jul 2011 00:33:20 -0700 (PDT) Received: by 10.100.152.9 with HTTP; Tue, 19 Jul 2011 00:33:20 -0700 (PDT) Date: Tue, 19 Jul 2011 09:33:20 +0200 Message-ID: From: Frediano Ziglio To: qemu-devel@nongnu.org, Kevin Wolf X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.173 Subject: [Qemu-devel] [PATCH] avoid core reading with bdrv_read (qemu-io) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch apply to kevin coroutine-block branch and avoid code. It fix "qcow: Use coroutines" patch. Test case: $ ./qemu-img create -f qcow aaa.img 1G Formatting 'aaa.img', fmt=qcow size=1073741824 encryption=off $ ./qemu-io aaa.img qemu-io> read 1024 1024 Segmentation fault Signed-off-by: Frediano Ziglio --- block/qcow.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) @@ -729,6 +731,7 @@ static int qcow_co_writev(BlockDriverState *bs, int64_t sector_num, if (acb->qiov->niov > 1) { qemu_vfree(acb->orig_buf); + acb->orig_buf = NULL; } qemu_aio_release(acb); diff --git a/block/qcow.c b/block/qcow.c index 6f7973c..1386e92 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -573,7 +573,8 @@ static int qcow_aio_read_cb(void *opaque) if (acb->nb_sectors == 0) { /* request completed */ - qemu_iovec_from_buffer(acb->qiov, acb->orig_buf, acb->qiov->size); + if (acb->orig_buf) + qemu_iovec_from_buffer(acb->qiov, acb->orig_buf, acb->qiov->size); return 0; } @@ -648,6 +649,7 @@ static int qcow_co_readv(BlockDriverState *bs, int64_t sector_num, if (acb->qiov->niov > 1) { qemu_vfree(acb->orig_buf); + acb->orig_buf = NULL; } qemu_aio_release(acb);