Exemple #1
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = params.get('dst_host_ip')
    qmp_port = int(params.get('qmp_port'))
    serial_port = int(params.get('serial_port'))
    incoming_port = params.get('incoming_port')
    share_images_dir = params.get('share_images_dir')
    matrix = params.get('matrix')
    disk1_name = params.get('disk1_name').split('.')[0]
    disk1_format = params.get('disk1_name').split('.')[1]
    disk2_name = params.get('disk2_name').split('.')[0]
    disk2_format = params.get('disk2_name').split('.')[1]
    disk3_name = params.get('disk3_name').split('.')[0]
    disk3_format = params.get('disk3_name').split('.')[1]
    disk4_name = params.get('disk4_name').split('.')[0]
    disk4_format = params.get('disk4_name').split('.')[1]
    disk5_name = params.get('disk5_name').split('.')[0]
    disk5_format = params.get('disk5_name').split('.')[1]
    iso = params.get('cdrom1_name')

    test = CreateTest(case_id='rhel7_109697', params=params)
    id = test.get_id()
    src_host_session = HostSession(id, params)
    test.test_print('=======Create test environment=======')
    test.sub_step_log('~~~~1. Create 5 data disks~~~~')
    utils_migration.create_disk(host_session=src_host_session,
                                disk_dir=share_images_dir,
                                disk_name=disk1_name,
                                disk_format=disk1_format,
                                disk_size=2048)
    utils_migration.create_disk(host_session=src_host_session,
                                disk_dir=share_images_dir,
                                disk_name=disk2_name,
                                disk_format=disk2_format,
                                disk_size=2048)
    utils_migration.create_disk(host_session=src_host_session,
                                disk_dir=share_images_dir,
                                disk_name=disk3_name,
                                disk_format=disk3_format,
                                disk_size=2048)
    utils_migration.create_disk(host_session=src_host_session,
                                disk_dir=share_images_dir,
                                disk_name=disk4_name,
                                disk_format=disk4_format,
                                disk_size=2048)
    utils_migration.create_disk(host_session=src_host_session,
                                disk_dir=share_images_dir,
                                disk_name=disk5_name,
                                disk_format=disk5_format,
                                disk_size=2048)

    test.sub_step_log('~~~~2. Create 1 iso~~~~')
    utils_stable_abi_ppc.create_iso(host_session=src_host_session,
                                    disk_dir=share_images_dir,
                                    iso=iso)

    test.sub_step_log('~~~~3. Configure host hugepage~~~~')
    utils_stable_abi_ppc.configure_host_hugepage(
        host_session=src_host_session,
        matrix=matrix,
        dst_ip=dst_host_ip,
        mount_point='/mnt/kvm_hugepage')

    test.sub_step_log('~~~~4. Check matrix~~~~')
    flag = utils_stable_abi_ppc.check_matrix(host_session=src_host_session,
                                             dst_ip=dst_host_ip,
                                             matrix=matrix)

    test.main_step_log('1. start guest on Source Host  host must have '
                       'following devices')
    if (flag == 'p9_to_p8'):
        params.vm_base_cmd_update('machine', 'pseries',
                                  'pseries-rhel7.3.0,max-cpu-compat=power8')
    else:
        params.vm_base_cmd_update('machine', 'pseries', 'pseries-rhel7.3.0')
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')

    test.sub_step_log('1.1 Connecting to src serial')
    src_remote_qmp = RemoteQMPMonitor(id,
                                      params,
                                      ip=src_host_ip,
                                      port=qmp_port)
    src_serial = RemoteSerialMonitor(id,
                                     params,
                                     ip=src_host_ip,
                                     port=serial_port)
    src_guest_ip = src_serial.serial_login()

    test.sub_step_log('2 Start guest on Destination Host  host with same '
                      'qemu cli as step1 but appending')
    if (flag == 'p8_to_p9'):
        params.vm_base_cmd_update('machine', 'pseries-rhel7.3.0',
                                  'pseries-rhel7.3.0,max-cpu-compat=power8')
    elif (flag == 'p9_to_p8'):
        params.vm_base_cmd_update('machine',
                                  'pseries-rhel7.3.0,max-cpu-compat=power8',
                                  'pseries-rhel7.3.0')
    incoming_val = 'tcp:0:%s' % incoming_port
    params.vm_base_cmd_add('incoming', incoming_val)
    params.vm_base_cmd_update(
        'chardev', 'socket,id=serial_id_serial0,host=%s,'
        'port=%s,server,nowait' % (src_host_ip, serial_port),
        'socket,id=serial_id_serial0,host=%s,port=%s,'
        'server,nowait' % (dst_host_ip, serial_port))
    dst_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_remote_guest(cmd=dst_qemu_cmd,
                                       ip=dst_host_ip,
                                       vm_alias='dst')
    dst_remote_qmp = RemoteQMPMonitor(id,
                                      params,
                                      ip=dst_host_ip,
                                      port=qmp_port)

    test.main_step_log(
        '3.In guest, execute the program to generate dirty pages')
    src_guest_session = GuestSession(case_id=id,
                                     params=params,
                                     ip=src_guest_ip)
    utils_migration.dirty_page_test(host_session=src_host_session,
                                    guest_session=src_guest_session,
                                    guest_ip=src_guest_ip,
                                    script='migration_dirtypage_2.c')

    test.main_step_log('4.Enable postcopy on both sides and do migration')
    utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}'\
          % (dst_host_ip, incoming_port)
    src_remote_qmp.qmp_cmd_output(cmd=cmd)

    test.main_step_log('5.check the migration status, after generating dirty '
                       'pages, change to postcopy mode')
    utils_migration.switch_to_postcopy(remote_qmp=src_remote_qmp)
    chk_info = utils_migration.query_migration(remote_qmp=src_remote_qmp)
    if chk_info == False:
        test.test_error('Migration timeout')

    test.main_step_log('6.Check devices function one by one')
    dst_serial = RemoteSerialMonitor(id,
                                     params,
                                     ip=dst_host_ip,
                                     port=serial_port)
    output = dst_serial.serial_cmd_output('dmesg')
    if re.findall(r'Call Trace:', output):
        test.test_error('Guest hit call trace after migration')
    dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}')
    dst_guest_ip = dst_serial.serial_login()
    dst_guest_session = GuestSession(case_id=id,
                                     params=params,
                                     ip=dst_guest_ip)
    test.sub_step_log('a.Check networking')
    dst_guest_session.guest_ping_test('www.redhat.com', 10)
    test.sub_step_log('b.Check block by the following methods')
    utils_migration.filebench_test(dst_guest_session)
    test.sub_step_log('c.Check VNC console and check keyboard by input keys')
    time.sleep(3)

    test.main_step_log('7.Migrate the guest back to src host and please '
                       'refer to step 4 and step 5')
    src_remote_qmp.qmp_cmd_output('{"execute":"quit"}')
    time.sleep(3)
    src_host_session.check_guest_process(src_ip=src_host_ip)

    if (flag == 'p8_to_p9'):
        params.vm_base_cmd_update('machine',
                                  'pseries-rhel7.3.0,max-cpu-compat=power8',
                                  'pseries-rhel7.3.0')
    elif (flag == 'p9_to_p8'):
        params.vm_base_cmd_update('machine', 'pseries-rhel7.3.0',
                                  'pseries-rhel7.3.0,max-cpu-compat=power8')
    params.vm_base_cmd_update(
        'chardev', 'socket,id=serial_id_serial0,host=%s,'
        'port=%s,server,nowait' % (dst_host_ip, serial_port),
        'socket,id=serial_id_serial0,host=%s,port=%s,'
        'server,nowait' % (src_host_ip, serial_port))
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')
    src_remote_qmp = RemoteQMPMonitor(id,
                                      params,
                                      ip=src_host_ip,
                                      port=qmp_port)

    utils_migration.dirty_page_test(host_session=src_host_session,
                                    guest_session=dst_guest_session,
                                    guest_ip=dst_guest_ip,
                                    script='migration_dirtypage_2.c')

    utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}'\
          % (src_host_ip, incoming_port)
    dst_remote_qmp.qmp_cmd_output(cmd=cmd)
    utils_migration.switch_to_postcopy(remote_qmp=dst_remote_qmp)
    chk_info = utils_migration.query_migration(remote_qmp=dst_remote_qmp)
    if chk_info == False:
        test.test_error('Migration timeout')

    test.main_step_log('8.Repeat step6')
    src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port)
    output = src_serial.serial_cmd_output('dmesg')
    if re.findall(r'Call Trace:', output):
        test.test_error('Guest hit call trace after migration')
    src_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}')
    src_guest_ip = src_serial.serial_login()
    src_guest_session = GuestSession(case_id=id,
                                     params=params,
                                     ip=src_guest_ip)
    test.sub_step_log('a.Check networking')
    src_guest_session.guest_ping_test('www.redhat.com', 10)
    test.sub_step_log('b.Check block by the following methods')
    utils_migration.filebench_test(src_guest_session)
    test.sub_step_log('c.Check VNC console and check keyboard by input keys')
Exemple #2
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = params.get('dst_host_ip')
    qmp_port = int(params.get('qmp_port'))
    serial_port = int(params.get('serial_port'))
    incoming_port = params.get('incoming_port')
    test = CreateTest(case_id='rhel7_58670', params=params)
    id = test.get_id()
    src_host_session = HostSession(id, params)
    val_M = '2000'
    val_s = '10000'
    ping_file = '/tmp/ping'

    test.main_step_log('1. Launch guest on source host')
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)
    src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port)
    src_guest_ip = src_serial.serial_login()
    src_guest_session = GuestSession(case_id=id, params=params,
                                     ip=src_guest_ip)

    test.sub_step_log('2. stress guest')
    utils_migration.stressapptest(guest_session=src_guest_session,
                                  val_M=val_M, val_s=val_s)

    test.main_step_log('3. ping guest from host, keep it during whole '
                       'migration process')
    flag = False
    endtime =time.time() + 300
    while time.time() < endtime:
        output = src_host_session.host_cmd_output(cmd='pgrep ping')
        if output:
            src_host_session.host_cmd(cmd='pgrep ping | xargs kill -9')
        else:
            flag = True
            break
    if flag == False:
        test.test_error('Failed to kill existing ping process')

    cmd = 'ping %s > %s &' % (src_guest_ip, ping_file)
    src_host_session.host_cmd(cmd=cmd)

    test.main_step_log('4. Launch guest on destination host ')
    incoming_val = 'tcp:0:%s' % incoming_port
    params.vm_base_cmd_add('incoming', incoming_val)
    dst_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip,
                                       vm_alias='dst')
    dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port)

    test.main_step_log('5. check postcopy capability on')
    test.sub_step_log('set src host postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    test.sub_step_log('set dst host postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')

    test.main_step_log('6. migrate guest to destination')
    cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \
          % (dst_host_ip, incoming_port)
    src_remote_qmp.qmp_cmd_output(cmd=cmd)

    test.main_step_log('7. Cancel migration')
    status = utils_migration.query_status(remote_qmp=src_remote_qmp,
                                          status='active')
    if (status == False):
        test.test_error('Migration status is not active')
    cmd = '{"execute":"migrate_cancel"}'
    src_remote_qmp.qmp_cmd_output(cmd=cmd)
    output = utils_migration.query_status(remote_qmp=src_remote_qmp,
                                          status='cancelled')
    if (output == True):
        test.test_print('Migration is cancelled successfully')
    if (output == False):
        test.test_error('Migration status is not cancelled')

    ping_pid = src_host_session.host_cmd_output(cmd='pgrep ping')
    if not ping_pid:
        test.test_error('The process of host ping guest is not existing')
    cmd = 'kill -9 %s' % ping_pid
    src_host_session.host_cmd(cmd=cmd)

    fo = open(ping_file, 'r')
    for line in fo.readlines():
        line = line.strip()
        if re.findall(r'unknown host name', line) \
                or re.findall(r'unreachable', line) \
                or re.findall(r'timeout', line):
            test.test_error('There is error in ping file')
    test.test_print('There is no error in ping file')
    fo.close()
Exemple #3
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = params.get('dst_host_ip')
    qmp_port = int(params.get('qmp_port'))
    serial_port = int(params.get('serial_port'))
    incoming_port = params.get('incoming_port')
    test = CreateTest(case_id='rhel7_85702', params=params)
    id = test.get_id()
    src_host_session = HostSession(id, params)
    script = 'migration_dirtypage_2.c'

    test.main_step_log('1.Boot a vm in src host with qemu cli:')
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)
    src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port)
    src_guest_ip = src_serial.serial_login()
    src_guest_session = GuestSession(case_id=id, params=params,
                                     ip=src_guest_ip)

    test.main_step_log('2.Boot a vm in dst host')
    incoming_val = 'tcp:0:%s' % incoming_port
    params.vm_base_cmd_add('incoming', incoming_val)
    dst_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip,
                                       vm_alias='dst')
    dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port)

    test.main_step_log('3.In the guest, execute the below program '
                       'to generate dirty pages')
    utils_migration.dirty_page_test(host_session=src_host_session,
                                    guest_session=src_guest_session,
                                    guest_ip=src_guest_ip, script=script)

    test.main_step_log('4. Set migration configuration in HMP and do migration')
    test.sub_step_log('set src host xbzrle and postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp,
                                               capabilities='xbzrle',
                                               state='true')
    utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    test.sub_step_log('set dst host xbzrle and postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp,
                                               capabilities='xbzrle',
                                               state='true')
    utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    test.sub_step_log('start to do migration')
    cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \
          % (dst_host_ip, incoming_port)
    src_remote_qmp.qmp_cmd_output(cmd=cmd)

    test.main_step_log('5. Check migration status, after producing dirty pages'
                       ' switch to post-copy.')
    utils_migration.switch_to_postcopy(remote_qmp=src_remote_qmp)
    chk_info = utils_migration.query_migration(remote_qmp=src_remote_qmp)
    if chk_info == False:
        test.test_error('Migration timeout')

    test.sub_step_log('Check guest status after migration finished')
    dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port)
    output = dst_serial.serial_cmd_output('dmesg')
    if re.findall(r'Call Trace:', output):
        test.test_error('Guest hit call trace after migration')
    dst_serial.serial_cmd(cmd='reboot')
    dst_guest_ip = dst_serial.serial_login()
    dst_guest_session = GuestSession(case_id=id, params=params,
                                     ip=dst_guest_ip)
    dst_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10)
