From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lnckc-0007av-7h for qemu-devel@nongnu.org; Sat, 28 Mar 2009 13:55:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lncka-0007ZJ-W8 for qemu-devel@nongnu.org; Sat, 28 Mar 2009 13:55:21 -0400 Received: from [199.232.76.173] (port=42997 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lncka-0007Z0-Q0 for qemu-devel@nongnu.org; Sat, 28 Mar 2009 13:55:20 -0400 Received: from savannah.gnu.org ([199.232.41.3]:34367 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lncka-0001hU-Ax for qemu-devel@nongnu.org; Sat, 28 Mar 2009 13:55:20 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LnckZ-0001CN-Pw for qemu-devel@nongnu.org; Sat, 28 Mar 2009 17:55:19 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LnckZ-0001CJ-GF for qemu-devel@nongnu.org; Sat, 28 Mar 2009 17:55:19 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Sat, 28 Mar 2009 17:55:19 +0000 Subject: [Qemu-devel] [6910] qemu-img: adding a "-F base_fmt" option to "qemu-img create -b" ( Uri Lublin) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6910 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6910 Author: aliguori Date: 2009-03-28 17:55:19 +0000 (Sat, 28 Mar 2009) Log Message: ----------- qemu-img: adding a "-F base_fmt" option to "qemu-img create -b" (Uri Lublin) If the user specifies the backing file format, then when opening the backing file, there is no need to probe the (backing file) image to figure out its format. This follows my previous patches implementing bdrv_create2 which keeps (for qcow2 only) the backing file format as a qcow2-extension Suggested by Daniel P. Berrange. Signed-off-by: Uri Lublin Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/qemu-img.c trunk/qemu-img.texi Modified: trunk/qemu-img.c =================================================================== --- trunk/qemu-img.c 2009-03-28 17:55:14 UTC (rev 6909) +++ trunk/qemu-img.c 2009-03-28 17:55:19 UTC (rev 6910) @@ -25,6 +25,7 @@ #include "osdep.h" #include "block_int.h" #include +#include #ifdef _WIN32 #include @@ -57,7 +58,7 @@ "QEMU disk image utility\n" "\n" "Command syntax:\n" - " create [-e] [-6] [-b base_image] [-f fmt] filename [size]\n" + " create [-e] [-6] [-F fmt] [-b base_image] [-f fmt] filename [size]\n" " commit [-f fmt] filename\n" " convert [-c] [-e] [-6] [-f fmt] [-O output_fmt] [-B output_base_image] filename [filename2 [...]] output_filename\n" " info [-f fmt] filename\n" @@ -217,6 +218,7 @@ { int c, ret, flags; const char *fmt = "raw"; + const char *base_fmt = NULL; const char *filename; const char *base_filename = NULL; uint64_t size; @@ -226,13 +228,16 @@ flags = 0; for(;;) { - c = getopt(argc, argv, "b:f:he6"); + c = getopt(argc, argv, "F:b:f:he6"); if (c == -1) break; switch(c) { case 'h': help(); break; + case 'F': + base_fmt = optarg; + break; case 'b': base_filename = optarg; break; @@ -253,7 +258,15 @@ size = 0; if (base_filename) { BlockDriverState *bs; - bs = bdrv_new_open(base_filename, NULL); + BlockDriver *base_drv = NULL; + + if (base_fmt) { + base_drv = bdrv_find_format(base_fmt); + if (base_drv == NULL) + error("Unknown basefile format '%s'", base_fmt); + } + + bs = bdrv_new_open(base_filename, base_fmt); bdrv_get_geometry(bs, &size); size *= 512; bdrv_delete(bs); @@ -284,9 +297,12 @@ if (base_filename) { printf(", backing_file=%s", base_filename); + if (base_fmt) + printf(", backing_fmt=%s", + base_fmt); } printf(", size=%" PRIu64 " kB\n", size / 1024); - ret = bdrv_create(drv, filename, size / 512, base_filename, flags); + ret = bdrv_create2(drv, filename, size / 512, base_filename, base_fmt, flags); if (ret < 0) { if (ret == -ENOTSUP) { error("Formatting or formatting option not supported for file format '%s'", fmt); Modified: trunk/qemu-img.texi =================================================================== --- trunk/qemu-img.texi 2009-03-28 17:55:14 UTC (rev 6909) +++ trunk/qemu-img.texi 2009-03-28 17:55:19 UTC (rev 6910) @@ -8,7 +8,7 @@ The following commands are supported: @table @option -@item create [-e] [-6] [-b @var{base_image}] [-f @var{fmt}] @var{filename} [@var{size}] +@item create [-e] [-6] [-F @var{base_fmt}] [-b @var{base_image}] [-f @var{fmt}] @var{filename} [@var{size}] @item commit [-f @var{fmt}] @var{filename} @item convert [-c] [-e] [-6] [-f @var{fmt}] [-O @var{output_fmt}] [-B @var{output_base_image}] @var{filename} [@var{filename2} [...]] @var{output_filename} @item info [-f @var{fmt}] @var{filename} @@ -27,6 +27,8 @@ image of the specified base image; @code{output_base_image} should have the same content as the input's base image, however the path, image format, etc may differ +@item base_fmt +is the disk image format of @var{base_image}. for more information look at @var{fmt} @item fmt is the disk image format. It is guessed automatically in most cases. The following formats are supported: