Francesco Romani has uploaded a new change for review.

Change subject: vm: always log when guest CPU state changes
......................................................................

vm: always log when guest CPU state changes

In order to track down recent 'paused' issues,
and in order to improve debuggability of VDSM,
add a log when the guest CPU state changes.

Since this event is supposed to be sporadic,
this will not add noise to the logs.

Change-Id: Ia0749c5082954b7c9ed8781a860d7e538d34aa7e
Relates-To: https://bugzilla.redhat.com/1131548
Signed-off-by: Francesco Romani <[email protected]>
---
M vdsm/virt/vm.py
1 file changed, 14 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/97/31697/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index be3418b..ecd2199 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2324,7 +2324,7 @@
                 self.log.error('cannot cont while %s', self.lastStatus)
                 return errCode['unexpected']
             self._underlyingCont()
-            self.updateGuestCpuRunning()
+            self._updateGuestCpuStatus(reason='continue')
             self._lastStatus = afterState
             try:
                 with self._confLock:
@@ -2344,7 +2344,7 @@
             with self._confLock:
                 self.conf['pauseCode'] = pauseCode
             self._underlyingPause()
-            self.updateGuestCpuRunning()
+            self._updateGuestCpuStatus(reason='pause')
             self._lastStatus = afterState
             return {'status': doneCode, 'output': ['']}
         finally:
@@ -2778,9 +2778,6 @@
         else:
             return status[0] == libvirt.VIR_DOMAIN_RUNNING
 
-    def updateGuestCpuRunning(self):
-        self._guestCpuRunning = self._isDomainRunning()
-
     def _getUnderlyingVmDevicesInfo(self):
         """
         Obtain underlying vm's devices info from libvirt.
@@ -2875,7 +2872,7 @@
             except Exception:
                 self.log.exception("Failed to connect to guest agent channel")
 
-        self._guestCpuRunning = self._isDomainRunning()
+        self._updateGuestCpuStatus(reason='domain initialization')
         if self.lastStatus not in (vmstatus.MIGRATION_DESTINATION,
                                    vmstatus.RESTORING_STATE):
             self._initTimePauseCode = self._readPauseCode(0)
@@ -4513,7 +4510,7 @@
             self.log.info('abnormal vm stop device %s error %s',
                           blockDevAlias, err)
             self.conf['pauseCode'] = err.upper()
-            self._guestCpuRunning = False
+            self._updateGuestCpuStatus(reason='onIOError', running=False)
             if err.upper() == 'ENOSPC':
                 if not self.extendDrivesIfNeeded():
                     self.log.info("No VM drives were extended")
@@ -5215,7 +5212,7 @@
                     self.user_destroy = True
                 self._onQemuDeath()
         elif event == libvirt.VIR_DOMAIN_EVENT_SUSPENDED:
-            self._guestCpuRunning = False
+            self._updateGuestCpuStatus(reason='onSuspend', running=False)
             if detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_PAUSED:
                 # Libvirt sometimes send the SUSPENDED/SUSPENDED_PAUSED event
                 # after RESUMED/RESUMED_MIGRATED (when VM status is PAUSED
@@ -5230,7 +5227,7 @@
                     hooks.after_vm_pause(domxml, self.conf)
 
         elif event == libvirt.VIR_DOMAIN_EVENT_RESUMED:
-            self._guestCpuRunning = True
+            self._updateGuestCpuStatus(reason='onResume', running=True)
             if detail == libvirt.VIR_DOMAIN_EVENT_RESUMED_UNPAUSED:
                 # This is not a real solution however the safest way to handle
                 # this for now. Ultimately we need to change the way how we are
@@ -5624,6 +5621,14 @@
             if dev['type'] == BALLOON_DEVICES:
                 yield dev
 
+    def _updateGuestCpuStatus(self, reason='update', running=None):
+        self._guestCpuRunning = (self._isDomainRunning()
+                                 if running is None else running)
+        self.log.debug('VM=`%s` CPU %s: %s',
+                       self.id,
+                       'running' if self._guestCpuRunning else 'stopped',
+                       reason)
+
 
 class LiveMergeCleanupThread(threading.Thread):
     def __init__(self, vm, jobId, drive):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0749c5082954b7c9ed8781a860d7e538d34aa7e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to