qemu-img: Deprecate obsolete -6 and -e options
If -6 or -e is specified, an error message is printed and we exit. It does not print help() to avoid the error message getting lost in the noise. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
f27aaf4b53
commit
eec77d9e71
|
@ -29,7 +29,6 @@
|
||||||
#include "qemu-queue.h"
|
#include "qemu-queue.h"
|
||||||
|
|
||||||
#define BLOCK_FLAG_ENCRYPT 1
|
#define BLOCK_FLAG_ENCRYPT 1
|
||||||
#define BLOCK_FLAG_COMPRESS 2
|
|
||||||
#define BLOCK_FLAG_COMPAT6 4
|
#define BLOCK_FLAG_COMPAT6 4
|
||||||
|
|
||||||
#define BLOCK_OPT_SIZE "size"
|
#define BLOCK_OPT_SIZE "size"
|
||||||
|
|
53
qemu-img.c
53
qemu-img.c
|
@ -261,21 +261,9 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_old_style_options(const char *fmt, QEMUOptionParameter *list,
|
static int add_old_style_options(const char *fmt, QEMUOptionParameter *list,
|
||||||
int flags, const char *base_filename, const char *base_fmt)
|
const char *base_filename,
|
||||||
|
const char *base_fmt)
|
||||||
{
|
{
|
||||||
if (flags & BLOCK_FLAG_ENCRYPT) {
|
|
||||||
if (set_option_parameter(list, BLOCK_OPT_ENCRYPT, "on")) {
|
|
||||||
error("Encryption not supported for file format '%s'", fmt);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (flags & BLOCK_FLAG_COMPAT6) {
|
|
||||||
if (set_option_parameter(list, BLOCK_OPT_COMPAT6, "on")) {
|
|
||||||
error("VMDK version 6 not supported for file format '%s'", fmt);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (base_filename) {
|
if (base_filename) {
|
||||||
if (set_option_parameter(list, BLOCK_OPT_BACKING_FILE, base_filename)) {
|
if (set_option_parameter(list, BLOCK_OPT_BACKING_FILE, base_filename)) {
|
||||||
error("Backing file not supported for file format '%s'", fmt);
|
error("Backing file not supported for file format '%s'", fmt);
|
||||||
|
@ -293,7 +281,7 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list,
|
||||||
|
|
||||||
static int img_create(int argc, char **argv)
|
static int img_create(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c, ret = 0, flags;
|
int c, ret = 0;
|
||||||
const char *fmt = "raw";
|
const char *fmt = "raw";
|
||||||
const char *base_fmt = NULL;
|
const char *base_fmt = NULL;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
@ -302,7 +290,6 @@ static int img_create(int argc, char **argv)
|
||||||
QEMUOptionParameter *param = NULL, *create_options = NULL;
|
QEMUOptionParameter *param = NULL, *create_options = NULL;
|
||||||
char *options = NULL;
|
char *options = NULL;
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
c = getopt(argc, argv, "F:b:f:he6o:");
|
c = getopt(argc, argv, "F:b:f:he6o:");
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
|
@ -323,11 +310,13 @@ static int img_create(int argc, char **argv)
|
||||||
fmt = optarg;
|
fmt = optarg;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
flags |= BLOCK_FLAG_ENCRYPT;
|
error("qemu-img: option -e is deprecated, please use \'-o "
|
||||||
break;
|
"encryption\' instead!");
|
||||||
|
return 1;
|
||||||
case '6':
|
case '6':
|
||||||
flags |= BLOCK_FLAG_COMPAT6;
|
error("qemu-img: option -6 is deprecated, please use \'-o "
|
||||||
break;
|
"compat6\' instead!");
|
||||||
|
return 1;
|
||||||
case 'o':
|
case 'o':
|
||||||
options = optarg;
|
options = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -385,7 +374,7 @@ static int img_create(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add old-style options to parameters */
|
/* Add old-style options to parameters */
|
||||||
ret = add_old_style_options(fmt, param, flags, base_filename, base_fmt);
|
ret = add_old_style_options(fmt, param, base_filename, base_fmt);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -674,7 +663,7 @@ static int compare_sectors(const uint8_t *buf1, const uint8_t *buf2, int n,
|
||||||
|
|
||||||
static int img_convert(int argc, char **argv)
|
static int img_convert(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c, ret = 0, n, n1, bs_n, bs_i, flags, cluster_size, cluster_sectors;
|
int c, ret = 0, n, n1, bs_n, bs_i, compress, cluster_size, cluster_sectors;
|
||||||
const char *fmt, *out_fmt, *out_baseimg, *out_filename;
|
const char *fmt, *out_fmt, *out_baseimg, *out_filename;
|
||||||
BlockDriver *drv, *proto_drv;
|
BlockDriver *drv, *proto_drv;
|
||||||
BlockDriverState **bs = NULL, *out_bs = NULL;
|
BlockDriverState **bs = NULL, *out_bs = NULL;
|
||||||
|
@ -691,7 +680,7 @@ static int img_convert(int argc, char **argv)
|
||||||
fmt = NULL;
|
fmt = NULL;
|
||||||
out_fmt = "raw";
|
out_fmt = "raw";
|
||||||
out_baseimg = NULL;
|
out_baseimg = NULL;
|
||||||
flags = 0;
|
compress = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
c = getopt(argc, argv, "f:O:B:s:hce6o:");
|
c = getopt(argc, argv, "f:O:B:s:hce6o:");
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
|
@ -712,14 +701,16 @@ static int img_convert(int argc, char **argv)
|
||||||
out_baseimg = optarg;
|
out_baseimg = optarg;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
flags |= BLOCK_FLAG_COMPRESS;
|
compress = 1;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
flags |= BLOCK_FLAG_ENCRYPT;
|
error("qemu-img: option -e is deprecated, please use \'-o "
|
||||||
break;
|
"encryption\' instead!");
|
||||||
|
return 1;
|
||||||
case '6':
|
case '6':
|
||||||
flags |= BLOCK_FLAG_COMPAT6;
|
error("qemu-img: option -6 is deprecated, please use \'-o "
|
||||||
break;
|
"compat6\' instead!");
|
||||||
|
return 1;
|
||||||
case 'o':
|
case 'o':
|
||||||
options = optarg;
|
options = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -806,7 +797,7 @@ static int img_convert(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
set_option_parameter_int(param, BLOCK_OPT_SIZE, total_sectors * 512);
|
set_option_parameter_int(param, BLOCK_OPT_SIZE, total_sectors * 512);
|
||||||
ret = add_old_style_options(out_fmt, param, flags, out_baseimg, NULL);
|
ret = add_old_style_options(out_fmt, param, out_baseimg, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -818,7 +809,7 @@ static int img_convert(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if compression is supported */
|
/* Check if compression is supported */
|
||||||
if (flags & BLOCK_FLAG_COMPRESS) {
|
if (compress) {
|
||||||
QEMUOptionParameter *encryption =
|
QEMUOptionParameter *encryption =
|
||||||
get_option_parameter(param, BLOCK_OPT_ENCRYPT);
|
get_option_parameter(param, BLOCK_OPT_ENCRYPT);
|
||||||
|
|
||||||
|
@ -860,7 +851,7 @@ static int img_convert(int argc, char **argv)
|
||||||
bdrv_get_geometry(bs[0], &bs_sectors);
|
bdrv_get_geometry(bs[0], &bs_sectors);
|
||||||
buf = qemu_malloc(IO_BUF_SIZE);
|
buf = qemu_malloc(IO_BUF_SIZE);
|
||||||
|
|
||||||
if (flags & BLOCK_FLAG_COMPRESS) {
|
if (compress) {
|
||||||
ret = bdrv_get_info(out_bs, &bdi);
|
ret = bdrv_get_info(out_bs, &bdi);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error("could not get block driver info");
|
error("could not get block driver info");
|
||||||
|
|
Loading…
Reference in New Issue