diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2014-05-13 10:35:46 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2014-05-13 10:35:47 +0100 |
| commit | 1b5498f6874ad661bcd9558bc2b0a4e25643a5bf (patch) | |
| tree | 08bd27ec88d368d9c7ae2b8bb5d233ab74c903a0 /qemu-img.c | |
| parent | e5bfd64050e81774b6bf71ab5dd064f7bcef0c4c (diff) | |
| parent | 5a007547df76446ab891df93ebc55749716609bf (diff) | |
| download | focaccia-qemu-1b5498f6874ad661bcd9558bc2b0a4e25643a5bf.tar.gz focaccia-qemu-1b5498f6874ad661bcd9558bc2b0a4e25643a5bf.zip | |
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request # gpg: Signature made Fri 09 May 2014 19:57:53 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: glib: fix g_poll early timeout on windows block: qemu-iotests - test for live migration block: qemu-iotests - update 085 to use common.qemu block: qemu-iotests - add common.qemu, for bash-controlled qemu tests block/raw-posix: Try both FIEMAP and SEEK_HOLE gluster: Correctly propagate errors when volume isn't accessible vl.c: remove init_clocks call from main block: Fix open flags with BDRV_O_SNAPSHOT qemu-iotests: Test converting to streamOptimized from small cluster size vmdk: Implement .bdrv_get_info() vmdk: Implement .bdrv_write_compressed qemu-img: Convert by cluster size if target is compressed block/iscsi: bump year in copyright notice block/nfs: Check for NULL server part qemu-img: sort block formats in help message iotests: Use configured python qcow2: Fix alloc_clusters_noref() overflow detection Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qemu-img.c')
| -rw-r--r-- | qemu-img.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/qemu-img.c b/qemu-img.c index 96f44638b7..04ce02aeb4 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -32,6 +32,7 @@ #include "block/block_int.h" #include "block/qapi.h" #include <getopt.h> +#include <glib.h> #define QEMU_IMG_VERSION "qemu-img version " QEMU_VERSION \ ", Copyright (c) 2004-2008 Fabrice Bellard\n" @@ -55,9 +56,25 @@ typedef enum OutputFormat { #define BDRV_O_FLAGS BDRV_O_CACHE_WB #define BDRV_DEFAULT_CACHE "writeback" -static void format_print(void *opaque, const char *name) +static gint compare_data(gconstpointer a, gconstpointer b, gpointer user) { - printf(" %s", name); + return g_strcmp0(a, b); +} + +static void print_format(gpointer data, gpointer user) +{ + printf(" %s", (char *)data); +} + +static void add_format_to_seq(void *opaque, const char *fmt_name) +{ + GSequence *seq = opaque; + + if (!g_sequence_lookup(seq, (gpointer)fmt_name, + compare_data, NULL)) { + g_sequence_insert_sorted(seq, (gpointer)fmt_name, + compare_data, NULL); + } } static void QEMU_NORETURN GCC_FMT_ATTR(1, 2) error_exit(const char *fmt, ...) @@ -142,10 +159,15 @@ static void QEMU_NORETURN help(void) " '-f' first image format\n" " '-F' second image format\n" " '-s' run in Strict mode - fail on different image size or sector allocation\n"; + GSequence *seq; printf("%s\nSupported formats:", help_msg); - bdrv_iterate_format(format_print, NULL); + seq = g_sequence_new(NULL); + bdrv_iterate_format(add_format_to_seq, seq); + g_sequence_foreach(seq, print_format, NULL); printf("\n"); + g_sequence_free(seq); + exit(EXIT_SUCCESS); } @@ -1480,6 +1502,7 @@ static int img_convert(int argc, char **argv) goto out; } } else { + compress = compress || bdi.needs_compressed_writes; cluster_sectors = bdi.cluster_size / BDRV_SECTOR_SIZE; } |