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

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


Milan Zamazal has uploaded a new change for review.

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

virt: Move Vm._getUnderlyingWatchdogDeviceInfo() out of Vm

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

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


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/94/54094/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index d5d34ce..c85d72a 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._getUnderlyingWatchdogDeviceInfo()
         self._getUnderlyingSmartcardDeviceInfo()
         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)
         self._getUnderlyingHostDeviceInfo()
         self._getUnderlyingMemoryDeviceInfo()
         # Obtain info of all unknown devices. Must be last!
@@ -4168,28 +4168,6 @@
                               'alias': alias,
                               'address': address}
                 self.conf['devices'].append(hostdevice)
-
-    def _getUnderlyingWatchdogDeviceInfo(self):
-        """
-        Obtain watchdog device info from libvirt.
-        """
-        for x in self._domain.get_device_elements('watchdog'):
-
-            # PCI watchdog has "address" different from ISA watchdog
-            if x.getElementsByTagName('address'):
-                address = vmxml.device_address(x)
-                alias = x.getElementsByTagName('alias')[0].getAttribute('name')
-
-                for wd in self._devices[hwclass.WATCHDOG]:
-                    if not hasattr(wd, 'address') or not hasattr(wd, 'alias'):
-                        wd.address = address
-                        wd.alias = alias
-
-                for dev in self.conf['devices']:
-                    if ((dev['type'] == hwclass.WATCHDOG) and
-                            (not dev.get('address') or not dev.get('alias'))):
-                        dev['address'] = address
-                        dev['alias'] = alias
 
     def _getDriveIdentification(self, dom):
         sources = dom.getElementsByTagName('source')
diff --git a/vdsm/virt/vmdevices/core.py b/vdsm/virt/vmdevices/core.py
index 07b2559..21b45f4 100644
--- a/vdsm/virt/vmdevices/core.py
+++ b/vdsm/virt/vmdevices/core.py
@@ -434,6 +434,26 @@
         if not hasattr(self, 'specParams'):
             self.specParams = {}
 
+    @classmethod
+    def update_device_info(cls, vm):
+        for x in vm.domain.get_device_elements('watchdog'):
+
+            # PCI watchdog has "address" different from ISA watchdog
+            if x.getElementsByTagName('address'):
+                address = vmxml.device_address(x)
+                alias = x.getElementsByTagName('alias')[0].getAttribute('name')
+
+                for wd in vm.get_devices(hwclass.WATCHDOG):
+                    if not hasattr(wd, 'address') or not hasattr(wd, 'alias'):
+                        wd.address = address
+                        wd.alias = alias
+
+                for dev in vm.conf['devices']:
+                    if ((dev['type'] == hwclass.WATCHDOG) and
+                            (not dev.get('address') or not dev.get('alias'))):
+                        dev['address'] = address
+                        dev['alias'] = alias
+
     def getXML(self):
         """
         Create domxml for a watchdog device.


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

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