summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
authorJean-François Dagenais <dagenaisj@sonatest.com>2012-01-15 20:11:05 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-16 12:24:42 +0000
commit16e09b850dcb44cb1afe411439e40a4bae7e8002 (patch)
tree0137705bd729e8616ded6e648f58ce09a336b217 /meta
parentaad04928116feea421fba84c4780b93191be6169 (diff)
downloadopenembedded-core-16e09b850dcb44cb1afe411439e40a4bae7e8002.tar.gz
openembedded-core-16e09b850dcb44cb1afe411439e40a4bae7e8002.tar.bz2
openembedded-core-16e09b850dcb44cb1afe411439e40a4bae7e8002.zip
buildstats: tolerate absence of /proc/diskstats
In OpenVZ containers (and probably lx containers as well), the diskstats entry is not even present. Use the "NoLogicalDrive" introduced by Elizabeth Flanagan in such case. This allows the bitbaking to occure within such containers. Signed-off-by: Jean-François Dagenais <jeff.dagenais@gmail.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/buildstats.bbclass25
1 files changed, 15 insertions, 10 deletions
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 4cd8fe6936..9690a04100 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -61,11 +61,13 @@ def set_device(e):
# we do not collect diskstats as the method to collect meaningful statistics
# for these fs types requires a bit more research.
############################################################################
- for line in open("/proc/diskstats", "r"):
- if majordev == int(line.split()[0]) and minordev == int(line.split()[1]):
- rdev=line.split()[2]
- else:
- rdev="NoLogicalDevice"
+ rdev="NoLogicalDevice"
+ try:
+ for line in open("/proc/diskstats", "r"):
+ if majordev == int(line.split()[0]) and minordev == int(line.split()[1]):
+ rdev=line.split()[2]
+ except:
+ pass
file = open(e.data.getVar('DEVFILE', True), "w")
file.write(rdev)
file.close()
@@ -82,12 +84,15 @@ def get_diskstats(dev):
# For info on what these are, see kernel doc file iostats.txt
############################################################################
DSTAT_KEYS = ['ReadsComp', 'ReadsMerged', 'SectRead', 'TimeReads', 'WritesComp', 'SectWrite', 'TimeWrite', 'IOinProgress', 'TimeIO', 'WTimeIO']
- for x in open("/proc/diskstats", "r"):
- if dev in x:
- diskstats_val = x.rstrip().split()[4:]
- diskstats = dict(itertools.izip(DSTAT_KEYS, diskstats_val))
+ try:
+ for x in open("/proc/diskstats", "r"):
+ if dev in x:
+ diskstats_val = x.rstrip().split()[4:]
+ except IOError as e:
+ return
+ diskstats = dict(itertools.izip(DSTAT_KEYS, diskstats_val))
return diskstats
-
+
def set_diskdata(var, dev, data):
data.setVar(var, get_diskstats(dev))