]> git.proxmox.com Git - qemu.git/blobdiff - qemu-img.c
list MST as pci layer maintainer
[qemu.git] / qemu-img.c
index b317305ff33cb59b07413d3035c7c293ca4570a7..1d97f2ebfb02f5c99d5c34570c9574b70f5bb8c3 100644 (file)
 #include <windows.h>
 #endif
 
-typedef struct img_cmd {
+typedef struct img_cmd_t {
     const char *name;
     int (*handler)(int argc, char **argv);
-} a_img_cmd;
+} img_cmd_t;
 
 /* Default to cache=writeback as data integrity is not important for qemu-tcg. */
 #define BRDV_O_FLAGS BDRV_O_CACHE_WB
@@ -71,16 +71,10 @@ static void help(void)
            "\n"
            "Command parameters:\n"
            "  'filename' is a disk image filename\n"
-           "  'base_image' is the read-only disk image which is used as base for a copy on\n"
-           "    write image; the copy on write image only stores the modified data\n"
-           "  'output_base_image' forces the output image to be created as a copy on write\n"
-           "    image of the specified base image; 'output_base_image' should have the same\n"
-           "    content as the input's base image, however the path, image format, etc may\n"
-           "    differ\n"
            "  'fmt' is the disk image format. It is guessed automatically in most cases\n"
-           "  'size' is the disk image size in kilobytes. Optional suffixes\n"
-           "    'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 * 1024 * 1024) are\n"
-           "    supported any 'k' or 'K' is ignored\n"
+           "  'size' is the disk image size in bytes. Optional suffixes\n"
+           "    'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)\n"
+           "    and T (terabyte, 1024G) are supported. 'b' is ignored.\n"
            "  'output_filename' is the destination disk image filename\n"
            "  'output_fmt' is the destination format\n"
            "  'options' is a comma separated list of format specific options in a\n"
@@ -297,13 +291,16 @@ static int img_create(int argc, char **argv)
         return 0;
     }
 
+    /* Create parameter list with default values */
+    param = parse_option_parameters("", drv->create_options, param);
+    set_option_parameter_int(param, BLOCK_OPT_SIZE, -1);
+
+    /* Parse -o options */
     if (options) {
         param = parse_option_parameters(options, drv->create_options, param);
         if (param == NULL) {
             error("Invalid options for file format '%s'.", fmt);
         }
-    } else {
-        param = parse_option_parameters("", drv->create_options, param);
     }
 
     /* Get the filename */
@@ -321,7 +318,7 @@ static int img_create(int argc, char **argv)
 
     // The size for the image must always be specified, with one exception:
     // If we are using a backing file, we can obtain the size from there
-    if (get_option_parameter(param, BLOCK_OPT_SIZE)->value.n == 0) {
+    if (get_option_parameter(param, BLOCK_OPT_SIZE)->value.n == -1) {
 
         QEMUOptionParameter *backing_file =
             get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
@@ -530,7 +527,7 @@ static int is_allocated_sectors(const uint8_t *buf, int n, int *pnum)
     return v;
 }
 
-#define IO_BUF_SIZE 65536
+#define IO_BUF_SIZE (2 * 1024 * 1024)
 
 static int img_convert(int argc, char **argv)
 {
@@ -610,6 +607,7 @@ static int img_convert(int argc, char **argv)
 
     if (options && !strcmp(options, "?")) {
         print_option_help(drv->create_options);
+        free(bs);
         return 0;
     }
 
@@ -746,7 +744,7 @@ static int img_convert(int argc, char **argv)
             if (n > bs_offset + bs_sectors - sector_num)
                 n = bs_offset + bs_sectors - sector_num;
 
-            if (strcmp(drv->format_name, "host_device")) {
+            if (!drv->no_zero_init) {
                 /* If the output image is being created as a copy on write image,
                    assume that sectors which are unallocated in the input image
                    are present in both the output's and input's base images (no
@@ -779,7 +777,7 @@ static int img_convert(int argc, char **argv)
                    If the output is to a host device, we also write out
                    sectors that are entirely 0, since whatever data was
                    already there is garbage, not 0s. */
-                if (strcmp(drv->format_name, "host_device") == 0 || out_baseimg ||
+                if (drv->no_zero_init || out_baseimg ||
                     is_allocated_sectors(buf1, n, &n1)) {
                     if (bdrv_write(out_bs, sector_num, buf1, n1) < 0)
                         error("error while writing");
@@ -1035,7 +1033,7 @@ static int img_snapshot(int argc, char **argv)
     return 0;
 }
 
-static const a_img_cmd img_cmds[] = {
+static const img_cmd_t img_cmds[] = {
 #define DEF(option, callback, arg_string)        \
     { option, callback },
 #include "qemu-img-cmds.h"
@@ -1046,7 +1044,7 @@ static const a_img_cmd img_cmds[] = {
 
 int main(int argc, char **argv)
 {
-    const a_img_cmd *cmd;
+    const img_cmd_t *cmd;
     const char *cmdname;
 
     bdrv_init();