From patchwork Mon Dec 13 07:32:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 75301 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 89D8BB6F11 for ; Mon, 13 Dec 2010 18:34:39 +1100 (EST) Received: from localhost ([127.0.0.1]:33680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PS2vc-00064E-3E for incoming@patchwork.ozlabs.org; Mon, 13 Dec 2010 02:34:36 -0500 Received: from [140.186.70.92] (port=42852 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PS2uD-00063p-AT for qemu-devel@nongnu.org; Mon, 13 Dec 2010 02:33:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PS2uB-00040i-JE for qemu-devel@nongnu.org; Mon, 13 Dec 2010 02:33:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PS2uB-00040I-AT for qemu-devel@nongnu.org; Mon, 13 Dec 2010 02:33:07 -0500 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.13.8/8.13.8) with ESMTP id oBD7X5DM004657 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Dec 2010 02:33:05 -0500 Received: from red-feather.redhat.com (ovpn-113-46.phx2.redhat.com [10.3.113.46]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBD7Wxp0032332; Mon, 13 Dec 2010 02:33:04 -0500 From: Jes.Sorensen@redhat.com To: kwolf@redhat.com Date: Mon, 13 Dec 2010 08:32:59 +0100 Message-Id: <1292225579-27320-4-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1292225579-27320-1-git-send-email-Jes.Sorensen@redhat.com> References: <1292225579-27320-1-git-send-email-Jes.Sorensen@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. Cc: qemu-devel@nongnu.org, armbru@redhat.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 3/3] Prevent creating an image with the same filename as backing file 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: Jes Sorensen Signed-off-by: Jes Sorensen --- block.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 3ab062c..403a434 100644 --- a/block.c +++ b/block.c @@ -2752,6 +2752,13 @@ int bdrv_img_create(const char *filename, const char *fmt, BlockDriver *drv, *proto_drv; int ret = 0; + if (!strcmp(filename, base_filename)) { + error_report("Error: Trying to create a snapshot with the same " + "filename as the backing file"); + ret = -1; + goto out; + } + /* Find driver and parse its options */ drv = bdrv_find_format(fmt); if (!drv) {