| OLD | NEW |
| 1 import os, logging, datetime, glob | 1 import os, logging, datetime, glob |
| 2 import shutil | 2 import shutil |
| 3 from autotest_lib.client.bin import utils, os_dep | 3 from autotest_lib.client.bin import utils, os_dep |
| 4 from autotest_lib.client.common_lib import error | 4 from autotest_lib.client.common_lib import error |
| 5 import kvm_utils | 5 import kvm_utils |
| 6 | 6 |
| 7 | 7 |
| 8 def check_configure_options(script_path): | 8 def check_configure_options(script_path): |
| 9 """ | 9 """ |
| 10 Return the list of available options (flags) of a given kvm configure build | 10 Return the list of available options (flags) of a given kvm configure build |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 224 |
| 225 # Do we want to save the result of the build on test.resultsdir? | 225 # Do we want to save the result of the build on test.resultsdir? |
| 226 self.save_results = True | 226 self.save_results = True |
| 227 save_results = params.get('save_results', 'no') | 227 save_results = params.get('save_results', 'no') |
| 228 if save_results == 'no': | 228 if save_results == 'no': |
| 229 self.save_results = False | 229 self.save_results = False |
| 230 | 230 |
| 231 self._full_module_list = list(self._module_list()) | 231 self._full_module_list = list(self._module_list()) |
| 232 | 232 |
| 233 | 233 |
| 234 def install_unittests(self): |
| 235 userspace_srcdir = os.path.join(self.srcdir, "kvm_userspace") |
| 236 test_repo = self.params.get("test_git_repo") |
| 237 test_branch = self.params.get("test_branch", "master") |
| 238 test_commit = self.params.get("test_commit", None) |
| 239 test_lbranch = self.params.get("test_lbranch", "master") |
| 240 |
| 241 if test_repo: |
| 242 test_srcdir = os.path.join(self.srcdir, "kvm-unit-tests") |
| 243 kvm_utils.get_git_branch(test_repo, test_branch, test_srcdir, |
| 244 test_commit, test_lbranch) |
| 245 unittest_cfg = os.path.join(test_srcdir, 'x86', |
| 246 'unittests.cfg') |
| 247 self.test_srcdir = test_srcdir |
| 248 else: |
| 249 unittest_cfg = os.path.join(userspace_srcdir, 'kvm', 'test', 'x86', |
| 250 'unittests.cfg') |
| 251 self.unittest_cfg = None |
| 252 if os.path.isfile(unittest_cfg): |
| 253 self.unittest_cfg = unittest_cfg |
| 254 else: |
| 255 if test_repo: |
| 256 logging.error("No unittest config file %s found, skipping " |
| 257 "unittest build", self.unittest_cfg) |
| 258 |
| 259 self.unittest_prefix = None |
| 260 if self.unittest_cfg: |
| 261 logging.info("Building and installing unittests") |
| 262 os.chdir(os.path.dirname(os.path.dirname(self.unittest_cfg))) |
| 263 utils.system('./configure --prefix=%s' % self.prefix) |
| 264 utils.system('make') |
| 265 utils.system('make install') |
| 266 self.unittest_prefix = os.path.join(self.prefix, 'share', 'qemu', |
| 267 'tests') |
| 268 |
| 269 |
| 234 def full_module_list(self): | 270 def full_module_list(self): |
| 235 """Return the module list used by the installer | 271 """Return the module list used by the installer |
| 236 | 272 |
| 237 Used by the module_probe test, to avoid using utils.unload_module(). | 273 Used by the module_probe test, to avoid using utils.unload_module(). |
| 238 """ | 274 """ |
| 239 if self._full_module_list is None: | 275 if self._full_module_list is None: |
| 240 raise KvmNotInstalled("KVM modules not installed yet (installer: %s)
" % (type(self))) | 276 raise KvmNotInstalled("KVM modules not installed yet (installer: %s)
" % (type(self))) |
| 241 return self._full_module_list | 277 return self._full_module_list |
| 242 | 278 |
| 243 | 279 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 370 |
| 335 def _install_packages(self): | 371 def _install_packages(self): |
| 336 """ | 372 """ |
| 337 Install all downloaded packages. | 373 Install all downloaded packages. |
| 338 """ | 374 """ |
| 339 os.chdir(self.srcdir) | 375 os.chdir(self.srcdir) |
| 340 utils.system("yum install --nogpgcheck -y *.rpm") | 376 utils.system("yum install --nogpgcheck -y *.rpm") |
| 341 | 377 |
| 342 | 378 |
| 343 def install(self): | 379 def install(self): |
| 380 self.install_unittests() |
| 344 self._clean_previous_installs() | 381 self._clean_previous_installs() |
| 345 self._get_packages() | 382 self._get_packages() |
| 346 self._install_packages() | 383 self._install_packages() |
| 347 create_symlinks(test_bindir=self.test_bindir, | 384 create_symlinks(test_bindir=self.test_bindir, |
| 348 bin_list=self.qemu_bin_paths) | 385 bin_list=self.qemu_bin_paths, |
| 386 unittest=self.unittest_prefix) |
| 349 self.reload_modules_if_needed() | 387 self.reload_modules_if_needed() |
| 350 if self.save_results: | 388 if self.save_results: |
| 351 save_build(self.srcdir, self.results_dir) | 389 save_build(self.srcdir, self.results_dir) |
| 352 | 390 |
| 353 | 391 |
| 354 class KojiInstaller(YumInstaller): | 392 class KojiInstaller(YumInstaller): |
| 355 """ | 393 """ |
| 356 Class that handles installing KVM from the fedora build service, koji. | 394 Class that handles installing KVM from the fedora build service, koji. |
| 357 It uses yum to install and remove packages. | 395 It uses yum to install and remove packages. |
| 358 """ | 396 """ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 379 """ | 417 """ |
| 380 downloader = kvm_utils.KojiDownloader(cmd=self.koji_cmd) | 418 downloader = kvm_utils.KojiDownloader(cmd=self.koji_cmd) |
| 381 downloader.get(src_package=self.src_pkg, tag=self.tag, | 419 downloader.get(src_package=self.src_pkg, tag=self.tag, |
| 382 build=self.build, dst_dir=self.srcdir) | 420 build=self.build, dst_dir=self.srcdir) |
| 383 | 421 |
| 384 | 422 |
| 385 def install(self): | 423 def install(self): |
| 386 super(KojiInstaller, self)._clean_previous_installs() | 424 super(KojiInstaller, self)._clean_previous_installs() |
| 387 self._get_packages() | 425 self._get_packages() |
| 388 super(KojiInstaller, self)._install_packages() | 426 super(KojiInstaller, self)._install_packages() |
| 427 self.install_unittests() |
| 389 create_symlinks(test_bindir=self.test_bindir, | 428 create_symlinks(test_bindir=self.test_bindir, |
| 390 bin_list=self.qemu_bin_paths) | 429 bin_list=self.qemu_bin_paths, |
| 430 unittest=self.unittest_prefix) |
| 391 self.reload_modules_if_needed() | 431 self.reload_modules_if_needed() |
| 392 if self.save_results: | 432 if self.save_results: |
| 393 save_build(self.srcdir, self.results_dir) | 433 save_build(self.srcdir, self.results_dir) |
| 394 | 434 |
| 395 | 435 |
| 396 class SourceDirInstaller(BaseInstaller): | 436 class SourceDirInstaller(BaseInstaller): |
| 397 """ | 437 """ |
| 398 Class that handles building/installing KVM directly from a tarball or | 438 Class that handles building/installing KVM directly from a tarball or |
| 399 a single source code dir. | 439 a single source code dir. |
| 400 """ | 440 """ |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 def _install(self): | 565 def _install(self): |
| 526 os.chdir(self.srcdir) | 566 os.chdir(self.srcdir) |
| 527 logging.info("Installing KVM userspace") | 567 logging.info("Installing KVM userspace") |
| 528 if self.repo_type == 1: | 568 if self.repo_type == 1: |
| 529 utils.system("make -C qemu install") | 569 utils.system("make -C qemu install") |
| 530 self._install_kmods_old_userspace(self.srcdir) | 570 self._install_kmods_old_userspace(self.srcdir) |
| 531 elif self.repo_type == 2: | 571 elif self.repo_type == 2: |
| 532 utils.system("make install") | 572 utils.system("make install") |
| 533 if self.path_to_roms: | 573 if self.path_to_roms: |
| 534 install_roms(self.path_to_roms, self.prefix) | 574 install_roms(self.path_to_roms, self.prefix) |
| 535 create_symlinks(self.test_bindir, self.prefix) | 575 self.install_unittests() |
| 576 create_symlinks(test_bindir=self.test_bindir, |
| 577 prefix=self.prefix, |
| 578 unittest=self.unittest_prefix) |
| 536 | 579 |
| 537 | 580 |
| 538 def _load_modules(self, mod_list): | 581 def _load_modules(self, mod_list): |
| 539 # load the installed KVM modules in case we installed them | 582 # load the installed KVM modules in case we installed them |
| 540 # ourselves. Otherwise, just load the system modules. | 583 # ourselves. Otherwise, just load the system modules. |
| 541 if self.installed_kmods: | 584 if self.installed_kmods: |
| 542 logging.info("Loading installed KVM modules") | 585 logging.info("Loading installed KVM modules") |
| 543 _load_kvm_modules(mod_list, module_dir=self.mod_install_dir) | 586 _load_kvm_modules(mod_list, module_dir=self.mod_install_dir) |
| 544 else: | 587 else: |
| 545 logging.info("Loading stock KVM modules") | 588 logging.info("Loading stock KVM modules") |
| (...skipping 11 matching lines...) Expand all Loading... |
| 557 class GitInstaller(SourceDirInstaller): | 600 class GitInstaller(SourceDirInstaller): |
| 558 def _pull_code(self): | 601 def _pull_code(self): |
| 559 """ | 602 """ |
| 560 Retrieves code from git repositories. | 603 Retrieves code from git repositories. |
| 561 """ | 604 """ |
| 562 params = self.params | 605 params = self.params |
| 563 | 606 |
| 564 kernel_repo = params.get("git_repo") | 607 kernel_repo = params.get("git_repo") |
| 565 user_repo = params.get("user_git_repo") | 608 user_repo = params.get("user_git_repo") |
| 566 kmod_repo = params.get("kmod_repo") | 609 kmod_repo = params.get("kmod_repo") |
| 567 test_repo = params.get("test_git_repo") | |
| 568 | 610 |
| 569 kernel_branch = params.get("kernel_branch", "master") | 611 kernel_branch = params.get("kernel_branch", "master") |
| 570 user_branch = params.get("user_branch", "master") | 612 user_branch = params.get("user_branch", "master") |
| 571 kmod_branch = params.get("kmod_branch", "master") | 613 kmod_branch = params.get("kmod_branch", "master") |
| 572 test_branch = params.get("test_branch", "master") | |
| 573 | 614 |
| 574 kernel_lbranch = params.get("kernel_lbranch", "master") | 615 kernel_lbranch = params.get("kernel_lbranch", "master") |
| 575 user_lbranch = params.get("user_lbranch", "master") | 616 user_lbranch = params.get("user_lbranch", "master") |
| 576 kmod_lbranch = params.get("kmod_lbranch", "master") | 617 kmod_lbranch = params.get("kmod_lbranch", "master") |
| 577 test_lbranch = params.get("test_lbranch", "master") | |
| 578 | 618 |
| 579 kernel_commit = params.get("kernel_commit", None) | 619 kernel_commit = params.get("kernel_commit", None) |
| 580 user_commit = params.get("user_commit", None) | 620 user_commit = params.get("user_commit", None) |
| 581 kmod_commit = params.get("kmod_commit", None) | 621 kmod_commit = params.get("kmod_commit", None) |
| 582 test_commit = params.get("test_commit", None) | |
| 583 | 622 |
| 584 kernel_patches = eval(params.get("kernel_patches", "[]")) | 623 kernel_patches = eval(params.get("kernel_patches", "[]")) |
| 585 user_patches = eval(params.get("user_patches", "[]")) | 624 user_patches = eval(params.get("user_patches", "[]")) |
| 586 kmod_patches = eval(params.get("user_patches", "[]")) | 625 kmod_patches = eval(params.get("user_patches", "[]")) |
| 587 | 626 |
| 588 if not user_repo: | 627 if not user_repo: |
| 589 message = "KVM user git repository path not specified" | 628 message = "KVM user git repository path not specified" |
| 590 logging.error(message) | 629 logging.error(message) |
| 591 raise error.TestError(message) | 630 raise error.TestError(message) |
| 592 | 631 |
| 593 userspace_srcdir = os.path.join(self.srcdir, "kvm_userspace") | 632 userspace_srcdir = os.path.join(self.srcdir, "kvm_userspace") |
| 594 kvm_utils.get_git_branch(user_repo, user_branch, userspace_srcdir, | 633 kvm_utils.get_git_branch(user_repo, user_branch, userspace_srcdir, |
| 595 user_commit, user_lbranch) | 634 user_commit, user_lbranch) |
| 596 self.userspace_srcdir = userspace_srcdir | 635 self.userspace_srcdir = userspace_srcdir |
| 597 | 636 |
| 598 if user_patches: | 637 if user_patches: |
| 599 os.chdir(self.userspace_srcdir) | 638 os.chdir(self.userspace_srcdir) |
| 600 for patch in user_patches: | 639 for patch in user_patches: |
| 601 utils.get_file(patch, os.path.join(self.userspace_srcdir, | 640 utils.get_file(patch, os.path.join(self.userspace_srcdir, |
| 602 os.path.basename(patch))) | 641 os.path.basename(patch))) |
| 603 utils.system('patch -p1 %s' % os.path.basename(patch)) | 642 utils.system('patch -p1 %s' % os.path.basename(patch)) |
| 604 | 643 |
| 605 if test_repo: | |
| 606 test_srcdir = os.path.join(self.srcdir, "kvm-unit-tests") | |
| 607 kvm_utils.get_git_branch(test_repo, test_branch, test_srcdir, | |
| 608 test_commit, test_lbranch) | |
| 609 unittest_cfg = os.path.join(test_srcdir, 'x86', | |
| 610 'unittests.cfg') | |
| 611 self.test_srcdir = test_srcdir | |
| 612 else: | |
| 613 unittest_cfg = os.path.join(userspace_srcdir, 'kvm', 'test', 'x86', | |
| 614 'unittests.cfg') | |
| 615 | |
| 616 self.unittest_cfg = None | |
| 617 if os.path.isfile(unittest_cfg): | |
| 618 self.unittest_cfg = unittest_cfg | |
| 619 | |
| 620 if kernel_repo: | 644 if kernel_repo: |
| 621 kernel_srcdir = os.path.join(self.srcdir, "kvm") | 645 kernel_srcdir = os.path.join(self.srcdir, "kvm") |
| 622 kvm_utils.get_git_branch(kernel_repo, kernel_branch, kernel_srcdir, | 646 kvm_utils.get_git_branch(kernel_repo, kernel_branch, kernel_srcdir, |
| 623 kernel_commit, kernel_lbranch) | 647 kernel_commit, kernel_lbranch) |
| 624 self.kernel_srcdir = kernel_srcdir | 648 self.kernel_srcdir = kernel_srcdir |
| 625 if kernel_patches: | 649 if kernel_patches: |
| 626 os.chdir(self.kernel_srcdir) | 650 os.chdir(self.kernel_srcdir) |
| 627 for patch in kernel_patches: | 651 for patch in kernel_patches: |
| 628 utils.get_file(patch, os.path.join(self.userspace_srcdir, | 652 utils.get_file(patch, os.path.join(self.userspace_srcdir, |
| 629 os.path.basename(patch))) | 653 os.path.basename(patch))) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 os.chdir(self.userspace_srcdir) | 700 os.chdir(self.userspace_srcdir) |
| 677 cfg += ' --prefix=%s' % self.prefix | 701 cfg += ' --prefix=%s' % self.prefix |
| 678 if "--disable-strip" in self.configure_options: | 702 if "--disable-strip" in self.configure_options: |
| 679 cfg += ' --disable-strip' | 703 cfg += ' --disable-strip' |
| 680 if self.extra_configure_options: | 704 if self.extra_configure_options: |
| 681 cfg += ' %s' % self.extra_configure_options | 705 cfg += ' %s' % self.extra_configure_options |
| 682 utils.system(cfg) | 706 utils.system(cfg) |
| 683 utils.system('make clean') | 707 utils.system('make clean') |
| 684 utils.system('make -j %s' % make_jobs) | 708 utils.system('make -j %s' % make_jobs) |
| 685 | 709 |
| 686 self.unittest_prefix = None | |
| 687 if self.unittest_cfg: | |
| 688 os.chdir(os.path.dirname(os.path.dirname(self.unittest_cfg))) | |
| 689 utils.system('./configure --prefix=%s' % self.prefix) | |
| 690 utils.system('make') | |
| 691 utils.system('make install') | |
| 692 self.unittest_prefix = os.path.join(self.prefix, 'share', 'qemu', | |
| 693 'tests') | |
| 694 | |
| 695 | 710 |
| 696 def _install(self): | 711 def _install(self): |
| 697 if self.kernel_srcdir: | 712 if self.kernel_srcdir: |
| 698 os.chdir(self.userspace_srcdir) | 713 os.chdir(self.userspace_srcdir) |
| 699 # the kernel module install with --prefix doesn't work, and DESTDIR | 714 # the kernel module install with --prefix doesn't work, and DESTDIR |
| 700 # wouldn't work for the userspace stuff, so we clear WANT_MODULE: | 715 # wouldn't work for the userspace stuff, so we clear WANT_MODULE: |
| 701 utils.system('make install WANT_MODULE=') | 716 utils.system('make install WANT_MODULE=') |
| 702 # and install the old-style-kmod modules manually: | 717 # and install the old-style-kmod modules manually: |
| 703 self._install_kmods_old_userspace(self.userspace_srcdir) | 718 self._install_kmods_old_userspace(self.userspace_srcdir) |
| 704 elif self.kmod_srcdir: | 719 elif self.kmod_srcdir: |
| 705 # if we have a kmod repository, it is easier: | 720 # if we have a kmod repository, it is easier: |
| 706 # 1) install userspace: | 721 # 1) install userspace: |
| 707 os.chdir(self.userspace_srcdir) | 722 os.chdir(self.userspace_srcdir) |
| 708 utils.system('make install') | 723 utils.system('make install') |
| 709 # 2) install kmod: | 724 # 2) install kmod: |
| 710 self._install_kmods(self.kmod_srcdir) | 725 self._install_kmods(self.kmod_srcdir) |
| 711 else: | 726 else: |
| 712 # if we don't have kmod sources, we just install | 727 # if we don't have kmod sources, we just install |
| 713 # userspace: | 728 # userspace: |
| 714 os.chdir(self.userspace_srcdir) | 729 os.chdir(self.userspace_srcdir) |
| 715 utils.system('make install') | 730 utils.system('make install') |
| 716 | 731 |
| 717 if self.path_to_roms: | 732 if self.path_to_roms: |
| 718 install_roms(self.path_to_roms, self.prefix) | 733 install_roms(self.path_to_roms, self.prefix) |
| 734 self.install_unittests() |
| 719 create_symlinks(test_bindir=self.test_bindir, prefix=self.prefix, | 735 create_symlinks(test_bindir=self.test_bindir, prefix=self.prefix, |
| 720 bin_list=None, | 736 bin_list=None, |
| 721 unittest=self.unittest_prefix) | 737 unittest=self.unittest_prefix) |
| 722 | 738 |
| 723 | 739 |
| 724 def install(self): | 740 def install(self): |
| 725 self._pull_code() | 741 self._pull_code() |
| 726 self._build() | 742 self._build() |
| 727 self._install() | 743 self._install() |
| 728 self.reload_modules_if_needed() | 744 self.reload_modules_if_needed() |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 return c | 788 return c |
| 773 | 789 |
| 774 | 790 |
| 775 def make_installer(params): | 791 def make_installer(params): |
| 776 # priority: | 792 # priority: |
| 777 # - 'install_mode' param | 793 # - 'install_mode' param |
| 778 # - 'mode' param | 794 # - 'mode' param |
| 779 mode = params.get("install_mode", params.get("mode")) | 795 mode = params.get("install_mode", params.get("mode")) |
| 780 klass = _installer_class(mode) | 796 klass = _installer_class(mode) |
| 781 return klass(mode) | 797 return klass(mode) |
| OLD | NEW |