Example #1
0
def add_qemu_bin_vt_option(parser):
    """
    Add qemu-bin vt option to parser
    """
    def _str_or_none(arg):
        if arg is None:
            return "Could not find one"
        else:
            return arg

    try:
        qemu_bin_path = standalone_test.find_default_qemu_paths()[0]
    except (RuntimeError, utils_path.CmdNotFoundError):
        qemu_bin_path = None
    qemu_bin = settings.get_value('vt.qemu', 'qemu_bin',
                                  default=qemu_bin_path)
    parser.add_argument("--vt-qemu-bin", action="store", dest="vt_qemu_bin",
                        default=qemu_bin, help="Path to a custom qemu binary "
                        "to be tested. If --vt-config is provided and this "
                        "flag is omitted, no attempt to set the qemu binaries "
                        "will be made. Current: %s" % _str_or_none(qemu_bin))
    qemu_dst = settings.get_value('vt.qemu', 'qemu_dst_bin',
                                  default=qemu_bin_path)
    parser.add_argument("--vt-qemu-dst-bin", action="store",
                        dest="vt_dst_qemu_bin", default=qemu_dst, help="Path "
                        "to a custom qemu binary to be tested for the "
                        "destination of a migration, overrides --vt-qemu-bin. "
                        "If --vt-config is provided and this flag is omitted, "
                        "no attempt to set the qemu binaries will be made. "
                        "Current: %s" % _str_or_none(qemu_dst))
Example #2
0
 def _process_qemu_img(self):
     """
     Puts the value of the qemu bin option in the cartesian parser command.
     """
     qemu_img_setting = "option --vt-qemu-img or " "config vt.qemu.qemu_img"
     if self.options.vt_config and self.options.vt_qemu_bin is None:
         logging.info("Config provided and no %s set. Not trying " "to automatically set qemu bin", qemu_img_setting)
     else:
         (_, qemu_img_path, _, _) = standalone_test.find_default_qemu_paths(
             self.options.vt_qemu_bin, self.options.vt_dst_qemu_bin
         )
         self.cartesian_parser.assign("qemu_img_binary", qemu_img_path)
Example #3
0
 def _process_qemu_img(self):
     """
     Puts the value of the qemu bin option in the cartesian parser command.
     """
     qemu_img_setting = ('option --vt-qemu-img or '
                         'config vt.qemu.qemu_img')
     if self.options.vt_config and self.options.vt_qemu_bin is None:
         logging.info(
             "Config provided and no %s set. Not trying "
             "to automatically set qemu bin", qemu_img_setting)
     else:
         (_, qemu_img_path, _, _) = standalone_test.find_default_qemu_paths(
             self.options.vt_qemu_bin, self.options.vt_dst_qemu_bin)
         self.cartesian_parser.assign("qemu_img_binary", qemu_img_path)
Example #4
0
 def _process_qemu_img(self):
     """
     Puts the value of the qemu bin option in the cartesian parser command.
     """
     qemu_img_setting = ('option --vt-qemu-img or '
                         'config vt.qemu.qemu_img')
     if (get_opt(self.config, 'vt.config')
             and get_opt(self.config, 'vt.qemu.bin') is None):
         LOG.info(
             "Config provided and no %s set. Not trying "
             "to automatically set qemu bin", qemu_img_setting)
     else:
         (_, qemu_img_path, _, _) = standalone_test.find_default_qemu_paths(
             get_opt(self.config, 'vt.qemu.qemu_bin'),
             get_opt(self.config, 'vt.qemu.qemu_dst_bin'))
         self.cartesian_parser.assign("qemu_img_binary", qemu_img_path)
Example #5
0
def add_qemu_bin_vt_option(parser):
    """
    Add qemu-bin vt option to parser
    """

    def _str_or_none(arg):
        if arg is None:
            return "Could not find one"
        else:
            return arg

    try:
        qemu_bin_path = standalone_test.find_default_qemu_paths()[0]
    except (RuntimeError, utils_path.CmdNotFoundError):
        qemu_bin_path = None
    qemu_bin = get_settings_value('vt.qemu', 'qemu_bin',
                                  default=None)
    if qemu_bin is None:  # Allow default to be None when not set in setting
        default_qemu_bin = None
        qemu_bin = qemu_bin_path
    else:
        default_qemu_bin = qemu_bin

    help_msg = ("Path to a custom qemu binary to be tested. If --vt-config is "
                "provided and this flag is omitted, no attempt to set the "
                "qemu binaries will be made. Current: %s" %
                _str_or_none(qemu_bin))
    add_option(parser,
               dest='vt.qemu.qemu_bin',
               arg='--vt-qemu-bin',
               default=default_qemu_bin,
               help=help_msg)

    qemu_dst = get_settings_value('vt.qemu', 'qemu_dst_bin',
                                  default=qemu_bin_path)
    help_msg = ("Path to a custom qemu binary to be tested for the destination"
                " of a migration, overrides --vt-qemu-bin. If --vt-config is "
                "provided and this flag is omitted, no attempt to set the qemu"
                " binaries will be made. Current: %s" % _str_or_none(qemu_dst))
    add_option(parser,
               dest='vt.qemu.qemu_dst_bin',
               arg='--vt-qemu-dst-bin',
               default=qemu_dst,
               help=help_msg)
Example #6
0
 def _process_qemu_bin(self):
     """
     Puts the value of the qemu bin option in the cartesian parser command.
     """
     qemu_bin_setting = ('option --vt-qemu-bin or '
                         'config vt.qemu.qemu_bin')
     if self.options.vt_config and self.options.vt_qemu_bin is None:
         logging.info("Config provided and no %s set. Not trying "
                      "to automatically set qemu bin.", qemu_bin_setting)
     else:
         (qemu_bin_path, qemu_img_path, qemu_io_path,
          qemu_dst_bin_path) = standalone_test.find_default_qemu_paths(
             self.options.vt_qemu_bin, self.options.vt_dst_qemu_bin)
         self.cartesian_parser.assign("qemu_binary", qemu_bin_path)
         self.cartesian_parser.assign("qemu_img_binary", qemu_img_path)
         self.cartesian_parser.assign("qemu_io_binary", qemu_io_path)
         if qemu_dst_bin_path is not None:
             self.cartesian_parser.assign("qemu_dst_binary",
                                          qemu_dst_bin_path)
Example #7
0
 def _process_qemu_bin(self):
     """
     Puts the value of the qemu bin option in the cartesian parser command.
     """
     qemu_bin_setting = ('option --vt-qemu-bin or '
                         'config vt.qemu.qemu_bin')
     if (get_opt(self.options, 'vt_config')
             and get_opt(self.options, 'vt_qemu_bin') is None):
         logging.info(
             "Config provided and no %s set. Not trying "
             "to automatically set qemu bin.", qemu_bin_setting)
     else:
         (qemu_bin_path, qemu_img_path, qemu_io_path,
          qemu_dst_bin_path) = standalone_test.find_default_qemu_paths(
              get_opt(self.options, 'vt_qemu_bin'),
              get_opt(self.options, 'vt_dst_qemu_bin'))
         self.cartesian_parser.assign("qemu_binary", qemu_bin_path)
         self.cartesian_parser.assign("qemu_img_binary", qemu_img_path)
         self.cartesian_parser.assign("qemu_io_binary", qemu_io_path)
         if qemu_dst_bin_path is not None:
             self.cartesian_parser.assign("qemu_dst_binary",
                                          qemu_dst_bin_path)
