- bnc#688519: correct indention in xend-domain-lock.patch
OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=112
This commit is contained in:
parent
76fdecff9e
commit
be3eccd8df
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Apr 20 17:50:04 CEST 2011 - ohering@suse.de
|
||||
|
||||
- bnc#688519: correct indention in xend-domain-lock.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Apr 11 15:55:04 MDT 2011 - jfehlig@suse.de
|
||||
|
||||
|
@ -1,3 +1,13 @@
|
||||
---
|
||||
tools/examples/xend-config.sxp | 59 ++++++++++++++++++++++
|
||||
tools/hotplug/Linux/Makefile | 1
|
||||
tools/hotplug/Linux/domain-lock | 83 ++++++++++++++++++++++++++++++++
|
||||
tools/hotplug/Linux/vm-monitor | 41 +++++++++++++++
|
||||
tools/python/xen/xend/XendCheckpoint.py | 3 +
|
||||
tools/python/xen/xend/XendDomainInfo.py | 74 ++++++++++++++++++++++++++++
|
||||
tools/python/xen/xend/XendOptions.py | 29 +++++++++++
|
||||
7 files changed, 290 insertions(+)
|
||||
|
||||
Index: xen-4.1.0-testing/tools/examples/xend-config.sxp
|
||||
===================================================================
|
||||
--- xen-4.1.0-testing.orig/tools/examples/xend-config.sxp
|
||||
@ -68,74 +78,6 @@ Index: xen-4.1.0-testing/tools/examples/xend-config.sxp
|
||||
# If we have a very big scsi device configuration, start of xend is slow,
|
||||
# because xend scans all the device paths to build its internal PSCSI device
|
||||
# list. If we need only a few devices for assigning to a guest, we can reduce
|
||||
Index: xen-4.1.0-testing/tools/python/xen/xend/XendOptions.py
|
||||
===================================================================
|
||||
--- xen-4.1.0-testing.orig/tools/python/xen/xend/XendOptions.py
|
||||
+++ xen-4.1.0-testing/tools/python/xen/xend/XendOptions.py
|
||||
@@ -154,6 +154,17 @@ class XendOptions:
|
||||
use loose check automatically if necessary."""
|
||||
pci_dev_assign_strict_check_default = True
|
||||
|
||||
+ """Default for the flag indicating whether xend should create
|
||||
+ a lock file for domains when they are started."""
|
||||
+ xend_domain_lock = 'no'
|
||||
+
|
||||
+ """Default domain lock storage path."""
|
||||
+ xend_domain_lock_path_default = '/var/lib/xen/images/vm_locks'
|
||||
+
|
||||
+ """Default script to acquire/release domain lock"""
|
||||
+ xend_domain_lock_utility = auxbin.scripts_dir() + "/domain-lock"
|
||||
+
|
||||
+
|
||||
def __init__(self):
|
||||
self.configure()
|
||||
|
||||
@@ -401,6 +412,24 @@ class XendOptions:
|
||||
else:
|
||||
return None
|
||||
|
||||
+ def get_xend_domain_lock(self):
|
||||
+ """Get the flag indicating whether xend should create a lock file
|
||||
+ for domains when they are started."""
|
||||
+ return self.get_config_bool("xend-domain-lock", self.xend_domain_lock)
|
||||
+
|
||||
+ def get_xend_domain_lock_path(self):
|
||||
+ """ Get the path for domain lock storage
|
||||
+ """
|
||||
+ return self.get_config_string("xend-domain-lock-path", self.xend_domain_lock_path_default)
|
||||
+
|
||||
+ def get_xend_domain_lock_utility(self):
|
||||
+ s = self.get_config_string('xend-domain-lock-utility')
|
||||
+
|
||||
+ if s:
|
||||
+ return os.path.join(auxbin.scripts_dir(), s)
|
||||
+ else:
|
||||
+ return self.xend_domain_lock_utility
|
||||
+
|
||||
|
||||
def get_vnc_tls(self):
|
||||
return self.get_config_string('vnc-tls', self.xend_vnc_tls)
|
||||
Index: xen-4.1.0-testing/tools/python/xen/xend/XendCheckpoint.py
|
||||
===================================================================
|
||||
--- xen-4.1.0-testing.orig/tools/python/xen/xend/XendCheckpoint.py
|
||||
+++ xen-4.1.0-testing/tools/python/xen/xend/XendCheckpoint.py
|
||||
@@ -133,6 +133,8 @@ def save(fd, dominfo, network, live, dst
|
||||
dominfo.shutdown('suspend')
|
||||
dominfo.waitForSuspend()
|
||||
if line in ('suspend', 'suspended'):
|
||||
+ if checkpoint == False:
|
||||
+ dominfo.release_running_lock(domain_name)
|
||||
dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2,
|
||||
domain_name)
|
||||
log.info("Domain %d suspended.", dominfo.getDomid())
|
||||
@@ -410,6 +412,7 @@ def restore(xd, fd, dominfo = None, paus
|
||||
if not paused:
|
||||
dominfo.unpause()
|
||||
|
||||
+ dominfo.acquire_running_lock()
|
||||
return dominfo
|
||||
except Exception, exn:
|
||||
dominfo.destroy()
|
||||
Index: xen-4.1.0-testing/tools/hotplug/Linux/Makefile
|
||||
===================================================================
|
||||
--- xen-4.1.0-testing.orig/tools/hotplug/Linux/Makefile
|
||||
@ -282,6 +224,27 @@ Index: xen-4.1.0-testing/tools/hotplug/Linux/vm-monitor
|
||||
+elif [ $0 = "$basedir/vm-monitor" ]; then
|
||||
+ monitor $*
|
||||
+fi
|
||||
Index: xen-4.1.0-testing/tools/python/xen/xend/XendCheckpoint.py
|
||||
===================================================================
|
||||
--- xen-4.1.0-testing.orig/tools/python/xen/xend/XendCheckpoint.py
|
||||
+++ xen-4.1.0-testing/tools/python/xen/xend/XendCheckpoint.py
|
||||
@@ -133,6 +133,8 @@ def save(fd, dominfo, network, live, dst
|
||||
dominfo.shutdown('suspend')
|
||||
dominfo.waitForSuspend()
|
||||
if line in ('suspend', 'suspended'):
|
||||
+ if checkpoint == False:
|
||||
+ dominfo.release_running_lock(domain_name)
|
||||
dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2,
|
||||
domain_name)
|
||||
log.info("Domain %d suspended.", dominfo.getDomid())
|
||||
@@ -410,6 +412,7 @@ def restore(xd, fd, dominfo = None, paus
|
||||
if not paused:
|
||||
dominfo.unpause()
|
||||
|
||||
+ dominfo.acquire_running_lock()
|
||||
return dominfo
|
||||
except Exception, exn:
|
||||
dominfo.destroy()
|
||||
Index: xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py
|
||||
===================================================================
|
||||
--- xen-4.1.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py
|
||||
@ -299,10 +262,10 @@ Index: xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py
|
||||
self._stateSet(DOM_STATE_HALTED)
|
||||
self.domid = None # Do not push into _stateSet()!
|
||||
+
|
||||
+ try:
|
||||
+ self.release_running_lock()
|
||||
+ except:
|
||||
+ log.exception("Failed to release domain lock.")
|
||||
+ try:
|
||||
+ self.release_running_lock()
|
||||
+ except:
|
||||
+ log.exception("Failed to release domain lock.")
|
||||
finally:
|
||||
self.refresh_shutdown_lock.release()
|
||||
|
||||
@ -310,74 +273,121 @@ Index: xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py
|
||||
def has_device(self, dev_class, dev_uuid):
|
||||
return (dev_uuid in self.info['%s_refs' % dev_class.lower()])
|
||||
|
||||
+ # Return name of host contained in lock file.
|
||||
+ def get_lock_host(self, path):
|
||||
+ fin = os.popen(xoptions.get_xend_domain_lock_utility() + \
|
||||
+ ' -s ' + path, 'r')
|
||||
+ hostname = "unknown"
|
||||
+ # Return name of host contained in lock file.
|
||||
+ def get_lock_host(self, path):
|
||||
+ fin = os.popen(xoptions.get_xend_domain_lock_utility() + \
|
||||
+ ' -s ' + path, 'r')
|
||||
+ hostname = "unknown"
|
||||
+
|
||||
+ try:
|
||||
+ tokens = fin.readline().split()
|
||||
+ for token in tokens:
|
||||
+ item = token.split('=')
|
||||
+ if item[0] == 'host':
|
||||
+ hostname = item[1]
|
||||
+ return hostname
|
||||
+ finally:
|
||||
+ fin.close()
|
||||
+ try:
|
||||
+ tokens = fin.readline().split()
|
||||
+ for token in tokens:
|
||||
+ item = token.split('=')
|
||||
+ if item[0] == 'host':
|
||||
+ hostname = item[1]
|
||||
+ return hostname
|
||||
+ finally:
|
||||
+ fin.close()
|
||||
+
|
||||
+ # Acquire a lock for the domain. No-op if domain locking is turned off.
|
||||
+ def acquire_running_lock(self):
|
||||
+ if not xoptions.get_xend_domain_lock():
|
||||
+ return
|
||||
+ def acquire_running_lock(self):
|
||||
+ if not xoptions.get_xend_domain_lock():
|
||||
+ return
|
||||
+
|
||||
+ log.debug("Acquiring lock for domain %s" % self.info['name_label'])
|
||||
+ path = xoptions.get_xend_domain_lock_path()
|
||||
+ path = os.path.join(path, self.get_uuid())
|
||||
+ log.debug("Acquiring lock for domain %s" % self.info['name_label'])
|
||||
+ path = xoptions.get_xend_domain_lock_path()
|
||||
+ path = os.path.join(path, self.get_uuid())
|
||||
+
|
||||
+ try:
|
||||
+ if not os.path.exists(path):
|
||||
+ mkdir.parents(path, stat.S_IRWXU)
|
||||
+ except:
|
||||
+ log.exception("%s could not be created." % path)
|
||||
+ raise XendError("%s could not be created." % path)
|
||||
+ try:
|
||||
+ if not os.path.exists(path):
|
||||
+ mkdir.parents(path, stat.S_IRWXU)
|
||||
+ except:
|
||||
+ log.exception("%s could not be created." % path)
|
||||
+ raise XendError("%s could not be created." % path)
|
||||
+
|
||||
+ status = os.system('%s -l -p %s -n %s -i %s %s' % \
|
||||
+ (xoptions.get_xend_domain_lock_utility(), \
|
||||
+ XendNode.instance().get_name(), \
|
||||
+ self.info['name_label'], \
|
||||
+ self.info['uuid'], \
|
||||
+ path))
|
||||
+ if status != 0:
|
||||
+ log.debug("Failed to aqcuire lock: status = %d" % status)
|
||||
+ raise XendError("The VM is locked and appears to be running on host %s." % self.get_lock_host(path))
|
||||
+ status = os.system('%s -l -p %s -n %s -i %s %s' % \
|
||||
+ (xoptions.get_xend_domain_lock_utility(), \
|
||||
+ XendNode.instance().get_name(), \
|
||||
+ self.info['name_label'], \
|
||||
+ self.info['uuid'], \
|
||||
+ path))
|
||||
+ if status != 0:
|
||||
+ log.debug("Failed to aqcuire lock: status = %d" % status)
|
||||
+ raise XendError("The VM is locked and appears to be running on host %s." % self.get_lock_host(path))
|
||||
+
|
||||
+ # Release lock for domain. No-op if domain locking is turned off.
|
||||
+ def release_running_lock(self, name = None):
|
||||
+ if not xoptions.get_xend_domain_lock():
|
||||
+ return
|
||||
+ # Release lock for domain. No-op if domain locking is turned off.
|
||||
+ def release_running_lock(self, name = None):
|
||||
+ if not xoptions.get_xend_domain_lock():
|
||||
+ return
|
||||
+
|
||||
+ dom_name = self.info['name_label']
|
||||
+ if name:
|
||||
+ dom_name = name
|
||||
+ log.debug("Releasing lock for domain %s" % dom_name)
|
||||
+ dom_name = self.info['name_label']
|
||||
+ if name:
|
||||
+ dom_name = name
|
||||
+ log.debug("Releasing lock for domain %s" % dom_name)
|
||||
+
|
||||
+ path = xoptions.get_xend_domain_lock_path()
|
||||
+ path = os.path.join(path, self.get_uuid())
|
||||
+ status = os.system('%s -u -p %s -n %s -i %s %s' % \
|
||||
+ (xoptions.get_xend_domain_lock_utility(), \
|
||||
+ XendNode.instance().get_name(), \
|
||||
+ dom_name, \
|
||||
+ self.info['uuid'], \
|
||||
+ path))
|
||||
+ if status != 0:
|
||||
+ log.exception("Failed to release lock: status = %s" % status)
|
||||
+ try:
|
||||
+ if len(os.listdir(path)) == 0:
|
||||
+ shutil.rmtree(path)
|
||||
+ except:
|
||||
+ log.exception("Failed to remove unmanaged directory %s." % path)
|
||||
+ path = xoptions.get_xend_domain_lock_path()
|
||||
+ path = os.path.join(path, self.get_uuid())
|
||||
+ status = os.system('%s -u -p %s -n %s -i %s %s' % \
|
||||
+ (xoptions.get_xend_domain_lock_utility(), \
|
||||
+ XendNode.instance().get_name(), \
|
||||
+ dom_name, \
|
||||
+ self.info['uuid'], \
|
||||
+ path))
|
||||
+ if status != 0:
|
||||
+ log.exception("Failed to release lock: status = %s" % status)
|
||||
+ try:
|
||||
+ if len(os.listdir(path)) == 0:
|
||||
+ shutil.rmtree(path)
|
||||
+ except:
|
||||
+ log.exception("Failed to remove unmanaged directory %s." % path)
|
||||
+
|
||||
def __str__(self):
|
||||
return '<domain id=%s name=%s memory=%s state=%s>' % \
|
||||
(str(self.domid), self.info['name_label'],
|
||||
Index: xen-4.1.0-testing/tools/python/xen/xend/XendOptions.py
|
||||
===================================================================
|
||||
--- xen-4.1.0-testing.orig/tools/python/xen/xend/XendOptions.py
|
||||
+++ xen-4.1.0-testing/tools/python/xen/xend/XendOptions.py
|
||||
@@ -154,6 +154,17 @@ class XendOptions:
|
||||
use loose check automatically if necessary."""
|
||||
pci_dev_assign_strict_check_default = True
|
||||
|
||||
+ """Default for the flag indicating whether xend should create
|
||||
+ a lock file for domains when they are started."""
|
||||
+ xend_domain_lock = 'no'
|
||||
+
|
||||
+ """Default domain lock storage path."""
|
||||
+ xend_domain_lock_path_default = '/var/lib/xen/images/vm_locks'
|
||||
+
|
||||
+ """Default script to acquire/release domain lock"""
|
||||
+ xend_domain_lock_utility = auxbin.scripts_dir() + "/domain-lock"
|
||||
+
|
||||
+
|
||||
def __init__(self):
|
||||
self.configure()
|
||||
|
||||
@@ -401,6 +412,24 @@ class XendOptions:
|
||||
else:
|
||||
return None
|
||||
|
||||
+ def get_xend_domain_lock(self):
|
||||
+ """Get the flag indicating whether xend should create a lock file
|
||||
+ for domains when they are started."""
|
||||
+ return self.get_config_bool("xend-domain-lock", self.xend_domain_lock)
|
||||
+
|
||||
+ def get_xend_domain_lock_path(self):
|
||||
+ """ Get the path for domain lock storage
|
||||
+ """
|
||||
+ return self.get_config_string("xend-domain-lock-path", self.xend_domain_lock_path_default)
|
||||
+
|
||||
+ def get_xend_domain_lock_utility(self):
|
||||
+ s = self.get_config_string('xend-domain-lock-utility')
|
||||
+
|
||||
+ if s:
|
||||
+ return os.path.join(auxbin.scripts_dir(), s)
|
||||
+ else:
|
||||
+ return self.xend_domain_lock_utility
|
||||
+
|
||||
|
||||
def get_vnc_tls(self):
|
||||
return self.get_config_string('vnc-tls', self.xend_vnc_tls)
|
||||
|
Loading…
Reference in New Issue
Block a user