Exemple #4
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = params.get('dst_host_ip')
    qmp_port = int(params.get('qmp_port'))
    serial_port = int(params.get('serial_port'))
    incoming_port = params.get('incoming_port')
    test = CreateTest(case_id='rhel7_93722', params=params)
    id = test.get_id()
    src_host_session = HostSession(id, params)
    size = '2147483648'

    test.main_step_log('1.configure hugepage(both src and dst)')
    output = src_host_session.host_cmd_output(cmd='lscpu')
    if re.findall(r'POWER8', output):
        matrix = 'P8_P8'
    elif re.findall(r'POWER9', output):
        matrix = 'P9_P9'
    utils_stable_abi_ppc.configure_host_hugepage(
        host_session=src_host_session,
        matrix=matrix,
        dst_ip=dst_host_ip,
        mount_point='/mnt/kvm_hugepage')

    test.main_step_log(
        '2.Boot a guest with hugepage memdev and numa on src host')
    params.vm_base_cmd_add(
        'object', 'memory-backend-file,id=ram-node0,prealloc=yes,'
        'mem-path=/dev/hugepages,size=%s' % size)
    params.vm_base_cmd_add('numa', 'node,nodeid=0,cpus=0-1,memdev=ram-node0')
    params.vm_base_cmd_add(
        'object', 'memory-backend-file,id=ram-node1,prealloc=yes,'
        'mem-path=/dev/hugepages,size=%s' % size)
    params.vm_base_cmd_add('numa', 'node,nodeid=1,cpus=2-3,memdev=ram-node1')
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)
    src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port)
    src_serial.serial_login()

    test.main_step_log('3. Boot a guest on dst host')
    incoming_val = 'tcp:0:%s' % incoming_port
    params.vm_base_cmd_add('incoming', incoming_val)
    dst_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_remote_guest(cmd=dst_qemu_cmd,
                                       ip=dst_host_ip,
                                       vm_alias='dst')
    dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port)

    test.main_step_log('4.On src host and dst host, '
                       'enable postcopy and do migration')
    test.sub_step_log('set src host postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    test.sub_step_log('set dst host postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    test.sub_step_log('start to do migration')
    cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \
          % (dst_host_ip, incoming_port)
    src_remote_qmp.qmp_cmd_output(cmd=cmd)
    utils_migration.switch_to_postcopy(remote_qmp=src_remote_qmp,
                                       dirty_count_threshold=0)
    chk_info = utils_migration.query_migration(remote_qmp=src_remote_qmp)
    if chk_info == False:
        test.test_error('Migration timeout')

    test.sub_step_log('Check guest status after migration finished')
    dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port)
    output = dst_serial.serial_cmd_output('dmesg')
    if re.findall(r'Call Trace:', output):
        test.test_error('Guest hit call trace after migration')
    dst_serial.serial_cmd(cmd='reboot')
    dst_guest_ip = dst_serial.serial_login()
    dst_guest_session = GuestSession(case_id=id,
                                     params=params,
                                     ip=dst_guest_ip)
    dst_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10)
