From ea3dd10f1bdd7c52850f61a33da53ca9f29a33e2 Mon Sep 17 00:00:00 2001 From: nanli Date: Mon, 3 Jul 2023 15:46:59 +0800 Subject: [PATCH] add case for restart service after config shared memory VIRT-298224: Verify the libvirt can identify shared memory after restart libvirtd/virtqemud Signed-off-by: nanli --- .../cfg/virtual_device/filesystem_device.cfg | 8 ++++ .../src/virtual_device/filesystem_device.py | 37 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/libvirt/tests/cfg/virtual_device/filesystem_device.cfg b/libvirt/tests/cfg/virtual_device/filesystem_device.cfg index 22ab89a0c46..6d0a24f4e1e 100644 --- a/libvirt/tests/cfg/virtual_device/filesystem_device.cfg +++ b/libvirt/tests/cfg/virtual_device/filesystem_device.cfg @@ -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" diff --git a/libvirt/tests/src/virtual_device/filesystem_device.py b/libvirt/tests/src/virtual_device/filesystem_device.py index 7f621f8b7ae..8a6c0db9171 100644 --- a/libvirt/tests/src/virtual_device/filesystem_device.py +++ b/libvirt/tests/src/virtual_device/filesystem_device.py @@ -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 @@ -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") @@ -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 = [] @@ -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}