Error on O_DIRECT for physical CDROM/DVD drives
PATCH 1/1 Error on O_DIRECT for physical CDROM/DVD drives
From: Jes Sorensen <[email protected]>
O_DIRECT (cache=none) requires sector alignment, however the physical sector size of CDROM/DVD drives is 2048, as opposed to most disk devices which use 512. QEMU is hard coding 512 all over the place, so allowing O_DIRECT for CDROM/DVD devices does not work. Exit with an error!
--- block/raw-posix.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
block/raw-posix.c +5 -0
@@ -1139,6 +1139,11 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)BDRVRawState *s = bs->opaque; s->type =FTYPE_CD ; +if (flags &BDRV_O_NOCACHE ) { +fprintf (stderr,"O_DIRECT (cache=none) for CDROM/DVD device (%s) " +"is unsupported\n" , filename); +exit (1 ); + }/* open will not fail even if no CD is inserted, so add O_NONBLOCK */ return raw_open_common (bs, filename, flags,O_NONBLOCK );
Signature · 1 line
1.7.1.1
Quoted 18 lines · On 07/20/10 10:09, [email protected] wrote:
From: Jes Sorensen <[email protected]>
O_DIRECT(cache=none) requires sector alignment, however the physical sector size of CDROM/DVD drives is 2048, as opposed to most disk devices which use 512. QEMU is hard coding 512 all over the place, so allowingO_DIRECTfor CDROM/DVD devices does not work. Exit with an error!Signed-off-by Jes Sorensen <[email protected]>--- block/raw-posix.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)block/raw-posix.c +0
-0
block/raw-posix.c static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) · line 1146
Quoted 8 lines
block/raw-posix.c +5
-0@@ -1139,6 +1139,11 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)BDRVRawState *s = bs->opaque; s->type =FTYPE_CD ; +if (flags &BDRV_O_NOCACHE ) { +fprintf (stderr,"O_DIRECT (cache=none) for CDROM/DVD device (%s) " +"is unsupported\n" , filename); +exit (1 ); + }
If a cdrom is added via the monitor this would abruptly terminate the VM
- which is not good.
David
Quoted 3 lines
block/raw-posix.c +0
-0/* open will not fail even if no CD is inserted, so add O_NONBLOCK */ return raw_open_common (bs, filename, flags,O_NONBLOCK );
Quoted 8 lines · David S. Ahern
Quoted 7 lines · On 07/20/10 10:09, [email protected] wrote:
block/raw-posix.c +0
-0@@ -1139,6 +1139,11 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)BDRVRawState *s = bs->opaque;
Quoted 9 lines
block/raw-posix.c static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) · line 1146
Quoted 6 lines
block/raw-posix.c +5
-0s->type =FTYPE_CD ; +if (flags &BDRV_O_NOCACHE ) { +fprintf (stderr,"O_DIRECT (cache=none) for CDROM/DVD device (%s) " +"is unsupported\n" , filename); +exit (1 ); + }If a cdrom is added via the monitor this would abruptly terminate the VM
- which is not good.
True, but this would only happen if the user explicitly marks it cache=none which is not the default value for a new drive, so it would be a corner case.
Cheers,
Jes
Quoted 19 lines · Jes Sorensen
Quoted 8 lines · David S. Ahern
Quoted 7 lines · On 07/20/10 10:09, [email protected] wrote:
block/raw-posix.c +0
-0@@ -1139,6 +1139,11 @@ static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)BDRVRawState *s = bs->opaque;Quoted 9 lines
block/raw-posix.c static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) · line 1146
Quoted 6 lines
block/raw-posix.c +5
-0s->type =FTYPE_CD ; +if (flags &BDRV_O_NOCACHE ) { +fprintf (stderr,"O_DIRECT (cache=none) for CDROM/DVD device (%s) " +"is unsupported\n" , filename); +exit (1 ); + }If a cdrom is added via the monitor this would abruptly terminate the VM
- which is not good.
Quoted 3 lines
True, but this would only happen if the user explicitly marks it cache=none which is not the default value for a new drive, so it would be a corner case.
Why not return -ENOTSUP?
Quoted 7 lines · Markus Armbruster
Quoted 5 lines · Jes Sorensen
Quoted 3 lines · David S. Ahern
On 07/20/10 10:09, [email protected] wrote:
If a cdrom is added via the monitor this would abruptly terminate the VM
- which is not good.
Quoted 5 lines
Quoted 3 lines
True, but this would only happen if the user explicitly marks it cache=none which is not the default value for a new drive, so it would be a corner case.
Why not return
-ENOTSUP?
Good point, just posted v3 of the patch that does this instead of exit()
Jes