config_tools: update virtio console to support multiple console sockets

this patch updates virtio console in schema and launch script generation
logic to support multiple console sockets. And check the schema and launch
script, now we support multiple console/input/network/block, multiple gpu is
not supported in schema.

Tracked-On: #6690
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Kunhui-Li 2022-04-22 13:47:00 +08:00 committed by acrnsi-robot
parent e63a17a7c8
commit 68f88a4bc9
2 changed files with 8 additions and 7 deletions

View File

@ -262,22 +262,23 @@ def generate_for_one_vm(board_etree, hv_scenario_etree, vm_scenario_etree, vm_id
elif backend_device_file is not None:
script.add_virtual_device("virtio-input", options=backend_device_file)
for backend_type in eval_xpath_all(vm_scenario_etree, ".//virtio_devices/console/backend_type[text() != '']/text()"):
for virtio_console_etree in eval_xpath_all(vm_scenario_etree, ".//virtio_devices/console"):
preceding_mask = ""
use_type = eval_xpath(vm_scenario_etree, ".//virtio_devices/console/use_type/text()")
use_type = eval_xpath(virtio_console_etree, "./use_type/text()")
backend_type = eval_xpath(virtio_console_etree, "./backend_type/text()")
if use_type == "Virtio console":
preceding_mask = "@"
if backend_type == "file":
output_file_path = eval_xpath(vm_scenario_etree, ".//virtio_devices/console/output_file_path/text()")
output_file_path = eval_xpath(virtio_console_etree, "./output_file_path/text()")
script.add_virtual_device("virtio-console", options=f"{preceding_mask}file:file_port={output_file_path}")
elif backend_type == "tty":
tty_file_path = eval_xpath(vm_scenario_etree, ".//virtio_devices/console/tty_device_path/text()")
tty_file_path = eval_xpath(virtio_console_etree, "./tty_device_path/text()")
script.add_virtual_device("virtio-console", options=f"{preceding_mask}tty:tty_port={tty_file_path}")
elif backend_type == "sock server" or backend_type == "sock client":
sock_file_path = eval_xpath(vm_scenario_etree, ".//virtio_devices/console/sock_file_path/text()")
sock_file_path = eval_xpath(virtio_console_etree, "./sock_file_path/text()")
script.add_virtual_device("virtio-console", options=f"socket:{os.path.basename(sock_file_path).split('.')[0]}={sock_file_path}:{backend_type.replace('sock ', '')}")
else:
elif backend_type == "pty" or backend_type == "stdio":
script.add_virtual_device("virtio-console", options=f"{preceding_mask}{backend_type}:{backend_type}_port")
for interface_name in eval_xpath_all(vm_scenario_etree, ".//virtio_devices/network/interface_name[text() != '']/text()"):

View File

@ -443,7 +443,7 @@ argument and memory.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="console" type="VirtioConsoleConfiguration" minOccurs="0">
<xs:element name="console" type="VirtioConsoleConfiguration" minOccurs="0" maxOccurs="unbounded">
<xs:annotation acrn:title="Virtio console device" acrn:views="basic">
<xs:documentation>Virtio console device for data input and output.
The virtio console BE driver copies data from the frontend's transmitting virtqueue when it receives a kick on virtqueue (implemented as a vmexit).