Exemple #5
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = params.get('dst_host_ip')
    qmp_port = int(params.get('qmp_port'))
    serial_port = int(params.get('serial_port'))
    incoming_port = params.get('incoming_port')
    test = CreateTest(case_id='rhel7_49062', params=params)
    id = test.get_id()
    src_host_session = HostSession(id, params)
    val_M = '2000'
    val_s = '10000'

    test.main_step_log('1. Launch guest on source host')
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)
    src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port)
    src_guest_ip = src_serial.serial_login()
    src_guest_session = GuestSession(case_id=id,
                                     params=params,
                                     ip=src_guest_ip)

    test.sub_step_log('2. stress guest(migration could finish for scenario1/'
                      'could never finish for scenario 2)')
    utils_migration.stressapptest(guest_session=src_guest_session,
                                  val_M=val_M,
                                  val_s=val_s)

    test.main_step_log('3. Launch guest on destination host')
    incoming_val = 'tcp:0:%s' % incoming_port
    params.vm_base_cmd_add('incoming', incoming_val)
    dst_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_remote_guest(cmd=dst_qemu_cmd,
                                       ip=dst_host_ip,
                                       vm_alias='dst')
    dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port)

    test.main_step_log('4. On source qemu & dst qemu, set postcopy mode on')
    test.sub_step_log('set src host postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    test.sub_step_log('set dst host postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')

    test.main_step_log('5. migrate guest to destination')
    cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \
          % (dst_host_ip, incoming_port)
    src_remote_qmp.qmp_cmd_output(cmd=cmd)

    test.sub_step_log('6. Change into postcopy mode')
    output = utils_migration.query_migration(remote_qmp=src_remote_qmp,
                                             chk_timeout=300)
    if (output == False):
        test.test_print('Migration can not finish without postcopy')
        cmd = '{"execute":"migrate-start-postcopy"}'
        src_remote_qmp.qmp_cmd_output(cmd=cmd)
        info = utils_migration.query_migration(remote_qmp=src_remote_qmp)
        if (info == False):
            test.test_error('Migration timeout with postcopy')
    else:
        test.test_print('Migration finished without postcopy')

    test.main_step_log(
        '7. Check guest status before and after migration finished')
    dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port)
    output = dst_serial.serial_cmd_output('dmesg')
    if re.findall(r'Call Trace:', output):
        test.test_error('Guest hit call trace after migration')
    dst_serial.serial_cmd(cmd='reboot')
    dst_guest_ip = dst_serial.serial_login()
    dst_guest_session = GuestSession(case_id=id,
                                     params=params,
                                     ip=dst_guest_ip)
    dst_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10)

    test.main_step_log('8. Check postcopy statistics')
    cmd = '{"execute":"query-migrate"}'
    output = src_remote_qmp.qmp_cmd_output(cmd=cmd)
    if re.findall(r'"postcopy-requests": 0', output):
        test.test_error('the value postcopy-requests is zero')
    else:
        test.test_print('the value postcopy-requests is not zero')

    test.main_step_log(
        '9.repeat step2~8 to migrate guest back to source host.')
    test.sub_step_log('9.1 quit src qemu')
    src_remote_qmp.qmp_cmd_output(cmd='{"execute":"quit"}')
    src_host_session.check_guest_process(src_ip=src_host_ip)

    test.sub_step_log('9.2 boot src guest again')
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)

    test.sub_step_log('9.3 stress guest')
    utils_migration.stressapptest(guest_session=dst_guest_session,
                                  val_M=val_M,
                                  val_s=val_s)

    test.sub_step_log('9.4 set src and dst postcopy-ram on')
    test.sub_step_log('set src host postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')
    test.sub_step_log('set dst host postcopy-ram on')
    utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp,
                                               capabilities='postcopy-ram',
                                               state='true')

    test.sub_step_log('9.5 migrate guest to source')
    cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \
          % (src_host_ip, incoming_port)
    dst_remote_qmp.qmp_cmd_output(cmd=cmd)

    test.sub_step_log('9.6. Change into postcopy mode')
    output = utils_migration.query_migration(remote_qmp=dst_remote_qmp,
                                             chk_timeout=300)
    if (output == False):
        test.test_print('Migration can not finish without postcopy')
        cmd = '{"execute":"migrate-start-postcopy"}'
        dst_remote_qmp.qmp_cmd_output(cmd=cmd)
        info = utils_migration.query_migration(remote_qmp=dst_remote_qmp)
        if (info == False):
            test.test_error('Migration timeout with postcopy')
    else:
        test.test_print('Migration finished without postcopy')

    test.main_step_log(
        '9.7. Check guest status before and after migration finished')
    src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port)
    output = src_serial.serial_cmd_output('dmesg')
    if re.findall(r'Call Trace:', output):
        test.test_error('Guest hit call trace after migration')
    src_serial.serial_cmd(cmd='reboot')
    src_guest_ip = src_serial.serial_login()
    src_guest_session = GuestSession(case_id=id,
                                     params=params,
                                     ip=src_guest_ip)
    src_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10)

    test.main_step_log('9.8. Check postcopy statistics')
    cmd = '{"execute":"query-migrate"}'
    output = dst_remote_qmp.qmp_cmd_output(cmd=cmd)
    if re.findall(r'"postcopy-requests": 0', output):
        test.test_error('the value postcopy-requests is zero')
    else:
        test.test_print('the value postcopy-requests is not zero')