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

virttools: add type and first test #3865

Closed
wants to merge 105 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
970e56e
This commit is a fix for remote_with_unix.negative_testing.socket_wit…
kamilvarga Nov 3, 2021
021aea7
virttools: add type and first test
smitterl Oct 8, 2021
e7050ec
vDPA: Add a test to check hotplug/unplug vdpa type interface
Yingshun Oct 26, 2021
0324a9b
snapshot: set timeout for snapshot_create_as
liuyd96 Nov 9, 2021
f34b363
virsh_cpu_baseline: new case --migratable
dzhengfy Nov 8, 2021
5903c1e
virsh_event: Stopped failed event if kill qemu
yanqzhan Nov 9, 2021
dae2cf1
Revert "v2v: fix the failed cases with error 'Not find cirrus device'"
xiaodwan Nov 10, 2021
44a1a13
Merge pull request #3858 from liuyd96/fix_snapshot
Yingshun Nov 11, 2021
4e9bd56
Merge pull request #3862 from autotest/revert-3860-func86-debug-1
xiaodwan Nov 11, 2021
255e571
Add testcase for all the sub-daemons starting in foreground
yafu-1 Nov 1, 2021
b35bad6
Merge pull request #3847 from yafu-1/modular_daemon_function
kylazhang Nov 11, 2021
becddb0
Merge pull request #3852 from kamilvarga/fix_remote_unix_negative_pol…
chunfuwen Nov 12, 2021
2722840
iface_network: direct br iface with vlan
yanqzhan Nov 12, 2021
19b8491
virsh_domjobinfo: test --keep-completed option
yanqzhan Nov 10, 2021
387fbc0
net_update: add ip-dhcp-range on nonexist index
yanqzhan Nov 12, 2021
6111ce3
crypto_nodedev_create_destroy: restore matrix device
smitterl Nov 15, 2021
29a9a68
cpu_stats: Correct the cpu time checking
Yingshun Nov 16, 2021
b3bc95d
v2v: add a new case for datetime format settings in windows
xiaodwan Nov 16, 2021
887bbf0
live_migration: Add case about migration_port_min
cliping Sep 6, 2021
ed82dcf
Merge pull request #3838 from Yingshun/vdpa_hotplug
dzhengfy Nov 16, 2021
bb99e0f
Merge pull request #3759 from cliping/port
dzhengfy Nov 16, 2021
81bea37
Merge pull request #3857 from dzhengfy/case_migratable
Yingshun Nov 16, 2021
74523a7
Determine image path
smitterl Nov 16, 2021
add5a57
Modify the expect ownership of '/var/cache/libvirt/qemu' after libvir…
yafu-1 Nov 17, 2021
686f216
Merge pull request #3874 from yafu-1/dac_check
Yingshun Nov 17, 2021
f9e6ca9
migrate_service_control: Add 3 cases about kill service
cliping Sep 7, 2021
4983761
Modify to start 'virtnetworkd' to do the test in the modular daemon mode
yafu-1 Nov 17, 2021
185b39f
Merge pull request #3873 from yafu-1/networkd-iptables
Yingshun Nov 18, 2021
7fc3c67
Fix gluster disk device detach event issue
chunfuwen Oct 20, 2021
e52b564
Fix change media matrix event not received issue
chunfuwen Nov 18, 2021
bb9f1f2
Merge pull request #3764 from cliping/kill
Yingshun Nov 18, 2021
00322ce
virsh_qemu_monitor_command: Update error message
cliping Nov 18, 2021
d16e446
Merge pull request #3831 from chunfuwen/fix_gluster_not_receive_event…
dzhengfy Nov 19, 2021
68f6db2
Merge pull request #3878 from cliping/fix
chunfuwen Nov 19, 2021
d3c114c
virsh_blockcopy.py: remove libvirtd status check to adapt to the spli…
meinaLi Nov 19, 2021
2b67f9d
vDPA: Add a case to test domain lifecycle
Yingshun Oct 29, 2021
41bfcd0
Merge pull request #3867 from meinaLi/block
Yingshun Nov 19, 2021
1c5e682
Merge pull request #3845 from Yingshun/vdpa_dom_lc
dzhengfy Nov 19, 2021
4dfa358
virsh_snapshot_disk: Fix No more available PCI slot
liuyd96 Nov 22, 2021
b3b8484
numa_numanode_cpu_info: Run bash cmd in subshell
liuyd96 Nov 22, 2021
4990fe5
numa_numanode_cpu_info: Add cleanup for node page set
liuyd96 Nov 22, 2021
ea8210b
Merge pull request #3880 from liuyd96/fix_numa
Yingshun Nov 23, 2021
a01310b
Revert ""v2v: modify dir location for -o json""
xiaodwan Nov 22, 2021
089c29d
v2v: cleanup the os_directory content at the end
xiaodwan Nov 23, 2021
460eed7
Merge pull request #3872 from xiaodwan/v2v_add_case_for_special_date_…
xiaodwan Nov 23, 2021
fa92868
Merge pull request #3870 from smitterl/ap_improvement
dzhengfy Nov 23, 2021
db2408c
Merge pull request #3882 from xiaodwan/v2v_revert_commit_11e1f0d703
xiaodwan Nov 23, 2021
7a584b8
nwfilter_binding_dumpxml: Fix No more available PCI slot
liuyd96 Nov 23, 2021
e460717
Merge pull request #3877 from chunfuwen/fix_change_media_matrix_event…
dzhengfy Nov 23, 2021
f97ae5b
Merge pull request #3871 from Yingshun/cpu_time
dzhengfy Nov 23, 2021
ffe0aa5
Merge pull request #3879 from liuyd96/fix_snapshot
Yingshun Nov 23, 2021
abe110b
live_migration: Add case about abort migration
cliping Nov 23, 2021
c26c340
migrate_vm: Fix variable 'uri' reference issue
cliping Nov 23, 2021
47cefca
virsh_vol_create.py: fix secret issue in storage volume with acl test
meinaLi Nov 24, 2021
0a76628
Merge pull request #3887 from meinaLi/secret
Yingshun Nov 24, 2021
974406e
Merge pull request #3886 from cliping/fix-uri
Yingshun Nov 25, 2021
10f3107
Merge pull request #3861 from yanqzhan/stop_fail_event
dzhengfy Nov 25, 2021
5c95e53
Merge pull request #3885 from cliping/domjobabort
Yingshun Nov 25, 2021
e997800
migrate_with_various_hostname: Add 3 cases about set hostname
cliping Nov 17, 2021
a71777d
numa_memory_spread: Fix session exception handling
liuyd96 Nov 25, 2021
1f0abe3
remote_access:Add new test for TLS with multiple certs
kamilvarga Nov 22, 2021
f0f5358
virsh_boot.cfg: update error info of negative case
meinaLi Nov 26, 2021
246d363
Merge pull request #3869 from yanqzhan/netupdate_dhcp_nonexist_index
dzhengfy Nov 26, 2021
e7569ef
Merge pull request #3875 from cliping/hostname
dzhengfy Nov 26, 2021
0750e84
Merge pull request #3868 from yanqzhan/direct_br_vlan
dzhengfy Nov 26, 2021
f0cd3fa
Merge pull request #3883 from xiaodwan/v2v_cleanup_os_directory
xiaodwan Nov 29, 2021
161216e
tpm_device: Expose error when test suite failed
yanqzhan Nov 23, 2021
9660893
Fix up inspekt check failure
Yingshun Nov 29, 2021
419d615
Merge pull request #3894 from Yingshun/ci_err
dzhengfy Nov 29, 2021
ffc40cc
Merge pull request #3890 from meinaLi/bios
dzhengfy Nov 29, 2021
88acdf3
Merge pull request #3866 from yanqzhan/domjobinfo_keep_complete
dzhengfy Nov 29, 2021
d704663
Merge pull request #3884 from yanqzhan/vtpm_testsuite_showerror
dzhengfy Nov 29, 2021
ace58b8
Merge pull request #3881 from kamilvarga/remote_tls_multiple_certs
dzhengfy Nov 29, 2021
45158af
Merge pull request #3889 from liuyd96/fix_numa
Yingshun Nov 30, 2021
c72257f
virsh_pool.py: update to restart virtstoraged service
meinaLi Nov 30, 2021
b54064a
Start guest after reset guest PCI
liuyd96 Nov 30, 2021
18d3b51
Merge pull request #3896 from meinaLi/pool
Yingshun Nov 30, 2021
c14fbaa
Merge pull request #3897 from liuyd96/fix_snapshot
Yingshun Nov 30, 2021
d806e04
Clean snap file and raise unclean xml error if precious case not clea…
nanli1 Nov 29, 2021
f32eb56
controller_functional: Fix model for ppc
dzhengfy Dec 1, 2021
1825bde
migrate_vm: Add '-F' option to qemu-img create command
Yingshun Dec 2, 2021
1519b4a
Merge pull request #3901 from Yingshun/mig_vm_bs
Yingshun Dec 2, 2021
25cfab0
Merge pull request #3899 from dzhengfy/fix_controller_ppc
Yingshun Dec 2, 2021
10a69ee
Adjust the order to set hostname
cliping Dec 2, 2021
7a5e6fe
virsh_event: metadata-change event output fix
yanqzhan Dec 2, 2021
0032196
Add attaching ccw address devices test cases
chunfuwen Sep 27, 2021
ce8979a
Merge pull request #3905 from yanqzhan/metadata_event_fix
chunfuwen Dec 2, 2021
7900378
Merge pull request #3903 from cliping/fix-hostname
Yingshun Dec 2, 2021
d2c8a9c
Merge pull request #3895 from nanli1/clean_snapfile_and_raise_unclean…
Yingshun Dec 2, 2021
2924754
Add cmd status check for blockcopy
kylazhang Dec 3, 2021
5e57445
virtual_disks_dasd: add test case
smitterl Dec 1, 2021
72f3f15
migrate_option_mix: Fix variable 'vm_xml_backup' reference issue
cliping Dec 6, 2021
8b0745b
Merge pull request #3809 from chunfuwen/add_ccw_addr_attach_cases
chunfuwen Dec 7, 2021
3809199
Merge pull request #3900 from smitterl/dasd_virtio_blk
dzhengfy Dec 7, 2021
c976bf7
Merge pull request #3907 from kylazhang/blockcopy_update
Yingshun Dec 7, 2021
f6a4499
Merge pull request #3909 from cliping/fix-unboundlocalerror
Yingshun Dec 7, 2021
c9fb1d0
virt_install: test with fix mdev nodedev and manual log inspection
smitterl Dec 7, 2021
1ffc580
virttools: add passing hostdev mdev test
smitterl Dec 7, 2021
d110b02
virttools: add type and first test
smitterl Oct 8, 2021
c79b09b
Determine image path
smitterl Nov 16, 2021
c3d2a33
virt_install: test with fix mdev nodedev and manual log inspection
smitterl Dec 7, 2021
df8e216
virttools: add passing hostdev mdev test
smitterl Dec 7, 2021
ff68f17
Merge branch 'virt_tools' of https://github.com/smitterl/tp-libvirt i…
smitterl Dec 7, 2021
69b0509
virt-install: fix tear down
smitterl Dec 7, 2021
46c0077
spelling: fix some parameter docstrings and add exceptions to spellin…
smitterl Dec 7, 2021
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
Prev Previous commit
Next Next commit
vDPA: Add a test to check hotplug/unplug vdpa type interface
This PR adds:
RHEL-196261: hotplug/unplug vdpa type interface

Signed-off-by: Yingshun Cui <yicui@redhat.com>
  • Loading branch information
Yingshun committed Nov 8, 2021
commit e7050ecb20a3541f0fc67244217751da8489e70b
14 changes: 14 additions & 0 deletions libvirt/tests/cfg/virtual_interface/interface_hotplug.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- interface_hotplug:
type = interface_hotplug
start_vm = no
repeat_times = 1

variants dev_type:
- vdpa:
only x86_64
func_supported_since_libvirt_ver = (7, 3, 0)
func_supported_since_qemu_kvm_ver = (6, 0, 0)
iface_dict = {"source": {'dev':'/dev/vhost-vdpa-0'}}
variants test_target:
- simulator:
- mellanox:
104 changes: 104 additions & 0 deletions libvirt/tests/src/virtual_interface/interface_hotplug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import logging

from virttest import libvirt_version
from virttest import utils_misc
from virttest import utils_vdpa
from virttest.libvirt_xml import vm_xml
from virttest.staging import service
from virttest.utils_libvirt import libvirt_vmxml

from provider.interface import interface_base
from provider.interface import vdpa_base


def run(test, params, env):
"""
Test Hotplug/unplug interface device(s)
"""

def setup_default():
"""
Default setup
"""
logging.debug("Remove VM's interface devices.")
libvirt_vmxml.remove_vm_devices_by_type(vm, 'interface')

def teardown_default():
"""
Default cleanup
"""
pass

def setup_vdpa():
"""
Setup vDPA environment
"""
setup_default()
test_env_obj = None
if test_target == "simulator":
test_env_obj = utils_vdpa.VDPASimulatorTest()
else:
pf_pci = utils_vdpa.get_vdpa_pci()
test_env_obj = utils_vdpa.VDPAOvsTest(pf_pci)
test_env_obj.setup()
return test_env_obj

def teardown_vdpa():
"""
Cleanup vDPA environment
"""
if test_target != "simulator":
service.Factory.create_service("NetworkManager").restart()
if test_obj:
test_obj.cleanup()

def test_vdpa():
"""
Hotplug/unplug vDPA type interface

1) Start the vm, hotplug the interface
2) Login to the vm and check the network function
3) Hot-unplug the interface
"""
vm.start()
vm_session = vm.wait_for_serial_login(timeout=240)

br_name = None
if test_target == "mellanox":
br_name = test_obj.br_name
for _i in range(eval(params.get('repeat_times', '1'))):
interface_base.attach_iface_device(vm_name, dev_type, params)
vdpa_base.check_vdpa_conn(vm_session, test_target, br_name)
interface_base.detach_iface_device(vm_name, dev_type)

libvirt_version.is_libvirt_feature_supported(params)
supported_qemu_ver = eval(params.get('func_supported_since_qemu_kvm_ver', '()'))
if supported_qemu_ver:
if not utils_misc.compare_qemu_version(*supported_qemu_ver, False):
test.cancel("Current qemu version doesn't support this test!")

