diff --git a/libvirt/tests/cfg/virtio/virtio_page_per_vq.cfg b/libvirt/tests/cfg/virtio/virtio_page_per_vq.cfg index 44a6a7c12b..98a7c30804 100644 --- a/libvirt/tests/cfg/virtio/virtio_page_per_vq.cfg +++ b/libvirt/tests/cfg/virtio/virtio_page_per_vq.cfg @@ -41,7 +41,7 @@ - mouse: - tablet: - passthrough: - device_dict = {**${device_dict}, 'source_evdev': '/dev/input/event1'} + device_dict = {**${device_dict}, 'source_evdev': '%s'} - video: only default_start device_dict = {'model_type': 'virtio', **${driver_dict}, 'model_heads': '1'} diff --git a/libvirt/tests/src/virtio/virtio_page_per_vq.py b/libvirt/tests/src/virtio/virtio_page_per_vq.py index f39435fde9..0e29545a3e 100644 --- a/libvirt/tests/src/virtio/virtio_page_per_vq.py +++ b/libvirt/tests/src/virtio/virtio_page_per_vq.py @@ -1,6 +1,8 @@ import os import platform +from avocado.utils import process + from virttest import libvirt_version from virttest import utils_net from virttest import virsh @@ -17,6 +19,24 @@ from virttest.utils_test import libvirt +def get_input_event_file(test): + """ + Get the input event file on the host + + :return: str, the last file path if exists, otherwise skip the test + """ + ret = process.run("ls /dev/input/event*", + shell=True, + verbose=True, + ignore_status=True) + if ret.exit_status != 0: + if ret.stderr_text.count("No such file or directory"): + test.cancel(ret.stderr_text) + else: + test.fail(ret.stderr_text) + return ret.stdout_text.splitlines[-1] + + def run(test, params, env): """ Start guest with virtio page_per_vq attribute - various virtio devices @@ -55,6 +75,8 @@ def prepare_test(vmxml): device_dict['source']['attrs']['file'] = disk_image_path if device_type == "input": device_xml = eval(device_obj)(input_type) + if input_type == "passthrough": + device_dict['source_evdev'] = get_input_event_file(test) else: device_xml = eval(device_obj)() device_xml.setup_attrs(**device_dict)