Example #8
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        def str_or_none(arg):
            if arg is None:
                return "Could not find one"
            else:
                return arg
        run_subcommand_parser = parser.subcommands.choices.get('run', None)
        if run_subcommand_parser is None:
            return

        try:
            qemu_bin_path = standalone_test.find_default_qemu_paths()[0]
        except (RuntimeError, utils_path.CmdNotFoundError):
            qemu_bin_path = None

        qemu_nw_msg = "QEMU network option (%s). " % ", ".join(
            SUPPORTED_NET_TYPES)
        qemu_nw_msg += "Default: user"

        vt_compat_group_setup = run_subcommand_parser.add_argument_group(
            'Virt-Test compat layer - VM Setup options')
        vt_compat_group_common = run_subcommand_parser.add_argument_group(
            'Virt-Test compat layer - Common options')
        vt_compat_group_qemu = run_subcommand_parser.add_argument_group(
            'Virt-Test compat layer - QEMU options')
        vt_compat_group_libvirt = run_subcommand_parser.add_argument_group(
            'Virt-Test compat layer - Libvirt options')

        vt_compat_group_common.add_argument("--vt-config", action="store",
                                            dest="vt_config",
                                            help=("Explicitly choose a "
                                                  "cartesian config. "
                                                  "When choosing this, "
                                                  "some options will be "
                                                  "ignored (see options "
                                                  "below)"))
        vt_compat_group_common.add_argument("--vt-type", action="store",
                                            dest="vt_type",
                                            help=("Choose test type (%s). "
                                                  "Default: qemu" %
                                                  ", ".join(
                                                      SUPPORTED_TEST_TYPES)),
                                            default='qemu')
        arch = settings.get_value('vt.common', 'arch', default=None)
        vt_compat_group_common.add_argument("--vt-arch",
                                            help="Choose the VM architecture. "
                                            "Default: %s" % arch,
                                            default=arch)
        machine = settings.get_value('vt.common', 'machine_type',
                                     default=defaults.DEFAULT_MACHINE_TYPE)
        vt_compat_group_common.add_argument("--vt-machine-type",
                                            help="Choose the VM machine type. "
                                            "Default: %s" % machine,
                                            default=machine)
        vt_compat_group_common.add_argument("--vt-guest-os", action="store",
                                            dest="vt_guest_os",
                                            default=defaults.DEFAULT_GUEST_OS,
                                            help=("Select the guest OS to "
                                                  "be used. If --vt-config is "
                                                  "provided, this will be "
                                                  "ignored. Default: %s" %
                                                  defaults.DEFAULT_GUEST_OS))
        vt_compat_group_common.add_argument("--vt-no-filter", action="store",
                                            dest="vt_no_filter", default="",
                                            help=("List of space separated "
                                                  "'no' filters to be passed "
                                                  "to the config parser. "
                                                  " Default: ''"))
        vt_compat_group_common.add_argument("--vt-only-filter", action="store",
                                            dest="vt_only_filter", default="",
                                            help=("List of space separated "
                                                  "'only' filters to be passed"
                                                  " to the config parser. "
                                                  " Default: ''"))
        qemu_bin = settings.get_value('vt.qemu', 'qemu_bin',
                                      default=qemu_bin_path)
        vt_compat_group_qemu.add_argument("--vt-qemu-bin", action="store",
                                          dest="vt_qemu_bin",
                                          default=qemu_bin,
                                          help=("Path to a custom qemu binary "
                                                "to be tested. If --vt-config "
                                                "is provided and this flag is "
                                                "omitted, no attempt to set "
                                                "the qemu binaries will be "
                                                "made. Current: %s" %
                                                str_or_none(qemu_bin)))
        qemu_dst = settings.get_value('vt.qemu', 'qemu_dst_bin',
                                      default=qemu_bin_path)
        vt_compat_group_qemu.add_argument("--vt-qemu-dst-bin", action="store",
                                          dest="vt_dst_qemu_bin",
                                          default=qemu_dst,
                                          help=("Path to a custom qemu binary "
                                                "to be tested for the "
                                                "destination of a migration, "
                                                "overrides --vt-qemu-bin. "
                                                "If --vt-config is provided "
                                                "and this flag is omitted, "
                                                "no attempt to set the qemu "
                                                "binaries will be made. "
                                                "Current: %s" %
                                                str_or_none(qemu_dst)))
        vt_compat_group_qemu.add_argument("--vt-extra-params", nargs='*',
                                          help="List of 'key=value' pairs "
                                          "passed to cartesian parser.")
        supported_uris = ", ".join(SUPPORTED_LIBVIRT_URIS)
        uri_current = settings.get_value('vt.libvirt', 'connect_uri',
                                         default=None)
        vt_compat_group_libvirt.add_argument("--vt-connect-uri",
                                             action="store",
                                             dest="vt_connect_uri",
                                             default=uri_current,
                                             help=("Choose test connect uri "
                                                   "for libvirt (E.g: %s). "
                                                   "Current: %s" %
                                                   (supported_uris,
                                                    uri_current)))
