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_120633', 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_serial = RemoteSerialMonitor(id,
                                     params,
                                     ip=src_host_ip,
                                     port=serial_port)
    src_serial.serial_login()
    src_remote_qmp = RemoteQMPMonitor(id,
                                      params,
                                      ip=src_host_ip,
                                      port=qmp_port)

    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. Migrate guest from Source Host host to Destination'
                       ' Host  host')
    check_info = utils_migration.do_migration(remote_qmp=src_remote_qmp,
                                              migrate_port=incoming_port,
                                              dst_ip=dst_host_ip)
    if (check_info == False):
        test.test_error('Migration timeout')

    test.main_step_log('4.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('5.Migrate the guest back to Source Host host and '
                       'please refer to step 3')
    src_remote_qmp.qmp_cmd_output('{"execute":"quit"}', recv_timeout=3)
    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)
    check_info = utils_migration.do_migration(remote_qmp=dst_remote_qmp,
                                              migrate_port=incoming_port,
                                              dst_ip=src_host_ip)
    if (check_info == False):
        test.test_error('Migration timeout')

    test.main_step_log('6.Repeat step 4')
    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')
    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='rhel_135046', 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-sxxm,max-cpu-compat=power8')
    else:
        params.vm_base_cmd_update('machine', 'pseries',
                                  'pseries-rhel7.3.0-sxxm')
    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-sxxm',
            'pseries-rhel7.3.0-sxxm,max-cpu-compat=power8')
    elif (flag == 'p9_to_p8'):
        params.vm_base_cmd_update(
            'machine', 'pseries-rhel7.3.0-sxxm,max-cpu-compat=power8',
            'pseries-rhel7.3.0-sxxm')
    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-sxxm,max-cpu-compat=power8',
            'pseries-rhel7.3.0-sxxm')
    elif (flag == 'p9_to_p8'):
        params.vm_base_cmd_update(
            'machine', 'pseries-rhel7.3.0-sxxm',
            'pseries-rhel7.3.0-sxxm,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 #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_10078_win', params=params)
    id = test.get_id()
    guest_name = test.guest_name
    src_host_session = HostSession(id, params)
    balloon_val = '2147483648'
    chk_timeout = 180

    test.main_step_log('1. Boot guest on src host with memory balloon device.')
    params.vm_base_cmd_add(
        'device', 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9')
    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 --- skip for windows guest')

    test.main_step_log('2 Check if memory balloon device works.')
    test.sub_step_log('2.1 Check if balloon device exists')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)
    output = src_remote_qmp.qmp_cmd_output('{"execute":"query-balloon"}')
    original_val = eval(output).get('return').get('actual')
    if re.findall(r'No balloon', output):
        src_remote_qmp.test_error('No balloon device has been activated.')

    test.sub_step_log('2.2 Change the value of balloon to %s bytes' %
                      balloon_val)
    change_balloon_val(new_value=balloon_val, remote_qmp=src_remote_qmp)

    test.sub_step_log('2.3 Restore balloon to original value')
    change_balloon_val(new_value=original_val, remote_qmp=src_remote_qmp)

    test.main_step_log('3. Hot unplug this memory balloon from guest.')
    cmd = '{"execute":"device_del","arguments":{"id":"balloon0"}}'
    src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5)

    test.sub_step_log('Check if the balloon is hot unplug successfully')
    cmd = '{"execute":"query-balloon"}'
    output = src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5)
    if re.findall(r'No balloon', output):
        test.test_print("Balloon device is hot unplug successfully")

    test.main_step_log('4. Boot guest with \'-incoming\' and '
                       'without memory balloon device on des host.')
    params.vm_base_cmd_del(
        'device', 'virtio-balloon-pci,id=balloon0,'
        'bus=pci.0,addr=0x9')
    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)
    output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-balloon"}',
                                           recv_timeout=5)
    if re.findall(r'No balloon', output):
        test.test_print("Destination guest don't have balloon device")

    test.main_step_log('5. Start live migration, should finish successfully')
    flag = do_migration(remote_qmp=src_remote_qmp,
                        migrate_port=incoming_port,
                        dst_ip=dst_host_ip)
    if (flag == False):
        test.test_error('Migration timeout')

    test.main_step_log('6. Check guest on des, guest should work well.')
    status = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}')
    if '\"status\": \"running\"' not in status:
        dst_remote_qmp.test_error('Dst vm is not running')

    test.main_step_log('7. Hot plug a memory balloon device to '
                       'destination guest.')
    cmd = '{"execute":"device_add","arguments":{"driver":"virtio-balloon-pci",' \
          '"bus":"pci.0","addr":"0x9","id":"balloon0"}}'
    dst_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5)
    output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-balloon"}',
                                           recv_timeout=5)
    if re.findall(r'No balloon', output):
        dst_remote_qmp.test_error('Failed to hotplug balloon device')

    test.main_step_log('8. Repeat step2')
    change_balloon_val(new_value=balloon_val, remote_qmp=dst_remote_qmp)
    change_balloon_val(new_value=original_val, remote_qmp=dst_remote_qmp)

    test.main_step_log('9. Quit qemu on src host. Then boot guest with '
                       '\'-incoming\' on src host')
    output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}')
    if output:
        test.test_error('Failed to quit qemu on src host')
    src_host_session.check_guest_process(src_ip=src_host_ip)
    params.vm_base_cmd_add(
        'device', 'virtio-balloon-pci,id=balloon0,'
        'bus=pci.0,addr=0x9')
    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)
    output = src_remote_qmp.qmp_cmd_output('{"execute":"query-balloon"}')
    if re.findall(r'No balloon', output):
        src_remote_qmp.test_error('src host do not has balloon device')

    test.main_step_log('10. Do migration from dst to src')
    flag = do_migration(remote_qmp=dst_remote_qmp,
                        migrate_port=incoming_port,
                        dst_ip=src_host_ip)
    if (flag == False):
        test.test_error('Migration timeout')

    test.main_step_log('11&12. Check guest on src, reboot, ' 'and shutdown.')

    test.sub_step_log('11.1 Check src guest status')
    status = src_remote_qmp.qmp_cmd_output('{"execute":"query-status"}')
    if '\"status\": \"running\"' not in status:
        src_remote_qmp.test_error('Src vm is not running')

    test.sub_step_log('11.2 Reboot src guest')
    src_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}')

    test.sub_step_log('11.3 quit qemu on dst end and shutdown vm on src end')
    output = dst_remote_qmp.qmp_cmd_output('{"execute":"quit"}',
                                           recv_timeout=3)
    if output:
        dst_remote_qmp.test_error('Failed to quit qemu on dst end')

    time.sleep(30)
    status = src_remote_qmp.qmp_cmd_output('{"execute":"query-status"}')
    if '\"status\": \"running\"' not in status:
        src_remote_qmp.test_error('Src vm is not running after reboot')

    output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}')
    if output:
        src_remote_qmp.test_error('Failed to quit qemu on src end')
Exemple #4
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = params.get('dst_host_ip')
    incoming_port = params.get('incoming_port')
    serial_port = int(params.get('serial_port'))
    qmp_port = int(params.get('qmp_port'))

    test = CreateTest(case_id='rhel7_10062', params=params)
    id = test.get_id()
    query_migration_time = 2400
    src_host_session = HostSession(id, params)
    src_qemu_cmd = params.create_qemu_cmd()

    test.main_step_log('Scenario 1:src: vhost des'
                       'fileCopy: from src host to guest ')
    test.main_step_log('1.1 Start VM in src host ')
    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('Connecting to src serial')
    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('1.2. Start listening mode without vhost in des host ')
    params.vm_base_cmd_del('netdev', 'tap,id=tap0,vhost=on')
    params.vm_base_cmd_add('netdev', 'tap,id=tap0')
    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)
    dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port)

    test.main_step_log('1.3.Copy a large file(eg 2G) from host to guest '
                       'in src host, then start to do migration '
                       'during transferring file.')
    src_host_session.host_cmd(cmd='rm -rf /home/file_host')
    cmd = 'dd if=/dev/urandom of=/home/file_host bs=1M count=2048 oflag=direct'
    src_host_session.host_cmd_output(cmd, timeout=600)
    src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest')
    thread = threading.Thread(target=src_host_session.host_cmd_scp_put,
                              args=('/home/file_host', '/home/file_guest',
                                    params.get('guest_passwd'), src_guest_ip,
                                    600))
    thread.name = 'scp_thread_put'
    thread.daemon = True
    thread.start()
    time.sleep(3)

    test.main_step_log('1.4. Migrate to the destination')
    check_info = do_migration(remote_qmp=src_remote_qmp,
                              migrate_port=incoming_port,
                              dst_ip=dst_host_ip,
                              chk_timeout_2=query_migration_time)
    if (check_info == False):
        test.test_error('Migration timeout ')

    test.main_step_log(
        '1.5.After migration finishes,until transferring finished'
        'reboot guest,Check file in host and guest.'
        'value of md5sum is the same.')
    test.sub_step_log('check status of transferring the file')
    while True:
        pid = src_host_session.host_cmd_output('pgrep -x scp')
        if not pid:
            break
    time.sleep(3)

    test.sub_step_log('reboot guest')
    dst_serial = RemoteSerialMonitor(case_id=id,
                                     params=params,
                                     ip=dst_host_ip,
                                     port=serial_port)
    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('network of guest should be woking')
    external_host_ip = 'www.redhat.com'
    cmd_ping = 'ping %s -c 10' % external_host_ip
    output = dst_guest_session.guest_cmd_output(cmd=cmd_ping)
    if re.findall(r'100% packet loss', output):
        dst_guest_session.test_error('Ping failed')

    test.sub_step_log('Check file in host and guest')
    file_src_host_md5 = src_host_session.host_cmd_output(
        cmd='md5sum /home/file_host')
    file_guest_md5 = dst_guest_session.guest_cmd_output(
        cmd='md5sum /home/file_guest')
    if file_src_host_md5.split(' ')[0] != file_guest_md5.split(' ')[0]:
        test.test_error('Value of md5sum error!')

    test.sub_step_log('1.6 quit qemu on src end and shutdown vm on dst end')
    output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}',
                                           recv_timeout=3)
    if output:
        src_remote_qmp.test_error('Failed to quit qemu on src host')

    dst_serial.serial_shutdown_vm()
    src_host_session.check_guest_process(src_ip=src_host_ip,
                                         dst_ip=dst_host_ip)

    time.sleep(3)
    test.main_step_log('Scenario 2.src: des: vhost,'
                       'fileCopy: from src host to guest')
    src_host_session = HostSession(id, params)

    test.main_step_log('2.1. Start VM in src host ')
    incoming_val = 'tcp:0:%s' % (incoming_port)
    params.vm_base_cmd_del('incoming', incoming_val)
    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('Connecting to src serial')
    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.2 Start listening mode without vhost in des host ')
    params.vm_base_cmd_del('netdev', 'tap,id=tap0')
    params.vm_base_cmd_add('netdev', 'tap,id=tap0,vhost=on')
    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)
    dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port)

    test.main_step_log('2.3.Copy a large file(eg 2G) from host to guest '
                       'in src host, then start to do migration '
                       'during transferring file.')
    src_host_session.host_cmd(cmd='rm -rf /home/file_host')
    cmd = 'dd if=/dev/urandom of=/home/file_host bs=1M count=2000 oflag=direct'
    src_host_session.host_cmd_output(cmd, timeout=600)
    src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest')
    thread = threading.Thread(target=src_host_session.host_cmd_scp_put,
                              args=('/home/file_host', '/home/file_guest',
                                    params.get('guest_passwd'), src_guest_ip,
                                    600))
    thread.name = 'scp_thread_put'
    thread.daemon = True
    thread.start()
    time.sleep(3)

    test.main_step_log('2.4. Migrate to the destination')
    check_info = do_migration(remote_qmp=src_remote_qmp,
                              migrate_port=incoming_port,
                              dst_ip=dst_host_ip,
                              chk_timeout_2=query_migration_time)
    if (check_info == False):
        test.test_error('Migration timeout ')

    test.main_step_log(
        '2.5.After migration finishes,until transferring finished'
        'reboot guest,Check file in host and guest.'
        'value of md5sum is the same.')
    test.sub_step_log('check status of transferring the file')
    while True:
        pid = src_host_session.host_cmd_output('pgrep -x scp')
        if not pid:
            break

    time.sleep(3)

    test.sub_step_log('reboot guest')
    dst_serial = RemoteSerialMonitor(case_id=id,
                                     params=params,
                                     ip=dst_host_ip,
                                     port=serial_port)
    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('network of guest should be woking')
    external_host_ip = 'www.redhat.com'
    cmd_ping = 'ping %s -c 10' % external_host_ip
    output = dst_guest_session.guest_cmd_output(cmd=cmd_ping)
    if re.findall(r'100% packet loss', output):
        dst_guest_session.test_error('Ping failed')

    test.sub_step_log('Check file in host and guest')
    file_src_host_md5 = src_host_session.host_cmd_output(
        cmd='md5sum /home/file_host')
    file_guest_md5 = dst_guest_session.guest_cmd_output(
        cmd='md5sum /home/file_guest')
    if file_src_host_md5.split(' ')[0] != file_guest_md5.split(' ')[0]:
        test.test_error('Value of md5sum error!')

    test.sub_step_log('2.6.quit qemu on src end and shutdown vm on dst end')
    output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}',
                                           recv_timeout=3)
    if output:
        src_remote_qmp.test_error('Failed to quit qemu on src host')

    dst_serial.serial_shutdown_vm()
    src_host_session.check_guest_process(src_ip=src_host_ip,
                                         dst_ip=dst_host_ip)

    time.sleep(3)
    test.main_step_log('Scenario 3.src:vhost des:,'
                       'fileCopy: from src guest to host')
    src_host_session = HostSession(id, params)

    test.main_step_log('3.1. Start VM in src host ')
    incoming_val = 'tcp:0:%s' % (incoming_port)
    params.vm_base_cmd_del('incoming', incoming_val)
    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('Connecting to src serial')
    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('3.2. Start listening mode without vhost in des host ')
    params.vm_base_cmd_del('netdev', 'tap,id=tap0,vhost=on')
    params.vm_base_cmd_add('netdev', 'tap,id=tap0')
    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)
    dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port)

    test.main_step_log('3.3.Copy a large file(eg 2G) from host to guest '
                       'in src host, then start to do migration '
                       'during transferring file. ')
    src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest')
    cmd = 'dd if=/dev/urandom of=/home/file_guest ' \
          'bs=1M count=2000 oflag=direct'
    src_guest_session.guest_cmd_output(cmd, timeout=600)
    src_host_session.host_cmd_output(cmd='rm -rf /home/file_host')
    thread = threading.Thread(target=src_host_session.host_cmd_scp_get,
                              args=('/home/file_host', '/home/file_guest',
                                    params.get('guest_passwd'), src_guest_ip,
                                    600))
    thread.name = 'scp_thread_get'
    thread.daemon = True
    thread.start()
    time.sleep(3)

    test.main_step_log('3.4. Migrate to the destination')
    check_info = do_migration(remote_qmp=src_remote_qmp,
                              migrate_port=incoming_port,
                              dst_ip=dst_host_ip,
                              chk_timeout_2=query_migration_time)
    if (check_info == False):
        test.test_error('Migration timeout ')

    test.main_step_log(
        '3.5.After migration finishes,until transferring finished'
        'reboot guest,Check file in host and guest.'
        'value of md5sum is the same.')
    test.sub_step_log('check status of transferring the file')
    while True:
        pid = src_host_session.host_cmd_output('pgrep -x scp')
        if not pid:
            break

    time.sleep(3)
    test.sub_step_log('reboot guest')
    dst_serial = RemoteSerialMonitor(case_id=id,
                                     params=params,
                                     ip=dst_host_ip,
                                     port=serial_port)
    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('network of guest should be woking')
    external_host_ip = 'www.redhat.com'
    cmd_ping = 'ping %s -c 10' % external_host_ip
    output = dst_guest_session.guest_cmd_output(cmd=cmd_ping)
    if re.findall(r'100% packet loss', output):
        dst_guest_session.test_error('Ping failed')

    test.sub_step_log('Check file in host and guest')
    file_src_host_md5 = src_host_session.host_cmd_output(
        cmd='md5sum /home/file_host')
    file_guest_md5 = dst_guest_session.guest_cmd_output(
        cmd='md5sum /home/file_guest')
    if file_src_host_md5.split(' ')[0] != file_guest_md5.split(' ')[0]:
        test.test_error('Value of md5sum error!')

    test.sub_step_log('3.6 quit qemu on src end and shutdown vm on dst end')
    output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}',
                                           recv_timeout=3)
    if output:
        src_remote_qmp.test_error('Failed to quit qemu on src host')

    dst_serial.serial_shutdown_vm()
    src_host_session.check_guest_process(src_ip=src_host_ip,
                                         dst_ip=dst_host_ip)

    time.sleep(3)
    test.main_step_log('Scenario 4.src: des:vhost ,'
                       'fileCopy: from src guest to host')
    src_host_session = HostSession(id, params)

    test.main_step_log('4.1. Start VM in src host ')
    incoming_val = 'tcp:0:%s' % (incoming_port)
    params.vm_base_cmd_del('incoming', incoming_val)
    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('Connecting to src serial')
    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('4.2. Start listening mode without vhost in des host ')
    params.vm_base_cmd_del('netdev', 'tap,id=tap0')
    params.vm_base_cmd_add('netdev', 'tap,id=tap0,vhost=on')
    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)
    dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port)

    test.main_step_log('4.3.Copy a large file(eg 2G) from host to guest '
                       'in src host, then start to do migration '
                       'during transferring file.')
    src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest')
    cmd = 'dd if=/dev/urandom of=/home/file_guest ' \
          'bs=1M count=2000 oflag=direct'
    src_guest_session.guest_cmd_output(cmd, timeout=600)
    src_host_session.host_cmd_output(cmd='rm -rf /home/file_host')
    thread = threading.Thread(target=src_host_session.host_cmd_scp_get,
                              args=('/home/file_host', '/home/file_guest',
                                    params.get('guest_passwd'), src_guest_ip,
                                    600))
    thread.name = 'scp_thread_get'
    thread.daemon = True
    thread.start()
    time.sleep(3)

    test.main_step_log('4.4. Migrate to the destination')
    check_info = do_migration(remote_qmp=src_remote_qmp,
                              migrate_port=incoming_port,
                              dst_ip=dst_host_ip,
                              chk_timeout_2=query_migration_time)
    if (check_info == False):
        test.test_error('Migration timeout ')

    test.main_step_log(
        '4.5.After migration finishes,until transferring finished'
        'reboot guest,Check file in host and guest.'
        'value of md5sum is the same.')
    while True:
        pid = src_host_session.host_cmd_output('pgrep -x scp')
        if not pid:
            break

    time.sleep(3)
    test.sub_step_log('reboot guest')
    dst_serial = RemoteSerialMonitor(case_id=id,
                                     params=params,
                                     ip=dst_host_ip,
                                     port=serial_port)
    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('network of guest should be woking')
    external_host_ip = 'www.redhat.com'
    cmd_ping = 'ping %s -c 10' % external_host_ip
    output = dst_guest_session.guest_cmd_output(cmd=cmd_ping)
    if re.findall(r'100% packet loss', output):
        dst_guest_session.test_error('Ping failed')

    test.sub_step_log('Check file in host and guest')
    file_src_host_md5 = src_host_session.host_cmd_output(
        cmd='md5sum /home/file_host')
    file_guest_md5 = dst_guest_session.guest_cmd_output(
        cmd='md5sum /home/file_guest')
    if file_src_host_md5.split(' ')[0] != file_guest_md5.split(' ')[0]:
        test.test_error('Value of md5sum error!')

    test.sub_step_log('4.6 quit qemu on src end and shutdown vm on dst end')
    output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}',
                                           recv_timeout=3)
    if output:
        src_remote_qmp.test_error('Failed to quit qemu on src host')

    dst_serial.serial_shutdown_vm()
