From patchwork Mon Jan 24 21:10:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 80266 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 B689AB7107 for ; Tue, 25 Jan 2011 08:36:45 +1100 (EST) Received: from localhost ([127.0.0.1]:33277 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhU53-0004MC-Rp for incoming@patchwork.ozlabs.org; Mon, 24 Jan 2011 16:36:09 -0500 Received: from [140.186.70.92] (port=60818 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhTfq-000195-Uc for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:10:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhTfn-0007U7-TO for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:10:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58151) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhTfn-0007Ts-Ld for qemu-devel@nongnu.org; Mon, 24 Jan 2011 16:10:03 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0OLA0sc027024 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Jan 2011 16:10:01 -0500 Received: from dhcp-5-188.str.redhat.com (vpn1-5-230.ams2.redhat.com [10.36.5.230]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0OL9I7B003712; Mon, 24 Jan 2011 16:09:59 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Mon, 24 Jan 2011 22:10:43 +0100 Message-Id: <1295903452-18017-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1295903452-18017-1-git-send-email-kwolf@redhat.com> References: <1295903452-18017-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 14/23] qed: Refuse to create images on block devices 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: Stefan Hajnoczi QED relies on the underlying filesystem to extend the file and maintain its size. Check that images are not created on a block device. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/qed.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/block/qed.c b/block/qed.c index 085c4f2..a46f9ef 100644 --- a/block/qed.c +++ b/block/qed.c @@ -469,6 +469,12 @@ static int qed_create(const char *filename, uint32_t cluster_size, return ret; } + /* File must start empty and grow, check truncate is supported */ + ret = bdrv_truncate(bs, 0); + if (ret < 0) { + goto out; + } + if (backing_file) { header.features |= QED_F_BACKING_FILE; header.backing_filename_offset = sizeof(le_header);