|
@@ -32,6 +32,7 @@
|
|
#include "block/block_int.h"
|
|
#include "block/block_int.h"
|
|
#include <getopt.h>
|
|
#include <getopt.h>
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
|
|
+#include <stdarg.h>
|
|
|
|
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#include <windows.h>
|
|
@@ -96,6 +97,7 @@ static void help(void)
|
|
" rebasing in this case (useful for renaming the backing file)\n"
|
|
" rebasing in this case (useful for renaming the backing file)\n"
|
|
" '-h' with or without a command shows this help and lists the supported formats\n"
|
|
" '-h' with or without a command shows this help and lists the supported formats\n"
|
|
" '-p' show progress of command (only certain commands)\n"
|
|
" '-p' show progress of command (only certain commands)\n"
|
|
|
|
+ " '-q' use Quiet mode - do not print any output (except errors)\n"
|
|
" '-S' indicates the consecutive number of bytes that must contain only zeros\n"
|
|
" '-S' indicates the consecutive number of bytes that must contain only zeros\n"
|
|
" for qemu-img to create a sparse image during conversion\n"
|
|
" for qemu-img to create a sparse image during conversion\n"
|
|
" '--output' takes the format in which the output must be done (human or json)\n"
|
|
" '--output' takes the format in which the output must be done (human or json)\n"
|
|
@@ -119,6 +121,18 @@ static void help(void)
|
|
exit(1);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int qprintf(bool quiet, const char *fmt, ...)
|
|
|
|
+{
|
|
|
|
+ int ret = 0;
|
|
|
|
+ if (!quiet) {
|
|
|
|
+ va_list args;
|
|
|
|
+ va_start(args, fmt);
|
|
|
|
+ ret = vprintf(fmt, args);
|
|
|
|
+ va_end(args);
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
#if defined(WIN32)
|
|
#if defined(WIN32)
|
|
/* XXX: put correct support for win32 */
|
|
/* XXX: put correct support for win32 */
|
|
static int read_password(char *buf, int buf_size)
|
|
static int read_password(char *buf, int buf_size)
|
|
@@ -237,7 +251,8 @@ static int print_block_option_help(const char *filename, const char *fmt)
|
|
static BlockDriverState *bdrv_new_open(const char *filename,
|
|
static BlockDriverState *bdrv_new_open(const char *filename,
|
|
const char *fmt,
|
|
const char *fmt,
|
|
int flags,
|
|
int flags,
|
|
- bool require_io)
|
|
|
|
|
|
+ bool require_io,
|
|
|
|
+ bool quiet)
|
|
{
|
|
{
|
|
BlockDriverState *bs;
|
|
BlockDriverState *bs;
|
|
BlockDriver *drv;
|
|
BlockDriver *drv;
|
|
@@ -263,7 +278,7 @@ static BlockDriverState *bdrv_new_open(const char *filename,
|
|
}
|
|
}
|
|
|
|
|
|
if (bdrv_is_encrypted(bs) && require_io) {
|
|
if (bdrv_is_encrypted(bs) && require_io) {
|
|
- printf("Disk image '%s' is encrypted.\n", filename);
|
|
|
|
|
|
+ qprintf(quiet, "Disk image '%s' is encrypted.\n", filename);
|
|
if (read_password(password, sizeof(password)) < 0) {
|
|
if (read_password(password, sizeof(password)) < 0) {
|
|
error_report("No password given");
|
|
error_report("No password given");
|
|
goto fail;
|
|
goto fail;
|
|
@@ -312,9 +327,10 @@ static int img_create(int argc, char **argv)
|
|
const char *base_filename = NULL;
|
|
const char *base_filename = NULL;
|
|
char *options = NULL;
|
|
char *options = NULL;
|
|
Error *local_err = NULL;
|
|
Error *local_err = NULL;
|
|
|
|
+ bool quiet = false;
|
|
|
|
|
|
for(;;) {
|
|
for(;;) {
|
|
- c = getopt(argc, argv, "F:b:f:he6o:");
|
|
|
|
|
|
+ c = getopt(argc, argv, "F:b:f:he6o:q");
|
|
if (c == -1) {
|
|
if (c == -1) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -343,6 +359,9 @@ static int img_create(int argc, char **argv)
|
|
case 'o':
|
|
case 'o':
|
|
options = optarg;
|
|
options = optarg;
|
|
break;
|
|
break;
|
|
|
|
+ case 'q':
|
|
|
|
+ quiet = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -375,7 +394,7 @@ static int img_create(int argc, char **argv)
|
|
}
|
|
}
|
|
|
|
|
|
bdrv_img_create(filename, fmt, base_filename, base_fmt,
|
|
bdrv_img_create(filename, fmt, base_filename, base_fmt,
|
|
- options, img_size, BDRV_O_FLAGS, &local_err);
|
|
|
|
|
|
+ options, img_size, BDRV_O_FLAGS, &local_err, quiet);
|
|
if (error_is_set(&local_err)) {
|
|
if (error_is_set(&local_err)) {
|
|
error_report("%s", error_get_pretty(local_err));
|
|
error_report("%s", error_get_pretty(local_err));
|
|
error_free(local_err);
|
|
error_free(local_err);
|
|
@@ -385,7 +404,7 @@ static int img_create(int argc, char **argv)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static void dump_json_image_check(ImageCheck *check)
|
|
|
|
|
|
+static void dump_json_image_check(ImageCheck *check, bool quiet)
|
|
{
|
|
{
|
|
Error *errp = NULL;
|
|
Error *errp = NULL;
|
|
QString *str;
|
|
QString *str;
|
|
@@ -396,47 +415,52 @@ static void dump_json_image_check(ImageCheck *check)
|
|
obj = qmp_output_get_qobject(ov);
|
|
obj = qmp_output_get_qobject(ov);
|
|
str = qobject_to_json_pretty(obj);
|
|
str = qobject_to_json_pretty(obj);
|
|
assert(str != NULL);
|
|
assert(str != NULL);
|
|
- printf("%s\n", qstring_get_str(str));
|
|
|
|
|
|
+ qprintf(quiet, "%s\n", qstring_get_str(str));
|
|
qobject_decref(obj);
|
|
qobject_decref(obj);
|
|
qmp_output_visitor_cleanup(ov);
|
|
qmp_output_visitor_cleanup(ov);
|
|
QDECREF(str);
|
|
QDECREF(str);
|
|
}
|
|
}
|
|
|
|
|
|
-static void dump_human_image_check(ImageCheck *check)
|
|
|
|
|
|
+static void dump_human_image_check(ImageCheck *check, bool quiet)
|
|
{
|
|
{
|
|
if (!(check->corruptions || check->leaks || check->check_errors)) {
|
|
if (!(check->corruptions || check->leaks || check->check_errors)) {
|
|
- printf("No errors were found on the image.\n");
|
|
|
|
|
|
+ qprintf(quiet, "No errors were found on the image.\n");
|
|
} else {
|
|
} else {
|
|
if (check->corruptions) {
|
|
if (check->corruptions) {
|
|
- printf("\n%" PRId64 " errors were found on the image.\n"
|
|
|
|
- "Data may be corrupted, or further writes to the image "
|
|
|
|
- "may corrupt it.\n",
|
|
|
|
- check->corruptions);
|
|
|
|
|
|
+ qprintf(quiet, "\n%" PRId64 " errors were found on the image.\n"
|
|
|
|
+ "Data may be corrupted, or further writes to the image "
|
|
|
|
+ "may corrupt it.\n",
|
|
|
|
+ check->corruptions);
|
|
}
|
|
}
|
|
|
|
|
|
if (check->leaks) {
|
|
if (check->leaks) {
|
|
- printf("\n%" PRId64 " leaked clusters were found on the image.\n"
|
|
|
|
- "This means waste of disk space, but no harm to data.\n",
|
|
|
|
- check->leaks);
|
|
|
|
|
|
+ qprintf(quiet,
|
|
|
|
+ "\n%" PRId64 " leaked clusters were found on the image.\n"
|
|
|
|
+ "This means waste of disk space, but no harm to data.\n",
|
|
|
|
+ check->leaks);
|
|
}
|
|
}
|
|
|
|
|
|
if (check->check_errors) {
|
|
if (check->check_errors) {
|
|
- printf("\n%" PRId64 " internal errors have occurred during the check.\n",
|
|
|
|
- check->check_errors);
|
|
|
|
|
|
+ qprintf(quiet,
|
|
|
|
+ "\n%" PRId64
|
|
|
|
+ " internal errors have occurred during the check.\n",
|
|
|
|
+ check->check_errors);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (check->total_clusters != 0 && check->allocated_clusters != 0) {
|
|
if (check->total_clusters != 0 && check->allocated_clusters != 0) {
|
|
- printf("%" PRId64 "/%" PRId64 " = %0.2f%% allocated, "
|
|
|
|
- "%0.2f%% fragmented, %0.2f%% compressed clusters\n",
|
|
|
|
- check->allocated_clusters, check->total_clusters,
|
|
|
|
- check->allocated_clusters * 100.0 / check->total_clusters,
|
|
|
|
- check->fragmented_clusters * 100.0 / check->allocated_clusters,
|
|
|
|
- check->compressed_clusters * 100.0 / check->allocated_clusters);
|
|
|
|
|
|
+ qprintf(quiet, "%" PRId64 "/%" PRId64 " = %0.2f%% allocated, "
|
|
|
|
+ "%0.2f%% fragmented, %0.2f%% compressed clusters\n",
|
|
|
|
+ check->allocated_clusters, check->total_clusters,
|
|
|
|
+ check->allocated_clusters * 100.0 / check->total_clusters,
|
|
|
|
+ check->fragmented_clusters * 100.0 / check->allocated_clusters,
|
|
|
|
+ check->compressed_clusters * 100.0 /
|
|
|
|
+ check->allocated_clusters);
|
|
}
|
|
}
|
|
|
|
|
|
if (check->image_end_offset) {
|
|
if (check->image_end_offset) {
|
|
- printf("Image end offset: %" PRId64 "\n", check->image_end_offset);
|
|
|
|
|
|
+ qprintf(quiet,
|
|
|
|
+ "Image end offset: %" PRId64 "\n", check->image_end_offset);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -496,6 +520,7 @@ static int img_check(int argc, char **argv)
|
|
int fix = 0;
|
|
int fix = 0;
|
|
int flags = BDRV_O_FLAGS | BDRV_O_CHECK;
|
|
int flags = BDRV_O_FLAGS | BDRV_O_CHECK;
|
|
ImageCheck *check;
|
|
ImageCheck *check;
|
|
|
|
+ bool quiet = false;
|
|
|
|
|
|
fmt = NULL;
|
|
fmt = NULL;
|
|
output = NULL;
|
|
output = NULL;
|
|
@@ -508,7 +533,7 @@ static int img_check(int argc, char **argv)
|
|
{"output", required_argument, 0, OPTION_OUTPUT},
|
|
{"output", required_argument, 0, OPTION_OUTPUT},
|
|
{0, 0, 0, 0}
|
|
{0, 0, 0, 0}
|
|
};
|
|
};
|
|
- c = getopt_long(argc, argv, "f:hr:",
|
|
|
|
|
|
+ c = getopt_long(argc, argv, "f:hr:q",
|
|
long_options, &option_index);
|
|
long_options, &option_index);
|
|
if (c == -1) {
|
|
if (c == -1) {
|
|
break;
|
|
break;
|
|
@@ -535,6 +560,9 @@ static int img_check(int argc, char **argv)
|
|
case OPTION_OUTPUT:
|
|
case OPTION_OUTPUT:
|
|
output = optarg;
|
|
output = optarg;
|
|
break;
|
|
break;
|
|
|
|
+ case 'q':
|
|
|
|
+ quiet = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (optind >= argc) {
|
|
if (optind >= argc) {
|
|
@@ -551,7 +579,7 @@ static int img_check(int argc, char **argv)
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
- bs = bdrv_new_open(filename, fmt, flags, true);
|
|
|
|
|
|
+ bs = bdrv_new_open(filename, fmt, flags, true, quiet);
|
|
if (!bs) {
|
|
if (!bs) {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
@@ -574,12 +602,13 @@ static int img_check(int argc, char **argv)
|
|
corruptions_fixed = check->corruptions_fixed;
|
|
corruptions_fixed = check->corruptions_fixed;
|
|
|
|
|
|
if (output_format == OFORMAT_HUMAN) {
|
|
if (output_format == OFORMAT_HUMAN) {
|
|
- printf("The following inconsistencies were found and repaired:\n\n"
|
|
|
|
- " %" PRId64 " leaked clusters\n"
|
|
|
|
- " %" PRId64 " corruptions\n\n"
|
|
|
|
- "Double checking the fixed image now...\n",
|
|
|
|
- check->leaks_fixed,
|
|
|
|
- check->corruptions_fixed);
|
|
|
|
|
|
+ qprintf(quiet,
|
|
|
|
+ "The following inconsistencies were found and repaired:\n\n"
|
|
|
|
+ " %" PRId64 " leaked clusters\n"
|
|
|
|
+ " %" PRId64 " corruptions\n\n"
|
|
|
|
+ "Double checking the fixed image now...\n",
|
|
|
|
+ check->leaks_fixed,
|
|
|
|
+ check->corruptions_fixed);
|
|
}
|
|
}
|
|
|
|
|
|
ret = collect_image_check(bs, check, filename, fmt, 0);
|
|
ret = collect_image_check(bs, check, filename, fmt, 0);
|
|
@@ -590,10 +619,10 @@ static int img_check(int argc, char **argv)
|
|
|
|
|
|
switch (output_format) {
|
|
switch (output_format) {
|
|
case OFORMAT_HUMAN:
|
|
case OFORMAT_HUMAN:
|
|
- dump_human_image_check(check);
|
|
|
|
|
|
+ dump_human_image_check(check, quiet);
|
|
break;
|
|
break;
|
|
case OFORMAT_JSON:
|
|
case OFORMAT_JSON:
|
|
- dump_json_image_check(check);
|
|
|
|
|
|
+ dump_json_image_check(check, quiet);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -622,11 +651,12 @@ static int img_commit(int argc, char **argv)
|
|
int c, ret, flags;
|
|
int c, ret, flags;
|
|
const char *filename, *fmt, *cache;
|
|
const char *filename, *fmt, *cache;
|
|
BlockDriverState *bs;
|
|
BlockDriverState *bs;
|
|
|
|
+ bool quiet = false;
|
|
|
|
|
|
fmt = NULL;
|
|
fmt = NULL;
|
|
cache = BDRV_DEFAULT_CACHE;
|
|
cache = BDRV_DEFAULT_CACHE;
|
|
for(;;) {
|
|
for(;;) {
|
|
- c = getopt(argc, argv, "f:ht:");
|
|
|
|
|
|
+ c = getopt(argc, argv, "f:ht:q");
|
|
if (c == -1) {
|
|
if (c == -1) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -641,6 +671,9 @@ static int img_commit(int argc, char **argv)
|
|
case 't':
|
|
case 't':
|
|
cache = optarg;
|
|
cache = optarg;
|
|
break;
|
|
break;
|
|
|
|
+ case 'q':
|
|
|
|
+ quiet = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (optind >= argc) {
|
|
if (optind >= argc) {
|
|
@@ -655,14 +688,14 @@ static int img_commit(int argc, char **argv)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- bs = bdrv_new_open(filename, fmt, flags, true);
|
|
|
|
|
|
+ bs = bdrv_new_open(filename, fmt, flags, true, quiet);
|
|
if (!bs) {
|
|
if (!bs) {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
ret = bdrv_commit(bs);
|
|
ret = bdrv_commit(bs);
|
|
switch(ret) {
|
|
switch(ret) {
|
|
case 0:
|
|
case 0:
|
|
- printf("Image committed.\n");
|
|
|
|
|
|
+ qprintf(quiet, "Image committed.\n");
|
|
break;
|
|
break;
|
|
case -ENOENT:
|
|
case -ENOENT:
|
|
error_report("No disk inserted");
|
|
error_report("No disk inserted");
|
|
@@ -805,6 +838,7 @@ static int img_convert(int argc, char **argv)
|
|
const char *snapshot_name = NULL;
|
|
const char *snapshot_name = NULL;
|
|
float local_progress = 0;
|
|
float local_progress = 0;
|
|
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;
|
|
|
|
|
|
fmt = NULL;
|
|
fmt = NULL;
|
|
out_fmt = "raw";
|
|
out_fmt = "raw";
|
|
@@ -812,7 +846,7 @@ static int img_convert(int argc, char **argv)
|
|
out_baseimg = NULL;
|
|
out_baseimg = NULL;
|
|
compress = 0;
|
|
compress = 0;
|
|
for(;;) {
|
|
for(;;) {
|
|
- c = getopt(argc, argv, "f:O:B:s:hce6o:pS:t:");
|
|
|
|
|
|
+ c = getopt(argc, argv, "f:O:B:s:hce6o:pS:t:q");
|
|
if (c == -1) {
|
|
if (c == -1) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -866,9 +900,16 @@ static int img_convert(int argc, char **argv)
|
|
case 't':
|
|
case 't':
|
|
cache = optarg;
|
|
cache = optarg;
|
|
break;
|
|
break;
|
|
|
|
+ case 'q':
|
|
|
|
+ quiet = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (quiet) {
|
|
|
|
+ progress = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
bs_n = argc - optind - 1;
|
|
bs_n = argc - optind - 1;
|
|
if (bs_n < 1) {
|
|
if (bs_n < 1) {
|
|
help();
|
|
help();
|
|
@@ -897,7 +938,8 @@ static int img_convert(int argc, char **argv)
|
|
|
|
|
|
total_sectors = 0;
|
|
total_sectors = 0;
|
|
for (bs_i = 0; bs_i < bs_n; bs_i++) {
|
|
for (bs_i = 0; bs_i < bs_n; bs_i++) {
|
|
- bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt, BDRV_O_FLAGS, true);
|
|
|
|
|
|
+ bs[bs_i] = bdrv_new_open(argv[optind + bs_i], fmt, BDRV_O_FLAGS, true,
|
|
|
|
+ quiet);
|
|
if (!bs[bs_i]) {
|
|
if (!bs[bs_i]) {
|
|
error_report("Could not open '%s'", argv[optind + bs_i]);
|
|
error_report("Could not open '%s'", argv[optind + bs_i]);
|
|
ret = -1;
|
|
ret = -1;
|
|
@@ -1016,7 +1058,7 @@ static int img_convert(int argc, char **argv)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- out_bs = bdrv_new_open(out_filename, out_fmt, flags, true);
|
|
|
|
|
|
+ out_bs = bdrv_new_open(out_filename, out_fmt, flags, true, quiet);
|
|
if (!out_bs) {
|
|
if (!out_bs) {
|
|
ret = -1;
|
|
ret = -1;
|
|
goto out;
|
|
goto out;
|
|
@@ -1479,7 +1521,7 @@ static ImageInfoList *collect_image_info_list(const char *filename,
|
|
g_hash_table_insert(filenames, (gpointer)filename, NULL);
|
|
g_hash_table_insert(filenames, (gpointer)filename, NULL);
|
|
|
|
|
|
bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING,
|
|
bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING,
|
|
- false);
|
|
|
|
|
|
+ false, false);
|
|
if (!bs) {
|
|
if (!bs) {
|
|
goto err;
|
|
goto err;
|
|
}
|
|
}
|
|
@@ -1605,11 +1647,12 @@ static int img_snapshot(int argc, char **argv)
|
|
int c, ret = 0, bdrv_oflags;
|
|
int c, ret = 0, bdrv_oflags;
|
|
int action = 0;
|
|
int action = 0;
|
|
qemu_timeval tv;
|
|
qemu_timeval tv;
|
|
|
|
+ bool quiet = false;
|
|
|
|
|
|
bdrv_oflags = BDRV_O_FLAGS | BDRV_O_RDWR;
|
|
bdrv_oflags = BDRV_O_FLAGS | BDRV_O_RDWR;
|
|
/* Parse commandline parameters */
|
|
/* Parse commandline parameters */
|
|
for(;;) {
|
|
for(;;) {
|
|
- c = getopt(argc, argv, "la:c:d:h");
|
|
|
|
|
|
+ c = getopt(argc, argv, "la:c:d:hq");
|
|
if (c == -1) {
|
|
if (c == -1) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -1650,6 +1693,9 @@ static int img_snapshot(int argc, char **argv)
|
|
action = SNAPSHOT_DELETE;
|
|
action = SNAPSHOT_DELETE;
|
|
snapshot_name = optarg;
|
|
snapshot_name = optarg;
|
|
break;
|
|
break;
|
|
|
|
+ case 'q':
|
|
|
|
+ quiet = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1659,7 +1705,7 @@ static int img_snapshot(int argc, char **argv)
|
|
filename = argv[optind++];
|
|
filename = argv[optind++];
|
|
|
|
|
|
/* Open the image */
|
|
/* Open the image */
|
|
- bs = bdrv_new_open(filename, NULL, bdrv_oflags, true);
|
|
|
|
|
|
+ bs = bdrv_new_open(filename, NULL, bdrv_oflags, true, quiet);
|
|
if (!bs) {
|
|
if (!bs) {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
@@ -1719,6 +1765,7 @@ static int img_rebase(int argc, char **argv)
|
|
int c, flags, ret;
|
|
int c, flags, ret;
|
|
int unsafe = 0;
|
|
int unsafe = 0;
|
|
int progress = 0;
|
|
int progress = 0;
|
|
|
|
+ bool quiet = false;
|
|
|
|
|
|
/* Parse commandline parameters */
|
|
/* Parse commandline parameters */
|
|
fmt = NULL;
|
|
fmt = NULL;
|
|
@@ -1726,7 +1773,7 @@ static int img_rebase(int argc, char **argv)
|
|
out_baseimg = NULL;
|
|
out_baseimg = NULL;
|
|
out_basefmt = NULL;
|
|
out_basefmt = NULL;
|
|
for(;;) {
|
|
for(;;) {
|
|
- c = getopt(argc, argv, "uhf:F:b:pt:");
|
|
|
|
|
|
+ c = getopt(argc, argv, "uhf:F:b:pt:q");
|
|
if (c == -1) {
|
|
if (c == -1) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -1753,9 +1800,16 @@ static int img_rebase(int argc, char **argv)
|
|
case 't':
|
|
case 't':
|
|
cache = optarg;
|
|
cache = optarg;
|
|
break;
|
|
break;
|
|
|
|
+ case 'q':
|
|
|
|
+ quiet = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (quiet) {
|
|
|
|
+ progress = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
if ((optind >= argc) || (!unsafe && !out_baseimg)) {
|
|
if ((optind >= argc) || (!unsafe && !out_baseimg)) {
|
|
help();
|
|
help();
|
|
}
|
|
}
|
|
@@ -1777,7 +1831,7 @@ static int img_rebase(int argc, char **argv)
|
|
* Ignore the old backing file for unsafe rebase in case we want to correct
|
|
* Ignore the old backing file for unsafe rebase in case we want to correct
|
|
* the reference to a renamed or moved backing file.
|
|
* the reference to a renamed or moved backing file.
|
|
*/
|
|
*/
|
|
- bs = bdrv_new_open(filename, fmt, flags, true);
|
|
|
|
|
|
+ bs = bdrv_new_open(filename, fmt, flags, true, quiet);
|
|
if (!bs) {
|
|
if (!bs) {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
@@ -1989,6 +2043,7 @@ static int img_resize(int argc, char **argv)
|
|
int c, ret, relative;
|
|
int c, ret, relative;
|
|
const char *filename, *fmt, *size;
|
|
const char *filename, *fmt, *size;
|
|
int64_t n, total_size;
|
|
int64_t n, total_size;
|
|
|
|
+ bool quiet = false;
|
|
BlockDriverState *bs = NULL;
|
|
BlockDriverState *bs = NULL;
|
|
QemuOpts *param;
|
|
QemuOpts *param;
|
|
static QemuOptsList resize_options = {
|
|
static QemuOptsList resize_options = {
|
|
@@ -2017,7 +2072,7 @@ static int img_resize(int argc, char **argv)
|
|
/* Parse getopt arguments */
|
|
/* Parse getopt arguments */
|
|
fmt = NULL;
|
|
fmt = NULL;
|
|
for(;;) {
|
|
for(;;) {
|
|
- c = getopt(argc, argv, "f:h");
|
|
|
|
|
|
+ c = getopt(argc, argv, "f:hq");
|
|
if (c == -1) {
|
|
if (c == -1) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -2029,6 +2084,9 @@ static int img_resize(int argc, char **argv)
|
|
case 'f':
|
|
case 'f':
|
|
fmt = optarg;
|
|
fmt = optarg;
|
|
break;
|
|
break;
|
|
|
|
+ case 'q':
|
|
|
|
+ quiet = true;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (optind >= argc) {
|
|
if (optind >= argc) {
|
|
@@ -2062,7 +2120,7 @@ static int img_resize(int argc, char **argv)
|
|
n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);
|
|
n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);
|
|
qemu_opts_del(param);
|
|
qemu_opts_del(param);
|
|
|
|
|
|
- bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR, true);
|
|
|
|
|
|
+ bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR, true, quiet);
|
|
if (!bs) {
|
|
if (!bs) {
|
|
ret = -1;
|
|
ret = -1;
|
|
goto out;
|
|
goto out;
|
|
@@ -2082,7 +2140,7 @@ static int img_resize(int argc, char **argv)
|
|
ret = bdrv_truncate(bs, total_size);
|
|
ret = bdrv_truncate(bs, total_size);
|
|
switch (ret) {
|
|
switch (ret) {
|
|
case 0:
|
|
case 0:
|
|
- printf("Image resized.\n");
|
|
|
|
|
|
+ qprintf(quiet, "Image resized.\n");
|
|
break;
|
|
break;
|
|
case -ENOTSUP:
|
|
case -ENOTSUP:
|
|
error_report("This image does not support resize");
|
|
error_report("This image does not support resize");
|