block: kill BDRV_O_CREAT
PATCH v2 2/2 block: kill BDRV_O_CREAT
The BDRV_O_CREAT option is unused inside qemu and partially duplicates the bdrv_create method. Remove it, and the -C option to qemu-io which isn't used in qemu-iotests anyway.
block.h +0 -1
@@ -28,7 +28,6 @@ typedef struct QEMUSnapshotInfo { } QEMUSnapshotInfo;#define BDRV_O_RDWR 0x0002 -#define BDRV_O_CREAT 0x0004/* create an empty file */ #define BDRV_O_SNAPSHOT 0x0008/* open the file read only and save writes in a snapshot */ #define BDRV_O_FILE 0x0010/* open as a raw file (do not try to use a disk image format on top of
block/nbd.c +0 -3
@@ -49,9 +49,6 @@ static int nbd_open(BlockDriverState *bssize_t blocksize;int ret; -if ((flags &BDRV_O_CREAT )) -return -EINVAL ; -if (!strstart (filename,"nbd:" , &host))return -EINVAL ;
block/raw-posix.c +1 -5
@@ -205,13 +205,9 @@ out_close:static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque; -int open_flags =0 ; s->type =FTYPE_FILE ; -if (flags &BDRV_O_CREAT ) - open_flags =O_CREAT |O_TRUNC ; - -return raw_open_common (bs, filename, flags, open_flags); +return raw_open_common (bs, filename, flags,0 ); }/* XXX: use host sector size if necessary with:
block/raw-win32.c +3 -7
@@ -76,7 +76,7 @@ static int set_sparse(int fd)static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque; -int access_flags, create_flags; +int access_flags;DWORD overlapped; s->type =FTYPE_FILE ;
@@ -86,11 +86,7 @@ static int raw_open(BlockDriverState *bs }else { access_flags =GENERIC_READ ; } -if (flags &BDRV_O_CREAT ) { - create_flags =CREATE_ALWAYS ; - }else { - create_flags =OPEN_EXISTING ; - } + overlapped =FILE_ATTRIBUTE_NORMAL ;if ((flags &BDRV_O_NOCACHE )) overlapped |=FILE_FLAG_NO_BUFFERING |FILE_FLAG_WRITE_THROUGH ;
@@ -98,7 +94,7 @@ static int raw_open(BlockDriverState *bs overlapped |=FILE_FLAG_WRITE_THROUGH ; s->hfile =CreateFile (filename, access_flags,FILE_SHARE_READ ,NULL , - create_flags, overlapped,NULL ); +OPEN_EXISTING , overlapped,NULL );if (s->hfile ==INVALID_HANDLE_VALUE ) {int err =GetLastError ();
qemu-io.c +3 -12
@@ -1307,7 +1307,6 @@ open_help(void)" 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\n" "\n" " Opens a file for subsequent use by all of the other qemu-io commands.\n" -" -C, -- create new file if it doesn't exist\n" " -r, -- open file read-only\n" " -s, -- use snapshot file\n" " -n, -- disable host cache\n"
@@ -1337,7 +1336,7 @@ open_f(int argc, char **argv)int growable =0 ;int c; -while ((c =getopt (argc, argv,"snCrg" )) !=EOF ) { +while ((c =getopt (argc, argv,"snrg" )) !=EOF ) {switch (c) {case 's' : flags |=BDRV_O_SNAPSHOT ;
@@ -1345,9 +1344,6 @@ open_f(int argc, char **argv)case 'n' : flags |=BDRV_O_NOCACHE ;break ; -case 'C' : - flags |=BDRV_O_CREAT ; -break ;case 'r' : readonly =1 ;break ;
@@ -1395,10 +1391,9 @@ init_check_command(static void usage (const char *name) {printf ( -"Usage: %s [-h] [-V] [-Crsnm] [-c cmd] ... [file]\n" +"Usage: %s [-h] [-V] [-rsnm] [-c cmd] ... [file]\n" "QEMU Disk exerciser\n" "\n" -" -C, --create create new file if it doesn't exist\n" " -c, --cmd command to execute\n" " -r, --read-only export read-only\n" " -s, --snapshot use snapshot file\n"
@@ -1417,13 +1412,12 @@ int main(int argc, char **argv) {int readonly =0 ;int growable =0 ; -const char *sopt ="hVc:Crsnmgk" ; +const char *sopt ="hVc:rsnmgk" ;const struct option lopt[] = { {"help" ,0 ,NULL ,'h' }, {"version" ,0 ,NULL ,'V' }, {"offset" ,1 ,NULL ,'o' }, {"cmd" ,1 ,NULL ,'c' }, - {"create" ,0 ,NULL ,'C' }, {"read-only" ,0 ,NULL ,'r' }, {"snapshot" ,0 ,NULL ,'s' }, {"nocache" ,0 ,NULL ,'n' },
@@ -1449,9 +1443,6 @@ int main(int argc, char **argv)case 'c' :add_user_command (optarg);break ; -case 'C' : - flags |=BDRV_O_CREAT ; -break ;case 'r' : readonly =1 ;break ;
Anthony, any reason you didn't pick this one up? Is the -C option important enough to reimplement is using bdrv_create?
Quoted 146 lines · Christoph Hellwig
The
BDRV_O_CREAToption is unused inside qemu and partially duplicates thebdrv_createmethod. Remove it, and the -C option to qemu-io which isn't used in qemu-iotests anyway.Signed-off-by Christoph Hellwig <[email protected]>Index:
qemu/block.h
===================================================================block.h +0
-1@@ -28,7 +28,6 @@ typedef struct QEMUSnapshotInfo { } QEMUSnapshotInfo;#define BDRV_O_RDWR 0x0002 -#define BDRV_O_CREAT 0x0004/* create an empty file */ #define BDRV_O_SNAPSHOT 0x0008/* open the file read only and save writes in a snapshot */ #define BDRV_O_FILE 0x0010/* open as a raw file (do not try to use a disk image format on top of Index:
qemu/block/nbd.c
===================================================================block/nbd.c +0
-3@@ -49,9 +49,6 @@ static int nbd_open(BlockDriverState *bssize_t blocksize;int ret; -if ((flags &BDRV_O_CREAT )) -return -EINVAL ; -if (!strstart (filename,"nbd:" , &host))return -EINVAL ;Index:
qemu/block/raw-posix.c
===================================================================block/raw-posix.c +1
-5@@ -205,13 +205,9 @@ out_close:static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque; -int open_flags =0 ; s->type =FTYPE_FILE ; -if (flags &BDRV_O_CREAT ) - open_flags =O_CREAT |O_TRUNC ; - -return raw_open_common (bs, filename, flags, open_flags); +return raw_open_common (bs, filename, flags,0 ); }/* XXX: use host sector size if necessary with: Index:
qemu/block/raw-win32.c
===================================================================block/raw-win32.c +3
-7@@ -76,7 +76,7 @@ static int set_sparse(int fd)static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque; -int access_flags, create_flags; +int access_flags;DWORD overlapped; s->type =FTYPE_FILE ;@@ -86,11 +86,7 @@ static int raw_open(BlockDriverState *bs }else { access_flags =GENERIC_READ ; } -if (flags &BDRV_O_CREAT ) { - create_flags =CREATE_ALWAYS ; - }else { - create_flags =OPEN_EXISTING ; - } + overlapped =FILE_ATTRIBUTE_NORMAL ;if ((flags &BDRV_O_NOCACHE )) overlapped |=FILE_FLAG_NO_BUFFERING |FILE_FLAG_WRITE_THROUGH ;@@ -98,7 +94,7 @@ static int raw_open(BlockDriverState *bs overlapped |=FILE_FLAG_WRITE_THROUGH ; s->hfile =CreateFile (filename, access_flags,FILE_SHARE_READ ,NULL , - create_flags, overlapped,NULL ); +OPEN_EXISTING , overlapped,NULL );if (s->hfile ==INVALID_HANDLE_VALUE ) {int err =GetLastError ();Index:
qemu/qemu-io.c
===================================================================qemu-io.c +3
-9@@ -1307,7 +1307,6 @@ open_help(void)" 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\n" "\n" " Opens a file for subsequent use by all of the other qemu-io commands.\n" -" -C, -- create new file if it doesn't exist\n" " -r, -- open file read-only\n" " -s, -- use snapshot file\n" " -n, -- disable host cache\n" @@ -1337,7 +1336,7 @@ open_f(int argc, char **argv)int growable =0 ;int c; -while ((c =getopt (argc, argv,"snCrg" )) !=EOF ) { +while ((c =getopt (argc, argv,"snrg" )) !=EOF ) {switch (c) {case 's' : flags |=BDRV_O_SNAPSHOT ;@@ -1345,9 +1344,6 @@ open_f(int argc, char **argv)case 'n' : flags |=BDRV_O_NOCACHE ;break ; -case 'C' : - flags |=BDRV_O_CREAT ; -break ;case 'r' : readonly =1 ;break ;@@ -1395,10 +1391,9 @@ init_check_command(static void usage (const char *name) {printf ( -"Usage: %s [-h] [-V] [-Crsnm] [-c cmd] ... [file]\n" +"Usage: %s [-h] [-V] [-rsnm] [-c cmd] ... [file]\n" "QEMU Disk exerciser\n" "\n" -" -C, --create create new file if it doesn't exist\n" " -c, --cmd command to execute\n" " -r, --read-only export read-only\n" " -s, --snapshot use snapshot file\n"@@ -1417,13 +1412,12 @@ int main(int argc, char **argv) {int readonly =0 ;int growable =0 ; -const char *sopt ="hVc:Crsnmgk" ; +const char *sopt ="hVc:rsnmgk" ;const struct option lopt[] = { {"help" ,0 ,NULL ,'h' }, {"version" ,0 ,NULL ,'V' }, {"offset" ,1 ,NULL ,'o' }, {"cmd" ,1 ,NULL ,'c' }, - {"create" ,0 ,NULL ,'C' }, {"read-only" ,0 ,NULL ,'r' }, {"snapshot" ,0 ,NULL ,'s' }, {"nocache" ,0 ,NULL ,'n' },
qemu-io.c int main(int argc, char **argv) · line 1448
Quoted 9 lines
qemu-io.c +0
-3@@ -1449,9 +1443,6 @@ int main(int argc, char **argv)case 'c' :add_user_command (optarg);break ; -case 'C' : - flags |=BDRV_O_CREAT ; -break ;case 'r' : readonly =1 ;break ;
---end quoted text---
Quoted 3 lines · Christoph Hellwig
Anthony, any reason you didn't pick this one up? Is the -C option important enough to reimplement is using
bdrv_create?
I did. See below.
commit 9a2d77ad0dd6b3e93669543b846a75c02878eba7
Author: Christoph Hellwig <[email protected]> Date: Wed Jan 20 18:13:42 2010 +0100
block: kill BDRV_O_CREAT
The BDRV_O_CREAT option is unused inside qemu and partially duplicates the bdrv_create method. Remove it, and the -C option to qemu-io which isn't used in qemu-iotests anyway.
Regards,
Anthony Liguori
Quoted 160 lines · Christoph Hellwig
Quoted 148 lines
The
BDRV_O_CREAToption is unused inside qemu and partially duplicates thebdrv_createmethod. Remove it, and the -C option to qemu-io which isn't used in qemu-iotests anyway.Signed-off-by Christoph Hellwig<[email protected]>Index:
qemu/block.h
===================================================================block.h +0
-1@@ -28,7 +28,6 @@ typedef struct QEMUSnapshotInfo { } QEMUSnapshotInfo;#define BDRV_O_RDWR 0x0002 -#define BDRV_O_CREAT 0x0004/* create an empty file */ #define BDRV_O_SNAPSHOT 0x0008/* open the file read only and save writes in a snapshot */ #define BDRV_O_FILE 0x0010/* open as a raw file (do not try to use a disk image format on top of Index:
qemu/block/nbd.c
===================================================================block/nbd.c +0
-3@@ -49,9 +49,6 @@ static int nbd_open(BlockDriverState *bssize_t blocksize;int ret; -if ((flags&BDRV_O_CREAT )) -return -EINVAL ; -if (!strstart (filename,"nbd:" ,&host))return -EINVAL ;Index:
qemu/block/raw-posix.c
===================================================================block/raw-posix.c +1
-5@@ -205,13 +205,9 @@ out_close:static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque; -int open_flags =0 ; s->type =FTYPE_FILE ; -if (flags&BDRV_O_CREAT ) - open_flags =O_CREAT |O_TRUNC ; - -return raw_open_common (bs, filename, flags, open_flags); +return raw_open_common (bs, filename, flags,0 ); }/* XXX: use host sector size if necessary with: Index:
qemu/block/raw-win32.c
===================================================================block/raw-win32.c +3
-7@@ -76,7 +76,7 @@ static int set_sparse(int fd)static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque; -int access_flags, create_flags; +int access_flags;DWORD overlapped; s->type =FTYPE_FILE ;@@ -86,11 +86,7 @@ static int raw_open(BlockDriverState *bs }else { access_flags =GENERIC_READ ; } -if (flags&BDRV_O_CREAT ) { - create_flags =CREATE_ALWAYS ; - }else { - create_flags =OPEN_EXISTING ; - } + overlapped =FILE_ATTRIBUTE_NORMAL ;if ((flags&BDRV_O_NOCACHE )) overlapped |=FILE_FLAG_NO_BUFFERING |FILE_FLAG_WRITE_THROUGH ;@@ -98,7 +94,7 @@ static int raw_open(BlockDriverState *bs overlapped |=FILE_FLAG_WRITE_THROUGH ; s->hfile =CreateFile (filename, access_flags,FILE_SHARE_READ ,NULL , - create_flags, overlapped,NULL ); +OPEN_EXISTING , overlapped,NULL );if (s->hfile ==INVALID_HANDLE_VALUE ) {int err =GetLastError ();Index:
qemu/qemu-io.c
===================================================================qemu-io.c +3
-9@@ -1307,7 +1307,6 @@ open_help(void)" 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\n" "\n" " Opens a file for subsequent use by all of the other qemu-io commands.\n" -" -C, -- create new file if it doesn't exist\n" " -r, -- open file read-only\n" " -s, -- use snapshot file\n" " -n, -- disable host cache\n" @@ -1337,7 +1336,7 @@ open_f(int argc, char **argv)int growable =0 ;int c; -while ((c =getopt (argc, argv,"snCrg" )) !=EOF ) { +while ((c =getopt (argc, argv,"snrg" )) !=EOF ) {switch (c) {case 's' : flags |=BDRV_O_SNAPSHOT ;@@ -1345,9 +1344,6 @@ open_f(int argc, char **argv)case 'n' : flags |=BDRV_O_NOCACHE ;break ; -case 'C' : - flags |=BDRV_O_CREAT ; -break ;case 'r' : readonly =1 ;break ;@@ -1395,10 +1391,9 @@ init_check_command(static void usage (const char *name) {printf ( -"Usage: %s [-h] [-V] [-Crsnm] [-c cmd] ... [file]\n" +"Usage: %s [-h] [-V] [-rsnm] [-c cmd] ... [file]\n" "QEMU Disk exerciser\n" "\n" -" -C, --create create new file if it doesn't exist\n" " -c, --cmd command to execute\n" " -r, --read-only export read-only\n" " -s, --snapshot use snapshot file\n"@@ -1417,13 +1412,12 @@ int main(int argc, char **argv) {int readonly =0 ;int growable =0 ; -const char *sopt ="hVc:Crsnmgk" ; +const char *sopt ="hVc:rsnmgk" ;const struct option lopt[] = { {"help" ,0 ,NULL ,'h' }, {"version" ,0 ,NULL ,'V' }, {"offset" ,1 ,NULL ,'o' }, {"cmd" ,1 ,NULL ,'c' }, - {"create" ,0 ,NULL ,'C' }, {"read-only" ,0 ,NULL ,'r' }, {"snapshot" ,0 ,NULL ,'s' }, {"nocache" ,0 ,NULL ,'n' },qemu-io.c int main(int argc, char **argv) · line 1448
Quoted 9 lines
qemu-io.c +0
-3@@ -1449,9 +1443,6 @@ int main(int argc, char **argv)case 'c' :add_user_command (optarg);break ; -case 'C' : - flags |=BDRV_O_CREAT ; -break ;case 'r' : readonly =1 ;break ;---end quoted text---