Francesco Romani has uploaded a new change for review.

Change subject: vm: reorganize the graphic devices lookup
......................................................................

vm: reorganize the graphic devices lookup

this patch extracts a method to gather and
return all the graphic devices of a Vm, either
new style (proper device) or legacy (reconstructed
from the display* params).

The correct order of the devices is preserved:
* first the one reconstructed from the legacy params,
  if any
* then the additional one

and proper locking (using _confLock) is used to avoid
races.

Change-Id: I231087647e515a1f310de45b659e512444bd0a1d
Signed-off-by: Francesco Romani <from...@redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 14 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/96/27596/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 198cbce..445a750 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2651,10 +2651,16 @@
         # updated in Vm._run (buildConfDevices and the following code).
         # easily reproduced with functional tests, but also possible
         # in the wild
-        for dev in self.conf.get('devices', []) + self.getConfGraphics():
+        for dev in self._getAllConfGraphicDevices():
+            stats.update(getInfo(dev))
+            break
+
+    def _getAllConfGraphicDevices(self):
+        with self._confLock:
+            devices = self.getConfGraphics() + self.conf.get('devices', [])
+        for dev in devices:
             if dev['type'] == GRAPHICS_DEVICES:
-                stats.update(getInfo(dev))
-                break
+                yield dev
 
     def isMigrating(self):
         return self._migrationSourceThread.isAlive()
@@ -3016,8 +3022,9 @@
         for dev in devices.values():
             newDevices.extend(dev)
 
-        self.conf['devices'] = newDevices
-        self._cleanLegacyGraphics()
+        with self._confLock:
+            self.conf['devices'] = newDevices
+            self._cleanLegacyGraphics()
 
     def _cleanLegacyGraphics(self):
         """
@@ -4389,10 +4396,8 @@
 
     @property
     def hasSpice(self):
-        return any(
-            dev['device'] == 'spice'
-            for dev in self.conf.get('devices', self.getConfGraphics())
-            if dev['type'] == GRAPHICS_DEVICES)
+        return any(dev['device'] == 'spice'
+                   for dev in self._getAllConfGraphicDevices())
 
     def _getPid(self):
         pid = '0'


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I231087647e515a1f310de45b659e512444bd0a1d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <from...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to