summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorBob Ball <bob.ball@citrix.com>2013-03-19 14:12:29 +0000
committerBob Ball <bob.ball@citrix.com>2013-03-25 09:39:33 +0000
commit90cda3512ae509d548bf2b4343ce0d8b8b9bfb43 (patch)
treebd567c209717b9061c0794dca44d4c531fdc8eac /nova/virt
parentdb8dfce9516957c445583015bb983ae4ebbc6d9d (diff)
xenapi: Retrieve VM uuid from xenstore.
Fall back to retrieving the uuid from xenstore if /sys/hypervisor/uuid isn't accessible. Change-Id: I409079068d3102ff86a71431b29c1ce2e6fe8857 Fixes: bug #1157211
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/vm_utils.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 26bd9d268..99e7712c8 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -1918,11 +1918,25 @@ def vdi_attached_here(session, vdi_ref, read_only=False):
LOG.debug(_('Destroying VBD for VDI %s done.'), vdi_ref)
-def get_this_vm_uuid():
+def _get_sys_hypervisor_uuid():
with file('/sys/hypervisor/uuid') as f:
return f.readline().strip()
+def get_this_vm_uuid():
+ try:
+ return _get_sys_hypervisor_uuid()
+ except IOError:
+ # Some guest kernels (without 5c13f8067745efc15f6ad0158b58d57c44104c25)
+ # cannot read from uuid after a reboot. Fall back to trying xenstore.
+ # See https://bugs.launchpad.net/ubuntu/+source/xen-api/+bug/1081182
+ domid, _ = utils.execute('xenstore-read', 'domid', run_as_root=True)
+ vm_key, _ = utils.execute('xenstore-read',
+ '/local/domain/%s/vm' % domid.strip(),
+ run_as_root=True)
+ return vm_key.strip()[4:]
+
+
def _get_this_vm_ref(session):
return session.call_xenapi("VM.get_by_uuid", get_this_vm_uuid())