mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
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@cs.toronto.edu> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
This commit is contained in:
1 parent
0dba100da6
commit
5856aed296
2 files changed
+24
-24
No files matched your search
@@ -60,6 +60,7 @@ from xen.xend.xenstore.xswatch import xswatch
|
||||
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));
|
||||
|
||||
@@ -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')
|
||||
|
||||