From patchwork Wed Mar 16 10:47:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 87229 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 49D58B700A for ; Wed, 16 Mar 2011 21:55:16 +1100 (EST) Received: from localhost ([127.0.0.1]:53679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzoNk-0000J3-4f for incoming@patchwork.ozlabs.org; Wed, 16 Mar 2011 06:55:12 -0400 Received: from [140.186.70.92] (port=49743 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzoEt-0004aj-SU for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:46:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzoEs-0002QY-L4 for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:46:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzoEs-0002QT-BZ for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:46:02 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2GAk08d005256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Mar 2011 06:46:00 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2GAjrlU019365; Wed, 16 Mar 2011 06:45:59 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Wed, 16 Mar 2011 11:47:57 +0100 Message-Id: <1300272481-8744-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1300272481-8744-1-git-send-email-kwolf@redhat.com> References: <1300272481-8744-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 5/9] Don't allow multiwrites against a block device without underlying medium 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 From: Ryan Harper If the block device has been closed, we no longer have a medium to submit IO against, check for this before submitting io. This prevents a segfault further in the code where we dereference elements of the block driver. Signed-off-by: Ryan Harper Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 0559d83..c8e2f97 100644 --- a/block.c +++ b/block.c @@ -2398,6 +2398,14 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs) MultiwriteCB *mcb; int i; + /* don't submit writes if we don't have a medium */ + if (bs->drv == NULL) { + for (i = 0; i < num_reqs; i++) { + reqs[i].error = -ENOMEDIUM; + } + return -1; + } + if (num_reqs == 0) { return 0; }