Esempio n. 1
0
    def set_migratepostcopy(self, vm_name, uri=None):
        """
        Switch to postcopy during migration.

        :param vm_name: vm's name
        :param uri: target virsh uri
        :raise: test.error when command fails
        """
        cmd = "event --loop --all"
        virsh_event_session = virsh.VirshSession(virsh_exec=virsh.VIRSH_EXEC,
                                                 auto_close=True,
                                                 uri=uri)
        virsh_event_session.sendline(cmd)

        if not utils_misc.wait_for(
                lambda: not virsh.migrate_postcopy(
                    vm_name, uri=uri, debug=True).exit_status, 10):
            raise exceptions.TestError("Failed to set migration postcopy.")

        exp_str = "Suspended Post-copy"
        if not utils_misc.wait_for(
                lambda: re.findall(
                    exp_str, virsh_event_session.get_stripped_output()), 30):
            raise exceptions.TestError(
                "Unalbe to find event {}".format(exp_str))
Esempio n. 2
0
    def set_migratepostcopy():
        """
        Switch to postcopy during migration
        """
        res = virsh.migrate_postcopy(vm_name)
        logging.debug("Command output: %s", res)

        if not utils_misc.wait_for(
           lambda: migration_test.check_vm_state(vm_name, "paused",
                                                 "post-copy"), 10):
            test.fail("vm status is expected to 'paused (post-copy)'")
Esempio n. 3
0
    def check_bandwidth(params):
        """
        Check migration bandwidth

        :param params: the parameters used
        :raise: test.fail if migration bandwidth does not match expected values
        """
        exp_migrate_speed = eval(params.get('exp_migrate_speed', '{}'))
        migrate_postcopy_cmd = "yes" == params.get("migrate_postcopy_cmd",
                                                   "yes")
        if extra.count("bandwidth"):
            get_speed(exp_migrate_speed)
        if params.get("set_postcopy_in_precopy_phase"):
            virsh.migrate_setspeed(vm_name,
                                   params.get("set_postcopy_in_precopy_phase"),
                                   "--postcopy", **virsh_args)
            get_speed(exp_migrate_speed)

        params.update({
            'compare_to_value':
            exp_migrate_speed.get("precopy_speed", "8796093022207")
        })

        if exp_migrate_speed.get("precopy_speed", "0") == "8796093022207":
            params.update({'domjob_ignore_status': True})
        libvirt_domjobinfo.check_domjobinfo(vm, params)

        if migrate_postcopy_cmd:
            if not utils_misc.wait_for(
                    lambda: not virsh.migrate_postcopy(vm_name, **virsh_args).
                    exit_status, 5):
                test.fail("Failed to set migration postcopy.")

            if params.get("set_postcopy_in_postcopy_phase"):
                virsh.migrate_setspeed(
                    vm_name, params.get("set_postcopy_in_postcopy_phase"),
                    "--postcopy", **virsh_args)
                get_speed(exp_migrate_speed)
            time.sleep(5)

            if exp_migrate_speed.get("postcopy_speed"):
                params.update(
                    {'compare_to_value': exp_migrate_speed["postcopy_speed"]})
                params.update({'domjob_ignore_status': False})
            libvirt_domjobinfo.check_domjobinfo(vm, params)