Rev 1 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | madcat | 1 | --- /root/xen_lock_patch/XendDomainInfo.py 2011-03-14 11:03:21.000000000 +0100 |
2 | madcat | 2 | +++ /usr/lib/xen-4.1/lib/python/xen/xend/XendDomainInfo.py 2011-03-14 15:50:52.000000000 +0100 |
3 | @@ -365,6 +365,8 @@ |
||
1 | madcat | 4 | @type state_updated: threading.Condition |
5 | @ivar refresh_shutdown_lock: lock for polling shutdown state |
||
6 | @type refresh_shutdown_lock: threading.Condition |
||
7 | + @ivar running_lock: lock for running VM |
||
8 | + @type running_lock: bool or None |
||
9 | @ivar _deviceControllers: device controller cache for this domain |
||
10 | @type _deviceControllers: dict 'string' to DevControllers |
||
11 | """ |
||
2 | madcat | 12 | @@ -444,6 +446,8 @@ |
1 | madcat | 13 | self.refresh_shutdown_lock = threading.Condition() |
14 | self._stateSet(DOM_STATE_HALTED) |
||
15 | |||
16 | + self.running_lock = None |
||
17 | + |
||
18 | self._deviceControllers = {} |
||
19 | |||
20 | for state in DOM_STATES_OLD: |
||
2 | madcat | 21 | @@ -470,6 +474,7 @@ |
1 | madcat | 22 | |
23 | if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED): |
||
24 | try: |
||
25 | + self.acquire_running_lock(); |
||
26 | XendTask.log_progress(0, 30, self._constructDomain) |
||
27 | XendTask.log_progress(31, 60, self._initDomain) |
||
28 | |||
2 | madcat | 29 | @@ -496,6 +501,7 @@ |
1 | madcat | 30 | state = self._stateGet() |
31 | if state in (DOM_STATE_SUSPENDED, DOM_STATE_HALTED): |
||
32 | try: |
||
33 | + self.acquire_running_lock(); |
||
34 | self._constructDomain() |
||
35 | |||
36 | try: |
||
2 | madcat | 37 | @@ -2950,6 +2956,11 @@ |
1 | madcat | 38 | |
39 | self._stateSet(DOM_STATE_HALTED) |
||
40 | self.domid = None # Do not push into _stateSet()! |
||
41 | + |
||
42 | + try: |
||
43 | + self.release_running_lock() |
||
44 | + except: |
||
45 | + log.exception("Release running lock failed: %s" % status) |
||
46 | finally: |
||
47 | self.refresh_shutdown_lock.release() |
||
48 | |||
2 | madcat | 49 | @@ -4438,6 +4449,32 @@ |
1 | madcat | 50 | def has_device(self, dev_class, dev_uuid): |
51 | return (dev_uuid in self.info['%s_refs' % dev_class.lower()]) |
||
52 | |||
53 | + def acquire_running_lock(self): |
||
54 | + if not self.running_lock: |
||
55 | + lock_path = xoptions.get_xend_domains_lock_path() |
||
56 | + if lock_path: |
||
57 | + doms_lock_path = xoptions.get_xend_domains_path() |
||
58 | + if doms_lock_path: |
||
59 | + status = os.system('%s --lock --name %s --uuid %s --path %s' % \ |
||
60 | + (lock_path, self.info['name_label'], self.info['uuid'], doms_lock_path)) |
||
61 | + if status == 0: |
||
62 | + self.running_lock = True |
||
63 | + else: |
||
64 | + raise XendError('Acquire running lock failed: %s' % status) |
||
65 | + |
||
66 | + def release_running_lock(self): |
||
67 | + if self.running_lock: |
||
68 | + lock_path = xoptions.get_xend_domains_lock_path() |
||
69 | + if lock_path: |
||
70 | + doms_lock_path = xoptions.get_xend_domains_path() |
||
71 | + if doms_lock_path: |
||
72 | + status = os.system('%s --unlock --name %s --uuid %s --path %s' % \ |
||
73 | + (lock_path, self.info['name_label'], self.info['uuid'], doms_lock_path)) |
||
74 | + if status == 0: |
||
75 | + self.running_lock = False |
||
76 | + else: |
||
77 | + raise XendError('Release running lock failed: %s' % status) |
||
78 | + |
||
79 | def __str__(self): |
||
80 | return '<domain id=%s name=%s memory=%s state=%s>' % \ |
||
81 | (str(self.domid), self.info['name_label'], |
||
82 | --- /root/xen_lock_patch/XendDomain.py 2011-03-14 11:04:13.000000000 +0100 |
||
2 | madcat | 83 | +++ /usr/lib/xen-4.1/lib/python/xen/xend/XendDomain.py 2011-03-14 11:26:44.000000000 +0100 |
84 | @@ -1368,6 +1368,7 @@ |
||
1 | madcat | 85 | raise XendError("Domain is not a managed domain") |
86 | |||
87 | """ The following call may raise a XendError exception """ |
||
88 | + dominfo.release_running_lock(); |
||
89 | dominfo.testMigrateDevices(True, dst) |
||
90 | |||
91 | if live: |
||
92 | --- /root/xen_lock_patch/XendOptions.py 2011-03-14 11:02:52.000000000 +0100 |
||
2 | madcat | 93 | +++ /usr/lib/xen-4.1/lib/python/xen/xend/XendOptions.py 2011-03-14 11:27:33.000000000 +0100 |
94 | @@ -321,6 +321,11 @@ |
||
1 | madcat | 95 | """ |
96 | return self.get_config_string("xend-domains-path", self.xend_domains_path_default) |
||
97 | |||
98 | + def get_xend_domains_lock_path(self): |
||
99 | + """ Get the path of the lock utility for running domains. |
||
100 | + """ |
||
101 | + return self.get_config_string("xend-domains-lock-path") |
||
102 | + |
||
103 | def get_xend_state_path(self): |
||
104 | """ Get the path for persistent domain configuration storage |
||
105 | """ |