Milan Zamazal has uploaded a new change for review.
Change subject: virt: Fetch only minimum VM stats during post-copy migration ......................................................................
virt: Fetch only minimum VM stats during post-copy migration
When a migration switches to post-copy mode, the VM starts running on the destination. Libvirt no longer provides actual stats on the source, with the exception of progress, which is still available on the source and only on the source.
This patch stops reporting stats other than progress during post-copy migration.
Change-Id: Iac3da08b0816e7a9a247969147c17b15518c7624 Signed-off-by: Milan Zamazal mzamazal@redhat.com Bug-Url: https://bugzilla.redhat.com/1354343 --- M vdsm/virt/migration.py M vdsm/virt/vm.py 2 files changed, 21 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/63552/8
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py index 13f2155..63cdf8c 100644 --- a/vdsm/virt/migration.py +++ b/vdsm/virt/migration.py @@ -149,6 +149,11 @@ def hibernating(self): return self._mode == MODE_FILE
+ @property + def in_post_copy(self): + return (self._monitorThread is not None and + self._monitorThread.in_post_copy) + def getStat(self): """ Get the status of the migration. @@ -653,6 +658,10 @@ def enabled(self): return MonitorThread._MIGRATION_MONITOR_INTERVAL > 0
+ @property + def in_post_copy(self): + return self._in_post_copy + @utils.traceback() def run(self): if self.enabled: diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index e274388..f32d119 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -1198,10 +1198,15 @@ if self.lastStatus == vmstatus.DOWN: stats.update(self._getDownVmStats()) else: - stats.update(self._getConfigVmStats()) - stats.update(self._getRunningVmStats()) + if self.isMigrating() and self._migrationSourceThread.in_post_copy: + # Stats are on the destination during post-copy migration, + # except for migration progress, which is always on the source. + stats['migrationProgress'] = self._get_vm_migration_progress() + else: + stats.update(self._getConfigVmStats()) + stats.update(self._getRunningVmStats()) + stats.update(self._getGuestStats()) stats['status'] = self._getVmStatus() - stats.update(self._getGuestStats()) return stats
def _getDownVmStats(self): @@ -1255,7 +1260,7 @@ if 'pauseCode' in self.conf: stats['pauseCode'] = self.conf['pauseCode'] if self.isMigrating(): - stats['migrationProgress'] = self.migrateStatus()['progress'] + stats['migrationProgress'] = self._get_vm_migration_progress()
try: vm_sample = sampling.stats_cache.get(self.id) @@ -1346,6 +1351,9 @@ else: return self.lastStatus
+ def _get_vm_migration_progress(self): + return self.migrateStatus()['progress'] + def _getGraphicsStats(self): def getInfo(dev): return {