From 596b2459e2789a8ca6438e2fb553a934cc56ba0a Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 21 Mar 2012 14:58:05 +0000
Subject: [PATCH] KVM: don't add -nographic using spice

This fixes issue 222.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/hypervisor/hv_kvm.py | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index a314fc145..69b0126b7 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -654,8 +654,20 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if mem_path:
       kvm_cmd.extend(["-mem-path", mem_path, "-mem-prealloc"])
 
+    monitor_dev = ("unix:%s,server,nowait" %
+                   self._InstanceMonitor(instance.name))
+    kvm_cmd.extend(["-monitor", monitor_dev])
+    if hvp[constants.HV_SERIAL_CONSOLE]:
+      serial_dev = ("unix:%s,server,nowait" %
+                    self._InstanceSerial(instance.name))
+      kvm_cmd.extend(["-serial", serial_dev])
+    else:
+      kvm_cmd.extend(["-serial", "none"])
+
     mouse_type = hvp[constants.HV_USB_MOUSE]
     vnc_bind_address = hvp[constants.HV_VNC_BIND_ADDRESS]
+    spice_bind = hvp[constants.HV_KVM_SPICE_BIND]
+    spice_ip_version = None
 
     if mouse_type:
       kvm_cmd.extend(["-usb"])
@@ -707,22 +719,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
         vnc_arg = "unix:%s/%s.vnc" % (vnc_bind_address, instance.name)
 
       kvm_cmd.extend(["-vnc", vnc_arg])
-    else:
-      kvm_cmd.extend(["-nographic"])
-
-    monitor_dev = ("unix:%s,server,nowait" %
-                   self._InstanceMonitor(instance.name))
-    kvm_cmd.extend(["-monitor", monitor_dev])
-    if hvp[constants.HV_SERIAL_CONSOLE]:
-      serial_dev = ("unix:%s,server,nowait" %
-                    self._InstanceSerial(instance.name))
-      kvm_cmd.extend(["-serial", serial_dev])
-    else:
-      kvm_cmd.extend(["-serial", "none"])
-
-    spice_bind = hvp[constants.HV_KVM_SPICE_BIND]
-    spice_ip_version = None
-    if spice_bind:
+    elif spice_bind:
       if netutils.IsValidInterface(spice_bind):
         # The user specified a network interface, we have to figure out the IP
         # address.
@@ -768,6 +765,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
       logging.info("KVM: SPICE will listen on port %s", instance.network_port)
       kvm_cmd.extend(["-spice", spice_arg])
 
+    else:
+      kvm_cmd.extend(["-nographic"])
+
     if hvp[constants.HV_USE_LOCALTIME]:
       kvm_cmd.extend(["-localtime"])
 
-- 
GitLab