From patchwork Tue Oct 18 15:47:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 120456 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 B62B1B71AD for ; Wed, 19 Oct 2011 02:44:56 +1100 (EST) Received: from localhost ([::1]:54599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGBqY-0000kV-9o for incoming@patchwork.ozlabs.org; Tue, 18 Oct 2011 11:44:54 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGBqO-0000bT-LO for qemu-devel@nongnu.org; Tue, 18 Oct 2011 11:44:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGBqG-0003ME-Ez for qemu-devel@nongnu.org; Tue, 18 Oct 2011 11:44:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGBqG-0003M2-6C for qemu-devel@nongnu.org; Tue, 18 Oct 2011 11:44:36 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9IFiZmm008948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Oct 2011 11:44:35 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9IFiXVM023692; Tue, 18 Oct 2011 11:44:34 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2011 17:47:37 +0200 Message-Id: <1318952858-18960-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH 1/2] qemu-img: Don't allow preallocation and compression at the same time 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 Only qcow and qcow2 can do compression at all, and they require unallocated clusters when writing the compressed data. Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi --- qemu-img.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 6a39731..511f136 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -824,6 +824,8 @@ static int img_convert(int argc, char **argv) if (compress) { QEMUOptionParameter *encryption = get_option_parameter(param, BLOCK_OPT_ENCRYPT); + QEMUOptionParameter *preallocation = + get_option_parameter(param, BLOCK_OPT_PREALLOC); if (!drv->bdrv_write_compressed) { error_report("Compression not supported for this file format"); @@ -837,6 +839,13 @@ static int img_convert(int argc, char **argv) ret = -1; goto out; } + + if (preallocation && strcmp(preallocation->value.s, "off")) { + error_report("Compression and preallocation not supported at " + "the same time"); + ret = -1; + goto out; + } } /* Create the new image */