Exemplo n.º 1
0
    def __enter__(self):
        print("Checking Qemu out...")
        self.qemuwc = qemuwc = fast_repo_clone(
            self.qemugit, version=self.qproject.target_version, prefix="qemu")

        # 1: Instead of canceling cleaning just ignore directory absence.
        # It's easy to forget cancel the cleaning in future.
        self.cleaner.rmtree(qemuwc.working_tree_dir, absent_ok=True)

        # `fast_repo_clone` changes `.gitmodules` file. This change is not
        # required for consequent operation. So, revert it to avoid junk in
        # diff files.
        qemuwc.git.reset("HEAD", hard=True)

        self.tmp_build = tmp_build = mkdtemp(prefix="qemu-%s-build-" %
                                             self.qproject.target_version)

        self.cleaner.rmtree(tmp_build, absent_ok=True)  # search for # 1:

        print("Configuring Qemu...")
        configure = Popen([
            join(qemuwc.working_tree_dir, "configure"),
            "--target-list=" + ",".join(["x86_64-softmmu"])
        ],
                          env=dict(TEST_STARTUP_ENV),
                          cwd=tmp_build,
                          stderr=PIPE,
                          stdout=PIPE)
        configure.wait()
        if configure.returncode:
            raise RuntimeError(
                "Qemu configuration failed %u\nstdout:\n%s\nstderr:\n%s\n" %
                (configure.returncode, configure.stdout.read(),
                 configure.stderr.read()))

        if self.caches is not None:
            for cache in glob(join(self.caches, self.qvc_pattern)):
                copy(cache, tmp_build)

        print("Backing Qemu configuration...")
        self.q_back = q_back = mkdtemp(prefix="qemu-%s-back-" %
                                       self.qproject.target_version)

        self.cleaner.rmtree(q_back, absent_ok=True)  # search for # 1:

        copytree_ignore_error(qemuwc.working_tree_dir, join(q_back, "src"))
        copytree_ignore_error(tmp_build, join(q_back, "build"))

        self.prev_diff = None

        return self
Exemplo n.º 2
0
    def __enter__(self):
        print("Checking Qemu out...")
        self.qemuwc = qemuwc = fast_repo_clone(
            self.qemugit, version=self.qproject.target_version, prefix="qemu")

        # `fast_repo_clone` changes `.gitmodules` file. This change is not
        # required for consequent operation. So, revert it to avoid junk in
        # diff files.
        qemuwc.git.reset("HEAD", hard=True)

        self.tmp_build = tmp_build = mkdtemp(prefix="qemu-%s-build-" %
                                             self.qproject.target_version)

        print("Configuring Qemu...")
        configure = Popen([
            join(qemuwc.working_tree_dir, "configure"),
            "--target-list=" + ",".join(["x86_64-softmmu"])
        ],
                          env=dict(TEST_STARTUP_ENV),
                          cwd=tmp_build,
                          stderr=PIPE,
                          stdout=PIPE)
        configure.wait()
        if configure.returncode:
            raise RuntimeError(
                "Qemu configuration failed %u\nstdout:\n%s\nstderr:\n%s\n" %
                (configure.returncode, configure.stdout.read(),
                 configure.stderr.read()))

        print("Backing Qemu configuration...")
        self.q_back = q_back = mkdtemp(prefix="qemu-%s-back-" %
                                       self.qproject.target_version)

        copytree(qemuwc.working_tree_dir, join(q_back, "src"))
        copytree(tmp_build, join(q_back, "build"))

        self.prev_diff = None

        return self
Exemplo n.º 3
0
    def co_init_cache(self):
        if self.qvc is not None:
            print("Multiple QVC initialization " + self.src_path)
            self.qvc = None

        qvc_path = self.qvc_path = join(self.build_path, self.qvc_file_name)

        qemu_heuristic_hash = calculate_qh_hash()

        yield True

        if not isfile(qvc_path):
            self.qvc = QemuVersionCache()

            # Check out Qemu source to a temporary directory and analyze it
            # there. This avoids problems with user changes in main working
            # directory.

            print("Checking out temporary source tree...")

            # Note. Alternatively, checking out can be performed without
            # cloning. Instead, a magic might be casted on GIT_DIR and
            # GIT_WORK_TREE environment variables. But, this approach resets
            # staged files in src_path repository which can be inconvenient
            # for a user.
            tmp_repo = fast_repo_clone(self.repo, self.commit_sha, "qdt-qemu")
            tmp_work_dir = tmp_repo.working_tree_dir

            print("Temporary source tree: %s" % tmp_work_dir)

            # make new QVC active and begin construction
            prev_qvc = self.qvc.use()
            for path, recursive in self.include_paths:
                yield Header.co_build_inclusions(join(tmp_work_dir, path),
                                                 recursive)

            self.qvc.list_headers = self.qvc.stc.create_header_db()

            rmtree(tmp_work_dir)

            yield self.co_init_device_tree()

            yield self.co_gen_known_targets()

            # gen version description
            yield self.qvc.co_computing_parameters(self.repo, self.commit_sha)
            self.qvc.version_desc[QVD_QH_HASH] = qemu_heuristic_hash

            # Search for PCI Ids
            PCIClassification.build()

            yield True

            pythonize(self.qvc, qvc_path)
        else:
            self.load_cache()
            # make just loaded QVC active
            prev_qvc = self.qvc.use()

            if self.qvc.list_headers is not None:
                yield True

                yield self.qvc.stc.co_load_header_db(self.qvc.list_headers)

            yield True

            # verify that the version_desc is not outdated
            is_outdated = False
            try:
                checksum = self.qvc.version_desc[QVD_QH_HASH]
            except KeyError:
                is_outdated = True
            else:
                if not checksum == qemu_heuristic_hash:
                    is_outdated = True
            if is_outdated:
                yield self.qvc.co_computing_parameters(self.repo,
                                                       self.commit_sha)
                self.qvc.version_desc[QVD_QH_HASH] = qemu_heuristic_hash

            dt = self.qvc.device_tree
            if dt:
                # Targets to be added to the cache
                new_targets = self.softmmu_targets - dt.arches
                has_new_target = len(new_targets) > 0
            else:
                new_targets = self.softmmu_targets
                has_new_target = True

            if has_new_target:
                yield self.co_init_device_tree(new_targets)

            if is_outdated or has_new_target:
                pythonize(self.qvc, qvc_path)

        yield True

        # set Qemu version heuristics according to current version
        initialize_version(self.qvc.version_desc)

        yield True

        # initialize Qemu types in QVC
        get_vp()["qemu types definer"]()
        get_vp()["msi_init type definer"]()

        if prev_qvc is not None:
            prev_qvc.use()

        self.qvc_is_ready = True