ia64/xen-unstable

changeset 1725:0c56e48ba3b6

bitkeeper revision 1.1056 (40ee8548FSHN81_Xbjs1fGV_cPdH5Q)

Get the EINTR-safe _readline and _readlines.
author mjw@wray-m-3.hpl.hp.com
date Fri Jul 09 11:45:12 2004 +0000 (2004-07-09)
parents e04e40b4615f
children 1836a17e5c3f
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Jul 09 10:39:20 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Jul 09 11:45:12 2004 +0000
     1.3 @@ -19,6 +19,7 @@ from twisted.internet import defer
     1.4  
     1.5  import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
     1.6  import xen.util.ip
     1.7 +from xen.util.ip import _readline, _readlines
     1.8  
     1.9  import sxp
    1.10  
    1.11 @@ -31,24 +32,6 @@ xend = server.SrvDaemon.instance()
    1.12  SIF_BLK_BE_DOMAIN = (1<<4)
    1.13  SIF_NET_BE_DOMAIN = (1<<5)
    1.14  
    1.15 -def readlines(fd):
    1.16 -    """Version of readlines safe against EINTR.
    1.17 -    """
    1.18 -    import errno
    1.19 -    
    1.20 -    lines = []
    1.21 -    while 1:
    1.22 -        try:
    1.23 -            line = fd.readline()
    1.24 -        except IOError, ex:
    1.25 -            if ex.errno == errno.EINTR:
    1.26 -                continue
    1.27 -            else:
    1.28 -                raise
    1.29 -        if line == '': break
    1.30 -        lines.append(line)
    1.31 -    return lines
    1.32 -
    1.33  class VmError(ValueError):
    1.34      """Vm construction error."""
    1.35  
    1.36 @@ -90,7 +73,7 @@ def lookup_raw_partn(partition):
    1.37  
    1.38      if drive == partition:
    1.39          fd = os.popen( '/sbin/sfdisk -s ' + drive + ' 2>/dev/null' )
    1.40 -        line = readline(fd)
    1.41 +        line = _readline(fd)
    1.42          if line:
    1.43              return [ { 'device' : blkdev_name_to_number(drive),
    1.44                         'start_sector' : long(0),
    1.45 @@ -102,7 +85,7 @@ def lookup_raw_partn(partition):
    1.46      fd = os.popen( '/sbin/sfdisk -d ' + drive + ' 2>/dev/null' )
    1.47  
    1.48      #['/dev/sda3 : start= 16948575, size=16836120, Id=83, bootable\012']
    1.49 -    lines = readlines(fd)
    1.50 +    lines = _readlines(fd)
    1.51      for line in lines:
    1.52          m = re.search( '^' + partition + '\s*: start=\s*([0-9]+), ' +
    1.53                         'size=\s*([0-9]+), Id=\s*(\S+).*$', line)