Change in vdsm[ovirt-3.6]: supervdsm: only trigger 'vfio' subsystem for VFIO devices

mpolednik at redhat.com mpolednik at redhat.com
Tue Sep 22 08:55:04 UTC 2015


Hello Piotr Kliczewski, Francesco Romani,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/46508

to review the following change.

Change subject: supervdsm: only trigger 'vfio' subsystem for VFIO devices
......................................................................

supervdsm: only trigger 'vfio' subsystem for VFIO devices

In order to avoid triggering of all events we need to use specialized
variant of udevTrigger. This patch creates new private trigger function
to add ability to trigger specific subsystems. This avoids refreshing
everything, possibly eliminating way of triggering everything via
host devices subsystem.

Change-Id: Icb4fecbe5108a6ff7d695887e6e60df36e4874d7
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/45345
Continuous-Integration: Jenkins CI
Reviewed-by: Michal Skrivanek <michal.skrivanek at redhat.com>
Reviewed-by: Francesco Romani <fromani at redhat.com>
Reviewed-by: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
---
M lib/vdsm/udevadm.py
M vdsm/supervdsmServer
2 files changed, 21 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/08/46508/1

diff --git a/lib/vdsm/udevadm.py b/lib/vdsm/udevadm.py
index 24327d3..35970fe 100644
--- a/lib/vdsm/udevadm.py
+++ b/lib/vdsm/udevadm.py
@@ -61,7 +61,7 @@
         logging.error("%s", e)
 
 
-def trigger(attr_matches=(), property_matches=()):
+def trigger(attr_matches=(), property_matches=(), subsystem_matches=()):
     '''
     Request device events from the kernel.
 
@@ -84,6 +84,13 @@
 
                         and causes only events from devices that match
                         given property to be triggered.
+
+    subsystem_matches   Expects an iterable of subsystems.
+
+                        ('a', 'b') ~> --subsystem-match=a --subsystem-match=b
+
+                        Causes only events related to specified subsystem to
+                        be triggered.
     '''
     _run_command(['control', '--reload'])
 
@@ -95,6 +102,9 @@
     for name, value in attr_matches:
         cmd.append('--attr-match={}={}'.format(name, value))
 
+    for name in subsystem_matches:
+        cmd.append('--subsystem-match={}'.format(name))
+
     _run_command(cmd)
 
 
diff --git a/vdsm/supervdsmServer b/vdsm/supervdsmServer
index a12e440..0dc0670 100755
--- a/vdsm/supervdsmServer
+++ b/vdsm/supervdsmServer
@@ -303,11 +303,7 @@
 
     @logDecorator
     def udevTriggerMultipath(self, guid):
-        try:
-            udevadm.trigger(property_matches=(('DM_NAME', guid),))
-        except udevadm.Error as e:
-            raise OSError(errno.EINVAL, 'Could not trigger change '
-                          'out %s\nerr %s' % (e.out, e.err))
+        self._udevTrigger(property_matches=(('DM_NAME', guid),))
 
     @logDecorator
     def appropriateMultipathDevice(self, guid, thiefId):
@@ -362,7 +358,7 @@
                 self.log.debug("Creating rule %s: %r", rule_file, rule)
                 rf.write(rule)
 
-            udevadm.trigger()
+            self._udevTrigger(subsystem_matches=('vfio',))
 
     @logDecorator
     def rmAppropriateIommuGroup(self, iommu_group):
@@ -389,7 +385,7 @@
             self.log.debug("Removing rule %s", rule_file)
 
         if not error:
-            udevadm.trigger()
+            self._udevTrigger(subsystem_matches=('vfio',))
 
     @logDecorator
     def ksmTune(self, tuningParams):
@@ -465,6 +461,13 @@
     def set_rp_filter_strict(self, dev):
         sysctl.set_rp_filter_strict(dev)
 
+    def _udevTrigger(self, *args, **kwargs):
+        try:
+            udevadm.trigger(*args, **kwargs)
+        except udevadm.Error as e:
+            raise OSError(errno.EINVAL, 'Could not trigger change '
+                          'out %s\nerr %s' % (e.out, e.err))
+
 
 def terminate(signo, frame):
     global _running


-- 
To view, visit https://gerrit.ovirt.org/46508
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb4fecbe5108a6ff7d695887e6e60df36e4874d7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>


More information about the vdsm-patches mailing list