WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xend: A small cleanup to the find_sysfs_m

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: A small cleanup to the find_sysfs_mnt() of pci.py
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Jul 2008 06:10:11 -0700
Delivery-date: Mon, 14 Jul 2008 06:10:16 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1216026565 -3600
# Node ID 2463e2ef602f64e091d14303beef1ae10126c3c4
# Parent  d14c017e8163a7619d72b18b77f2bf3dbfce25de
xend: A small cleanup to the find_sysfs_mnt() of pci.py
Signed-off-by: Dexuan Cui <dexuan.cui@xxxxxxxxx>
---
 tools/python/xen/util/pci.py |   54 +++++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 30 deletions(-)

diff -r d14c017e8163 -r 2463e2ef602f tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Mon Jul 14 10:07:11 2008 +0100
+++ b/tools/python/xen/util/pci.py      Mon Jul 14 10:09:25 2008 +0100
@@ -40,6 +40,9 @@ MSIX_SIZE_MASK = 0x7ff
 # Global variable to store information from lspci
 lspci_info = None
 
+# Global variable to store the sysfs mount point
+sysfs_mnt_point = None
+
 #Calculate PAGE_SHIFT: number of bits to shift an address to get the page 
number
 PAGE_SIZE = resource.getpagesize()
 PAGE_SHIFT = 0
@@ -63,27 +66,28 @@ def parse_hex(val):
         return None
 
 def find_sysfs_mnt():
-    mounts_file = open(PROC_MNT_PATH,'r')
-
-    for line in mounts_file:
-        sline = line.split()
-        if len(sline)<3:
-            continue
-
-        if sline[2]=='sysfs':
-            return sline[1]
-
+    global sysfs_mnt_point
+    if not sysfs_mnt_point is None:
+        return sysfs_mnt_point
+
+    try:
+        mounts_file = open(PROC_MNT_PATH,'r')
+
+        for line in mounts_file:
+            sline = line.split()
+            if len(sline)<3:
+                continue
+            if sline[2]=='sysfs':
+                sysfs_mnt_point= sline[1]
+                return sysfs_mnt_point
+    except IOError, (errno, strerr):
+        raise PciDeviceParseError(('Failed to locate sysfs mount: %s: %s (%d)'%
+            (PROC_PCI_PATH, strerr, errno)))
     return None
 
 def get_all_pci_names():
-    try:
-        sysfs_mnt = find_sysfs_mnt()
-    except IOError, (errno, strerr):
-        raise PciDeviceParseError(('Failed to locate sysfs mount: %s (%d)' %
-            (PROC_PCI_PATH, strerr, errno)))
-
+    sysfs_mnt = find_sysfs_mnt()
     pci_names = os.popen('ls ' + sysfs_mnt + 
SYSFS_PCI_DEVS_PATH).read().split()
-
     return pci_names
 
 def get_all_pci_devices():
@@ -175,12 +179,7 @@ class PciDevice:
         self.get_info_from_lspci()
 
     def find_capability(self, type):
-        try:
-            sysfs_mnt = find_sysfs_mnt()
-        except IOError, (errno, strerr):
-            raise PciDeviceParseError(('Failed to locate sysfs mount: %s (%d)' 
%
-                (PROC_PCI_PATH, strerr, errno)))
-
+        sysfs_mnt = find_sysfs_mnt()
         if sysfs_mnt == None:
             return False
         path = sysfs_mnt+SYSFS_PCI_DEVS_PATH+'/'+ \
@@ -218,7 +217,7 @@ class PciDevice:
                         self.pba_offset = self.pba_offset & ~MSIX_BIR_MASK
                         break
         except IOError, (errno, strerr):
-            raise PciDeviceParseError(('Failed to locate sysfs mount: %s (%d)' 
%
+            raise PciDeviceParseError(('Failed to locate sysfs mount: %s: %s 
(%d)' %
                 (PROC_PCI_PATH, strerr, errno)))
 
     def remove_msix_iomem(self, index, start, size):
@@ -237,12 +236,7 @@ class PciDevice:
 
     def get_info_from_sysfs(self):
         self.find_capability(0x11)
-        try:
-            sysfs_mnt = find_sysfs_mnt()
-        except IOError, (errno, strerr):
-            raise PciDeviceParseError(('Failed to locate sysfs mount: %s (%d)' 
%
-                (PROC_PCI_PATH, strerr, errno)))
-
+        sysfs_mnt = find_sysfs_mnt()
         if sysfs_mnt == None:
             return False
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xend: A small cleanup to the find_sysfs_mnt() of pci.py, Xen patchbot-unstable <=