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