Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migration: Add 3 migration cases to check disks port option #3343

Merged
merged 1 commit into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions libvirt/tests/cfg/migration/migrate_storage.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,44 @@
server_info_ip = ""
virsh_migrate_extra = "--tls --migrateuri tcp://${migrate_dest_host}"
err_msg = "Certificate does not match the hostname"
- migrateuri:
only copy_storage_all
check_disks_port = "yes"
func_params_exists = "yes"
bandwidth_opt = "--bandwidth 200"
variants:
- @default:
migrateuri_port = 49153
variants:
- ipv4:
virsh_migrate_extra = "--migrateuri tcp://${migrate_dest_host}:${migrateuri_port} ${bandwidth_opt}"
- ipv6:
ipv6_config = "yes"
ipv6_addr_src = "ENTER.YOUR.IPv6.SOURCE"
ipv6_addr_des = "ENTER.YOUR.IPv6.DESTINATION"
virsh_migrate_extra = "--migrateuri tcp://[${ipv6_addr_des}]:${migrateuri_port} ${bandwidth_opt}"
- disks_port:
migrateuri_port = 49155
port_to_check = 49158
virsh_migrate_extra = "--migrateuri tcp://${migrate_dest_host}:${migrateuri_port} --disks-port ${port_to_check} ${bandwidth_opt}"
- disks_uri:
virsh_migrate_options = "--live --verbose --p2p"
func_supported_since_libvirt_ver = (6, 8, 0)
unspported_err_msg = "This libvirt version doesn't support migration with --disks-uri option."
ipv6_addr_des = "ENTER.YOUR.IPv6.DESTINATION"
variants:
- custom_port:
port_to_check = 49157
variants:
- hostname:
virsh_migrate_extra = "--disks-uri tcp://ENTER.DEST.HOSTNAME:${port_to_check} --listen-address ${migrate_dest_host} --migrateuri tcp://${migrate_dest_host} ${bandwidth_opt}"
- ipv4_addr:
virsh_migrate_extra = "--disks-uri tcp://${migrate_dest_host}:${port_to_check} --listen-address [${ipv6_addr_des}] --migrateuri tcp://[${ipv6_addr_des}] ${bandwidth_opt}"
- ipv6_addr:
ipv6_config = "yes"
ipv6_addr_src = "ENTER.YOUR.IPv6.SOURCE"
virsh_migrate_extra = "--disks-uri tcp://[${ipv6_addr_des}]:${port_to_check} --listen-address ${migrate_dest_host} --migrateuri tcp://${migrate_dest_host} ${bandwidth_opt}"
- default_port:
variants:
- ipv4_addr:
virsh_migrate_extra = "--disks-uri tcp://${migrate_dest_host} --listen-address [${ipv6_addr_des}] --migrateuri tcp://[${ipv6_addr_des}] ${bandwidth_opt}"
19 changes: 13 additions & 6 deletions libvirt/tests/src/migration/migrate_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from avocado.utils import process

from virttest import libvirt_version
from virttest import libvirt_vm
from virttest import utils_misc
from virttest import migration
Expand All @@ -13,6 +14,7 @@
from virttest.libvirt_xml import vm_xml
from virttest.utils_test import libvirt
from virttest.utils_libvirt import libvirt_config
from virttest.utils_libvirt import libvirt_network


def run(test, params, env):
Expand All @@ -24,6 +26,9 @@ def run(test, params, env):
3) Copy only the top image for storage migration with backing chain
4) Migrate vm with copy storage - Native TLS(--tls) - inconsistent CN and
server hostname
5) Migrate vm with copy storage over TCP transport - Specified IP
6) Migrate vm with copy storage over TCP transport - Specified IP+Port
7) Migrate vm with copy storage over TCP transport - Specified disks_uri

:param test: test object
:param params: Dictionary with the test parameters
Expand Down Expand Up @@ -107,6 +112,7 @@ def prepare_nfs_backingfile(vm, params):
log_file = params.get("log_outputs", "/var/log/libvirt/libvirtd.log")
daemon_conf_dict = eval(params.get("daemon_conf_dict", '{}'))
cancel_migration = "yes" == params.get("cancel_migration", "no")
check_disks_port = "yes" == params.get("check_disks_port", "no")
migrate_again = "yes" == params.get("migrate_again", "no")
precreation = "yes" == params.get("precreation", "yes")
tls_recovery = "yes" == params.get("tls_auto_recovery", "yes")
Expand All @@ -125,6 +131,8 @@ def prepare_nfs_backingfile(vm, params):
remove_dict = {}
src_libvirt_file = None

libvirt_version.is_libvirt_feature_supported(params)

# params for migration connection
params["virsh_migrate_desturi"] = libvirt_vm.complete_uri(
params.get("migrate_dest_host"))
Expand All @@ -141,6 +149,8 @@ def prepare_nfs_backingfile(vm, params):
extra_args.update({'func_params': params})
if cancel_migration:
func_name = migration_test.do_cancel
elif check_disks_port:
func_name = libvirt_network.check_established

# For safety reasons, we'd better back up xmlfile.
vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
Expand All @@ -150,7 +160,6 @@ def prepare_nfs_backingfile(vm, params):
if backingfile_type:
if backingfile_type == "nfs":
prepare_nfs_backingfile(vm, params)

if extra.count("copy-storage-all") and precreation:
blk_source = vm.get_first_disk_devices()['source']
vsize = utils_misc.get_image_info(blk_source).get("vsize")
Expand Down Expand Up @@ -204,7 +213,7 @@ def prepare_nfs_backingfile(vm, params):
migration_test.check_result(mig_result, params)

if migrate_again and status_error:
logging.debug("Sleeping 10 seconds before rerun migration")
logging.debug("Sleeping 10 seconds before rerunning the migration.")
time.sleep(10)
if cancel_migration:
func_name = None
Expand All @@ -229,12 +238,10 @@ def prepare_nfs_backingfile(vm, params):
# Clean VM on destination and source
try:
migration_test.cleanup_dest_vm(vm, vm.connect_uri, dest_uri)
if vm.is_alive():
vm.destroy(gracefully=False)
except Exception as err:
logging.error(err)

logging.info("Recovery VM XML configration")
if vm.is_alive():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose to move this part out of try block?

Copy link
Contributor Author

@Yingshun Yingshun Mar 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When an exception is thrown while destroying a remote VM, the vm on local will not be destroyed in previous code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose to move this part out of try block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my answer above.

vm.destroy(gracefully=False)
orig_config_xml.sync()

if daemon_conf:
Expand Down