mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
Block patches
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJTB8hAAAoJEH8JsnLIjy/WQdgP/jEu5baA1/qKanDsS9l+81u1 /sIYSWpHDEJ0uavqTMBeyMOwkzel7SZRusIwA/d5pMqxbY6/86YJumTTozFWvtqc IABqHtRKCxjcLdZRPbkuNAOiw6p76vSZa543o2t8OAhK2DIFy530wWXeoQEYvuJX 4pOh0lTradOrF1z6uW4ozgQ1efPppwh/iqwfWWNJVTgfnWxJk6qQaATEgkuSdsUN Wp78UzOxLGO6JKJB6kP3LfNL0ANTYHpfH2/wkE6cW6TkSUduOm6hIBY+tb9khqYt INOKxqFADK6EOgjvJBsZuZUtOnHK5oM921LepN/mOPAs6gKcn2j+FfqJrl3I1/5M AXM3M0FPuijEKPGWw7pCLt7j84KJkD9a/rsKO37yRzw17fOma2Rpr4TrX43BF+5t CGqQ7PzDJ6Fng4EXjyNDzviwXIK8xmG1tfn92tq/BUd6OuM9MCyzEGvEiGOMBoXv w4iOV7UC+1P3TjnTBhMlBVGywSfdOJoHr9k4lXGNp0h8fPhM9rfruI3BFysxaas6 GmKbd7yvKwXOTptd3I9SB8BzVUL3CcD3FK24+cWKAl8GgyiDIWRlvBYyMp3p8Z8f NDzcxYP6aRGsoddvpIWr3Tz89hw5wTW5u3RmNgxJUguz6HYKFbl30dpGT+96q2BN YIAANTdPxn7BP6r3glQH =ZaDG -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging Block patches # gpg: Signature made Fri 21 Feb 2014 21:42:24 GMT using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (54 commits) iotests: Mixed quorum child device specifications quorum: Simplify quorum_open() quorum: Add unit test. quorum: Add quorum_open() and quorum_close(). quorum: Implement recursive .bdrv_recurse_is_first_non_filter in quorum. quorum: Add quorum_co_flush(). quorum: Add quorum_invalidate_cache(). quorum: Add quorum_getlength(). quorum: Add quorum mechanism. quorum: Add quorum_aio_readv. blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify. quorum: Add quorum_aio_writev and its dependencies. quorum: Create BDRVQuorumState and BlkDriver and do init. quorum: Create quorum.c, add QuorumChildRequest and QuorumAIOCB. check-qdict: Test termination of qdict_array_split() check-qdict: Adjust test for qdict_array_split() qdict: Extract non-QDicts in qdict_array_split() qemu-config: Sections must consist of keys qemu-iotests: Check qemu-img command line parsing qemu-img: Allow -o help with incomplete argument list ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
e7a1d6c52a
50 changed files with 2821 additions and 636 deletions
147
qemu-img.c
147
qemu-img.c
|
@ -250,16 +250,19 @@ static int print_block_option_help(const char *filename, const char *fmt)
|
|||
return 1;
|
||||
}
|
||||
|
||||
proto_drv = bdrv_find_protocol(filename, true);
|
||||
if (!proto_drv) {
|
||||
error_report("Unknown protocol '%s'", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
create_options = append_option_parameters(create_options,
|
||||
drv->create_options);
|
||||
create_options = append_option_parameters(create_options,
|
||||
proto_drv->create_options);
|
||||
|
||||
if (filename) {
|
||||
proto_drv = bdrv_find_protocol(filename, true);
|
||||
if (!proto_drv) {
|
||||
error_report("Unknown protocol '%s'", filename);
|
||||
return 1;
|
||||
}
|
||||
create_options = append_option_parameters(create_options,
|
||||
proto_drv->create_options);
|
||||
}
|
||||
|
||||
print_option_help(create_options);
|
||||
free_option_parameters(create_options);
|
||||
return 0;
|
||||
|
@ -289,7 +292,7 @@ static BlockDriverState *bdrv_new_open(const char *filename,
|
|||
drv = NULL;
|
||||
}
|
||||
|
||||
ret = bdrv_open(bs, filename, NULL, flags, drv, &local_err);
|
||||
ret = bdrv_open(&bs, filename, NULL, NULL, flags, drv, &local_err);
|
||||
if (ret < 0) {
|
||||
error_report("Could not open '%s': %s", filename,
|
||||
error_get_pretty(local_err));
|
||||
|
@ -310,9 +313,7 @@ static BlockDriverState *bdrv_new_open(const char *filename,
|
|||
}
|
||||
return bs;
|
||||
fail:
|
||||
if (bs) {
|
||||
bdrv_unref(bs);
|
||||
}
|
||||
bdrv_unref(bs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -371,13 +372,23 @@ static int img_create(int argc, char **argv)
|
|||
case 'e':
|
||||
error_report("option -e is deprecated, please use \'-o "
|
||||
"encryption\' instead!");
|
||||
return 1;
|
||||
goto fail;
|
||||
case '6':
|
||||
error_report("option -6 is deprecated, please use \'-o "
|
||||
"compat6\' instead!");
|
||||
return 1;
|
||||
goto fail;
|
||||
case 'o':
|
||||
options = optarg;
|
||||
if (!is_valid_option_list(optarg)) {
|
||||
error_report("Invalid option list: %s", optarg);
|
||||
goto fail;
|
||||
}
|
||||
if (!options) {
|
||||
options = g_strdup(optarg);
|
||||
} else {
|
||||
char *old_options = options;
|
||||
options = g_strdup_printf("%s,%s", options, optarg);
|
||||
g_free(old_options);
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
quiet = true;
|
||||
|
@ -386,10 +397,16 @@ static int img_create(int argc, char **argv)
|
|||
}
|
||||
|
||||
/* Get the filename */
|
||||
filename = (optind < argc) ? argv[optind] : NULL;
|
||||
if (options && has_help_option(options)) {
|
||||
g_free(options);
|
||||
return print_block_option_help(filename, fmt);
|
||||
}
|
||||
|
||||
if (optind >= argc) {
|
||||
help();
|
||||
}
|
||||
filename = argv[optind++];
|
||||
optind++;
|
||||
|
||||
/* Get image size, if specified */
|
||||
if (optind < argc) {
|
||||
|
@ -405,7 +422,7 @@ static int img_create(int argc, char **argv)
|
|||
error_report("kilobytes, megabytes, gigabytes, terabytes, "
|
||||
"petabytes and exabytes.");
|
||||
}
|
||||
return 1;
|
||||
goto fail;
|
||||
}
|
||||
img_size = (uint64_t)sval;
|
||||
}
|
||||
|
@ -413,19 +430,20 @@ static int img_create(int argc, char **argv)
|
|||
help();
|
||||
}
|
||||
|
||||
if (options && is_help_option(options)) {
|
||||
return print_block_option_help(filename, fmt);
|
||||
}
|
||||
|
||||
bdrv_img_create(filename, fmt, base_filename, base_fmt,
|
||||
options, img_size, BDRV_O_FLAGS, &local_err, quiet);
|
||||
if (local_err) {
|
||||
error_report("%s: %s", filename, error_get_pretty(local_err));
|
||||
error_free(local_err);
|
||||
return 1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
g_free(options);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
g_free(options);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void dump_json_image_check(ImageCheck *check, bool quiet)
|
||||
|
@ -1150,6 +1168,9 @@ static int img_convert(int argc, char **argv)
|
|||
Error *local_err = NULL;
|
||||
QemuOpts *sn_opts = NULL;
|
||||
|
||||
/* Initialize before goto out */
|
||||
qemu_progress_init(progress, 1.0);
|
||||
|
||||
fmt = NULL;
|
||||
out_fmt = "raw";
|
||||
cache = "unsafe";
|
||||
|
@ -1181,13 +1202,26 @@ static int img_convert(int argc, char **argv)
|
|||
case 'e':
|
||||
error_report("option -e is deprecated, please use \'-o "
|
||||
"encryption\' instead!");
|
||||
return 1;
|
||||
ret = -1;
|
||||
goto out;
|
||||
case '6':
|
||||
error_report("option -6 is deprecated, please use \'-o "
|
||||
"compat6\' instead!");
|
||||
return 1;
|
||||
ret = -1;
|
||||
goto out;
|
||||
case 'o':
|
||||
options = optarg;
|
||||
if (!is_valid_option_list(optarg)) {
|
||||
error_report("Invalid option list: %s", optarg);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
if (!options) {
|
||||
options = g_strdup(optarg);
|
||||
} else {
|
||||
char *old_options = options;
|
||||
options = g_strdup_printf("%s,%s", options, optarg);
|
||||
g_free(old_options);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
snapshot_name = optarg;
|
||||
|
@ -1198,7 +1232,8 @@ static int img_convert(int argc, char **argv)
|
|||
if (!sn_opts) {
|
||||
error_report("Failed in parsing snapshot param '%s'",
|
||||
optarg);
|
||||
return 1;
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
snapshot_name = optarg;
|
||||
|
@ -1211,7 +1246,8 @@ static int img_convert(int argc, char **argv)
|
|||
sval = strtosz_suffix(optarg, &end, STRTOSZ_DEFSUFFIX_B);
|
||||
if (sval < 0 || *end) {
|
||||
error_report("Invalid minimum zero buffer size for sparse output specified");
|
||||
return 1;
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
min_sparse = sval / BDRV_SECTOR_SIZE;
|
||||
|
@ -1237,19 +1273,17 @@ static int img_convert(int argc, char **argv)
|
|||
}
|
||||
|
||||
bs_n = argc - optind - 1;
|
||||
out_filename = bs_n >= 1 ? argv[argc - 1] : NULL;
|
||||
|
||||
if (options && has_help_option(options)) {
|
||||
ret = print_block_option_help(out_filename, out_fmt);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (bs_n < 1) {
|
||||
help();
|
||||
}
|
||||
|
||||
out_filename = argv[argc - 1];
|
||||
|
||||
/* Initialize before goto out */
|
||||
qemu_progress_init(progress, 1.0);
|
||||
|
||||
if (options && is_help_option(options)) {
|
||||
ret = print_block_option_help(out_filename, out_fmt);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (bs_n > 1 && out_baseimg) {
|
||||
error_report("-B makes no sense when concatenating multiple input "
|
||||
|
@ -1639,6 +1673,7 @@ out:
|
|||
free_option_parameters(create_options);
|
||||
free_option_parameters(param);
|
||||
qemu_vfree(buf);
|
||||
g_free(options);
|
||||
if (sn_opts) {
|
||||
qemu_opts_del(sn_opts);
|
||||
}
|
||||
|
@ -2314,7 +2349,7 @@ static int img_rebase(int argc, char **argv)
|
|||
|
||||
bs_old_backing = bdrv_new("old_backing");
|
||||
bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name));
|
||||
ret = bdrv_open(bs_old_backing, backing_name, NULL, BDRV_O_FLAGS,
|
||||
ret = bdrv_open(&bs_old_backing, backing_name, NULL, NULL, BDRV_O_FLAGS,
|
||||
old_backing_drv, &local_err);
|
||||
if (ret) {
|
||||
error_report("Could not open old backing file '%s': %s",
|
||||
|
@ -2324,8 +2359,8 @@ static int img_rebase(int argc, char **argv)
|
|||
}
|
||||
if (out_baseimg[0]) {
|
||||
bs_new_backing = bdrv_new("new_backing");
|
||||
ret = bdrv_open(bs_new_backing, out_baseimg, NULL, BDRV_O_FLAGS,
|
||||
new_backing_drv, &local_err);
|
||||
ret = bdrv_open(&bs_new_backing, out_baseimg, NULL, NULL,
|
||||
BDRV_O_FLAGS, new_backing_drv, &local_err);
|
||||
if (ret) {
|
||||
error_report("Could not open new backing file '%s': %s",
|
||||
out_baseimg, error_get_pretty(local_err));
|
||||
|
@ -2637,7 +2672,18 @@ static int img_amend(int argc, char **argv)
|
|||
help();
|
||||
break;
|
||||
case 'o':
|
||||
options = optarg;
|
||||
if (!is_valid_option_list(optarg)) {
|
||||
error_report("Invalid option list: %s", optarg);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
if (!options) {
|
||||
options = g_strdup(optarg);
|
||||
} else {
|
||||
char *old_options = options;
|
||||
options = g_strdup_printf("%s,%s", options, optarg);
|
||||
g_free(old_options);
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
fmt = optarg;
|
||||
|
@ -2648,15 +2694,21 @@ static int img_amend(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
if (optind != argc - 1) {
|
||||
help();
|
||||
}
|
||||
|
||||
if (!options) {
|
||||
help();
|
||||
}
|
||||
|
||||
filename = argv[argc - 1];
|
||||
filename = (optind == argc - 1) ? argv[argc - 1] : NULL;
|
||||
if (fmt && has_help_option(options)) {
|
||||
/* If a format is explicitly specified (and possibly no filename is
|
||||
* given), print option help here */
|
||||
ret = print_block_option_help(filename, fmt);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (optind != argc - 1) {
|
||||
help();
|
||||
}
|
||||
|
||||
bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR, true, quiet);
|
||||
if (!bs) {
|
||||
|
@ -2667,7 +2719,8 @@ static int img_amend(int argc, char **argv)
|
|||
|
||||
fmt = bs->drv->format_name;
|
||||
|
||||
if (is_help_option(options)) {
|
||||
if (has_help_option(options)) {
|
||||
/* If the format was auto-detected, print option help here */
|
||||
ret = print_block_option_help(filename, fmt);
|
||||
goto out;
|
||||
}
|
||||
|
@ -2694,6 +2747,8 @@ out:
|
|||
}
|
||||
free_option_parameters(create_options);
|
||||
free_option_parameters(options_param);
|
||||
g_free(options);
|
||||
|
||||
if (ret) {
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue