From daa49d6f7761547e5776d9dce65ac33bac8382da Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Tue, 18 Dec 2012 13:19:18 +0100
Subject: [PATCH] Fix error during cluster initialization due to hv_kvm

Commit 141d148 was a bit too enthusiastic. The three parameters added to
the list of parameters to be checked default to a value not evaluating
to false, leading to a failure on cluster initialization.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/hypervisor/hv_kvm.py                  |  3 ---
 test/ganeti.hypervisor.hv_kvm_unittest.py | 18 +++++++++++++++++-
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py
index 3b2d81ed3..a388ec254 100644
--- a/lib/hypervisor/hv_kvm.py
+++ b/lib/hypervisor/hv_kvm.py
@@ -77,9 +77,6 @@ _SPICE_ADDITIONAL_PARAMS = frozenset([
   constants.HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR,
   constants.HV_KVM_SPICE_STREAMING_VIDEO_DETECTION,
   constants.HV_KVM_SPICE_USE_TLS,
-  constants.HV_KVM_SPICE_AUDIO_COMPR,
-  constants.HV_KVM_SPICE_TLS_CIPHERS,
-  constants.HV_KVM_SPICE_USE_VDAGENT,
   ])
 
 
diff --git a/test/ganeti.hypervisor.hv_kvm_unittest.py b/test/ganeti.hypervisor.hv_kvm_unittest.py
index f401d3351..358448496 100755
--- a/test/ganeti.hypervisor.hv_kvm_unittest.py
+++ b/test/ganeti.hypervisor.hv_kvm_unittest.py
@@ -260,13 +260,29 @@ class TestVersionChecking(testutils.GanetiTestCase):
 
 class TestSpiceParameterList(unittest.TestCase):
   def test(self):
+    defaults = constants.HVC_DEFAULTS[constants.HT_KVM]
+
     params = \
       compat.UniqueFrozenset(getattr(constants, name)
                              for name in dir(constants)
                              if name.startswith("HV_KVM_SPICE_"))
 
+    # Parameters whose default value evaluates to True and don't need to be set
+    defaults_true = frozenset(filter(defaults.__getitem__, params))
+
+    self.assertEqual(defaults_true, frozenset([
+      constants.HV_KVM_SPICE_AUDIO_COMPR,
+      constants.HV_KVM_SPICE_USE_VDAGENT,
+      constants.HV_KVM_SPICE_TLS_CIPHERS,
+      ]))
+
+    # HV_KVM_SPICE_BIND decides whether the other parameters must be set if
+    # their default evaluates to False
+    assert constants.HV_KVM_SPICE_BIND in params
+    assert constants.HV_KVM_SPICE_BIND not in defaults_true
+
     # Exclude some parameters
-    params -= frozenset([
+    params -= defaults_true | frozenset([
       constants.HV_KVM_SPICE_BIND,
       ])
 
-- 
GitLab