Change in vdsm[master]: WIP: mom: better integration

fromani at redhat.com fromani at redhat.com
Mon Aug 18 10:03:34 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: WIP: mom: better integration
......................................................................

WIP: mom: better integration

this patch makes integration with MOM more efficient.
MOM is being updated to drop the implicit requirement of one thread
per VM being monitored, which of course scales poorly.

MOM will demand the actual call of the monitoring callbacks
to the hypervisor (VDSM) which can do that whatever way fits best
(event loop, threads, thread pool...) on the overall architecture.

The drawback is that MOM and VDSM requires a little bit complex
handshake, because each other can perform the registration
of the sampling code only at startup.

Moreover, now VM sampling must accapt opaque sampling code from
the outside, but this fits quite cleanly with the current and
with the future planned architecture.

This patch implement these new changes needed by VDSM.

Change-Id: I669e91be77c468b6fe8405d5b840d9fbb0dc2430
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm.spec.in
M vdsm/clientIF.py
M vdsm/virt/vm.py
3 files changed, 19 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/99/31599/1

diff --git a/vdsm.spec.in b/vdsm.spec.in
index 362067d..01ed15f 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -132,7 +132,7 @@
 Requires: libnl
 Requires: %{name}-xmlrpc = %{version}-%{release}
 Requires: %{name}-jsonrpc = %{version}-%{release}
-Requires: mom >= 0.4.1
+Requires: mom >= 0.5.0
 Requires: numactl
 
 %ifarch x86_64
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index bb42ee4..a84a96c 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -395,8 +395,9 @@
                         self.log.warning('vm %s already exists' %
                                          vmParams['vmId'])
                         return errCode['exist']
-                vm = Vm(self, vmParams, vmRecover)
-                self.vmContainer[vmParams['vmId']] = vm
+                with self.mom.register(vmParams['vmId']) as mmon:
+                    vm = Vm(self, vmParams, vmRecover, vmMonitors=(mmon,))
+                    self.vmContainer[vmParams['vmId']] = vm
             finally:
                 container_len = len(self.vmContainer)
         vm.run()
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 5b607b5..7510c55 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -195,7 +195,7 @@
 
     # CPU tune sampling window
     # minimum supported value is 2
-    CPU_TUNE_SAMPLING_WINDOW = 2
+    GENERIC_SAMPLING_WINDOW = 2
 
     # This flag will prevent excessive log flooding when running
     # on libvirt with no support for metadata xml elements.
@@ -206,7 +206,7 @@
     # TODO: Remove as soon as there is a hard dependency we can use
     _libvirt_metadata_supported = True
 
-    def __init__(self, vm):
+    def __init__(self, vm, extraMonitors=None):
         AdvancedStatsThread.__init__(self, log=vm.log, daemon=True)
         self._vm = vm
 
@@ -258,13 +258,22 @@
             AdvancedStatsFunction(
                 self._sampleCpuTune,
                 config.getint('vars', 'vm_sample_cpu_tune_interval'),
-                self.CPU_TUNE_SAMPLING_WINDOW))
+                self.GENERIC_SAMPLING_WINDOW))
 
         self.addStatsFunction(
             self.highWrite, self.updateVolumes, self.sampleCpu,
             self.sampleDisk, self.sampleDiskLatency, self.sampleNet,
             self.sampleBalloon, self.sampleVmJobs, self.sampleVcpuPinning,
             self.sampleCpuTune)
+
+        extraMonitors = (tuple() if extraMonitors is None
+                         else tuple(extraMonitors))
+        for mon in extraMonitors:
+            self.addStatsFunction(
+                AdvancedStatsFunction(
+                    mon.collect,
+                    mon.interval,
+                    self.GENERIC_SAMPLING_WIDNOW))
 
     def _highWrite(self):
         if not self._vm.isDisksStatsCollectionEnabled():
@@ -1478,7 +1487,7 @@
                                    caps.Architecture.PPC64: 'scsi'}
         return DEFAULT_DISK_INTERFACES[self.arch]
 
-    def __init__(self, cif, params, recover=False):
+    def __init__(self, cif, params, recover=False, monitors=None):
         """
         Initialize a new VM instance.
 
@@ -1557,6 +1566,7 @@
 
         self._powerDownEvent = threading.Event()
         self._liveMergeCleanupThreads = {}
+        self._extraMonitors = tuple() if monitors is None else monitors
 
     def _get_lastStatus(self):
         PAUSED_STATES = (vmstatus.POWERING_DOWN, vmstatus.REBOOT_IN_PROGRESS,
@@ -2733,7 +2743,7 @@
         return domxml.toxml()
 
     def _initVmStats(self):
-        self._vmStats = VmStatsThread(self)
+        self._vmStats = VmStatsThread(self, self._extraMonitors)
         self._vmStats.start()
         self._guestEventTime = self._startTime
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I669e91be77c468b6fe8405d5b840d9fbb0dc2430
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list