Skip to content

Commit

Permalink
Merge pull request #6018 from smitterl/migrate_network
Browse files Browse the repository at this point in the history
migrate_network: enable configuration of host interface
  • Loading branch information
chloerh authored Dec 2, 2024
2 parents ceeb822 + 67c2745 commit 860954e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions libvirt/tests/cfg/migration/migrate_network.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
virsh_migrate_dest_state = running
virsh_migrate_src_state = running
virsh_migrate_options = "--live --p2p --verbose"
host_iface_src =
host_iface_dst =
# Local URI
virsh_migrate_connect_uri = "qemu:///system"
migrate_vm_back = "yes"
Expand Down
12 changes: 8 additions & 4 deletions libvirt/tests/src/migration/migrate_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,19 @@ def update_iface_xml(vm_name, iface_dict, virsh_instance=virsh):
vm_sync(vmxml, vm_name, virsh_instance=virsh_instance)
logging.debug("VM XML after updating interface: %s" % vmxml)

def update_net_dict(net_dict, runner=utils_net.local_runner):
def update_net_dict(net_dict, iface_name, runner=utils_net.local_runner):
"""
Update network dict
:param net_dict: The network dict to be updated
:param iface_name: host iface name to use for direct network
:param runner: Command runner
:return: Updated network dict
"""
if net_dict.get("name", "") == "direct-macvtap":
logging.info("Updating network iface name")
iface_name = utils_net.get_net_if(runner=runner, state="UP")[0]
if not iface_name:
iface_name = utils_net.get_net_if(runner=runner, state="UP")[0]
net_dict.update({'forward_interface': [{'dev': iface_name}]})
else:
# TODO: support other types
Expand Down Expand Up @@ -204,6 +206,8 @@ def create_fake_tap(remote_session):
params.get("migrate_source_host"))
src_uri = params.get("virsh_migrate_connect_uri")
dest_uri = params.get("virsh_migrate_desturi")
host_iface_src = params.get("host_iface_src")
host_iface_dst = params.get("host_iface_dst")

vm_name = params.get("migrate_main_vm")
vm = env.get_vm(vm_name)
Expand Down Expand Up @@ -257,11 +261,11 @@ def create_fake_tap(remote_session):
test.fail("Failed to create ovs bridge on remote. Status: %s"
"Stdout: %s" % (status, stdout))
if network_dict:
update_net_dict(network_dict, runner=remote_session.cmd)
update_net_dict(network_dict, host_iface_src, runner=remote_session.cmd)
libvirt_network.create_or_del_network(
network_dict, remote_args=remote_virsh_dargs)
logging.info("dest: network created")
update_net_dict(network_dict)
update_net_dict(network_dict, host_iface_dst)
libvirt_network.create_or_del_network(network_dict)
logging.info("localhost: network created")

Expand Down

0 comments on commit 860954e

Please sign in to comment.