Skip to content

Commit

Permalink
Merge pull request #5882 from dzhengfy/fix_input_device_unexist
Browse files Browse the repository at this point in the history
virtio_page_per_vq: enhance input event file
  • Loading branch information
dzhengfy authored Dec 3, 2024
2 parents eb340da + c0b2055 commit 05f452c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libvirt/tests/cfg/virtio/virtio_page_per_vq.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
- mouse:
- tablet:
- passthrough:
device_dict = {**${device_dict}, 'source_evdev': '/dev/input/event0'}
device_dict = {**${device_dict}, 'source_evdev': '%s'}
- video:
only default_start
device_dict = {'model_type': 'virtio', **${driver_dict}, 'model_heads': '1'}
Expand Down
22 changes: 22 additions & 0 deletions libvirt/tests/src/virtio/virtio_page_per_vq.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -56,6 +76,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)
Expand Down

0 comments on commit 05f452c

Please sign in to comment.