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 <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6910
c046a42c-6fe2-441c-8c8c-
71466251a162
#include "osdep.h"
#include "block_int.h"
#include <assert.h>
#include "osdep.h"
#include "block_int.h"
#include <assert.h>
#ifdef _WIN32
#include <windows.h>
#ifdef _WIN32
#include <windows.h>
"QEMU disk image utility\n"
"\n"
"Command syntax:\n"
"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"
" 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"
{
int c, ret, flags;
const char *fmt = "raw";
{
int c, ret, flags;
const char *fmt = "raw";
+ const char *base_fmt = NULL;
const char *filename;
const char *base_filename = NULL;
uint64_t size;
const char *filename;
const char *base_filename = NULL;
uint64_t size;
- 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;
if (c == -1)
break;
switch(c) {
case 'h':
help();
break;
+ case 'F':
+ base_fmt = optarg;
+ break;
case 'b':
base_filename = optarg;
break;
case 'b':
base_filename = optarg;
break;
size = 0;
if (base_filename) {
BlockDriverState *bs;
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);
bdrv_get_geometry(bs, &size);
size *= 512;
bdrv_delete(bs);
if (base_filename) {
printf(", backing_file=%s",
base_filename);
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);
}
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);
if (ret < 0) {
if (ret == -ENOTSUP) {
error("Formatting or formatting option not supported for file format '%s'", fmt);
The following commands are supported:
@table @option
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}
@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}
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
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:
@item fmt
is the disk image format. It is guessed automatically in most cases. The following formats are supported: