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 3, 2023
1 parent 9eccd75 commit 36d29b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 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,13 @@
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:
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
26 changes: 26 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 @@ -222,6 +223,11 @@ 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)
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')

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

try:
if setup_mem:
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)
return
# Define filesystem device xml
for index in range(fs_num):
driver = {'type': driver_type, 'queue': queue_size}
Expand Down

0 comments on commit 36d29b7

Please sign in to comment.