qemu-img: Deprecate obsolete -6 and -e options
PATCH 1/1 qemu-img: Deprecate obsolete -6 and -e options
From: Jes Sorensen <[email protected]>
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.
--- block_int.h | 1 - qemu-img.c | 53 ++++++++++++++++++++++------------------------------- 2 files changed, 22 insertions(+), 32 deletions(-)
block_int.h +0 -1
@@ -29,7 +29,6 @@#include "qemu-queue.h" #define BLOCK_FLAG_ENCRYPT 1 -#define BLOCK_FLAG_COMPRESS 2#define BLOCK_FLAG_COMPAT6 4#define BLOCK_OPT_SIZE "size"
qemu-img.c +22 -31
124 lines not on this page · raw message
Signature · 1 line
1.7.3.2
Am 07.12.2010 12:31, schrieb [email protected]:
Quoted 70 lines
From: Jes Sorensen <[email protected]>
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 <[email protected]>--- block_int.h | 1 - qemu-img.c | 53 ++++++++++++++++++++++------------------------------- 2 files changed, 22 insertions(+), 32 deletions(-)block_int.h +0
-1@@ -29,7 +29,6 @@#include "qemu-queue.h" #define BLOCK_FLAG_ENCRYPT 1 -#define BLOCK_FLAG_COMPRESS 2#define BLOCK_FLAG_COMPAT6 4#define BLOCK_OPT_SIZE "size"qemu-img.c +3
-16@@ -261,21 +261,9 @@ fail: }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 (set_option_parameter (list,BLOCK_OPT_BACKING_FILE , base_filename)) {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) { -int c, ret =0 , flags; +int c, ret =0 ;const char *fmt ="raw" ;const char *base_fmt =NULL ;const char *filename;@@ -302,7 +290,6 @@ static int img_create(int argc, char **argv)QEMUOptionParameter *param =NULL , *create_options =NULL ;char *options =NULL ; - flags =0 ;for (;;) { c =getopt (argc, argv,"F:b:f:he6o:" );if (c ==-1 ) {
qemu-img.c static int img_create(int argc, char **argv) · line 315
Quoted 8 lines
qemu-img.c +3
-2@@ -323,11 +310,13 @@ static int img_create(int argc, char **argv) fmt = optarg;break ;case 'e' : - flags |=BLOCK_FLAG_ENCRYPT ; -break ; +printf ("qemu-img: option -e is deprecated, please use \'-o " +"encryption\' instead!\n" ); +return -1 ;
The return value of this function is used as exit code of qemu-img, so 1 is probably better than -1.
Also, is there a reason why you use printf and not error (which writes the message to stderr)?
Kevin
Quoted 13 lines · Kevin Wolf
qemu-img.c static int img_create(int argc, char **argv) · line 315
Quoted 9 lines
qemu-img.c +3
-2@@ -323,11 +310,13 @@ static int img_create(int argc, char **argv) fmt = optarg;break ;case 'e' : - flags |=BLOCK_FLAG_ENCRYPT ; -break ; +printf ("qemu-img: option -e is deprecated, please use \'-o " +"encryption\' instead!\n" ); +return -1 ;The return value of this function is used as exit code of qemu-img, so 1 is probably better than -1.
Quoted 2 lines
Also, is there a reason why you use printf and not error (which writes the message to stderr)?
I looked for fprintf(stderr.... and found nothing so I used printf() instead. I'm happy to change it to use error() and the return value too.
Thanks for the feedback.
Cheers,
Jes