lib/parallel_guest_migration_base.pm

run

Main subroutine to execute test.

pre_run_test

Run before test run starts. Check host healthy state and do logs cleanup.

run_test

Actual test is executed in this subroutine which needs to be overloaded in test module which uses this module as base.

post_run_test

Run after test run finishes. Judge overall test run result and die if test fails.

get_parallel_role

Get role (parent or children) of job based on whether PARALLEL_WITH is given.

create_barrier

Create barriers to be used for synchronization between peers.

set_test_run_progress

Any subroutine calls this set_test_run_progress will set TEST_RUN_PROGRESS to the name of FILE::SUBROUTINE. If argument token is not empty, it will be added to the end of the name of FILE::SUBROUTINE.

get_test_run_progress

Return TEST_RUN_PROGRESS of peer or self job depends on whether argument peer is set (1) or not (0);

get_test_run_result

Return TEST_RUN_RESULT of peer or self job depends on whether argument peer is set (1) or not (0);

do_local_initialization

Initialization information about local host and save it into variables.

do_peer_initialization

Initialization information about peer, save it into variables and setup passwordless ssh connection to it.

get_peer_info

Get peer job info and variables.

config_ssh_pubkey_auth

Configure SSH Public Key Authentication to host or guest. Main arguments are address to which ssh connects, whether overwrite (1) or not (0) existing keys, either host (1) or guest (0) on which operation will be done and whether die (1) or not (0) if any failures happen.

check_host_architecture

Check source and destination hosts have the same architecture, otherwise test run can not proceed.

check_host_os

Check source and destination hosts operating system version. Guest migration can not be done from the newer to the older. Main argument is host role (src or dst).

check_host_virtualization

Check virtualization modules and services are ready, otherwise test run can not proceed.

check_host_package

Install necessary packages to facilitate test run down the road. Main argument is packages to be installed.

check_host_uid

Check source and destination hosts have the same user id for user qemu. If any discrepancy, set the same group id on both side by using the value provided in _user.

check_host_gid

Check source and destination hosts have the same group id for groups qemu, kvm and libvirt. If any discrepancy, set the same group id on both side by using the value provided in _group.

config_host_shared_storage

Configure shared nfs storage on server and mount it on client. Main arguments are type of shared storage, path of exported shared storage, server or client , original source path on server and mount path on server and client.

config_host_security

Get rid of limitations come from security services and rules which may have impact on connectivity between host and guest.

guest_under_test

Obtain all guests to be tested, either from test suite level setting GUEST_LIST or those already on host. Destination host retrieves such information from source. At last, initialize guest_matrix to empty.

initialize_test_result

Initialize hash structure test_result, which contains all tests specified by test suite level setting GUEST_MIGRATION_TEST, to 'FAILED' and TEST_RUN_RESULT to empty. The detailed test commands are stored in guest_migration_matrix.

save_guest_asset

Save guest xml config for use down the road. Main arguments are guest to be manipulated , directory in which xml config is stored and whether die (1) or not (0) if any failures happen. This subroutine also calls construct_uri to determine the desired URI to be used if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.

restore_guest_asset

Find guest disk and xml config with domain name, restore them to their original names and places. Main arguments are guest to be manipulated, whether die (1) or not (0) if any failures happen, directories in which guest asset and config are stored. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.

config_guest_clock

Configure guest clock to kvm-clock or tsc. Please refer to guest migration requirements: https://susedoc.github.io/doc-sle/main/single-html/SLES-virtualization/#libvirt-admin-live-migration-requirements Main arguments are guest to be configured, directory in which guest xml config is stored and whether die (1) or not (0) if any failures happen.

config_guest_storage

Configure guest storage cache mode to none. Please refer to guest migration requirements: https://susedoc.github.io/doc-sle/main/single-html/SLES-virtualization/#libvirt-admin-live-migration-requirements Main arguments are guest to be configured, directory in which guest xml config is stored and whether die (1) or not (0) if any failures happen.

config_guest_console

Configure serial console for guest by using libguestfs tools. Main arguments are guest to be configured, directory in which guest xml config is stored and whether die (1) or not (0) if any failures happen. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.

start_guest

Start guest by using virsh start and wait for it up and running if necessary. Main arguments are guest to start, virtualization management tool to be used, whether restart (1) or not (0), whether die (1) or not (0) if any failures happen and whether wait (1) or not (0) for guest up and running. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.

wait_guest

Wait for guest up and running by obtaining ip address, adding mapping in /etc/hosts, and calling wait_guest_ssh. Main arguments are guest to wait, whether check ip address (1) or not (0) and whether die (1) or not (0) if any failures happen.

wait_guest_ssh

Detect whether guest ssh port is open by using nc. Main arguments are guest to be detected, times of retry and whether die (1) or not (0) if any failures happen.

check_guest_network_config

Check and obtain guest network configuration. Guest xml config contains enough information about network to which guest connects on boot, for example: <interface type="network"> <mac address="00:16:3e:4f:5a:35"/> <source network="vnet_nat"/> </interface> or <interface type='bridge'> <mac address='52:54:00:70:9d:b2'/> <source bridge='br123'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface> Interface type, source network/bridge name and model type are those useful ones determine the network, they will be stored in guest_matrix{guest}{nettype}, guest_matrix{guest}{netname} and guest_matrix{guest}{netmode}. In order to obtain netmode conveniently and consistently, netname should take the form of "vnet_" + "nat/route/host" + "_other_strings" if virtual network to be used. Addtionally, guest_matrix{guest}{macaddr} is also upated by querying domiflist and ip address guest_matrix{guest}{ipaddr} can also be obtained from lib/virt_autotest/common.pm if static ip address is being used. The main arguments are guest to be checked and directory in which guest xml config is stored. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.

check_guest_network_address

Check and obtain guest ip address. If static ip address is being used, there is no need to check it anymore. If guest uses bridge device directly, its ip address can be obtained by querying journal log or scanning subnet by using nmap (if host bridge device br0 is being used directly) with mac address. If guest uses virtual network created by virsh, its ip address can be obtained by querying dhcp leases of the virtual network or scanning subnet by using nmap (if host bridge device is being used in the virtual network directly) with mac address. The main arguments is guest to be checked. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.

create_guest_network

Create network, type of which is either network or bridge, to be used with guest. In order to make this work consistent, data in hash structure guest_network_matrix will be used for network creating, and the network name should begin with "vnet_" followed by "nat", "route" or "host" if network type is "network", or be "br0" or "br123" if network type is "bridge". For guest using static ip address, network address info is derived from guest ip address. Main arguments are guest to be served, the directory in which network xml config will be stored and whether die (1) or not (0) if any error.This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.

initialize_guest_matrix

Initialize guest matrix and associated variables. If variables are not empty, then update them. These variables will be shared between source and destination host to facilitate collaborative operations. On source host, putting values of variables into corresponding arrays which will be filled up or updated by calling fill_up_array. At last, storing updated values in arrays in variables. On destination host, initialize or update variables by retrieving corresponding information from source.

fill_up_array

Fill up or update existing array which contains information about running guest, mac address, ip address, network type, network name, network mode and use static ip (yes) or not (no). Updated array will be used to set corresponding variables, for example, GUEST_UNDER_TEST_IPADDR. Main arguments are reference to the array, guest to be involved and variable related. Guest attribute name is derived from corresponding variable, for example, guest_matrix{guest}{netmode} is derived from GUEST_UNDER_TEST_NETMODE. At last, array will be filled up or updated by the latest guest_matrix{guest}{attribute}.

test_guest_network

Test networking accessibility of guest. All guests should can be reached on host and can reach outside from inside. The only guest that can be reached from outside host is the one uses host bridge network. Main arguments are guest to be tested and whether die (1) or not (0) if any error.

test_guest_storage

Test whether writing into guest disk is successful and return the result. Main arguments are guest to be tested and whether die (1) or not (0) if any error.

do_guest_administration

Perform basic administration on guest and return overall result. Main arguments are guest to be manipulated, virttool (virsh or xl) to be used, directory in which original guest config file resides and whether die (1) or not (0) if any error. This subroutine also calls construct_uri to determine the desired URI to be connected if the interested party is not localhost. Please refer to subroutine construct_uri for the arguments related.

virsh_migrate_manual_postcopy

Perform manual postcopy guest migration which needs an extra command to be executed alongside main migration command. The return value of this extra command indicates whether it is a successful manual postcopy guest migration. Main arguments are guest to be migrated, main migraiton command and whether die (1) or not (0) if any error.

create_junit_log

Create xml file to be parsed by parse_junit_log by using XML::LibXML. The data source is a hash structure like test_result which stores test results and some other side information like product and time.

create_junit_element

Create xml elements that may have attributes, text or child and return array of created elements. Accepted arguments are references to xml doc object, parent of element to be created, array of elements to be created, array of attributes of elements and array of texts of elements. The order in which elements appear in array of elements to be created should be the same as those respective attributes and texts in their arrays.

check_peer_test_run

Check progress of test run of peer job. This subroutine is called to verify whether peer job is destined to fail or not and return its test run result. This is usually called by paired job that is already in post_fail_hook to wait for peer job if it already failed or is about to fail, so the peer job can finish operations instead of being cancelled due to paired job fails and terminates. This can be achieved simply by barrier_wait on certain lock by both jobs if the peer fails as well. There are situations in which peer job needs to move pass current running subroutines like, do_guest_migration or post_run_test, before entering into post_fail_hook, so it is necessary to wait a period before having the final resolution. But if peer job still remains any earlier steps, it is not meaningful to wait anymore because locks ahead.

filter_migration_tests

Filters migration tests based on specified criteria.

post_fail_hook

Set TEST_RUN_RESULT to FAILED, create junit log and collect logs.