Skip to content

Commit

Permalink
virtio_page_per_vq: enhance input event file
Browse files Browse the repository at this point in the history
Regarding /dev/input/event* files, there might be some different
situation.
For example,
- No event file exsit at all
- Only /dev/input/event0 exists
- Only /dev/input/event1 exists
- Both /dev/input/event0 and /dev/input/event1 exists
- and more ...

So this patch is intending to support above situations instead of
hardcoding with event1.

Signed-off-by: Dan Zheng <[email protected]>
  • Loading branch information
dzhengfy committed Sep 6, 2024
1 parent 03ea5b7 commit 1ca036c
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/event1'}
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 @@ -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)
Expand Down

0 comments on commit 1ca036c

Please sign in to comment.