Re: [Qemu-devel] [PATCH for-1.4] block/raw-posix: Build fix for O_ASYNC
On Sat, Jan 26, 2013 at 02:38:45PM +0100, Andreas Färber wrote: Commit eeb6b45d48800e96f67ef2a5c80332557fd45ddb (block: raw-posix image file reopen) broke the build on OpenIndiana. illumos has no O_ASYNC. Exclude it from flags to be compared and use I_SETSIG ioctl after newly opening file. Cf. e61ab1da7e98357da47c54d8f893b9bd6ff2f7f9 for qemu-ga. Cc: qemu-sta...@nongnu.org (1.3.x) Cc: Jeff Cody jc...@redhat.com Signed-off-by: Andreas Färber andreas.faer...@web.de --- block/raw-posix.c | 14 +- 1 Datei geändert, 13 Zeilen hinzugefügt(+), 1 Zeile entfernt(-) Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan
Re: [Qemu-devel] [PATCH for-1.4] block/raw-posix: Build fix for O_ASYNC
Il 26/01/2013 14:38, Andreas Färber ha scritto: Commit eeb6b45d48800e96f67ef2a5c80332557fd45ddb (block: raw-posix image file reopen) broke the build on OpenIndiana. illumos has no O_ASYNC. Exclude it from flags to be compared and use I_SETSIG ioctl after newly opening file. Cf. e61ab1da7e98357da47c54d8f893b9bd6ff2f7f9 for qemu-ga. Cc: qemu-sta...@nongnu.org (1.3.x) Cc: Jeff Cody jc...@redhat.com Signed-off-by: Andreas Färber andreas.faer...@web.de --- block/raw-posix.c | 14 +- 1 Datei geändert, 13 Zeilen hinzugefügt(+), 1 Zeile entfernt(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 657af95..336c938 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -46,6 +46,7 @@ #ifdef __sun__ #define _POSIX_PTHREAD_SEMANTICS 1 #include sys/dkio.h +#include stropts.h #endif #ifdef __linux__ #include sys/types.h @@ -345,7 +346,10 @@ static int raw_reopen_prepare(BDRVReopenState *state, raw_s-fd = -1; -int fcntl_flags = O_APPEND | O_ASYNC | O_NONBLOCK; +int fcntl_flags = O_APPEND | O_NONBLOCK; +#ifndef CONFIG_SOLARIS +fcntl_flags |= O_ASYNC; +#endif #ifdef O_NOATIME fcntl_flags |= O_NOATIME; #endif @@ -376,6 +380,14 @@ static int raw_reopen_prepare(BDRVReopenState *state, raw_s-fd = qemu_open(state-bs-filename, raw_s-open_flags); if (raw_s-fd == -1) { ret = -1; +} else { +#ifdef CONFIG_SOLARIS +ret = ioctl(raw_s-fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI); +if (ret == -1) { +qemu_close(raw_s-fd); +raw_s-fd = -1; +} +#endif The flag is not set unconditionally. It is only set if it was in s-open_flags, and it should never be. I would just add an #ifdef O_ASYNC /* Not all operating systems have O_ASYNC, and those that don't * will not let us track the state into raw_s-open_flags (typically * you achieve the same effect with an ioctl, for example I_SETSIG * on Solaris). But we do not use O_ASYNC, so that's fine. */ assert((s-open_flags O_ASYNC) == 0); #endif Paolo
Re: [Qemu-devel] [PATCH for-1.4] block/raw-posix: Build fix for O_ASYNC
On Mon, Jan 28, 2013 at 10:47:28AM +0100, Paolo Bonzini wrote: Il 26/01/2013 14:38, Andreas Färber ha scritto: Commit eeb6b45d48800e96f67ef2a5c80332557fd45ddb (block: raw-posix image file reopen) broke the build on OpenIndiana. illumos has no O_ASYNC. Exclude it from flags to be compared and use I_SETSIG ioctl after newly opening file. Cf. e61ab1da7e98357da47c54d8f893b9bd6ff2f7f9 for qemu-ga. Cc: qemu-sta...@nongnu.org (1.3.x) Cc: Jeff Cody jc...@redhat.com Signed-off-by: Andreas Färber andreas.faer...@web.de --- block/raw-posix.c | 14 +- 1 Datei geändert, 13 Zeilen hinzugefügt(+), 1 Zeile entfernt(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 657af95..336c938 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -46,6 +46,7 @@ #ifdef __sun__ #define _POSIX_PTHREAD_SEMANTICS 1 #include sys/dkio.h +#include stropts.h #endif #ifdef __linux__ #include sys/types.h @@ -345,7 +346,10 @@ static int raw_reopen_prepare(BDRVReopenState *state, raw_s-fd = -1; -int fcntl_flags = O_APPEND | O_ASYNC | O_NONBLOCK; +int fcntl_flags = O_APPEND | O_NONBLOCK; +#ifndef CONFIG_SOLARIS +fcntl_flags |= O_ASYNC; +#endif #ifdef O_NOATIME fcntl_flags |= O_NOATIME; #endif @@ -376,6 +380,14 @@ static int raw_reopen_prepare(BDRVReopenState *state, raw_s-fd = qemu_open(state-bs-filename, raw_s-open_flags); if (raw_s-fd == -1) { ret = -1; +} else { +#ifdef CONFIG_SOLARIS +ret = ioctl(raw_s-fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI); +if (ret == -1) { +qemu_close(raw_s-fd); +raw_s-fd = -1; +} +#endif The flag is not set unconditionally. It is only set if it was in s-open_flags, and it should never be. I would just add an #ifdef O_ASYNC /* Not all operating systems have O_ASYNC, and those that don't * will not let us track the state into raw_s-open_flags (typically * you achieve the same effect with an ioctl, for example I_SETSIG * on Solaris). But we do not use O_ASYNC, so that's fine. */ assert((s-open_flags O_ASYNC) == 0); #endif Good point. Andreas: Do you want to send a new patch? Stefan
Re: [Qemu-devel] [PATCH for-1.4] block/raw-posix: Build fix for O_ASYNC
Am 28.01.2013 13:27, schrieb Stefan Hajnoczi: On Mon, Jan 28, 2013 at 10:47:28AM +0100, Paolo Bonzini wrote: Il 26/01/2013 14:38, Andreas Färber ha scritto: Commit eeb6b45d48800e96f67ef2a5c80332557fd45ddb (block: raw-posix image file reopen) broke the build on OpenIndiana. illumos has no O_ASYNC. Exclude it from flags to be compared and use I_SETSIG ioctl after newly opening file. Cf. e61ab1da7e98357da47c54d8f893b9bd6ff2f7f9 for qemu-ga. Cc: qemu-sta...@nongnu.org (1.3.x) Cc: Jeff Cody jc...@redhat.com Signed-off-by: Andreas Färber andreas.faer...@web.de --- block/raw-posix.c | 14 +- 1 Datei geändert, 13 Zeilen hinzugefügt(+), 1 Zeile entfernt(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 657af95..336c938 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -46,6 +46,7 @@ #ifdef __sun__ #define _POSIX_PTHREAD_SEMANTICS 1 #include sys/dkio.h +#include stropts.h #endif #ifdef __linux__ #include sys/types.h @@ -345,7 +346,10 @@ static int raw_reopen_prepare(BDRVReopenState *state, raw_s-fd = -1; -int fcntl_flags = O_APPEND | O_ASYNC | O_NONBLOCK; +int fcntl_flags = O_APPEND | O_NONBLOCK; +#ifndef CONFIG_SOLARIS +fcntl_flags |= O_ASYNC; +#endif #ifdef O_NOATIME fcntl_flags |= O_NOATIME; #endif @@ -376,6 +380,14 @@ static int raw_reopen_prepare(BDRVReopenState *state, raw_s-fd = qemu_open(state-bs-filename, raw_s-open_flags); if (raw_s-fd == -1) { ret = -1; +} else { +#ifdef CONFIG_SOLARIS +ret = ioctl(raw_s-fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI); +if (ret == -1) { +qemu_close(raw_s-fd); +raw_s-fd = -1; +} +#endif The flag is not set unconditionally. It is only set if it was in s-open_flags, and it should never be. I would just add an #ifdef O_ASYNC /* Not all operating systems have O_ASYNC, and those that don't * will not let us track the state into raw_s-open_flags (typically * you achieve the same effect with an ioctl, for example I_SETSIG * on Solaris). But we do not use O_ASYNC, so that's fine. */ assert((s-open_flags O_ASYNC) == 0); #endif Good point. Andreas: Do you want to send a new patch? Yes, please unqueue it, I see that the last hunk is wrong. I won't get to it immediately though and will have to digest the above suggestion. Andreas
[Qemu-devel] [PATCH for-1.4] block/raw-posix: Build fix for O_ASYNC
Commit eeb6b45d48800e96f67ef2a5c80332557fd45ddb (block: raw-posix image file reopen) broke the build on OpenIndiana. illumos has no O_ASYNC. Exclude it from flags to be compared and use I_SETSIG ioctl after newly opening file. Cf. e61ab1da7e98357da47c54d8f893b9bd6ff2f7f9 for qemu-ga. Cc: qemu-sta...@nongnu.org (1.3.x) Cc: Jeff Cody jc...@redhat.com Signed-off-by: Andreas Färber andreas.faer...@web.de --- block/raw-posix.c | 14 +- 1 Datei geändert, 13 Zeilen hinzugefügt(+), 1 Zeile entfernt(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 657af95..336c938 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -46,6 +46,7 @@ #ifdef __sun__ #define _POSIX_PTHREAD_SEMANTICS 1 #include sys/dkio.h +#include stropts.h #endif #ifdef __linux__ #include sys/types.h @@ -345,7 +346,10 @@ static int raw_reopen_prepare(BDRVReopenState *state, raw_s-fd = -1; -int fcntl_flags = O_APPEND | O_ASYNC | O_NONBLOCK; +int fcntl_flags = O_APPEND | O_NONBLOCK; +#ifndef CONFIG_SOLARIS +fcntl_flags |= O_ASYNC; +#endif #ifdef O_NOATIME fcntl_flags |= O_NOATIME; #endif @@ -376,6 +380,14 @@ static int raw_reopen_prepare(BDRVReopenState *state, raw_s-fd = qemu_open(state-bs-filename, raw_s-open_flags); if (raw_s-fd == -1) { ret = -1; +} else { +#ifdef CONFIG_SOLARIS +ret = ioctl(raw_s-fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI); +if (ret == -1) { +qemu_close(raw_s-fd); +raw_s-fd = -1; +} +#endif } } return ret; -- 1.7.10.4