WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] tools/python/xend: VBD QoS policy bits

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] tools/python/xend: VBD QoS policy bits
From: William Pitcock <nenolod@xxxxxxxxxxxxxxxx>
Date: Fri Aug 14 09:48:47 2009 -0500
Delivery-date: Fri, 14 Aug 2009 08:04:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Add the ability to define VBD QoS policy in the xend layer.

Consider the following vbd entry:

vbd = [
   'phy:/dev/server/virtualmachine1-disk,xvda1,w,credit=5000/s@50ms',
]

This means that a VM may perform 5000 I/O operations per second, with
credit being replenished every 50 milliseconds.

The 'credit' xenstore value is by the blkback driver to ratelimit I/O
operations for the specific device.

Signed-off-by: William Pitcock <nenolod@xxxxxxxxxxxxxxxx>

---

 README.sxpcfg            |    1 +
 xen/xend/server/blkif.py |   43 ++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/tools/python/README.sxpcfg b/tools/python/README.sxpcfg
--- a/tools/python/README.sxpcfg
+++ b/tools/python/README.sxpcfg
@@ -82,6 +82,7 @@
   - uname
   - dev (ioemu:, .. etc)
   - mode (r, w. w!)
+  - credit
 
 vif
   - type
diff --git a/tools/python/xen/xend/server/blkif.py 
b/tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py
+++ b/tools/python/xen/xend/server/blkif.py
@@ -42,6 +42,37 @@
 
         return os.access(auxbin.scripts_dir() + '/block-%s' % protocol, 
os.X_OK)
 
+    def _calculateRateLimit(self, credstr):
+        """Calculate the rate limit, given a string like: 5000/s@50ms.
+        If this fails, the limit is unlimited.
+        """
+        credit_per_interval = 0xffffffffL
+        interval_usecs = 0L
+
+        credit_re = re.compile("^([0-9]+)/s(@([0-9]+)([mu]?)s)?$")
+
+        m = credit_re.match(credstr)
+        if m:
+            credit_per_sec = m.group(1)
+
+            if m.group(2) is None:
+                interval_usecs = 50000L      # 50ms default
+            else:
+                interval_usecs = long(m.group(5))
+                if m.group(3) == '':
+                    interval_usecs *= 1000 * 1000
+                elif m.group(3) == 'm':
+                    interval_usecs *= 1000
+
+            credit_per_interval = (credit_per_sec * interval_usecs) / 1000000L
+
+            # overflow / underflow checking: default to unlimited rate
+            if credit_per_interval == 0 or credit_per_interval > 0xffffffffL 
or \
+               interval_usecs == 0 or interval_usecs > 0xffffffffL:
+                credit_per_interval = 0xffffffffL
+                interval_usecs     = 0L
+
+        return "%lu,%lu" % (credit_per_interval, interval_usecs)
 
     def getDeviceDetails(self, config):
         """@see DevController.getDeviceDetails"""
@@ -91,6 +122,10 @@
         if security.on() == xsconstants.XS_POLICY_USE:
             self.do_access_control(config, uname)
 
+        cred = config.get('credit', '')
+        if cred:
+            back['credit'] = self._calculateRateLimit(cred)
+
         (device_path, devid) = blkif.blkdev_name_to_number(dev)
         if devid is None:
             raise VmError('Unable to find number for device (%s)' % (dev))
@@ -153,12 +188,12 @@
         config = DevController.getDeviceConfiguration(self, devid, transaction)
         if transaction is None:
             devinfo = self.readBackend(devid, 'dev', 'type', 'params', 'mode',
-                                       'uuid', 'bootable')
+                                       'uuid', 'bootable', 'credit')
         else:
             devinfo = self.readBackendTxn(transaction, devid,
                                           'dev', 'type', 'params', 'mode', 
'uuid',
-                                          'bootable')
-        dev, typ, params, mode, uuid, bootable = devinfo
+                                          'bootable', 'credit')
+        dev, typ, params, mode, uuid, bootable, credit = devinfo
         
         if dev:
             if transaction is None:
@@ -178,6 +213,8 @@
             config['uuid'] = uuid
         if bootable != None:
             config['bootable'] = int(bootable)
+        if credit:
+            config['credit'] = credit
 
         proto = self.readFrontend(devid, 'protocol')
         if proto:

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>