From patchwork Thu Nov 5 18:17:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 540664 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 795351402B9 for ; Fri, 6 Nov 2015 06:11:44 +1100 (AEDT) Received: from localhost ([::1]:34747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuPwk-0005yc-M1 for incoming@patchwork.ozlabs.org; Thu, 05 Nov 2015 14:11:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuP7b-0002Ak-Qs for qemu-devel@nongnu.org; Thu, 05 Nov 2015 13:18:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuP7a-00061l-S8 for qemu-devel@nongnu.org; Thu, 05 Nov 2015 13:18:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuP7Y-0005zt-Qp; Thu, 05 Nov 2015 13:18:48 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 6334291DBD; Thu, 5 Nov 2015 18:18:48 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA5II7Vo025730; Thu, 5 Nov 2015 13:18:47 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 5 Nov 2015 19:17:56 +0100 Message-Id: <1446747485-6562-29-git-send-email-kwolf@redhat.com> In-Reply-To: <1446747485-6562-1-git-send-email-kwolf@redhat.com> References: <1446747485-6562-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 28/37] block: Disallow snapshots if the overlay doesn't support backing files 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 From: Alberto Garcia This addresses scenarios like this one: { 'execute': 'blockdev-add', 'arguments': { 'options': { 'driver': 'qcow2', 'node-name': 'new0', 'file': { 'driver': 'file', 'filename': 'new.qcow2', 'node-name': 'file0' } } } } { 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay': 'file0' } } Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- blockdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/blockdev.c b/blockdev.c index 2bf18a7..8749d78 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1668,6 +1668,11 @@ static void external_snapshot_prepare(BlkTransactionState *common, if (state->new_bs->backing != NULL) { error_setg(errp, "The snapshot already has a backing image"); + return; + } + + if (!state->new_bs->drv->supports_backing) { + error_setg(errp, "The snapshot does not support backing images"); } }