From 2f4e9b22b74f696fdac5aed8b57a70e34b113bc8 Mon Sep 17 00:00:00 2001
From: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Date: Mon, 2 Sep 2013 18:20:21 +0300
Subject: [PATCH] Fixes cinder-volume service startup on Windows

The Windows service fails due to missing non-blocking IO features
in eventlet. This fix adds a conditional path on Windows to execute
the service accordingly.

Fixes bug: #1219896

Change-Id: I74f662e736e3a5fe58a383d172780a691a2b36c7
---
 bin/cinder-volume | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/bin/cinder-volume b/bin/cinder-volume
index e9f9d1ca3..08199f0a2 100755
--- a/bin/cinder-volume
+++ b/bin/cinder-volume
@@ -20,10 +20,15 @@
 """Starter script for Cinder Volume."""
 
 import eventlet
+import os
 
-eventlet.monkey_patch()
+if os.name == 'nt':
+    # eventlet monkey patching the os module causes subprocess.Popen to fail
+    # on Windows when using pipes due to missing non-blocking IO support.
+    eventlet.monkey_patch(os=False)
+else:
+    eventlet.monkey_patch()
 
-import os
 import sys
 
 from oslo.config import cfg
@@ -54,7 +59,11 @@ if __name__ == '__main__':
          version=version.version_string())
     logging.setup("cinder")
     utils.monkey_patch()
-    launcher = service.ProcessLauncher()
+    if os.name == 'nt':
+        launcher = service
+        launcher.launch_server = service.serve
+    else:
+        launcher = service.ProcessLauncher()
     if CONF.enabled_backends:
         for backend in CONF.enabled_backends:
             host = "%s@%s" % (CONF.host, backend)
-- 
2.45.2