Francesco Romani has uploaded a new change for review.

Change subject: vm: use getVmPolicy for sampling
......................................................................

vm: use getVmPolicy for sampling

This patch lets VmStatsThread leverage getVmPolicy. Benefits:
- lesser coupling between VmStatsThread and Vm
- remove code duplicaton

Change-Id: Ie73d7b2200e6fb6d25552e2668b96670c5b87b13
Signed-off-by: Francesco Romani <[email protected]>
---
M vdsm/virt/vm.py
1 file changed, 6 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/29932/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index bb69792..cb6aa89 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -307,31 +307,18 @@
         infos['vcpuCount'] = self._vm._dom.vcpusFlags(
             libvirt.VIR_DOMAIN_VCPU_CURRENT)
 
-        metadataCpuLimit = None
+        qos = None
 
         try:
             if VmStatsThread._libvirt_metadata_supported:
-                metadataCpuLimit = self._vm._dom.metadata(
-                    libvirt.VIR_DOMAIN_METADATA_ELEMENT,
-                    METADATA_VM_TUNE_URI, 0)
+                qos = self._vm.getVmPolicy()
         except libvirt.libvirtError as e:
             if e.get_error_code() == libvirt.VIR_ERR_ARGUMENT_UNSUPPORTED:
                 VmStatsThread._libvirt_metadata_supported = False
                 self._log.error("libvirt does not support metadata")
 
-            elif (e.get_error_code()
-                  not in (libvirt.VIR_ERR_NO_DOMAIN,
-                          libvirt.VIR_ERR_NO_DOMAIN_METADATA)):
-                # Non-existing VM and no metadata block are expected
-                # conditions and no reasons for concern here.
-                # All other errors should be reported.
-                self._log.warn("Failed to retrieve QoS metadata because of %s",
-                               e)
-
-        if metadataCpuLimit:
-            metadataCpuLimitXML = _domParseStr(metadataCpuLimit)
-            nodeList = \
-                metadataCpuLimitXML.getElementsByTagName('vcpulimit')
+        if qos:
+            nodeList = qos.getElementsByTagName('vcpulimit')
             infos['vcpuLimit'] = nodeList[0].childNodes[0].data
 
         return infos
@@ -3690,7 +3677,7 @@
         #
         # Get the current QoS block
         metadata_modified = False
-        qos = self._getVmPolicy()
+        qos = self.getVmPolicy()
         if qos is None:
             return self._reportError(key='updateVmPolicyErr')
 
@@ -3737,7 +3724,7 @@
 
         return {'status': doneCode}
 
-    def _getVmPolicy(self):
+    def getVmPolicy(self):
         """
         This method gets the current qos block from the libvirt metadata.
         If there is not any, it will create a new empty DOM tree with


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie73d7b2200e6fb6d25552e2668b96670c5b87b13
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to