version 1.1.1.8, 2018/04/24 17:20:53
|
version 1.1.1.9, 2018/04/24 17:34:36
|
Line 71 static void help(void)
|
Line 71 static void help(void)
|
"\n" |
"\n" |
"Command parameters:\n" |
"Command parameters:\n" |
" 'filename' is a disk image filename\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" |
" '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" |
" 'size' is the disk image size in bytes. Optional suffixes\n" |
" 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 * 1024 * 1024) are\n" |
" 'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' (gigabyte, 1024M)\n" |
" supported any 'k' or 'K' is ignored\n" |
" and T (terabyte, 1024G) are supported. 'b' is ignored.\n" |
" 'output_filename' is the destination disk image filename\n" |
" 'output_filename' is the destination disk image filename\n" |
" 'output_fmt' is the destination format\n" |
" 'output_fmt' is the destination format\n" |
" '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" |
Line 297 static int img_create(int argc, char **a
|
Line 291 static int img_create(int argc, char **a
|
return 0; |
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) { |
if (options) { |
param = parse_option_parameters(options, drv->create_options, param); |
param = parse_option_parameters(options, drv->create_options, param); |
if (param == NULL) { |
if (param == NULL) { |
error("Invalid options for file format '%s'.", fmt); |
error("Invalid options for file format '%s'.", fmt); |
} |
} |
} else { |
|
param = parse_option_parameters("", drv->create_options, param); |
|
} |
} |
|
|
/* Get the filename */ |
/* Get the filename */ |
Line 321 static int img_create(int argc, char **a
|
Line 318 static int img_create(int argc, char **a
|
|
|
// The size for the image must always be specified, with one exception: |
// 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 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 = |
QEMUOptionParameter *backing_file = |
get_option_parameter(param, BLOCK_OPT_BACKING_FILE); |
get_option_parameter(param, BLOCK_OPT_BACKING_FILE); |
Line 530 static int is_allocated_sectors(const ui
|
Line 527 static int is_allocated_sectors(const ui
|
return v; |
return v; |
} |
} |
|
|
#define IO_BUF_SIZE 65536 |
#define IO_BUF_SIZE (2 * 1024 * 1024) |
|
|
static int img_convert(int argc, char **argv) |
static int img_convert(int argc, char **argv) |
{ |
{ |
Line 610 static int img_convert(int argc, char **
|
Line 607 static int img_convert(int argc, char **
|
|
|
if (options && !strcmp(options, "?")) { |
if (options && !strcmp(options, "?")) { |
print_option_help(drv->create_options); |
print_option_help(drv->create_options); |
|
free(bs); |
return 0; |
return 0; |
} |
} |
|
|
Line 746 static int img_convert(int argc, char **
|
Line 744 static int img_convert(int argc, char **
|
if (n > bs_offset + bs_sectors - sector_num) |
if (n > bs_offset + bs_sectors - sector_num) |
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, |
/* If the output image is being created as a copy on write image, |
assume that sectors which are unallocated in the input image |
assume that sectors which are unallocated in the input image |
are present in both the output's and input's base images (no |
are present in both the output's and input's base images (no |
Line 779 static int img_convert(int argc, char **
|
Line 777 static int img_convert(int argc, char **
|
If the output is to a host device, we also write out |
If the output is to a host device, we also write out |
sectors that are entirely 0, since whatever data was |
sectors that are entirely 0, since whatever data was |
already there is garbage, not 0s. */ |
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)) { |
is_allocated_sectors(buf1, n, &n1)) { |
if (bdrv_write(out_bs, sector_num, buf1, n1) < 0) |
if (bdrv_write(out_bs, sector_num, buf1, n1) < 0) |
error("error while writing"); |
error("error while writing"); |