[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] remus: init sch_plug module based on kernel version



# HG changeset patch
# User Shriram Rajagopalan <rshriram@xxxxxxxxx>
# Date 1365173581 25200
# Node ID 70553546d4b5d2d067d2b979524f105202ab5bdd
# Parent  47eefd4c4b405cdb6fba7cb2df972d0ba207911a
remus: init sch_plug module based on kernel version

sch_plug module, for network buffering, is available as part of linux
kernel (from 3.4 onwards), as opposed to an out-of-tree module.
The netlink message format to talk to the in-kernel module is different from
that of the old version.  So, before initializing the Plug Qdisc, check
the kernel version and use the appropriate message format.

Also change the names of the constants to reflect the format used by the 
mainline
module [CHECKPOINT -> BUFFER , RELEASE -> RELEASE_ONE ].

Signed-off-by: Shriram Rajagopalan <rshriram@xxxxxxxxx>

diff -r 47eefd4c4b40 -r 70553546d4b5 tools/python/xen/remus/device.py
--- a/tools/python/xen/remus/device.py  Thu Mar 28 10:32:17 2013 +0000
+++ b/tools/python/xen/remus/device.py  Fri Apr 05 07:53:01 2013 -0700
@@ -332,12 +332,12 @@
         if not self.installed:
             self.install()
 
-        self._sendqmsg(qdisc.TC_PLUG_CHECKPOINT)
+        self._sendqmsg(qdisc.TC_PLUG_BUFFER)
 
     def commit(self):
         '''Called when checkpoint has been acknowledged by
         the backup'''
-        self._sendqmsg(qdisc.TC_PLUG_RELEASE)
+        self._sendqmsg(qdisc.TC_PLUG_RELEASE_ONE)
 
     # private
     def _sendqmsg(self, action):
diff -r 47eefd4c4b40 -r 70553546d4b5 tools/python/xen/remus/qdisc.py
--- a/tools/python/xen/remus/qdisc.py   Thu Mar 28 10:32:17 2013 +0000
+++ b/tools/python/xen/remus/qdisc.py   Fri Apr 05 07:53:01 2013 -0700
@@ -1,6 +1,9 @@
 import socket, struct
 
 import netlink
+import platform
+
+kernelversion = platform.platform(terse=True).split("-")[1].split(".")
 
 qdisc_kinds = {}
 
@@ -146,13 +149,18 @@
 
 qdisc_kinds['cfifo'] = CfifoQdisc
 
-TC_PLUG_CHECKPOINT = 0
-TC_PLUG_RELEASE = 1
+TC_PLUG_BUFFER = 0
+TC_PLUG_RELEASE_ONE = 1
 
 class PlugQdisc(Qdisc):
-    fmt = 'I'
 
     def __init__(self, qdict=None):
+        if int(kernelversion[0]) >= 3 and int(kernelversion[1]) >= 4:
+            self.fmt = 'iI'
+            self.limit = 10000
+        else:
+            self.fmt = 'I'
+
         if not qdict:
             qdict = {'kind': 'plug',
                      'handle': TC_H_ROOT}
@@ -161,7 +169,10 @@
         self.action = 0
 
     def pack(self):
-        return struct.pack(self.fmt, self.action)
+        if int(kernelversion[0]) >= 3 and int(kernelversion[1]) >= 4:
+            return struct.pack(self.fmt, self.action, self.limit)
+        else:
+            return struct.pack(self.fmt, self.action)
 
     def parse(self, args):
         if not args:
@@ -169,9 +180,9 @@
         arg = args[0]
 
         if arg == 'checkpoint':
-            self.action = TC_PLUG_CHECKPOINT
+            self.action = TC_PLUG_BUFFER
         elif arg == 'release':
-            self.action = TC_PLUG_RELEASE
+            self.action = TC_PLUG_RELEASE_ONE
         else:
             raise QdiscException('unknown action')
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.