[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH][1] xend: avoid tapdisk2 not exit for tap-ctl list failed
Process a is closing tapdisk2 for vm1. Process b is starting to close vm2. Process b maybe cannot get the tapdisk info of vm2 using tap-ctl list. Signed-off-by: Yi Li <peteryili@xxxxxxxxxxx> --- tools/python/xen/xend/server/BlktapController.py | 31 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/python/xen/xend/server/BlktapController.py b/tools/python/xen/xend/server/BlktapController.py index 60079eb..0bff247 100644 --- a/tools/python/xen/xend/server/BlktapController.py +++ b/tools/python/xen/xend/server/BlktapController.py @@ -206,6 +206,8 @@ class TapdiskController(object): TAP_CTL = 'tap-ctl' TAP_DEV = '/dev/xen/blktap-2/tapdev' + TAPDISK_SYSFS = '/sys/class/blktap2' + TAPDISK_CONTROL = TAPDISK_SYSFS + '/blktap' class Tapdisk(object): def __init__(self, pid=None, minor=-1, state=None, @@ -274,11 +276,30 @@ class TapdiskController(object): @staticmethod def fromDevice(device): if device.startswith(TapdiskController.TAP_DEV): - minor = os.minor(os.stat(device).st_rdev) - tapdisks = filter(lambda x: x.minor == minor, - TapdiskController.list()) - if len(tapdisks) == 1: - return tapdisks[0] + tapdisk = TapdiskController.Tapdisk() + pattern = re.compile(TapdiskController.TAP_DEV + '(\d+)$') + groups = pattern.search(device) + if not groups: + raise Exception, 'malformed tap device: ' + device + minor = groups.group(1) + control = TapdiskController.TAPDISK_CONTROL + minor + + tapdisk.minor = int(minor) + if tapdisk.minor >= 0: + tapdisk.device = '%s%s' % \ + (TapdiskController.TAP_DEV, tapdisk.minor) + + pid_file = open(control + '/task') + tapdisk.pid = int(pid_file.readline()) + pid_file.close() + + args_file = open(control + '/name') + value = args_file.readline() + args_file.close() + if value.find(':') != -1: + tapdisk.dtype, tapdisk.image = value.split(':', 1) + + return tapdisk return None @staticmethod -- 1.7.12.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |