From c2dc141b8eb8d2c9eedb33144a40a9e07c49e927 Mon Sep 17 00:00:00 2001 From: Sebastian Mitterle Date: Mon, 8 Jan 2024 12:45:28 -0500 Subject: [PATCH] passt/function: fix for multi-arch 1. Configure values for s390x 2. Get IP addresses by host interface to avoid issues when there's more than one functional NIC. 3. Use the host_iface in several functions to make sure the right interface is tested. 4. The test needs to check the ports on the host not in the guest. Therefore, configure the host_iface. Signed-off-by: Sebastian Mitterle --- .../virtual_network/passt/passt_function.cfg | 15 ++++++++++---- .../virtual_network/passt/passt_function.py | 20 ++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/libvirt/tests/cfg/virtual_network/passt/passt_function.cfg b/libvirt/tests/cfg/virtual_network/passt/passt_function.cfg index e8103697ea..78468e5eb6 100644 --- a/libvirt/tests/cfg/virtual_network/passt/passt_function.cfg +++ b/libvirt/tests/cfg/virtual_network/passt/passt_function.cfg @@ -22,6 +22,9 @@ iface_attrs = {'model': 'virtio', 'acpi': {'index': '1'}, 'type_name': 'user', 'backend': {'type': 'passt'}, 'source': {'dev': host_iface}} vm_iface = eno1 vm_ping_outside = pass + s390-virtio: + iface_attrs = {'model': 'virtio', 'type_name': 'user', 'backend': {'type': 'passt'}, 'source': {'dev': host_iface}} + vm_iface = enc1 - ip_portfw: ipv6_prefix = 128 alias = {'name': 'ua-c87b89ff-b769-4abc-921f-30d42d7aec5b'} @@ -30,6 +33,8 @@ vm_iface = eno1 vm_ping_outside = pass vm_ping_host_public = pass + s390-virtio: + vm_iface = enc1 variants: - ip_addr: portForward_0 = {'attrs': {'proto': 'tcp'}, 'ranges': [{'start': '31339', 'to': '41339'}]} @@ -54,8 +59,8 @@ portForward_0 = {'attrs': {'proto': 'tcp', 'dev': host_iface}, 'ranges': [{'start': '31339', 'to': '41339'}]} portForward_1 = {'attrs': {'proto': 'udp', 'dev': host_iface}, 'ranges': [{'start': '2025'}]} portForwards = [${portForward_0}, ${portForward_1}] - tcp_port_list = [f'*%{vm_iface}:31339'] - udp_port_list = [f'0.0.0.0%{vm_iface}:2025', f'[::]%{vm_iface}:2025'] + tcp_port_list = [f'*%{host_iface}:31339'] + udp_port_list = [f'0.0.0.0%{host_iface}:2025', f'[::]%{host_iface}:2025'] conn_check_args_1 = ('TCP4', host_ip, 31339, 41339, True, None) conn_check_args_2 = ('TCP6', host_ip_v6, 31339, 41339, True, None) conn_check_args_3 = ('UDP4', host_ip, 2025, 2025, True, None) @@ -65,9 +70,11 @@ portForward_1 = {'attrs': {'proto': 'udp', 'address': host_ip, 'dev': host_iface}, 'ranges': [{'start': '2025'}]} portForward_2 = {'attrs': {'proto': 'tcp', 'address': host_ip_v6, 'dev': host_iface}, 'ranges': [{'start': '51339'}]} portForwards = [${portForward_0}, ${portForward_1}, ${portForward_2}] - tcp_port_list = [f'{host_ip}%{vm_iface}:31339', f'[{host_ip_v6}]%{vm_iface}:51339'] - udp_port_list = [f'{host_ip}%{vm_iface}:2025'] + tcp_port_list = [f'{host_ip}%{host_iface}:31339', f'[{host_ip_v6}]%{host_iface}:51339'] + udp_port_list = [f'{host_ip}%{host_iface}:2025'] conn_check_args_1 = ('TCP4', host_ip, 31339, 41339, True, None) conn_check_args_2 = ('UDP4', host_ip, 2025, 2025, True, None) conn_check_args_3 = ('TCP6', host_ip_v6, 51339, 51339, True, None) iface_attrs = {'model': 'virtio', 'acpi': {'index': '1'}, 'ips': ${ips}, 'backend': ${backend}, 'source': {'dev': host_iface}, 'alias': ${alias}, 'type_name': 'user', 'portForwards': ${portForwards}} + s390-virtio: + iface_attrs = {'model': 'virtio', 'ips': ${ips}, 'backend': ${backend}, 'source': {'dev': host_iface}, 'alias': ${alias}, 'type_name': 'user', 'portForwards': ${portForwards}} diff --git a/libvirt/tests/src/virtual_network/passt/passt_function.py b/libvirt/tests/src/virtual_network/passt/passt_function.py index b9d65d2535..ef57ffc606 100644 --- a/libvirt/tests/src/virtual_network/passt/passt_function.py +++ b/libvirt/tests/src/virtual_network/passt/passt_function.py @@ -52,17 +52,17 @@ def run(test, params, env): test_passwd) host_session.close() - host_ip = utils_net.get_host_ip_address(ip_ver='ipv4') - params['host_ip_v6'] = host_ip_v6 = utils_net.get_host_ip_address( - ip_ver='ipv6') + host_iface = params.get('host_iface') + host_iface = host_iface if host_iface else utils_net.get_net_if( + state="UP")[0] + host_ip = utils_net.get_ip_address_by_interface(host_iface, ip_ver='ipv4') + host_ip_v6 = utils_net.get_ip_address_by_interface(host_iface, ip_ver='ipv6') + params['host_ip_v6'] = host_ip_v6 params['socket_dir'] = socket_dir = eval(params.get('socket_dir')) params['proc_checks'] = proc_checks = eval(params.get('proc_checks', '{}')) vm_iface = params.get('vm_iface', 'eno1') mtu = params.get('mtu') outside_ip = params.get('outside_ip') - host_iface = params.get('host_iface') - host_iface = host_iface if host_iface else utils_net.get_net_if( - state="UP")[0] log_file = f'/run/user/{user_id}/passt.log' iface_attrs = eval(params.get('iface_attrs')) iface_attrs['backend']['logFile'] = log_file @@ -97,7 +97,7 @@ def run(test, params, env): test.fail(f'Logfile of passt "{log_file}" not created') session = vm.wait_for_serial_login(timeout=60) - passt.check_vm_ip(iface_attrs, session, host_iface) + passt.check_vm_ip(iface_attrs, session, host_iface, vm_iface) passt.check_vm_mtu(session, vm_iface, mtu) passt.check_default_gw(session) passt.check_nameserver(session) @@ -111,10 +111,12 @@ def run(test, params, env): firewalld.stop() LOG.debug(f'Status of firewalld: {firewalld.status()}') - passt.check_connection(vm, vm_iface, ['TCP4', 'TCP6', 'UDP4', 'UDP6']) + passt.check_connection(vm, vm_iface, + ['TCP4', 'TCP6', 'UDP4', 'UDP6'], + host_iface) if 'portForwards' in iface_attrs: - passt.check_portforward(vm, host_ip, params) + passt.check_portforward(vm, host_ip, params, host_iface) vm_sess = vm.wait_for_serial_login(timeout=60) vm_sess.cmd('systemctl start firewalld')