mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 20:53:46 +00:00
config_tools: update the text format of backend_device_file
Currently, the “backend_device_file” entry is a text combination of the elements `//device-classes/inputs/input/name` and `//device-classes/inputs/input/phys`. The format <name>:<phys> is shown in UI and the generated launch scripts. However, we find ":" in some device physical path in adl-s-crb platform, this will result in script can't correctly distinguish <name> and <phys> by a colon. And we are not sure if colon will be found in the name variable in the future. So this patch updates the text format of backend_device_file to "Device name: xxx, Device physical path: xxx" And the new text format will be shown in the UI and the generated launch script. Tracked-On: #6690 Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
This commit is contained in:
parent
06b942f5eb
commit
cceb169347
@ -275,7 +275,7 @@ def generate_for_one_vm(board_etree, hv_scenario_etree, vm_scenario_etree, vm_id
|
||||
backend_device_file = eval_xpath(virtio_input_etree, "./backend_device_file[text() != '']/text()")
|
||||
unique_identifier = eval_xpath(virtio_input_etree, "./id[text() != '']/text()")
|
||||
if backend_device_file is not None and unique_identifier is not None:
|
||||
script.add_virtual_device("virtio-input", options=f"{backend_device_file},id={unique_identifier}")
|
||||
script.add_virtual_device("virtio-input", options=f"{backend_device_file},id:{unique_identifier}")
|
||||
elif backend_device_file is not None:
|
||||
script.add_virtual_device("virtio-input", options=backend_device_file)
|
||||
|
||||
|
@ -134,35 +134,39 @@ function add_virtual_device() {
|
||||
fi
|
||||
|
||||
if [ "${kind}" = "virtio-input" ]; then
|
||||
if [[ "${options}" =~ id=([a-zA-Z0-9_\-]*) ]]; then
|
||||
options=$*
|
||||
if [[ "${options}" =~ id:([a-zA-Z0-9_\-]*) ]]; then
|
||||
unique_identifier="${BASH_REMATCH[1]}"
|
||||
options=${options/",id=${unique_identifier}"/''}
|
||||
options=${options/",id:${unique_identifier}"/''}
|
||||
fi
|
||||
|
||||
local IFS=$'\n'
|
||||
device_name_path=$(grep -r "${options%:*}" /sys/class/input/event*/device/name)
|
||||
if [ -n "${device_name_path}" ]; then
|
||||
for device_path in ${device_name_path}; do
|
||||
if [ "${options%:*}" = "${options#*:}" ]; then
|
||||
options="/dev/input/${device_path:17:6}"
|
||||
break
|
||||
else
|
||||
phys_path=$(grep -r "${options#*:}" /sys/class/input/event*/device/phys)
|
||||
if [[ "${options}" =~ (Device name: )(.*),( Device physical path: )(.*) ]]; then
|
||||
device_name="${BASH_REMATCH[2]}"
|
||||
phys_name="${BASH_REMATCH[4]}"
|
||||
local IFS=$'\n'
|
||||
device_name_paths=$(grep -r "${device_name}" /sys/class/input/event*/device/name)
|
||||
phys_paths=$(grep -r "${phys_name}" /sys/class/input/event*/device/phys)
|
||||
fi
|
||||
|
||||
if [ -n "${device_name_paths}" ] && [ -n "${phys_paths}" ]; then
|
||||
for device_path in ${device_name_paths}; do
|
||||
for phys_path in ${phys_paths}; do
|
||||
if [ "${device_path%/device*}" = "${phys_path%/device*}" ]; then
|
||||
options="/dev/input/${device_path:17:6}"
|
||||
break
|
||||
event_path=${device_path}
|
||||
if [[ ${event_path} =~ event([0-9]+) ]]; then
|
||||
event_num="${BASH_REMATCH[1]}"
|
||||
options="/dev/input/event${event_num}"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
else
|
||||
echo "${options%:*} device path is not found in the service vm." >> /dev/stderr
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ${options} =~ event([0-9]+) ]]; then
|
||||
echo "${options} input device path is available in the service vm." >> /dev/stderr
|
||||
else
|
||||
echo "${options#*:} input phys path is not found in the service vm." >> /dev/stderr
|
||||
echo "${options} input device path is not found in the service vm." >> /dev/stderr
|
||||
return
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user