# Variable assignment
test_target = params.get('test_target', '')
dev_type = params.get('dev_type', '')

vm_name = params.get('main_vm')
vm = env.get_vm(vm_name)

vmxml = vm_xml.VMXML.new_from_dumpxml(vm_name)
backup_vmxml = vmxml.copy()

run_test = eval("test_%s" % dev_type)
setup_test = eval("setup_%s" % dev_type) if "setup_%s" % dev_type in \
locals() else setup_default
teardown_test = eval("teardown_%s" % dev_type) if "teardown_%s" % \
dev_type in locals() else teardown_default

test_obj = None
try:
# Execute test
test_obj = setup_test()
run_test()

finally:
backup_vmxml.sync()
teardown_test()
74 changes: 74 additions & 0 deletions provider/interface/interface_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import logging
import time

from avocado.core import exceptions

from virttest import utils_net
from virttest import virsh
from virttest.libvirt_xml import vm_xml
from virttest.libvirt_xml.devices import interface
from virttest.utils_libvirt import libvirt_vmxml
from virttest.utils_test import libvirt


def create_iface(iface_type, iface_dict):
"""
Create Interface device

:param iface_type: String, interface type
:param iface_dict: Dict, attrs of Interface
:return: xml object of interface
"""
iface = interface.Interface(iface_type)
iface.setup_attrs(**iface_dict)

logging.debug("Interface XML: %s", iface)
return iface


def get_vm_iface(vm_session):
"""
Get VM's 1st interface

:param vm_session: An session to VM
:return: VM's first interface
"""
p_iface, _v_ifc = utils_net.get_remote_host_net_ifs(vm_session)
vm_iface = p_iface[:1:]
if not vm_iface:
raise exceptions.TestFail("Failed to get vm's iface!")
return vm_iface[0]


