debuggers.hg

changeset 20882:cec57fd4565e

tools: fix sysfs error path

Attached patch fixes sysfs error path.
NetBSD also has a /proc/mounts file but no sysfs.
On Linux you can test this with sysfs not mounted.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 21 11:27:11 2010 +0000 (2010-01-21)
parents 0bf9e66c5201
children d1efaaee441b
files tools/python/xen/util/pci.py tools/python/xen/util/utils.py tools/python/xen/util/vscsi_util.py
line diff
     1.1 --- a/tools/python/xen/util/pci.py	Thu Jan 21 11:26:26 2010 +0000
     1.2 +++ b/tools/python/xen/util/pci.py	Thu Jan 21 11:27:11 2010 +0000
     1.3 @@ -441,6 +441,8 @@ def find_sysfs_mnt():
     1.4  
     1.5  def get_all_pci_names():
     1.6      sysfs_mnt = find_sysfs_mnt()
     1.7 +    if sysfs_mnt is None:
     1.8 +        return None
     1.9      pci_names = os.popen('ls ' + sysfs_mnt + SYSFS_PCI_DEVS_PATH).read().split()
    1.10      return pci_names
    1.11  
     2.1 --- a/tools/python/xen/util/utils.py	Thu Jan 21 11:26:26 2010 +0000
     2.2 +++ b/tools/python/xen/util/utils.py	Thu Jan 21 11:27:11 2010 +0000
     2.3 @@ -68,7 +68,9 @@ def find_sysfs_mount():
     2.4                  continue
     2.5              if sline[2] == 'sysfs':
     2.6                  sysfs_mount_point= sline[1]
     2.7 -                return sysfs_mount_point
     2.8 +                break
     2.9 +        mounts_file.close()
    2.10 +        return sysfs_mount_point
    2.11      except IOError, (errno, strerr):
    2.12          raise
    2.13  
     3.1 --- a/tools/python/xen/util/vscsi_util.py	Thu Jan 21 11:26:26 2010 +0000
     3.2 +++ b/tools/python/xen/util/vscsi_util.py	Thu Jan 21 11:27:11 2010 +0000
     3.3 @@ -123,6 +123,9 @@ def _vscsi_get_scsidevices_by_sysfs():
     3.4      except:
     3.5          return devices
     3.6  
     3.7 +    if sysfs_mnt is None:
     3.8 +        return devices
     3.9 +
    3.10      for dirpath, dirnames, files in os.walk(sysfs_mnt + SYSFS_SCSI_PATH):
    3.11          for hctl in dirnames:
    3.12              paths = os.path.join(dirpath, hctl)