Skip to content

Commit

Permalink
add case for restart service after config shared memory
Browse files Browse the repository at this point in the history
    VIRT-298224: Verify the libvirt can identify shared memory after restart libvirtd/virtqemud

Signed-off-by: nanli <[email protected]>
  • Loading branch information
nanli1 committed Jul 11, 2023
1 parent 9eccd75 commit ea3dd10
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libvirt/tests/cfg/virtual_device/filesystem_device.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@
bug_url = "https://bugzilla.redhat.com/show_bug.cgi?id=1940276"
destroy_start = "yes"
stress_script = "#!/usr/bin/python3;import os;while True:; os.open("%s/moo", os.O_CREAT | os.O_RDWR); os.unlink("%s/moo");"
- restart_service:
func_supported_since_libvirt_ver = (8, 0, 0)
only file_backed
setup_mem = True
source_dir = "/var/tmp/mount_tag0"
dev_type = "filesystem"
vm_attrs = {'mb': {"source_type":"file", 'access_mode': 'shared'}}
fs_dict = {'accessmode':'passthrough', 'driver': {'type': 'virtiofs', 'queue':'512'}, 'source':{'dir': '${source_dir}'}, "target": {'dir': 'mount_tag0'}, 'binary': {'path': '/usr/libexec/virtiofsd', 'xattr': 'on','cache_mode':'none','lock_posix':'off','flock':'off'}}
- coldplug_coldunplug:
only xattr_on.flock_off.lock_posix_off.cache_mode_none..one_fs
coldplug = "yes"
Expand Down
37 changes: 37 additions & 0 deletions libvirt/tests/src/virtual_device/filesystem_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from virttest.utils_test import libvirt_device_utils
from virttest.utils_test import libvirt
from virttest.utils_libvirt import libvirt_pcicontr
from virttest.utils_libvirt import libvirt_vmxml


# Using as lower capital is not the best way to do, but this is just a
Expand Down Expand Up @@ -187,6 +188,37 @@ def check_filesystem_in_guest(vm, fs_dev):
test.fail("Mount virtiofs should failed after hotunplug device. %s" % output)
session.close()

def check_filesystem_hotplug_with_mem_setup():
"""
Check libvirt can not identify shared memory after restarting
virtqemud.
Bug 2078693, Version:8.8
"""
vm_attrs = eval(params.get('vm_attrs', '{}'))
fs_dict = eval(params.get('fs_dict', '{}'))
source_dir = params.get('source_dir')
dev_type = params.get('dev_type')

vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(
vm_names[int(guest_num) - 1])
vmxml.setup_attrs(**vm_attrs)
virsh.define(vmxml.xml, debug=True, ignore_status=False)

libvirtd = utils_libvirtd.Libvirtd()
libvirtd.restart()

vmxml = vm_xml.VMXML.new_from_dumpxml(vm_names[int(guest_num) - 1])
vmxml.remove_all_device_by_type(dev_type)
vmxml.sync()
vm = env.get_vm(vm_names[int(guest_num) - 1])
vm.start()
vm.wait_for_login(timeout=120)
os.mkdir(source_dir)

fs = libvirt_vmxml.create_vm_device_by_type(dev_type, fs_dict)
virsh.attach_device(vm_names[int(guest_num) - 1], fs.xml,
debug=True, ignore_status=False)

start_vm = params.get("start_vm", "no")
vm_names = params.get("vms", "avocado-vt-vm1").split()
cache_mode = params.get("cache_mode", "none")
Expand Down Expand Up @@ -222,6 +254,7 @@ def check_filesystem_in_guest(vm, fs_dev):
bug_url = params.get("bug_url", "")
script_content = params.get("stress_script", "")
stdio_handler_file = "file" == params.get("stdio_handler")
setup_mem = params.get("setup_mem", False)

fs_devs = []
vms = []
Expand All @@ -245,6 +278,10 @@ def check_filesystem_in_guest(vm, fs_dev):
test.cancel("Bug %s is not fixed on current build" % bug_url)

try:
if setup_mem:
libvirt_version.is_libvirt_feature_supported(params)
check_filesystem_hotplug_with_mem_setup()
return
# Define filesystem device xml
for index in range(fs_num):
driver = {'type': driver_type, 'queue': queue_size}
Expand Down

0 comments on commit ea3dd10

Please sign in to comment.