Esempio n. 1
0
    def _WorkloadSetup(self):
        # find our source tarball
        if 'tarball' in self._cfg:
            tarfile = os.path.join(self.srcdir, self._cfg.tarfile)
            if not os.path.exists(tarfile):
                raise rtevalRuntimeError(self, " tarfile %s does not exist!" % tarfile)
            self.source = tarfile
        else:
            tarfiles = glob.glob(os.path.join(self.srcdir, "%s*" % kernel_prefix))
            if tarfiles:
                self.source = tarfiles[0]
            else:
                raise rtevalRuntimeError(self, " no kernel tarballs found in %s" % self.srcdir)

        # check for existing directory
        kdir = None
        names = os.listdir(self.builddir)
        for d in names:
            if d.startswith(kernel_prefix):
                kdir = d
                break
        if kdir is None:
            self._extract_tarball()
            names = os.listdir(self.builddir)
            for d in names:
                self._log(Log.DEBUG, "checking %s" % d)
                if d.startswith(kernel_prefix):
                    kdir = d
                    break
        if kdir is None:
            raise rtevalRuntimeError(self, "Can't find kernel directory!")
        self.mydir = os.path.join(self.builddir, kdir)
        self._log(Log.DEBUG, "mydir = %s" % self.mydir)
        self._log(Log.DEBUG, "systopology: %s" % self.topology)
        self.jobs = len(self.topology)
        self.args = []

        # get the cpus for each node
        self.cpus = {}
        self.nodes = self.topology.getnodes()
        for n in self.nodes:
            self.cpus[n] = [int(c.split('/')[-1][3:]) for c in glob.glob('/sys/devices/system/node/node%s/cpu[0-9]*' % n)]
            self.cpus[n].sort()

            # if a cpulist was specified, only allow cpus in that list on the node
            if self.cpulist:
                self.cpus[n] = [c for c in self.cpus[n] if str(c) in expand_cpulist(self.cpulist)]

        # remove nodes with no cpus available for running
        for node, cpus in self.cpus.items():
            if not cpus:
                self.nodes.remove(node)
                self._log(Log.DEBUG, "node %s has no available cpus, removing" % node)

        for n in self.nodes:
            self._log(Log.DEBUG, "Configuring build job for node %d" % int(n))
            self.buildjobs[n] = KBuildJob(self.topology[n], self.mydir, \
                self.logger, self.cpus[n] if self.cpulist else None)
            self.args.append(str(self.buildjobs[n])+";")
Esempio n. 2
0
    def _WorkloadSetup(self):
        # find our source tarball
        if self._cfg.has_key('tarball'):
            tarfile = os.path.join(self.srcdir, self._cfg.tarfile)
            if not os.path.exists(tarfile):
                raise rtevalRuntimeError(
                    self, " tarfile %s does not exist!" % tarfile)
            self.source = tarfile
        else:
            tarfiles = glob.glob(
                os.path.join(self.srcdir, "%s*" % kernel_prefix))
            if len(tarfiles):
                self.source = tarfiles[0]
            else:
                raise rtevalRuntimeError(
                    self, " no kernel tarballs found in %s" % self.srcdir)

        # check for existing directory
        kdir = None
        names = os.listdir(self.builddir)
        for d in names:
            if d.startswith(kernel_prefix):
                kdir = d
                break
        if kdir == None:
            self._log(Log.DEBUG, "unpacking kernel tarball")
            tarargs = ['tar', '-C', self.builddir, '-x']
            if self.source.endswith(".bz2"):
                tarargs.append("-j")
            elif self.source.endswith(".gz"):
                tarargs.append("-z")
            tarargs.append("-f")
            tarargs.append(self.source)
            try:
                subprocess.call(tarargs)
            except:
                self._log(Log.DEBUG, "untar'ing kernel self.source failed!")
                sys.exit(-1)
            names = os.listdir(self.builddir)
            for d in names:
                self._log(Log.DEBUG, "checking %s" % d)
                if d.startswith(kernel_prefix):
                    kdir = d
                    break
        if kdir == None:
            raise rtevalRuntimeError(self, "Can't find kernel directory!")
        self.mydir = os.path.join(self.builddir, kdir)
        self._log(Log.DEBUG, "mydir = %s" % self.mydir)
        self._log(Log.DEBUG, "systopology: %s" % self.topology)
        self.jobs = len(self.topology)
        self.args = []
        for n in self.topology:
            self._log(Log.DEBUG, "Configuring build job for node %d" % int(n))
            self.buildjobs[n] = KBuildJob(n, self.mydir, self.logger)
            self.args.append(str(self.buildjobs[n]) + ";")
Esempio n. 3
0
    def _WorkloadSetup(self):
        # find our source tarball
        if self._cfg.has_key('source') and self._cfg.source is not None:
            source = os.path.abspath(self._cfg.source)
            if not os.path.exists(source):
                raise rtevalRuntimeError(self, " source directory %s does not exist!" % source)
            self.source = source
            self.mydir = source
        else:
            if self._cfg.has_key('tarball') and self._cfg.tarball is not None:
                tarfile = os.path.abspath(self._cfg.tarball)
                if not os.path.exists(tarfile):
                    raise rtevalRuntimeError(self, " tarfile %s does not exist!" % tarfile)
                self.source = tarfile
            else:
                tarfiles = glob.glob(os.path.join(self.srcdir, "%s*" % kernel_prefix))
                if len(tarfiles):
                    self.source = tarfiles[0]
                else:
                    raise rtevalRuntimeError(self, " no kernel tarballs found in %s" % self.srcdir)

            # check for existing directory
            kdir=None
            names=os.listdir(self.builddir)
            for d in names:
                if d.startswith(kernel_prefix):
                    kdir=d
                    break
            if kdir == None:
                self._log(Log.DEBUG, "unpacking kernel tarball")
                tarargs = ['tar', '-C', self.builddir, '-x']
                if self.source.endswith(".bz2"):
                    tarargs.append("-j")
                elif self.source.endswith(".gz"):
                    tarargs.append("-z")
                tarargs.append("-f")
                tarargs.append(self.source)
                try:
                    subprocess.call(tarargs, preexec_fn=set_usergroup_ids)
                except:
                    raise rtevalRuntimeError(self, " untar'ing kernel '%s' failed!" % self.source)
                names = os.listdir(self.builddir)
                for d in names:
                    self._log(Log.DEBUG, "checking %s" % d)
                    if d.startswith(kernel_prefix):
                        kdir=d
                        break
            if kdir == None:
                raise rtevalRuntimeError(self, "Can't find kernel directory!")
            self.mydir = os.path.join(self.builddir, kdir)
        self.jobs = 1 # We only run one instance of the kcompile job
        self._log(Log.DEBUG, "mydir = %s" % self.mydir)
Esempio n. 4
0
    def _WorkloadBuild(self):
        null = os.open("/dev/null", os.O_RDWR)
        if self._logging:
            out = self.open_logfile("kcompile-build.stdout")
            err = self.open_logfile("kcompile-build.stderr")
        else:
            out = err = null

        # clean up any damage from previous runs
        try:
            cmd = ["make", "-C", self.mydir, "mrproper"]
            ret = subprocess.call(cmd, stdin=null, stdout=out, stderr=err)
            if ret:
                # if the above make failed, remove and reinstall the source tree
                self._log(Log.DEBUG, "Invalid state in kernel build tree, reloading")
                self._remove_build_dirs()
                self._extract_tarball()
                ret = subprocess.call(cmd, stdin=null, stdout=out, stderr=err)
                if ret:
                    # give up
                    raise rtevalRuntimeError(self, "kcompile setup failed: %d" % ret)
        except KeyboardInterrupt as m:
            self._log(Log.DEBUG, "keyboard interrupt, aborting")
            return
        self._log(Log.DEBUG, "ready to run")
        if self._logging:
            os.close(out)
            os.close(err)
        # clean up object dirs and make sure each has a config file
        for n in self.nodes:
            self.buildjobs[n].clean(sin=null, sout=null, serr=null)
        os.close(null)
        self._setReady()
Esempio n. 5
0
 def _remove_build_dirs(self):
     if not os.path.isdir(self.builddir):
         return
     self._log(Log.DEBUG, "removing kcompile directories in %s" % self.builddir)
     null = os.open("/dev/null", os.O_RDWR)
     cmd = ["rm", "-rf", os.path.join(self.builddir, "kernel*"),
            os.path.join(self.builddir, "node*")]
     ret = subprocess.call(cmd, stdin=null, stdout=null, stderr=null)
     if ret:
         raise rtevalRuntimeError(self, \
             "error removing builddir (%s) (ret=%d)" % (self.builddir, ret))
Esempio n. 6
0
 def _extract_tarball(self):
     if self.source is None:
         raise rtevalRuntimeError(self, " no source tarball specified!")
     self._log(Log.DEBUG, "unpacking kernel tarball")
     tarargs = ['tar', '-C', self.builddir, '-x']
     if self.source.endswith(".bz2"):
         tarargs.append("-j")
     elif self.source.endswith(".gz"):
         tarargs.append("-z")
     tarargs.append("-f")
     tarargs.append(self.source)
     try:
         subprocess.call(tarargs)
     except:
         self._log(Log.DEBUG, "untar'ing kernel self.source failed!")
         sys.exit(-1)
Esempio n. 7
0
    def _WorkloadBuild(self):
        self._log(Log.DEBUG, "setting up all module config file in %s" % self.mydir)
        null = os.open("/dev/null", os.O_RDWR)
        if self._logging:
            out = self.open_logfile("kcompile-build.stdout")
            err = self.open_logfile("kcompile-build.stderr")
        else:
            out = err = null

        # clean up from potential previous run
        try:
            ret = subprocess.call(["make", "-C", self.mydir, "mrproper", "allmodconfig"], 
                                  stdin=null, stdout=out, stderr=err,
                                  preexec_fn=set_usergroup_ids)
            if ret:
                raise rtevalRuntimeError(self, "kcompile setup failed: %d" % ret)
        except KeyboardInterrupt, m:
            self._log(Log.DEBUG, "keyboard interrupt, aborting")
            return
Esempio n. 8
0
    def _WorkloadBuild(self):
        null = os.open("/dev/null", os.O_RDWR)
        if self._logging:
            out = self.open_logfile("kcompile-build.stdout")
            err = self.open_logfile("kcompile-build.stderr")
        else:
            out = err = null

        # clean up any damage from previous runs
        try:
            ret = subprocess.call(["make", "-C", self.mydir, "mrproper"],
                                  stdin=null,
                                  stdout=out,
                                  stderr=err)
            if ret:
                raise rtevalRuntimeError(self,
                                         "kcompile setup failed: %d" % ret)
        except KeyboardInterrupt, m:
            self._log(Log.DEBUG, "keyboard interrupt, aborting")
            return