Change in vdsm[master]: profile: runtime support to enable/disable profile

fromani at redhat.com fromani at redhat.com
Mon Nov 10 22:20:28 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: profile: runtime support to enable/disable profile
......................................................................

profile: runtime support to enable/disable profile

Currently, the only way to enable profiling support
in VDSM is to edit the configuration file and
restart the process.

This makes hard to profile specific flows without
doing a full restart of VDSM and adding extra noise.

This patch adds support to enable or disable
profiling support at runtime, using vdsClient.
This feature is expected to be used only in development,
or maybe as debug aid in controlled environments.

To prevent any form of misbehaving in production
environment, an additional tunable is added, disabled
by default, to enable this runtime support.

Change-Id: I32441b2c211acbf3bb91202b2e4c3e01eb3f40d9
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M client/vdsClient.py
M lib/vdsm/config.py.in
M vdsm/API.py
M vdsm/vdsm
4 files changed, 48 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/35016/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index 9091644..cc48906 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -1617,6 +1617,12 @@
             print message
             return 0, ''
 
+    def enableProfile(self, args):
+        return self.ExecAndExit(self.s.enableProfile())
+
+    def disableProfile(self, args):
+        return self.ExecAndExit(self.s.disableProfile())
+
     def _eqSplit(self, args):
         d = {}
         for arg in args:
@@ -2715,6 +2721,18 @@
                 '<vmId> <vcpuLimit>',
                 'set SLA parameter for a VM'
             )),
+        'enableProfile': (
+            serv.enableProfile, (
+                '',
+                'Enable dynamic profiling of VDSM. '
+                'Requires configuration on the host.'
+            )),
+        'disableProfile': (
+            serv.disableProfile, (
+                '',
+                'Disable dynamic profiling of VDSM. '
+                'Requires configuration on the host.'
+            )),
     }
     if _glusterEnabled:
         commands.update(ge.getGlusterCmdDict(serv))
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index 92d3af5..9618b7f 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -348,6 +348,9 @@
         ('profile_clock', 'cpu',
             'Sets the underlying clock type (cpu, wall)'),
 
+        ('profile_dynamic', 'false',
+            'Control profiling support using vdsClient'),
+
         ('python_warnings_enable', 'false',
             'Display python warnings in the log'),
 
diff --git a/vdsm/API.py b/vdsm/API.py
index 1ef4b00..0bf5d9a 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -38,6 +38,7 @@
 from clientIF import clientIF
 from vdsm import netinfo
 from vdsm import constants
+from vdsm import profile
 import storage.misc
 import storage.clusterlock
 import storage.volume
@@ -1613,6 +1614,28 @@
             return errCode['haErr']
         return {'status': doneCode}
 
+    def enableProfile(self):
+        if config.getboolean('devel', 'profile_dynamic'):
+            if not profile.is_running():
+                profile.start()
+                return {'status': doneCode}
+            else:
+                self.log.error("dynamic profiling already enabled")
+        else:
+            self.log.error("dynamic profiling not supported")
+        return errCode['unavail']
+
+    def disableProfile(self):
+        if config.getboolean('devel', 'profile_dynamic'):
+            if profile.is_running():
+                profile.stop()
+                return {'status': doneCode}
+            else:
+                self.log.error("dynamic profiling already disabled")
+        else:
+            self.log.error("dynamic profiling not supported")
+        return errCode['unavail']
+
     # take a rough estimate on how much free mem is available for new vm
     # memTotal = memFree + memCached + mem_used_by_non_qemu + resident  .
     # simply returning (memFree + memCached) is not good enough, as the
diff --git a/vdsm/vdsm b/vdsm/vdsm
index 9004c8c..2318030 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -75,7 +75,8 @@
     signal.signal(signal.SIGUSR1, sigusr1Handler)
     zombiereaper.registerSignalHandler()
 
-    profile.start()
+    if not config.getboolean('devel', 'profile_dynamic'):
+        profile.start()
 
     libvirtconnection.start_event_loop()
 
@@ -92,7 +93,8 @@
         while running[0]:
             signal.pause()
 
-        profile.stop()
+        if not config.getboolean('devel', 'profile_dynamic'):
+            profile.stop()
     finally:
         cif.prepareForShutdown()
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32441b2c211acbf3bb91202b2e4c3e01eb3f40d9
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