From b33b6f558bf214089a87fedba1f2d1b7c87245bf Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 25 Feb 2009 15:03:43 +0000
Subject: [PATCH] Fix mixed pvm/hvm clusters and instance listing

The current implementation of the combining of the instance lists will
only do this for instances whose all four-fields match in both
hypervisors; however, this is broken for the dynamic fields (state,
times) which can change between the invocations of the two different
hypervisors if the instance is busy.

The patch checks only the memory and VCPUs, and makes mixed clusters
work even with 100% CPU instances.

Reviewed-by: imsnah
---
 lib/backend.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index 831f36cf1..18d439e86 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -660,9 +660,14 @@ def GetAllInstancesInfo(hypervisor_list):
           'state': state,
           'time': times,
           }
-        if name in output and output[name] != value:
-          raise errors.HypervisorError("Instance %s running duplicate"
-                                       " with different parameters" % name)
+        if name in output:
+          # we only check static parameters, like memory and vcpus,
+          # and not state and time which can change between the
+          # invocations of the different hypervisors
+          for key in 'memory', 'vcpus':
+            if value[key] != output[name][key]:
+              raise errors.HypervisorError("Instance %s is running twice"
+                                           " with different parameters" % name)
         output[name] = value
 
   return output
-- 
GitLab