Change in vdsm[ovirt-3.3]: vm: Fix vm unpausing during recovery

nsoffer at redhat.com nsoffer at redhat.com
Wed Nov 27 13:27:45 UTC 2013


Nir Soffer has uploaded a new change for review.

Change subject: vm: Fix vm unpausing during recovery
......................................................................

vm: Fix vm unpausing during recovery

Domain monitor thread was not reporting when going from unknown state to
known state. The thread would start with a bogus valid state, before
checking the domain. If the first domain check found the domain as
valid, no notification was emitted. If there were paused vms while
connecting to the pool, they were not unpaused as they should.

This patch fixes various modules:

- Domain monitor status lastCheck is initialized now to special
  NOT_CHECKED_YET value. The monitor thread use this value to detect the
  first sample, and emit the missing notification.

- To get the new event when monitor thread starts, domain state change
  callbacks are registered now *before* the monitor threads are started.

- To get the vm unpause code to work in recovery mode, the Vm.sdIds is
  initialized in Vm._run. This probably fixes other issues with
  recovered vms.

Change-Id: I56c468edb967de5bcf15259029ace84333fc4b7e
Bug-Url: https://bugzilla.redhat.com/1003588
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/storage/domainMonitor.py
M vdsm/storage/hsm.py
M vdsm/vm.py
3 files changed, 19 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/21782/1

diff --git a/vdsm/storage/domainMonitor.py b/vdsm/storage/domainMonitor.py
index a998f80..ffa5e00 100644
--- a/vdsm/storage/domainMonitor.py
+++ b/vdsm/storage/domainMonitor.py
@@ -27,6 +27,8 @@
 from vdsm.config import config
 from sdc import sdCache
 
+NOT_CHECKED_YET = -1
+
 
 class DomainMonitorStatus(object):
     __slots__ = (
@@ -41,7 +43,7 @@
 
     def clear(self):
         self.error = None
-        self.lastCheck = time()
+        self.lastCheck = NOT_CHECKED_YET
         self.valid = True
         self.readDelay = 0
         self.diskUtilization = (None, None)
@@ -228,7 +230,7 @@
         self.nextStatus.lastCheck = time()
         self.nextStatus.valid = (self.nextStatus.error is None)
 
-        if self.status.valid != self.nextStatus.valid:
+        if self._statusDidChange():
             self.log.debug("Domain %s changed its status to %s", self.sdUUID,
                            "Valid" if self.nextStatus.valid else "Invalid")
 
@@ -250,3 +252,7 @@
                                self.sdUUID, exc_info=True)
 
         self.status.update(self.nextStatus)
+
+    def _statusDidChange(self):
+        return (self.status.lastCheck == NOT_CHECKED_YET or
+                self.status.valid != self.nextStatus.valid)
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index d4c5dfc..a91ae92 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -1051,12 +1051,16 @@
             pool = sp.StoragePool(spUUID, self.taskMng)
             if not hostID or not scsiKey or not msdUUID or not masterVersion:
                 hostID, scsiKey, msdUUID, masterVersion = pool.getPoolParams()
+
+            # Must register domain state change callbacks *before* connecting
+            # the pool, which starts domain monitor threads. Otherwise we will
+            # miss the first event from the monitor thread.
+            for cb in self.domainStateChangeCallbacks:
+                pool.domainMonitor.onDomainStateChange.register(cb)
+
             res = pool.connect(hostID, scsiKey, msdUUID, masterVersion)
             if res:
                 self.pools[spUUID] = pool
-                for callback in self.domainStateChangeCallbacks:
-                    self.pools[spUUID].domainMonitor.\
-                        onDomainStateChange.register(callback)
             return res
 
     @public
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 22d7a2d..b9ab60b 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -2953,6 +2953,10 @@
             else:
                 devices = self.getConfDevices()
 
+            for drive in devices[DISK_DEVICES]:
+                if drive['device'] == 'disk' and isVdsmImage(drive):
+                    self.sdIds.append(drive['domainID'])
+
         devMap = {DISK_DEVICES: Drive,
                   NIC_DEVICES: NetworkInterfaceDevice,
                   SOUND_DEVICES: SoundDevice,


-- 
To view, visit http://gerrit.ovirt.org/21782
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I56c468edb967de5bcf15259029ace84333fc4b7e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list