Example #9
0
        def initialize(self):
            if not is_registering_settings_required():
                return

            # [vt] section
            section = 'vt'

            help_msg = ('Explicitly choose a cartesian config. When choosing '
                        'this, some options will be ignored (see options '
                        'below)')
            settings.register_option(section, key='config', default=None,
                                     help_msg=help_msg)

            help_msg = 'Save the resulting cartesian config to a file'
            settings.register_option(section, key='save_config', default=None,
                                     help_msg=help_msg)

            help_msg = ("Choose test type (%s). Default: %%(default)s" %
                        ", ".join(SUPPORTED_TEST_TYPES))
            settings.register_option(section, key='type',
                                     default=SUPPORTED_TEST_TYPES[0],
                                     help_msg=help_msg)

            help_msg = ("Select the guest OS to be used. If --vt-config is "
                        "provided, this will be ignored. Default: %s" %
                        DEFAULT_GUEST_OS)
            settings.register_option(section, key='guest_os',
                                     default=DEFAULT_GUEST_OS,
                                     help_msg=help_msg)

            help_msg = ("List of space separated 'no' filters to be passed to "
                        "the config parser.")
            settings.register_option(section, key='no_filter', default='',
                                     help_msg=help_msg)

            help_msg = ("List of space separated 'only' filters to be passed "
                        "to the config  parser.")
            settings.register_option(section, key='only_filter', default='',
                                     help_msg=help_msg)

            help_msg = "List of 'key=value' pairs passed to cartesian parser."
            settings.register_option(section, key='extra_params', nargs='*',
                                     default=None, help_msg=help_msg)

            help_msg = ("Also list the available guests (this option ignores "
                        "the --vt-config and --vt-guest-os)")
            settings.register_option(section, key='list_guests', key_type=bool,
                                     default=False, help_msg=help_msg)
            help_msg = ("Also list the available arch/machines for the given "
                        "guest OS. (Use \"--vt-guest-os ''\" to see all "
                        "combinations; --vt-config --vt-machine-type and "
                        "--vt-arch args are ignored)")
            settings.register_option(section, key='list_archs', key_type=bool,
                                     default=False, help_msg=help_msg)

            # [vt.setup] section
            section = 'vt.setup'

            help_msg = 'Backup image before testing (if not already backed up)'
            settings.register_option(section, 'backup_image_before_test',
                                     help_msg=help_msg, key_type=bool,
                                     default=True)

            help_msg = 'Restore image after testing (if backup present)'
            settings.register_option(section, 'restore_image_after_test',
                                     help_msg=help_msg, key_type=bool,
                                     default=True)

            help_msg = 'Keep guest running between tests (faster, but unsafe)'
            settings.register_option(section, 'keep_guest_running',
                                     help_msg=help_msg, key_type=bool,
                                     default=False)

            # [vt.common] section
            section = 'vt.common'

            help_msg = ('Data dir path. If none specified, the default '
                        'virt-test data dir will be used')
            settings.register_option(section, 'data_dir',
                                     help_msg=help_msg,
                                     default='')

            help_msg = ('Make the temporary dir path persistent across jobs if'
                        ' needed. By default the data in the temporary '
                        'directory will be wiped after each test in some cases'
                        ' and after each job in others.')
            settings.register_option(section, 'tmp_dir',
                                     help_msg=help_msg,
                                     default='')

            help_msg = ('Enable only type specific tests. Shared tests will '
                        'not be tested')
            settings.register_option(section, 'type_specific_only',
                                     help_msg=help_msg, key_type=bool,
                                     default=False)

            help_msg = ('RAM dedicated to the main VM. Usually defaults to '
                        '1024, as set in "base.cfg", but can be a different '
                        'value depending on the various other configuration '
                        'files such as configuration files under "guest-os" '
                        'and test provider specific files')
            settings.register_option(section, 'mem',
                                     help_msg=help_msg,
                                     default=None)

            help_msg = 'Architecture under test'
            settings.register_option(section, 'arch',
                                     help_msg=help_msg,
                                     default=None)

            help_msg = 'Machine type under test'
            settings.register_option(section, 'machine_type',
                                     help_msg=help_msg,
                                     default=DEFAULT_MACHINE_TYPE)

            help_msg = 'Nettype (bridge, user, none)'
            settings.register_option(section, 'nettype',
                                     help_msg=help_msg,
                                     default='')

            help_msg = 'Bridge name to be used if you select bridge as a nettype'
            settings.register_option(section, 'netdst',
                                     help_msg=help_msg,
                                     default='virbr0')

            # [vt.qemu] section
            section = 'vt.qemu'

            try:
                default_qemu_bin_path = find_default_qemu_paths()[0]
            except (RuntimeError, utils_path.CmdNotFoundError):
                default_qemu_bin_path = None
            qemu_bin = get_settings_value(section, 'qemu_bin', default=None)
            if qemu_bin is None:  # Allow default to be None when not set in setting
                default_qemu_bin = None
            else:
                default_qemu_bin = qemu_bin
            help_msg = 'Path to a custom qemu binary to be tested'
            settings.register_option(section, 'qemu_bin',
                                     help_msg=help_msg,
                                     default=default_qemu_bin)

            help_msg = ('Path to a custom qemu binary to be tested for the '
                        'destination of a migration, overrides qemu_bin for '
                        'that particular purpose')
            settings.register_option(section, 'qemu_dst_bin',
                                     help_msg=help_msg,
                                     default=default_qemu_bin_path)

            help_msg = 'Accelerator used to run qemu (kvm or tcg)'
            settings.register_option(section, 'accel',
                                     help_msg=help_msg,
                                     default='kvm')

            help_msg = ('Whether to enable vhost for qemu (on/off/force). '
                        'Depends on nettype=bridge')
            settings.register_option(section, 'vhost',
                                     help_msg=help_msg,
                                     default='off')

            help_msg = 'Monitor type (human or qmp)'
            settings.register_option(section, 'monitor',
                                     help_msg=help_msg,
                                     default='')

            help_msg = 'Number of virtual cpus to use (1 or 2)'
            settings.register_option(section, 'smp',
                                     help_msg=help_msg,
                                     default='2')

            help_msg = 'Image format type to use (any valid qemu format)'
            settings.register_option(section, 'image_type',
                                     help_msg=help_msg,
                                     default=SUPPORTED_IMAGE_TYPES[0])

            help_msg = 'Guest network card model (any valid qemu card)'
            settings.register_option(section, 'nic_model',
                                     help_msg=help_msg,
                                     default=SUPPORTED_NIC_MODELS[0])

            help_msg = ('Guest disk bus for main image. One of ide, scsi, '
                        'virtio_blk, virtio_scsi, lsi_scsi, ahci, usb2 '
                        'or xenblk. Note: Older qemu versions and/or '
                        'operating systems (such as WinXP) might not support '
                        'virtio_scsi. Please use virtio_blk or ide instead.')
            settings.register_option(section, 'disk_bus',
                                     help_msg=help_msg,
                                     default=SUPPORTED_DISK_BUSES[0])

            help_msg = 'Enable qemu sandboxing (on/off)'
            settings.register_option(section, 'sandbox',
                                     help_msg=help_msg,
                                     default='on')

            help_msg = ('Prevent qemu from loading sysconfdir/qemu.conf '
                        'and sysconfdir/target-ARCH.conf at startup (yes/no)')
            settings.register_option(section, 'defconfig',
                                     help_msg=help_msg,
                                     default='yes')

            help_msg = ('Use MALLOC_PERTURB_ env variable set to 1 to help '
                        'catch memory allocation problems on qemu (yes/no)')
            settings.register_option(section, 'malloc_perturb',
                                     help_msg=help_msg,
                                     default='yes')

            # [vt.libvirt] section
            section = 'vt.libvirt'

            uri_current = get_settings_value(section, 'connect_uri',
                                             default=None)
            help_msg = ('Test connect URI for libvirt (qemu:///system, '
                        'lxc:///)')
            settings.register_option(section, 'connect_uri',
                                     help_msg=help_msg, default=uri_current)

            # [vt.debug] section
            help_msg = ('Do not clean up tmp files or VM processes at the end '
                        'of a virt-test execution')
            settings.register_option('vt.debug', 'no_cleanup',
                                     help_msg=help_msg, key_type=bool,
                                     default=False)

            # [vt.filter] section
            help_msg = ("Allows to selectively skip certain default filters. "
                        "This uses directly 'tests-shared.cfg' and instead of "
                        "'$provider/tests.cfg' and applies following lists of "
                        "default filters, unless they are specified as "
                        "arguments: no_9p_export,no_virtio_rng,"
                        "no_pci_assignable,smallpages,default_bios,ridge,"
                        "image_backend,multihost. This can be used to eg. run "
                        "hugepages tests by filtering 'smallpages' via this "
                        "option.")
            settings.register_option('vt.filter', key='default_filters',
                                     nargs='+', default=None,
                                     help_msg=help_msg)

            # [plugins.vtjoblock] section
            help_msg = 'Directory in which to write the lock file'
            settings.register_option('plugins.vtjoblock', 'dir',
                                     help_msg=help_msg,
                                     default='/tmp')

            virt_loader = getattr(importlib.import_module('avocado_vt.loader'),
                                  'VirtTestLoader')
            loader.register_plugin(virt_loader)
Example #10
0
        def initialize(self):
            if not is_registering_settings_required():
                return

            # [vt.setup] section
            section = 'vt.setup'
            help_msg = 'Backup image before testing (if not already backed up)'
            settings.register_option(section, 'backup_image_before_test',
                                     help_msg=help_msg, key_type=bool,
                                     default=True)

            help_msg = 'Restore image after testing (if backup present)'
            settings.register_option(section, 'restore_image_after_test',
                                     help_msg=help_msg, key_type=bool,
                                     default=True)

            help_msg = 'Keep guest running between tests (faster, but unsafe)'
            settings.register_option(section, 'keep_guest_running',
                                     help_msg=help_msg, key_type=bool,
                                     default=False)

            # [vt.common] section
            section = 'vt.common'

            help_msg = ('Data dir path. If none specified, the default '
                        'virt-test data dir will be used')
            settings.register_option(section, 'data_dir',
                                     help_msg=help_msg,
                                     default='')

            help_msg = ('Make the temporary dir path persistent across jobs if'
                        ' needed. By default the data in the temporary '
                        'directory will be wiped after each test in some cases'
                        ' and after each job in others.')
            settings.register_option(section, 'tmp_dir',
                                     help_msg=help_msg,
                                     default='')

            help_msg = ('Enable only type specific tests. Shared tests will '
                        'not be tested')
            settings.register_option(section, 'type_specific_only',
                                     help_msg=help_msg, key_type=bool,
                                     default=False)

            help_msg = ('RAM dedicated to the main VM. Usually defaults to '
                        '1024, as set in "base.cfg", but can be a different '
                        'value depending on the various other configuration '
                        'files such as configuration files under "guest-os" '
                        'and test provider specific files')
            settings.register_option(section, 'mem',
                                     help_msg=help_msg,
                                     default=None)

            help_msg = 'Architecture under test'
            settings.register_option(section, 'arch',
                                     help_msg=help_msg,
                                     default=None)

            help_msg = 'Machine type under test'
            settings.register_option(section, 'machine_type',
                                     help_msg=help_msg,
                                     default=DEFAULT_MACHINE_TYPE)

            help_msg = 'Nettype (bridge, user, none)'
            settings.register_option(section, 'nettype',
                                     help_msg=help_msg,
                                     default='')

            help_msg = 'Bridge name to be used if you select bridge as a nettype'
            settings.register_option(section, 'netdst',
                                     help_msg=help_msg,
                                     default='virbr0')

            # [vt.qemu] section
            section = 'vt.qemu'

            try:
                default_qemu_bin_path = find_default_qemu_paths()[0]
            except (RuntimeError, utils_path.CmdNotFoundError):
                default_qemu_bin_path = None
            help_msg = 'Path to a custom qemu binary to be tested'
            settings.register_option(section, 'qemu_bin',
                                     help_msg=help_msg,
                                     default=default_qemu_bin_path)

            help_msg = ('Path to a custom qemu binary to be tested for the '
                        'destination of a migration, overrides qemu_bin for '
                        'that particular purpose')
            settings.register_option(section, 'qemu_dst_bin',
                                     help_msg=help_msg,
                                     default=default_qemu_bin_path)

            help_msg = 'Accelerator used to run qemu (kvm or tcg)'
            settings.register_option(section, 'accel',
                                     help_msg=help_msg,
                                     default='kvm')

            help_msg = ('Whether to enable vhost for qemu (on/off/force). '
                        'Depends on nettype=bridge')
            settings.register_option(section, 'vhost',
                                     help_msg=help_msg,
                                     default='off')

            help_msg = 'Monitor type (human or qmp)'
            settings.register_option(section, 'monitor',
                                     help_msg=help_msg,
                                     default='')

            help_msg = 'Number of virtual cpus to use (1 or 2)'
            settings.register_option(section, 'smp',
                                     help_msg=help_msg,
                                     default='2')

            help_msg = 'Image format type to use (any valid qemu format)'
            settings.register_option(section, 'image_type',
                                     help_msg=help_msg,
                                     default=SUPPORTED_IMAGE_TYPES[0])

            help_msg = 'Guest network card model (any valid qemu card)'
            settings.register_option(section, 'nic_model',
                                     help_msg=help_msg,
                                     default=SUPPORTED_NIC_MODELS[0])

            help_msg = ('Guest disk bus for main image. One of ide, scsi, '
                        'virtio_blk, virtio_scsi, lsi_scsi, ahci, usb2 '
                        'or xenblk. Note: Older qemu versions and/or '
                        'operating systems (such as WinXP) might not support '
                        'virtio_scsi. Please use virtio_blk or ide instead.')
            settings.register_option(section, 'disk_bus',
                                     help_msg=help_msg,
                                     default=SUPPORTED_DISK_BUSES[0])

            help_msg = 'Enable qemu sandboxing (on/off)'
            settings.register_option(section, 'sandbox',
                                     help_msg=help_msg,
                                     default='on')

            help_msg = ('Prevent qemu from loading sysconfdir/qemu.conf '
                        'and sysconfdir/target-ARCH.conf at startup (yes/no)')
            settings.register_option(section, 'defconfig',
                                     help_msg=help_msg,
                                     default='yes')

            help_msg = ('Use MALLOC_PERTURB_ env variable set to 1 to help '
                        'catch memory allocation problems on qemu (yes/no)')
            settings.register_option(section, 'malloc_perturb',
                                     help_msg=help_msg,
                                     default='yes')

            # [vt.libvirt] section
            help_msg = ('Test connect URI for libvirt (qemu:///system, '
                        'lxc:///)')
            settings.register_option('vt.libvirt', 'connect_uri',
                                     help_msg=help_msg,
                                     default='qemu:///session')

            # [vt.debug] section
            help_msg = ('Do not clean up tmp files or VM processes at the end '
                        'of a virt-test execution')
            settings.register_option('vt.debug', 'no_cleanup',
                                     help_msg=help_msg, key_type=bool,
                                     default=False)

            # [plugins.vtjoblock] section
            help_msg = 'Directory in which to write the lock file'
            settings.register_option('plugins.vtjoblock', 'dir',
                                     help_msg=help_msg,
                                     default='/tmp')
Example #11
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        def str_or_none(arg):
            if arg is None:
                return "Could not find one"
            else:
                return arg

        run_subcommand_parser = parser.subcommands.choices.get('run', None)
        if run_subcommand_parser is None:
            return

        try:
            qemu_bin_path = standalone_test.find_default_qemu_paths()[0]
        except (RuntimeError, utils_path.CmdNotFoundError):
            qemu_bin_path = None

        qemu_nw_msg = "QEMU network option (%s). " % ", ".join(
            SUPPORTED_NET_TYPES)
        qemu_nw_msg += "Default: user"

        vt_compat_group_setup = run_subcommand_parser.add_argument_group(
            'Virt-Test compat layer - VM Setup options')
        vt_compat_group_common = run_subcommand_parser.add_argument_group(
            'Virt-Test compat layer - Common options')
        vt_compat_group_qemu = run_subcommand_parser.add_argument_group(
            'Virt-Test compat layer - QEMU options')
        vt_compat_group_libvirt = run_subcommand_parser.add_argument_group(
            'Virt-Test compat layer - Libvirt options')

        vt_compat_group_common.add_argument("--vt-config",
                                            action="store",
                                            dest="vt_config",
                                            help=("Explicitly choose a "
                                                  "cartesian config. "
                                                  "When choosing this, "
                                                  "some options will be "
                                                  "ignored (see options "
                                                  "below)"))
        vt_compat_group_common.add_argument(
            "--vt-type",
            action="store",
            dest="vt_type",
            help=("Choose test type (%s). "
                  "Default: qemu" % ", ".join(SUPPORTED_TEST_TYPES)),
            default='qemu')
        arch = settings.get_value('vt.common', 'arch', default=None)
        vt_compat_group_common.add_argument("--vt-arch",
                                            help="Choose the VM architecture. "
                                            "Default: %s" % arch,
                                            default=arch)
        machine = settings.get_value('vt.common',
                                     'machine_type',
                                     default=defaults.DEFAULT_MACHINE_TYPE)
        vt_compat_group_common.add_argument("--vt-machine-type",
                                            help="Choose the VM machine type. "
                                            "Default: %s" % machine,
                                            default=machine)
        vt_compat_group_common.add_argument("--vt-guest-os",
                                            action="store",
                                            dest="vt_guest_os",
                                            default=defaults.DEFAULT_GUEST_OS,
                                            help=("Select the guest OS to "
                                                  "be used. If --vt-config is "
                                                  "provided, this will be "
                                                  "ignored. Default: %s" %
                                                  defaults.DEFAULT_GUEST_OS))
        vt_compat_group_common.add_argument("--vt-no-filter",
                                            action="store",
                                            dest="vt_no_filter",
                                            default="",
                                            help=("List of space separated "
                                                  "'no' filters to be passed "
                                                  "to the config parser. "
                                                  "If --vt-config is "
                                                  "provided, this will be "
                                                  "ignored. Default: ''"))
        qemu_bin = settings.get_value('vt.qemu',
                                      'qemu_bin',
                                      default=qemu_bin_path)
        vt_compat_group_qemu.add_argument("--vt-qemu-bin",
                                          action="store",
                                          dest="vt_qemu_bin",
                                          default=qemu_bin,
                                          help=("Path to a custom qemu binary "
                                                "to be tested. If --vt-config "
                                                "is provided and this flag is "
                                                "omitted, no attempt to set "
                                                "the qemu binaries will be "
                                                "made. Current: %s" %
                                                str_or_none(qemu_bin)))
        qemu_dst = settings.get_value('vt.qemu',
                                      'qemu_dst_bin',
                                      default=qemu_bin_path)
        vt_compat_group_qemu.add_argument("--vt-qemu-dst-bin",
                                          action="store",
                                          dest="vt_dst_qemu_bin",
                                          default=qemu_dst,
                                          help=("Path to a custom qemu binary "
                                                "to be tested for the "
                                                "destination of a migration, "
                                                "overrides --vt-qemu-bin. "
                                                "If --vt-config is provided "
                                                "and this flag is omitted, "
                                                "no attempt to set the qemu "
                                                "binaries will be made. "
                                                "Current: %s" %
                                                str_or_none(qemu_dst)))
        vt_compat_group_qemu.add_argument("--vt-extra-params",
                                          nargs='*',
                                          help="List of 'key=value' pairs "
                                          "passed to cartesian parser.")
        supported_uris = ", ".join(SUPPORTED_LIBVIRT_URIS)
        uri_current = settings.get_value('vt.libvirt',
                                         'connect_uri',
                                         default=None)
        vt_compat_group_libvirt.add_argument(
            "--vt-connect-uri",
            action="store",
            dest="vt_connect_uri",
            default=uri_current,
            help=("Choose test connect uri "
                  "for libvirt (E.g: %s). "
                  "Current: %s" % (supported_uris, uri_current)))