Skip to content

Commit 610f617

Browse files
authored
virtual_network/migrate_with_bridge: enable remote host iface config (#6717)
* virtual_network/migrate_with_bridge: enable remote host iface config We previously enabled configuration for host face selection for bridge setup to account for environments where it's not the default interface (the first one). However, the test case also requires this for the remote host as it's a migration test case. Add this option and the same setting logic as for 'host_iface'. For this, the setting logic has to be brought further up in the execution where the variable is defined. Signed-off-by: Sebastian Mitterle <[email protected]> * virtual_network/migrate_with_bridge/ovs: enable host ifname config The ovs bridge must be created with a specific host interface that provides DHCP which in our case isn't the default. If the value is not configured the behavior is unchanged. Signed-off-by: Sebastian Mitterle <[email protected]> --------- Signed-off-by: Sebastian Mitterle <[email protected]>
1 parent 0b4c929 commit 610f617

File tree

2 files changed

+67
-34
lines changed

2 files changed

+67
-34
lines changed

libvirt/tests/cfg/virtual_network/migrate/migrate_with_bridge_type_interface.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
expected_xpath = [{'element_attrs': ["//interface/driver[@queues='${iface_queues}']"]}]
2828
check_network_accessibility_after_mig = "yes"
2929
host_iface =
30+
remote_host_iface =
3031
variants:
3132
- linux_bridge:
3233
bridge_type = "linux"

libvirt/tests/src/virtual_network/migrate/migrate_with_bridge_type_interface.py

Lines changed: 66 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def check_multiqueue_in_guest(vm_session):
4747
test.log.info("Checking multiqueue configuration in guest")
4848
guest_iface_info = vm_session.cmd_output("ip --color=never l").strip()
4949
iface_matches = re.findall(
50-
r"^\d+: (\S+?)[@:].*state UP.*$", guest_iface_info, re.MULTILINE)
50+
r"^\d+: (\S+?)[@:].*state UP.*$", guest_iface_info, re.MULTILINE
51+
)
5152
if not iface_matches:
5253
test.fail("Failed to get network interface name in guest")
5354
iface_name = iface_matches[0]
@@ -68,18 +69,19 @@ def setup_vm_interface():
6869
Setup VM interface according to configuration
6970
"""
7071
vm_xml = VMXML.new_from_inactive_dumpxml(vm_name)
71-
vm_xml.remove_all_device_by_type('interface')
72+
vm_xml.remove_all_device_by_type("interface")
7273
vm_xml.sync()
7374
if interface_timing == "hotplug":
7475
if not vm.is_alive():
7576
vm.start()
76-
iface = libvirt_vmxml.create_vm_device_by_type('interface', iface_dict)
77-
virsh.attach_device(vm_name, iface.xml, flagstr="--config",
78-
debug=True, ignore_status=False)
77+
iface = libvirt_vmxml.create_vm_device_by_type("interface", iface_dict)
78+
virsh.attach_device(
79+
vm_name, iface.xml, flagstr="--config", debug=True, ignore_status=False
80+
)
7981
else:
8082
libvirt_vmxml.modify_vm_device(
81-
VMXML.new_from_inactive_dumpxml(vm_name), 'interface',
82-
iface_dict)
83+
VMXML.new_from_inactive_dumpxml(vm_name), "interface", iface_dict
84+
)
8385
vm.start()
8486
vm.wait_for_serial_login().close()
8587
test.log.debug("Guest xml:\n%s", VMXML.new_from_dumpxml(vm_name))
@@ -103,19 +105,24 @@ def setup_test():
103105

104106
if bridge_type == "linux":
105107
utils_net.create_linux_bridge_tmux(bridge_name, iface_name=host_iface)
106-
107-
remote_host_iface = utils_net.get_default_gateway(
108-
iface_name=True, session=remote_session, force_dhcp=False, json=True)
109-
params.update({"remote_host_iface": remote_host_iface})
110108
utils_net.create_linux_bridge_tmux(
111-
bridge_name, iface_name=remote_host_iface, session=remote_session)
109+
bridge_name, iface_name=remote_host_iface, session=remote_session
110+
)
112111

113112
elif bridge_type == "ovs":
114-
utils_net.create_ovs_bridge(ovs_bridge_name, ip_options='-color=never')
115-
116-
utils_net.create_ovs_bridge(ovs_bridge_name, session=remote_session,
117-
ip_options='-color=never')
118-
libvirt_network.create_or_del_network(network_dict, remote_args=remote_virsh_dargs)
113+
utils_net.create_ovs_bridge(
114+
ovs_bridge_name, ip_options="-color=never", iface_name=host_iface
115+
)
116+
117+
utils_net.create_ovs_bridge(
118+
ovs_bridge_name,
119+
session=remote_session,
120+
ip_options="-color=never",
121+
iface_name=remote_host_iface,
122+
)
123+
libvirt_network.create_or_del_network(
124+
network_dict, remote_args=remote_virsh_dargs
125+
)
119126
libvirt_network.create_or_del_network(network_dict)
120127

121128
if vm.is_alive():
@@ -143,15 +150,16 @@ def run_test():
143150
vm_session_after_mig.cmd("dhclient -r; dhclient", timeout=120)
144151

145152
test.log.info("TEST_STEP: Testing guest ping to outside")
146-
ips = {'outside_ip': outside_ip}
153+
ips = {"outside_ip": outside_ip}
147154
network_base.ping_check(params, ips, vm_session_after_mig)
148155

149156
test.log.info("TEST_STEP: Checking multiqueue")
150157
check_multiqueue_in_guest(vm_session_after_mig)
151158
virsh_obj = virsh.VirshPersistent(uri=dest_uri)
152159
libvirt_vmxml.check_guest_xml_by_xpaths(
153160
VMXML.new_from_dumpxml(vm_name, virsh_instance=virsh_obj),
154-
expected_xpath)
161+
expected_xpath,
162+
)
155163

156164
if migrate_vm_back:
157165
test.log.info("TEST_STEP: Migrating VM back to source host")
@@ -165,14 +173,25 @@ def teardown_test():
165173
if bridge_type == "linux":
166174
utils_net.delete_linux_bridge_tmux(bridge_name, iface_name=host_iface)
167175
utils_net.delete_linux_bridge_tmux(
168-
bridge_name, iface_name=params.get("remote_host_iface"),
169-
session=remote_session)
176+
bridge_name,
177+
iface_name=params.get("remote_host_iface"),
178+
session=remote_session,
179+
)
170180

171181
elif bridge_type == "ovs":
172-
utils_net.delete_ovs_bridge(ovs_bridge_name, ip_options='-color=never')
173-
utils_net.delete_ovs_bridge(ovs_bridge_name, session=remote_session, ip_options='-color=never')
174-
175-
libvirt_network.create_or_del_network(network_dict, is_del=True, remote_args=remote_virsh_dargs)
182+
utils_net.delete_ovs_bridge(
183+
ovs_bridge_name, ip_options="-color=never", iface_name=host_iface
184+
)
185+
utils_net.delete_ovs_bridge(
186+
ovs_bridge_name,
187+
session=remote_session,
188+
ip_options="-color=never",
189+
iface_name=remote_host_iface,
190+
)
191+
192+
libvirt_network.create_or_del_network(
193+
network_dict, is_del=True, remote_args=remote_virsh_dargs
194+
)
176195
libvirt_network.create_or_del_network(network_dict, is_del=True)
177196
migration_obj.cleanup_connection()
178197

@@ -190,25 +209,38 @@ def teardown_test():
190209
migrate_vm_back = params.get_boolean("migrate_vm_back")
191210
cancel_migration = params.get_boolean("cancel_migration")
192211

193-
remote_virsh_dargs = {'remote_ip': server_ip, 'remote_user': server_user,
194-
'remote_pwd': server_pwd, 'unprivileged_user': params.get("unprivileged_user"),
195-
'ssh_remote_auth': params.get("ssh_remote_auth")}
212+
remote_virsh_dargs = {
213+
"remote_ip": server_ip,
214+
"remote_user": server_user,
215+
"remote_pwd": server_pwd,
216+
"unprivileged_user": params.get("unprivileged_user"),
217+
"ssh_remote_auth": params.get("ssh_remote_auth"),
218+
}
196219

197220
src_uri = params.get("virsh_migrate_connect_uri")
198221
dest_uri = params.get("virsh_migrate_desturi")
199222
expected_xpath = eval(params.get("expected_xpath"))
200223
iface_dict = eval(params.get("iface_dict", "{}"))
201-
host_iface = params.get('host_iface')
202-
host_iface = host_iface if host_iface else utils_net.get_default_gateway(
203-
iface_name=True, force_dhcp=False, json=True)
224+
host_iface = params.get("host_iface")
225+
host_iface = (
226+
host_iface
227+
if host_iface
228+
else utils_net.get_default_gateway(iface_name=True, force_dhcp=False, json=True)
229+
)
204230

205231
vm_name = guest_os.get_vm(params)
206232
vm = env.get_vm(vm_name)
207233
new_xml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
208234

209-
remote_session = aexpect.remote.remote_login("ssh", server_ip, "22",
210-
server_user, server_pwd,
211-
r'[$#%]')
235+
remote_session = aexpect.remote.remote_login(
236+
"ssh", server_ip, "22", server_user, server_pwd, r"[$#%]"
237+
)
238+
remote_host_iface = params.get("remote_host_iface")
239+
if not remote_host_iface:
240+
remote_host_iface = utils_net.get_default_gateway(
241+
iface_name=True, session=remote_session, force_dhcp=False, json=True
242+
)
243+
params.update({"remote_host_iface": remote_host_iface})
212244
migration_obj = base_steps.MigrationBase(test, vm, params)
213245

214246
try:

0 commit comments

Comments
 (0)