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=<width>x<height>+<x_off>+<y_off>,geometry=<width>x<height>+<x_off>+<y_off>"

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 <kunhuix.li@intel.com>
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Kunhui-Li 2022-08-10 11:31:24 +08:00 committed by acrnsi-robot
parent 4f3a28d29f
commit 5554040dbb
1 changed files with 13 additions and 3 deletions

View File

@ -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)