Change in vdsm[master]: vm: add helper to get disk params from bulk stats

fromani at redhat.com fromani at redhat.com
Fri Jan 9 09:44:13 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: vm: add helper to get disk params from bulk stats
......................................................................

vm: add helper to get disk params from bulk stats

Bulk stats give also the disk parameters (highest
allocated sector), so add an helper to leverage this
information and to avoid the need to another libvirt call.

Change-Id: I515500ee0b347e83c0230d2f67b5a554146f9807
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 21 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/36723/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index da736bd..5b6a3c7 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2309,7 +2309,7 @@
         with self._confLock:
             self.conf['timeOffset'] = newTimeOffset
 
-    def _getExtendCandidates(self):
+    def _getExtendCandidates(self, bulkStats=None):
         ret = []
 
         # FIXME: mergeCandidates should be a dictionary of candidate volumes
@@ -2319,7 +2319,11 @@
             if not drive.blockDev or drive.format != 'cow':
                 continue
 
-            capacity, alloc, physical = self._dom.blockInfo(drive.path, 0)
+            try:
+                capacity, alloc, physical = self._getDiskParameters(
+                    drive, bulkStats)
+            except (KeyError, ValueError):
+                continue
             ret.append((drive, drive.volumeID, capacity, alloc, physical))
 
             try:
@@ -2330,6 +2334,19 @@
                         mergeCandidate['capacity'], mergeCandidate['alloc'],
                         mergeCandidate['physical']))
         return ret
+
+    def _getDiskParameters(self, drive, bulkStats=None):
+        if bulkStats is None:
+            return self._dom.blockInfo(drive.path, 0)
+        else:
+            idx = _findBulkStatIndex(
+                'block', drive.path, bulkStats, attr='path')
+            if idx is None:
+                raise ValueError('missing block info for %s', drive.path)
+            return (
+                bulkStats['block.%d.capacity' % idx],
+                bulkStats['block.%d.allocation' % idx],
+                bulkStats['block.%d.physical' % idx])
 
     def _shouldExtendVolume(self, drive, volumeID, capacity, alloc, physical):
         # Since the check based on nextPhysSize is extremly risky (it
@@ -2365,9 +2382,9 @@
             return True
         return False
 
-    def extendDrivesIfNeeded(self):
+    def extendDrivesIfNeeded(self, bulkStats=None):
         try:
-            extend = [x for x in self._getExtendCandidates()
+            extend = [x for x in self._getExtendCandidates(bulkStats)
                       if self._shouldExtendVolume(*x)]
         except ImprobableResizeRequestError:
             return False


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I515500ee0b347e83c0230d2f67b5a554146f9807
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list