diff mbox

[RFC,2/5] iothread: Don't error on windows

Message ID 20170710072027.7948-3-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng July 10, 2017, 7:20 a.m. UTC
aio_context_set_poll_params is called unconditionally from iothread
initialization code and the contract is that if max_ns == 0 polling is
disabled, or otherwise windows reports and error. The current default
being non-zero will always make win32 to exit on an "-object iothread"
option, which is not nice.

Default to zero on windows and keep going.

(While we are at it, move the definition to the header, because it will
be shared with iothread-group.)

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 include/sysemu/iothread.h | 12 ++++++++++++
 iothread.c                |  6 ------
 util/aio-win32.c          |  4 +++-
 3 files changed, 15 insertions(+), 7 deletions(-)

Comments

Stefan Hajnoczi July 11, 2017, 1:35 p.m. UTC | #1
On Mon, Jul 10, 2017 at 03:20:24PM +0800, Fam Zheng wrote:
> aio_context_set_poll_params is called unconditionally from iothread
> initialization code and the contract is that if max_ns == 0 polling is
> disabled, or otherwise windows reports and error. The current default
> being non-zero will always make win32 to exit on an "-object iothread"
> option, which is not nice.
> 
> Default to zero on windows and keep going.
> 
> (While we are at it, move the definition to the header, because it will
> be shared with iothread-group.)
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  include/sysemu/iothread.h | 12 ++++++++++++
>  iothread.c                |  6 ------
>  util/aio-win32.c          |  4 +++-
>  3 files changed, 15 insertions(+), 7 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox

Patch

diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h
index eecfc19..37f033b 100644
--- a/include/sysemu/iothread.h
+++ b/include/sysemu/iothread.h
@@ -39,4 +39,16 @@  char *iothread_get_id(IOThread *iothread);
 AioContext *iothread_get_aio_context(IOThread *iothread);
 void iothread_stop_all(void);
 
+#ifndef _WIN32
+/* Benchmark results from 2016 on NVMe SSD drives show max polling times around
+ * 16-32 microseconds yield IOPS improvements for both iodepth=1 and iodepth=32
+ * workloads.
+ */
+#define IOTHREAD_POLL_MAX_NS_DEFAULT 32768ULL
+#else
+/* Our aio implementation on Windows doesn't support polling, don't enable it
+ * by default. */
+#define IOTHREAD_POLL_MAX_NS_DEFAULT 0
+#endif
+
 #endif /* IOTHREAD_H */
diff --git a/iothread.c b/iothread.c
index f5a01bb..ce56724 100644
--- a/iothread.c
+++ b/iothread.c
@@ -30,12 +30,6 @@  typedef ObjectClass IOThreadClass;
 #define IOTHREAD_CLASS(klass) \
    OBJECT_CLASS_CHECK(IOThreadClass, klass, TYPE_IOTHREAD)
 
-/* Benchmark results from 2016 on NVMe SSD drives show max polling times around
- * 16-32 microseconds yield IOPS improvements for both iodepth=1 and iodepth=32
- * workloads.
- */
-#define IOTHREAD_POLL_MAX_NS_DEFAULT 32768ULL
-
 static __thread IOThread *my_iothread;
 
 AioContext *qemu_get_current_aio_context(void)
diff --git a/util/aio-win32.c b/util/aio-win32.c
index d8a1b20..3d2de11 100644
--- a/util/aio-win32.c
+++ b/util/aio-win32.c
@@ -403,5 +403,7 @@  void aio_context_setup(AioContext *ctx)
 void aio_context_set_poll_params(AioContext *ctx, AioContextPollParams params,
                                  Error **errp)
 {
-    error_setg(errp, "AioContext polling is not implemented on Windows");
+    if (params.max_ns) {
+        error_setg(errp, "AioContext polling is not implemented on Windows");
+    }
 }