diff --git a/qemu/tests/cfg/virtio_fs_multi_vms.cfg b/qemu/tests/cfg/virtio_fs_multi_vms.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8caaf70480a31ef9f5f064011d531dde64c19029 --- /dev/null +++ b/qemu/tests/cfg/virtio_fs_multi_vms.cfg @@ -0,0 +1,68 @@ +- virtio_fs_multi_vms: + only Linux + no s390x + no RHEL.6 RHEL.7 RHEL.8.0 RHEL.8.1 + no Host_RHEL.m6 Host_RHEL.m7 Host_RHEL.m8.u0 Host_RHEL.m8.u1 + type = virtio_fs_multi_vms + required_qemu = [4.2.0,) + kill_vm = yes + start_vm = yes + mem = 4096 + mem_devs = mem1 + backend_mem1 = memory-backend-file + size_mem1 = 4G + use_mem_mem1 = no + share_mem = yes + io_timeout = 600 + vms = 'vm1 vm2 vm3' + clone_master = yes + master_images_clone = image1 + remove_image_image1 = yes + cmd_dd = 'dd if=/dev/urandom of=%s bs=1M count=2048 oflag=direct' + cmd_md5 = 'md5sum %s' + fs_source_type = mount + fs_driver = virtio-fs + fs_driver_props = {"queue-size": 1024} + force_create_fs_source = yes + remove_fs_source = yes + mem-path_mem1_vm1 = /dev/shm + mem-path_mem1_vm2 = /dev/shn + mem-path_mem1_vm3 = /dev/sho + guest_numa_nodes_vm1 = shm0 + guest_numa_nodes_vm2 = shn0 + guest_numa_nodes_vm3 = sho0 + numa_memdev_shm0 = mem-mem1 + numa_memdev_shn0 = mem-mem1 + numa_memdev_sho0 = mem-mem1 + numa_nodeid_shm0 = 0 + numa_nodeid_shn0 = 0 + numa_nodeid_sho0 = 0 + variants: + - with_multi_fs_sources: + filesystems_vm1 = fs1 + filesystems_vm2 = fs2 + filesystems_vm3 = fs3 + fs_target_fs1_vm1 = myfs1 + fs_target_fs2_vm2 = myfs2 + fs_target_fs3_vm3 = myfs3 + fs_source_dir_fs1_vm1 = '/tmp/virtio_fs1_test' + fs_source_dir_fs2_vm2 = '/tmp/virtio_fs2_test' + fs_source_dir_fs3_vm3 = '/tmp/virtio_fs3_test' + fs_dest_fs1_vm1 = '/mnt/${fs_target_fs1_vm1}' + fs_dest_fs2_vm2 = '/mnt/${fs_target_fs2_vm2}' + fs_dest_fs3_vm3 = '/mnt/${fs_target_fs3_vm3}' + - share_fs_source: + fs_name_list = 'fs0 fs0 fs0' + shared_fs_source_dir = '/tmp/virtio_fs_test' + filesystems_vm1 = fs0 + filesystems_vm2 = fs0 + filesystems_vm3 = fs0 + fs_target_fs0_vm1 = myfs1 + fs_target_fs0_vm2 = myfs2 + fs_target_fs0_vm3 = myfs3 + fs_source_dir_fs0_vm1 = ${shared_fs_source_dir} + fs_source_dir_fs0_vm2 = ${shared_fs_source_dir} + fs_source_dir_fs0_vm3 = ${shared_fs_source_dir} + fs_dest_fs0_vm1 = '/mnt/${fs_target_fs0_vm1}' + fs_dest_fs0_vm2 = '/mnt/${fs_target_fs0_vm2}' + fs_dest_fs0_vm3 = '/mnt/${fs_target_fs0_vm3}' diff --git a/qemu/tests/virtio_fs_multi_vms.py b/qemu/tests/virtio_fs_multi_vms.py new file mode 100644 index 0000000000000000000000000000000000000000..64fd1e8e1972e7bfd30c9e3f7bead6120e8e8112 --- /dev/null +++ b/qemu/tests/virtio_fs_multi_vms.py @@ -0,0 +1,85 @@ +import logging +import os + +from virttest import error_context +from virttest import utils_disk +from virttest import utils_misc + + +@error_context.context_aware +def run(test, params, env): + """ + Test to virtio-fs with the multiple VMs and virtiofs daemons. + Steps: + 1. Create shared directories on the host. + 2. Run virtiofs daemons on the host. + 3. Boot guests on the host with virtiofs options. + 4. Log into guest then mount the virtiofs targets. + 5. Generate files on the mount points inside guests. + 6. Compare the md5 among guests if multiple virtiofs + daemons share the source. + + :param test: QEMU test object. + :param params: Dictionary with the test parameters. + :param env: Dictionary with test environment. + """ + cmd_dd = params.get('cmd_dd') + cmd_md5 = params.get('cmd_md5') + io_timeout = params.get_numeric('io_timeout') + shared_fs_source_dir = params.get('shared_fs_source_dir') + + sessions = [] + vms = env.get_all_vms() + for vm in vms: + vm.verify_alive() + sessions.append(vm.wait_for_login()) + + mapping = {} + for vm, session in zip(params.objects('vms'), sessions): + vm_params = params.object_params(vm) + mapping[vm] = {'session': session, 'filesystems': []} + for fs in vm_params.objects('filesystems'): + fs_params = vm_params.object_params(fs) + fs_target = fs_params.get("fs_target") + fs_dest = fs_params.get("fs_dest") + guest_data = os.path.join(fs_dest, 'fs_test') + mapping[vm]['filesystems'].append({'fs_target': fs_target, + 'fs_dest': fs_dest, + 'guest_data': guest_data}) + + error_context.context( + "%s: Create a destination directory %s inside guest." % + (vm, fs_dest), logging.info) + utils_misc.make_dirs(fs_dest, session) + + error_context.context( + "%s: Mount the virtiofs target %s to %s inside guest." % + (vm, fs_target, fs_dest), logging.info) + utils_disk.mount(fs_target, fs_dest, 'virtiofs', session=session) + if cmd_dd: + logging.info("Creating file under %s inside guest." % fs_dest) + session.cmd(cmd_dd % guest_data, io_timeout) + if shared_fs_source_dir: + continue + error_context.context("%s: Umount the viriofs target %s." % + (vm, fs_target), logging.info) + utils_disk.umount(fs_target, fs_dest, 'virtiofs', session=session) + + if shared_fs_source_dir: + error_context.context("Compare the md5 among VMs.", logging.info) + md5_set = set() + for vm, info in mapping.items(): + session = info['session'] + for fs in info['filesystems']: + shared_data = fs['guest_data'] + error_context.context("%s: Get the md5 of %s." % + (vm, shared_data), logging.info) + val = session.cmd(cmd_md5 % shared_data).strip().split()[0] + logging.info(val) + md5_set.add(val) + error_context.context("%s: Umount the viriofs target %s." % + (vm, fs['fs_target']), logging.info) + utils_disk.umount(fs['fs_target'], fs['fs_dest'], + 'virtiofs', session=session) + if len(md5_set) != 1: + test.fail('The md5 values are different among VMs.')