Exemple #5
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = src_host_ip
    qmp_port = int(params.get('qmp_port'))
    serial_port = int(params.get('serial_port'))
    share_images_dir = params.get('share_images_dir')
    test = CreateTest(case_id='rhel7_10022', params=params)
    id = test.get_id()
    guest_name = test.guest_name

    test.main_step_log('1. Boot a guest.')
    src_host_session = HostSession(id, params)
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')

    test.sub_step_log('Check the status of src guest')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)

    test.sub_step_log('Connecting to src serial')
    src_serial = RemoteSerialMonitor(case_id=id,
                                     params=params,
                                     ip=src_host_ip,
                                     port=serial_port)
    src_guest_ip = src_serial.serial_login()
    guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip)

    test.sub_step_log('Check dmesg info ')
    cmd = 'dmesg'
    output = guest_session.guest_cmd_output(cmd)
    if re.findall(r'Call Trace:', output):
        guest_session.test_error('Guest hit call trace')

    test.main_step_log('2. Save VM state into a compressed file in host')
    src_remote_qmp.qmp_cmd_output('{"execute":"stop"}')
    src_remote_qmp.qmp_cmd_output('{"execute":"query-status"}')
    src_remote_qmp.qmp_cmd_output('{"execute":"migrate_set_speed", '
                                  '"arguments": { "value": 104857600 }}')

    statefile = '/%s/STATEFILE.gz' % share_images_dir
    src_host_session.host_cmd(cmd=('rm -rf %s' % statefile))
    src_remote_qmp.qmp_cmd_output('{"execute":"migrate",'
                                  '"arguments":{"uri": "exec:gzip -c > %s"}}' %
                                  statefile,
                                  recv_timeout=5)

    test.sub_step_log('Check the status of migration')
    info = query_migration(src_remote_qmp)
    if (info == True):
        test.test_print('Migration succeed')
    if (info == False):
        test.test_error('Migration timeout')

    src_remote_qmp.qmp_cmd_output('{"execute":"quit"}')
    src_host_session.check_guest_process(src_ip=src_host_ip)

    test.main_step_log('3. Load the file in dest host(src host).')
    params.vm_base_cmd_add('incoming', '"exec: gzip -c -d %s"' % statefile)
    dst_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=dst_qemu_cmd, vm_alias='dst')

    test.sub_step_log('3.1 Login dst guest')
    dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port)
    while True:
        output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}')
        if re.findall(r'"paused"', output):
            break
        time.sleep(3)

    dst_remote_qmp.qmp_cmd_output('{"execute":"cont"}')
    dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}')

    dst_serial = RemoteSerialMonitor(case_id=id,
                                     params=params,
                                     ip=src_host_ip,
                                     port=serial_port)
    guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip)

    test.main_step_log('4. Check if guest works well.')
    test.sub_step_log('4.1 Guest mouse and keyboard.')
    test.sub_step_log(
        '4.2. Ping external host / copy file between guest and host')
    guest_session.guest_ping_test('www.redhat.com', 10)

    test.sub_step_log('4.3 dd a file inside guest.')
    cmd_dd = 'dd if=/dev/zero of=/tmp/dd.io bs=512b count=2000 oflag=direct'
    guest_session.guest_cmd_output(cmd=cmd_dd, timeout=600)

    test.sub_step_log('check dmesg info')
    cmd = 'dmesg'
    output = guest_session.guest_cmd_output(cmd=cmd)
    if re.findall(r'Call Trace:', output) or not output:
        guest_session.test_error('Guest hit call trace')

    test.sub_step_log('4.4. Reboot and then shutdown guest.')
    dst_serial.serial_cmd(cmd='reboot')
    dst_serial.serial_login()
    dst_serial.serial_shutdown_vm()
Exemple #6
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')