ia64/xen-unstable

changeset 19700:e7b63b30ae3d

blktap2: human readable output for tapdisk2 creation problems

This patch fixes the "file object has no attribute find" failure
we've been seeing when starting blktap2 devices and adds more
meaningful error output to conditions where the tapdisk2 process is
unable to create a blktap2 device.

Signed-off-by: Dutch Meyer <dmeyer@cs.ubc.ca>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 03 11:10:07 2009 +0100 (2009-06-03)
parents 18c8270da77c
children f989778298d8
files tools/python/xen/xend/server/BlktapController.py
line diff
     1.1 --- a/tools/python/xen/xend/server/BlktapController.py	Wed Jun 03 11:09:14 2009 +0100
     1.2 +++ b/tools/python/xen/xend/server/BlktapController.py	Wed Jun 03 11:10:07 2009 +0100
     1.3 @@ -32,7 +32,7 @@ def doexec(args, inputtext=None):
     1.4          proc.tochild.write(inputtext)
     1.5      stdout = proc.fromchild
     1.6      stderr = proc.childerr
     1.7 -    rc = proc.poll()
     1.8 +    rc = proc.wait()
     1.9      return (rc,stdout,stderr)
    1.10  
    1.11  def parseDeviceString(device):
    1.12 @@ -131,7 +131,16 @@ class BlktapController(BlkifController):
    1.13          cmd = [ TAPDISK_BINARY, '-n', '%s:%s' % (params, file) ]
    1.14          (rc,stdout,stderr) = doexec(cmd)
    1.15  
    1.16 -        minor, device, control = parseDeviceString(stdout)
    1.17 +        if rc != 0:
    1.18 +            err = stderr.read();
    1.19 +            out = stdout.read();
    1.20 +            stdout.close();
    1.21 +            stderr.close();
    1.22 +            raise Exception, 'Failed to create device.\n    stdout: %s\n    stderr: %s\nCheck that target \"%s\" exists and that blktap2 driver installed in dom0.' % (out.rstrip(), err.rstrip(), file);
    1.23 +
    1.24 +        minor, device, control = parseDeviceString(stdout.readline())
    1.25 +        stdout.close();
    1.26 +        stderr.close();
    1.27  
    1.28          #modify the configuration to attach as a vbd, now that the
    1.29          #device is configured.  Then continue to create the device