KVM: fix a bug in _TryReadUidFile
authorGuido Trotter <ultrotter@google.com>
Wed, 21 Apr 2010 12:09:41 +0000 (13:09 +0100)
committerGuido Trotter <ultrotter@google.com>
Wed, 21 Apr 2010 14:48:46 +0000 (15:48 +0100)
If the uid pool is not in use _TryReadUidFile will try to return "uid"
even if it hasn't tried to read it at all.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/hypervisor/hv_kvm.py

index 6b74833..1fa6f1e 100644 (file)
@@ -235,13 +235,12 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if os.path.exists(uid_file):
       try:
         uid = int(utils.ReadFile(uid_file))
+        return uid
       except EnvironmentError:
         logging.warning("Can't read uid file", exc_info=True)
-        return None
       except (TypeError, ValueError):
         logging.warning("Can't parse uid file contents", exc_info=True)
-        return None
-    return uid
+    return None
 
   @classmethod
   def _RemoveInstanceRuntimeFiles(cls, pidfile, instance_name):