From 5554040dbb6cf5942af814575c37ebb9f2b2ee83 Mon Sep 17 00:00:00 2001 From: Kunhui-Li Date: Wed, 10 Aug 2022 11:31:24 +0800 Subject: [PATCH] config_tools: refine virtio gpu in launch script If display type is "Windows", the generated launch script will follow the below rule. "virtio-gpu,geometry=x++,geometry=x++" If display type is "Full screen", the generated launch script look like this. For example: "virtio-gpu,geometry=fullscreen:0,geometry=fullscreen:1" Tracked-On: #7970 Signed-off-by: Kunhui-Li Signed-off-by: Yang,Yu-chu Reviewed-by: Junjie Mao --- .../config_tools/launch_config/launch_cfg_gen.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/misc/config_tools/launch_config/launch_cfg_gen.py b/misc/config_tools/launch_config/launch_cfg_gen.py index 7c4668013..05ed0a396 100755 --- a/misc/config_tools/launch_config/launch_cfg_gen.py +++ b/misc/config_tools/launch_config/launch_cfg_gen.py @@ -373,9 +373,19 @@ def generate_for_one_vm(board_etree, hv_scenario_etree, vm_scenario_etree, vm_id script.add_virtual_device("virtio-blk", options=os.path.join(f"${{{var}}}", rootfs_img)) script.add_deinit_command(f"unmount_partition ${{{var}}}") - for virtio_gpu in eval_xpath_all(vm_scenario_etree, ".//virtio_devices/gpu[text() != '']/text()"): - if virtio_gpu is not None: - script.add_virtual_device("virtio-gpu", options=virtio_gpu) + for gpu_etree in eval_xpath_all(vm_scenario_etree, ".//virtio_devices/gpu"): + display_type = eval_xpath(gpu_etree, "./display_type[text() != '']/text()") + params = list() + for display_etree in eval_xpath_all(gpu_etree, "./displays/display"): + if display_type == "Window": + window_resolutions = eval_xpath(display_etree, "./window_resolutions/text()") + horizontal_offset = eval_xpath(display_etree, "./horizontal_offset/text()") + vertical_offset = eval_xpath(display_etree, "./vertical_offset/text()") + params.append(f"geometry={window_resolutions}+{horizontal_offset}+{vertical_offset}") + if display_type == "Full screen": + monitor_id = eval_xpath(display_etree, "./monitor_id/text()") + params.append(f"geometry=fullscreen:{monitor_id}") + script.add_virtual_device("virtio-gpu", options=",".join(params)) for vsock in eval_xpath_all(vm_scenario_etree, ".//virtio_devices/vsock[text() != '']/text()"): script.add_virtual_device("vhost-vsock", options="cid="+vsock)