qemu-img: add -l for snapshot in convert
Now qemu-img convert have similar options as qemu-nbd for internal snapshot. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
9c468a013f
commit
ef80654d0d
@ -34,9 +34,9 @@ STEXI
|
|||||||
ETEXI
|
ETEXI
|
||||||
|
|
||||||
DEF("convert", img_convert,
|
DEF("convert", img_convert,
|
||||||
"convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-s snapshot_name] [-S sparse_size] filename [filename2 [...]] output_filename")
|
"convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-O output_fmt] [-o options] [-s snapshot_id_or_name] [-l snapshot_param] [-S sparse_size] filename [filename2 [...]] output_filename")
|
||||||
STEXI
|
STEXI
|
||||||
@item convert [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
|
@item convert [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
|
||||||
ETEXI
|
ETEXI
|
||||||
|
|
||||||
DEF("info", img_info,
|
DEF("info", img_info,
|
||||||
|
44
qemu-img.c
44
qemu-img.c
@ -93,6 +93,11 @@ static void help(void)
|
|||||||
" 'options' is a comma separated list of format specific options in a\n"
|
" 'options' is a comma separated list of format specific options in a\n"
|
||||||
" name=value format. Use -o ? for an overview of the options supported by the\n"
|
" name=value format. Use -o ? for an overview of the options supported by the\n"
|
||||||
" used format\n"
|
" used format\n"
|
||||||
|
" 'snapshot_param' is param used for internal snapshot, format\n"
|
||||||
|
" is 'snapshot.id=[ID],snapshot.name=[NAME]', or\n"
|
||||||
|
" '[ID_OR_NAME]'\n"
|
||||||
|
" 'snapshot_id_or_name' is deprecated, use 'snapshot_param'\n"
|
||||||
|
" instead\n"
|
||||||
" '-c' indicates that target image must be compressed (qcow format only)\n"
|
" '-c' indicates that target image must be compressed (qcow format only)\n"
|
||||||
" '-u' enables unsafe rebasing. It is assumed that old and new backing file\n"
|
" '-u' enables unsafe rebasing. It is assumed that old and new backing file\n"
|
||||||
" match exactly. The image doesn't need a working backing file before\n"
|
" match exactly. The image doesn't need a working backing file before\n"
|
||||||
@ -1144,6 +1149,7 @@ static int img_convert(int argc, char **argv)
|
|||||||
int min_sparse = 8; /* Need at least 4k of zeros for sparse detection */
|
int min_sparse = 8; /* Need at least 4k of zeros for sparse detection */
|
||||||
bool quiet = false;
|
bool quiet = false;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
QemuOpts *sn_opts = NULL;
|
||||||
|
|
||||||
fmt = NULL;
|
fmt = NULL;
|
||||||
out_fmt = "raw";
|
out_fmt = "raw";
|
||||||
@ -1152,7 +1158,7 @@ static int img_convert(int argc, char **argv)
|
|||||||
compress = 0;
|
compress = 0;
|
||||||
skip_create = 0;
|
skip_create = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
c = getopt(argc, argv, "f:O:B:s:hce6o:pS:t:qn");
|
c = getopt(argc, argv, "f:O:B:s:hce6o:pS:t:qnl:");
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1187,6 +1193,18 @@ static int img_convert(int argc, char **argv)
|
|||||||
case 's':
|
case 's':
|
||||||
snapshot_name = optarg;
|
snapshot_name = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
|
||||||
|
sn_opts = qemu_opts_parse(&internal_snapshot_opts, optarg, 0);
|
||||||
|
if (!sn_opts) {
|
||||||
|
error_report("Failed in parsing snapshot param '%s'",
|
||||||
|
optarg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
snapshot_name = optarg;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
{
|
{
|
||||||
int64_t sval;
|
int64_t sval;
|
||||||
@ -1258,7 +1276,12 @@ static int img_convert(int argc, char **argv)
|
|||||||
total_sectors += bs_sectors;
|
total_sectors += bs_sectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot_name != NULL) {
|
if (sn_opts) {
|
||||||
|
ret = bdrv_snapshot_load_tmp(bs[0],
|
||||||
|
qemu_opt_get(sn_opts, SNAPSHOT_OPT_ID),
|
||||||
|
qemu_opt_get(sn_opts, SNAPSHOT_OPT_NAME),
|
||||||
|
&local_err);
|
||||||
|
} else if (snapshot_name != NULL) {
|
||||||
if (bs_n > 1) {
|
if (bs_n > 1) {
|
||||||
error_report("No support for concatenating multiple snapshot");
|
error_report("No support for concatenating multiple snapshot");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -1266,13 +1289,13 @@ static int img_convert(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bdrv_snapshot_load_tmp_by_id_or_name(bs[0], snapshot_name, &local_err);
|
bdrv_snapshot_load_tmp_by_id_or_name(bs[0], snapshot_name, &local_err);
|
||||||
if (error_is_set(&local_err)) {
|
}
|
||||||
error_report("Failed to load snapshot: %s",
|
if (error_is_set(&local_err)) {
|
||||||
error_get_pretty(local_err));
|
error_report("Failed to load snapshot: %s",
|
||||||
error_free(local_err);
|
error_get_pretty(local_err));
|
||||||
ret = -1;
|
error_free(local_err);
|
||||||
goto out;
|
ret = -1;
|
||||||
}
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find driver and parse its options */
|
/* Find driver and parse its options */
|
||||||
@ -1571,6 +1594,9 @@ out:
|
|||||||
free_option_parameters(create_options);
|
free_option_parameters(create_options);
|
||||||
free_option_parameters(param);
|
free_option_parameters(param);
|
||||||
qemu_vfree(buf);
|
qemu_vfree(buf);
|
||||||
|
if (sn_opts) {
|
||||||
|
qemu_opts_del(sn_opts);
|
||||||
|
}
|
||||||
if (out_bs) {
|
if (out_bs) {
|
||||||
bdrv_unref(out_bs);
|
bdrv_unref(out_bs);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,11 @@ is the destination disk image filename
|
|||||||
is a comma separated list of format specific options in a
|
is a comma separated list of format specific options in a
|
||||||
name=value format. Use @code{-o ?} for an overview of the options supported
|
name=value format. Use @code{-o ?} for an overview of the options supported
|
||||||
by the used format or see the format descriptions below for details.
|
by the used format or see the format descriptions below for details.
|
||||||
|
@item snapshot_param
|
||||||
|
is param used for internal snapshot, format is
|
||||||
|
'snapshot.id=[ID],snapshot.name=[NAME]' or '[ID_OR_NAME]'
|
||||||
|
@item snapshot_id_or_name
|
||||||
|
is deprecated, use snapshot_param instead
|
||||||
|
|
||||||
@item -c
|
@item -c
|
||||||
indicates that target image must be compressed (qcow format only)
|
indicates that target image must be compressed (qcow format only)
|
||||||
@ -179,10 +183,10 @@ Error on reading data
|
|||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@item convert [-c] [-p] [-n] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_name}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
|
@item convert [-c] [-p] [-n] [-f @var{fmt}] [-t @var{cache}] [-O @var{output_fmt}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
|
||||||
|
|
||||||
Convert the disk image @var{filename} or a snapshot @var{snapshot_name} to disk image @var{output_filename}
|
Convert the disk image @var{filename} or a snapshot @var{snapshot_param}(@var{snapshot_id_or_name} is deprecated)
|
||||||
using format @var{output_fmt}. It can be optionally compressed (@code{-c}
|
to disk image @var{output_filename} using format @var{output_fmt}. It can be optionally compressed (@code{-c}
|
||||||
option) or use any format specific options like encryption (@code{-o} option).
|
option) or use any format specific options like encryption (@code{-o} option).
|
||||||
|
|
||||||
Only the formats @code{qcow} and @code{qcow2} support compression. The
|
Only the formats @code{qcow} and @code{qcow2} support compression. The
|
||||||
|
Loading…
Reference in New Issue
Block a user