def attach_iface_device(vm_name, dev_type, params):
"""
Attach an interface to VM

:param vm_name: VM's name
:param dev_type: Interface device type
:param params: Dictionary with the test parameters
"""
iface_dict = eval(params.get('iface_dict', '{}'))
status_error = "yes" == params.get('status_error', 'no')

iface = create_iface(dev_type, iface_dict)
res = virsh.attach_device(vm_name, iface.xml, debug=True)
libvirt.check_exit_status(res, status_error)
libvirt_vmxml.check_guest_xml(vm_name, dev_type)
# FIXME: Sleep for 20 secs to make iface work properly
time.sleep(20)


def detach_iface_device(vm_name, dev_type):
"""
Detach an interface from VM

:param vm_name: VM's name
:param dev_type: Interface device type
"""
iface = interface.Interface(dev_type)
iface = vm_xml.VMXML.new_from_dumpxml(vm_name).devices.by_device_tag(
"interface")[0]
virsh.detach_device(vm_name, iface.xml, wait_for_event=True,
debug=True, ignore_status=False)
libvirt_vmxml.check_guest_xml(vm_name, dev_type, status_error=True)
90 changes: 90 additions & 0 deletions provider/interface/vdpa_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import logging
import re

from avocado.core import exceptions
from avocado.utils import process

from provider.interface import interface_base

from virttest import utils_test
from virttest import utils_misc
from virttest.staging import service


def config_vdpa_conn(vm_session, vm_iface, br_name,
br_ip_addr='100.100.100.100', cidr='24'):
"""
Config vdpa connection

:param vm_session: An session to VM
:param vm_iface: VM's interface
:param br_name: Bridge name
:param br_ip_addr: IP address of the bridge
:param cidr: CIDR
"""
vm_ip = re.sub('\d+$', '60', br_ip_addr)
service.Factory.create_service("NetworkManager").stop()

logging.debug("Config static ip %s for vm.", vm_ip)
cmd = ("nmcli con del {0}; nmcli con add type ethernet ifname {0} "
"con-name {0} ipv4.method manual ipv4.address {1}/{2}"
.format(vm_iface, vm_ip, cidr))
vm_session.cmd(cmd)
logging.debug("Set ip address of the bridge.")
cmd = ("ip addr add {0}/{1} dev {2}; sleep 5;ip link set {2} up"
.format(br_ip_addr, cidr, br_name))
process.run(cmd, shell=True)


def check_vdpa_network(vm_session, vm_iface, br_name,
ping_dest="100.100.100.100"):
"""
Check vdpa network connection

:param vm_session: An session to VM
:param vm_iface: VM's interface
:param br_name: Bridge name
:param ping_dest: The ip address to ping
"""
config_vdpa_conn(vm_session, vm_iface, br_name)

if not utils_misc.wait_for(lambda: not utils_test.ping(
ping_dest, count=3, timeout=5, output_func=logging.debug,
session=vm_session)[0], first=5, timeout=30):
raise exceptions.TestFail("Failed to ping %s." % ping_dest)


def check_rx_tx_packages(vm_session, vm_iface):
"""
Check rx and tx package

:param vm_session: An session to VM
:param vm_iface: VM's interface
"""
cmd = "ip -s -json link show %s" % vm_iface
status, stdout = vm_session.cmd_status_output(cmd)
if status or not stdout:
raise exceptions.TestFail("Failed to run cmd - {}, status - {}, "
"output - {}.".format(cmd, status, stdout))
ip_info = eval(stdout.strip())
logging.debug("VM iface's info: %s.", ip_info)

tx_info = ip_info[0]['stats64']['tx']['packets']
rx_info = ip_info[0]['stats64']['rx']['packets']
if rx_info != tx_info:
raise exceptions.TestFail("The value of rx and tx should be same.")


def check_vdpa_conn(vm_session, test_target, br_name=None):
"""
Check vDPA connection

:param vm_session: An session to VM
:param test_target: Test target env, eg, "mellanox" or "simulator"
:param br_name: Bridge name
"""
vm_iface = interface_base.get_vm_iface(vm_session)
if test_target == "mellanox":
check_vdpa_network(vm_session, vm_iface, br_name)
elif test_target == "simulator":
check_rx_tx_packages(vm_session, vm_iface)