Skip to content

Commit

Permalink
Merge pull request #5144 from cliping/update-unix
Browse files Browse the repository at this point in the history
migration: Update unix proxy case
  • Loading branch information
chunfuwen authored Sep 19, 2023
2 parents e0c39af + 8544899 commit f0d6846
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
disks_uri_socket_path = "/var/lib/libvirt/qemu/disks-uri-socket"
migrate_desturi_type = "unix_proxy"
virsh_migrate_desturi = "qemu+unix:///system?socket=${desturi_socket_path}"
disk_num = "3"
disk_dict = {"type_name":"file", "driver": {"name": "qemu", "type":"qcow2"}, "target":{"bus": "virtio"}}

variants:
- p2p:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,62 @@
import os

from six import itervalues

from avocado.utils import process

from virttest.libvirt_xml import vm_xml
from virttest.utils_libvirt import libvirt_disk
from virttest.utils_libvirt import libvirt_vmxml

from provider.migration import base_steps


def prepare_disks(params, vm, vm_name, test):
"""
Prepare disk
:param params: Dictionary with the test parameter
:param vm: vm object
:param vm_name: vm name
:param test: test object
"""
disk_format = params.get("disk_format", "qcow2")
disk_num = eval(params.get("disk_num", "1"))
blk_source = vm.get_first_disk_devices()['source']
disk_dict = eval(params.get("disk_dict"))

vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
for num in range(2, disk_num+1):
disk_path = os.path.join(os.path.dirname(blk_source),
"mig_test%s.img" % str(num))
disk_dict.update({"source": {"attrs": {"file": "%s" % disk_path}}})
if os.path.exists(disk_path):
os.remove(disk_path)
libvirt_disk.create_disk("file", disk_format=disk_format, path=disk_path)
target_dev = 'vd' + chr(num + ord('a') - 1)
disk_dict.update({"target": {"dev": "%s" % target_dev}})
test.log.debug("disk_dict: %s", disk_dict)
vmxml.add_device(libvirt_vmxml.create_vm_device_by_type("disk", disk_dict))
vmxml.sync()
vm.start()
vm.wait_for_login().close()


def cleanup_disks_local(vm):
"""
Cleanup disks on local host
:param vm: vm object
"""
all_vm_disks = vm.get_blk_devices()
blk_source = vm.get_first_disk_devices()['source']
for disk in list(itervalues(all_vm_disks)):
disk_path = disk.get("source")
if disk_path != blk_source:
cmd = "rm -f %s" % disk_path
process.run(cmd, ignore_status=False, shell=True)


def run(test, params, env):
"""
Test VM live migration with copy storage - network data transport - UNIX+Proxy.
Expand All @@ -15,9 +71,11 @@ def run(test, params, env):

try:
migration_obj.setup_connection()
prepare_disks(params, vm, vm_name, test)
base_steps.prepare_disks_remote(params, vm)
migration_obj.run_migration()
migration_obj.verify_default()
finally:
migration_obj.cleanup_connection()
base_steps.cleanup_disks_remote(params, vm)
cleanup_disks_local(vm)
migration_obj.cleanup_connection()

0 comments on commit f0d6846

Please sign in to comment.