* [Qemu-devel] [PATCH 0/2] Subject: [PATCH 0/2] raw-posix block driver fixes (v2)
@ 2009-06-16 13:21 Avi Kivity
2009-06-16 13:21 ` [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace Avi Kivity
2009-06-16 13:21 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
0 siblings, 2 replies; 6+ messages in thread
From: Avi Kivity @ 2009-06-16 13:21 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Christoph Hellwig
Fix the recent regression opening read-only files as well as using the
wrong constants for open flags.
Changes since v1:
- use O_ACCMODE unconditionally to clear the previous access mode, instead
of O_RDWR
Avi Kivity (2):
raw-posix: open flags use BDRV_ namespace, not posix namespace
raw-posix: Remove O_RDWR when attempting to open a file read-only
block/raw-posix.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace
2009-06-16 13:21 [Qemu-devel] [PATCH 0/2] Subject: [PATCH 0/2] raw-posix block driver fixes (v2) Avi Kivity
@ 2009-06-16 13:21 ` Avi Kivity
2009-06-16 13:28 ` [Qemu-devel] " Christoph Hellwig
2009-06-16 13:21 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
1 sibling, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2009-06-16 13:21 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Christoph Hellwig
The flags argument to raw_common_open() contain bits defined by the BDRV_O_*
namespace, not the posix O_* namespace.
Adjust to use the correct constants.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
block/raw-posix.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 5032348..5790206 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -133,7 +133,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
s->lseek_err_cnt = 0;
s->open_flags |= O_BINARY;
- if ((flags & BDRV_O_ACCESS) == O_RDWR) {
+ if ((flags & BDRV_O_ACCESS) == BDRV_O_RDWR) {
s->open_flags |= O_RDWR;
} else {
s->open_flags |= O_RDONLY;
--
1.6.0.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only
2009-06-16 13:21 [Qemu-devel] [PATCH 0/2] Subject: [PATCH 0/2] raw-posix block driver fixes (v2) Avi Kivity
2009-06-16 13:21 ` [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace Avi Kivity
@ 2009-06-16 13:21 ` Avi Kivity
2009-06-16 13:29 ` [Qemu-devel] " Christoph Hellwig
1 sibling, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2009-06-16 13:21 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Christoph Hellwig
When we open a file, we first attempt to open it read-write, then fall back
to read-only. Unfortunately we reuse the flags from the previous attempt,
so both attempts try to open the file with write permissions, and fail.
Fix by clearing the O_RDWR flag from the previous attempt.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
block/raw-posix.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 5790206..ccb014a 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -133,6 +133,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
s->lseek_err_cnt = 0;
s->open_flags |= O_BINARY;
+ s->open_flags &= ~O_ACCMODE;
if ((flags & BDRV_O_ACCESS) == BDRV_O_RDWR) {
s->open_flags |= O_RDWR;
} else {
--
1.6.0.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace
2009-06-16 13:21 ` [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace Avi Kivity
@ 2009-06-16 13:28 ` Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2009-06-16 13:28 UTC (permalink / raw)
To: Avi Kivity; +Cc: qemu-devel, Christoph Hellwig
On Tue, Jun 16, 2009 at 04:21:08PM +0300, Avi Kivity wrote:
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 5032348..5790206 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -133,7 +133,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
> s->lseek_err_cnt = 0;
>
> s->open_flags |= O_BINARY;
> - if ((flags & BDRV_O_ACCESS) == O_RDWR) {
> + if ((flags & BDRV_O_ACCESS) == BDRV_O_RDWR) {
> s->open_flags |= O_RDWR;
> } else {
> s->open_flags |= O_RDONLY;
Looks good.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only
2009-06-16 13:21 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
@ 2009-06-16 13:29 ` Christoph Hellwig
2009-06-16 21:18 ` Christoph Hellwig
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2009-06-16 13:29 UTC (permalink / raw)
To: Avi Kivity; +Cc: qemu-devel, Christoph Hellwig
On Tue, Jun 16, 2009 at 04:21:09PM +0300, Avi Kivity wrote:
> When we open a file, we first attempt to open it read-write, then fall back
> to read-only. Unfortunately we reuse the flags from the previous attempt,
> so both attempts try to open the file with write permissions, and fail.
>
> Fix by clearing the O_RDWR flag from the previous attempt.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
> block/raw-posix.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 5790206..ccb014a 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -133,6 +133,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
> s->lseek_err_cnt = 0;
>
> s->open_flags |= O_BINARY;
> + s->open_flags &= ~O_ACCMODE;
> if ((flags & BDRV_O_ACCESS) == BDRV_O_RDWR) {
> s->open_flags |= O_RDWR;
> } else {
Also looks good.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] Re: [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only
2009-06-16 13:29 ` [Qemu-devel] " Christoph Hellwig
@ 2009-06-16 21:18 ` Christoph Hellwig
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2009-06-16 21:18 UTC (permalink / raw)
To: Avi Kivity; +Cc: qemu-devel, Christoph Hellwig
On Tue, Jun 16, 2009 at 03:29:16PM +0200, Christoph Hellwig wrote:
> Also looks good.
Actually I think the variant from Blue Swirl is better as it gives
us a clean state to start from.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-06-16 21:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-16 13:21 [Qemu-devel] [PATCH 0/2] Subject: [PATCH 0/2] raw-posix block driver fixes (v2) Avi Kivity
2009-06-16 13:21 ` [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace Avi Kivity
2009-06-16 13:28 ` [Qemu-devel] " Christoph Hellwig
2009-06-16 13:21 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
2009-06-16 13:29 ` [Qemu-devel] " Christoph Hellwig
2009-06-16 21:18 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.