Change in vdsm[master]: virt: Move Vm._getUnderlyingRngDeviceInfo() out of Vm

mzamazal at redhat.com mzamazal at redhat.com
Fri Feb 26 16:24:32 UTC 2016


Milan Zamazal has uploaded a new change for review.

Change subject: virt: Move Vm._getUnderlyingRngDeviceInfo() out of Vm
......................................................................

virt: Move Vm._getUnderlyingRngDeviceInfo() out of Vm

This is just a simple move of code, following the Sound device example.

Change-Id: If4a8c14da22db5fd1091dde0f6e9c4d3a2dd8b40
Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
---
M vdsm/virt/vm.py
M vdsm/virt/vmdevices/core.py
2 files changed, 24 insertions(+), 26 deletions(-)


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

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 527aa5b..856bb8c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1726,12 +1726,12 @@
         vmdevices.core.Sound.update_device_info(self)
         vmdevices.core.Video.update_device_info(self)
         self._getUnderlyingGraphicsDeviceInfo()
-        self._getUnderlyingRngDeviceInfo()
         self._getUnderlyingConsoleDeviceInfo()
         vmdevices.core.Controller.update_device_info(self)
         vmdevices.core.Balloon.update_device_info(self)
         vmdevices.core.Watchdog.update_device_info(self)
         vmdevices.core.Smartcard.update_device_info(self)
+        vmdevices.core.Rng.update_device_info(self)
         self._getUnderlyingHostDeviceInfo()
         self._getUnderlyingMemoryDeviceInfo()
         # Obtain info of all unknown devices. Must be last!
@@ -4057,31 +4057,6 @@
                 if dev['device'] == hwclass.CONSOLE and \
                         not dev.get('alias'):
                     dev['alias'] = alias
-
-    def _getUnderlyingRngDeviceInfo(self):
-        """
-        Obtain rng device info from libvirt.
-        """
-        for rng in self._domain.get_device_elements('rng'):
-            address = vmxml.device_address(rng)
-            alias = rng.getElementsByTagName('alias')[0].getAttribute('name')
-            source = rng.getElementsByTagName('backend')[0].firstChild.\
-                nodeValue
-
-            for dev in self._devices[hwclass.RNG]:
-                if caps.RNG_SOURCES[dev.specParams['source']] == source and \
-                        not hasattr(dev, 'alias'):
-                    dev.address = address
-                    dev.alias = alias
-                    break
-
-            for dev in self.conf['devices']:
-                if dev['type'] == hwclass.RNG and \
-                        caps.RNG_SOURCES[dev['specParams']['source']] == \
-                        source and 'alias' not in dev:
-                    dev['address'] = address
-                    dev['alias'] = alias
-                    break
 
     def _getUnderlyingHostDeviceUSBInfo(self, x):
         alias = x.getElementsByTagName('alias')[0].getAttribute('name')
diff --git a/vdsm/virt/vmdevices/core.py b/vdsm/virt/vmdevices/core.py
index e6e19aa..0984411 100644
--- a/vdsm/virt/vmdevices/core.py
+++ b/vdsm/virt/vmdevices/core.py
@@ -382,6 +382,29 @@
 
         return rng
 
+    @classmethod
+    def update_device_info(cls, vm):
+        for rng in vm.domain.get_device_elements('rng'):
+            address = vmxml.device_address(rng)
+            alias = rng.getElementsByTagName('alias')[0].getAttribute('name')
+            source = rng.getElementsByTagName('backend')[0].firstChild.\
+                nodeValue
+
+            for dev in vm.get_devices(hwclass.RNG):
+                if caps.RNG_SOURCES[dev.specParams['source']] == source and \
+                        not hasattr(dev, 'alias'):
+                    dev.address = address
+                    dev.alias = alias
+                    break
+
+            for dev in vm.conf['devices']:
+                if dev['type'] == hwclass.RNG and \
+                        caps.RNG_SOURCES[dev['specParams']['source']] == \
+                        source and 'alias' not in dev:
+                    dev['address'] = address
+                    dev['alias'] = alias
+                    break
+
 
 class Tpm(Base):
     __slots__ = ()


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4a8c14da22db5fd1091dde0f6e9c4d3a2dd8b40
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Milan Zamazal <mzamazal at redhat.com>


More information about the vdsm-patches mailing list