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-changelog

[Xen-changelog] [xen-unstable] blktap2: Fix sysfs handling of blktap2

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] blktap2: Fix sysfs handling of blktap2
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 23 Oct 2009 02:40:15 -0700
Delivery-date: Fri, 23 Oct 2009 02:40:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1256288977 -3600
# Node ID b5c6c4a584951a653dca20e168cc40dced1e6bae
# Parent  1e5c3059d23bfd2d8e5088404d7fdb96c83732e8
blktap2: Fix sysfs handling of blktap2

The pause and unpause paths are currently broken due to a missing
slash. I took advantage of the opportunity to remove code repetition,
repeated strings that should point to the proper constants, etc

From: Andres Lagar Cavilla <andreslc@xxxxxxxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/python/xen/xend/XendDomainInfo.py          |   44 ++++++++++++-----------
 tools/python/xen/xend/server/BlktapController.py |    4 --
 2 files changed, 24 insertions(+), 24 deletions(-)

diff -r 1e5c3059d23b -r b5c6c4a58495 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Fri Oct 23 10:05:15 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Fri Oct 23 10:09:37 2009 +0100
@@ -60,6 +60,7 @@ from xen.xend.XendConstants import *
 from xen.xend.XendConstants import *
 from xen.xend.XendAPIConstants import *
 from xen.xend.server.DevConstants import xenbusState
+from xen.xend.server.BlktapController import TAPDISK_DEVICE, parseDeviceString
 
 from xen.xend.XendVMMetrics import XendVMMetrics
 
@@ -528,18 +529,18 @@ class XendDomainInfo:
         try:
             if(self.domid):
                 # get all blktap2 devices
-                dev =  xstransact.List(self.vmpath + 'device/tap2')
+                dev =  xstransact.List(self.vmpath + '/device/tap2')
                 for x in dev:
                     path = self.getDeviceController('tap2').readBackend(x, 
'params')
-                    if path and path.startswith('/dev/xen/blktap-2'):
-                        #Figure out the sysfs path.
-                        pattern = re.compile('/dev/xen/blktap-2/tapdev(\d+)$')
-                        ctrlid = pattern.search(path)
-                        ctrl = '/sys/class/blktap2/blktap' + ctrlid.group(1)   
         
-                        #pause the disk
-                        f = open(ctrl + '/pause', 'w')
-                        f.write('pause');
-                        f.close()
+                    if path and path.startswith(TAPDISK_DEVICE):
+                        try:
+                            _minor, _dev, ctrl = parseDeviceString(path)
+                            #pause the disk
+                            f = open(ctrl + '/pause', 'w')
+                            f.write('pause');
+                            f.close()
+                        except:
+                            pass
         except Exception, ex:
             log.warn('Could not pause blktap disk.');
 
@@ -557,19 +558,20 @@ class XendDomainInfo:
         """
         try:
             if(self.domid):
-                dev =  xstransact.List(self.vmpath + 'device/tap2')
+                dev =  xstransact.List(self.vmpath + '/device/tap2')
                 for x in dev:
                     path = self.getDeviceController('tap2').readBackend(x, 
'params')
-                    if path and path.startswith('/dev/xen/blktap-2'):
-                        #Figure out the sysfs path.
-                        pattern = re.compile('/dev/xen/blktap-2/tapdev(\d+)$')
-                        ctrlid = pattern.search(path)
-                        ctrl = '/sys/class/blktap2/blktap' + ctrlid.group(1)
-                        #unpause the disk
-                        if(os.path.exists(ctrl + '/resume')):                  
-                            f = open(ctrl + '/resume', 'w');
-                            f.write('resume');
-                            f.close();
+                    if path and path.startswith(TAPDISK_DEVICE):
+                        try:
+                            #Figure out the sysfs path.
+                            _minor, _dev, ctrl = parseDeviceString(path)
+                            #unpause the disk
+                            if(os.path.exists(ctrl + '/resume')):              
    
+                                f = open(ctrl + '/resume', 'w');
+                                f.write('resume');
+                                f.close();
+                        except:
+                            pass
 
         except Exception, ex:
             log.warn('Could not unpause blktap disk: %s' % str(ex));
diff -r 1e5c3059d23b -r b5c6c4a58495 
tools/python/xen/xend/server/BlktapController.py
--- a/tools/python/xen/xend/server/BlktapController.py  Fri Oct 23 10:05:15 
2009 +0100
+++ b/tools/python/xen/xend/server/BlktapController.py  Fri Oct 23 10:09:37 
2009 +0100
@@ -235,9 +235,7 @@ class Blktap2Controller(BlktapController
         self.waitForBackend_destroy(backpath)
 
         #Figure out the sysfs path.
-        pattern = re.compile('/dev/xen/blktap-2/tapdev(\d+)$')
-        ctrlid = pattern.search(path)
-        ctrl = '/sys/class/blktap2/blktap' + ctrlid.group(1)
+        minor, dev, ctrl = parseDeviceString(path)
 
         #Close out the disk
         f = open(ctrl + '/remove', 'w')

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] blktap2: Fix sysfs handling of blktap2, Xen patchbot-unstable <=