[PATCH v3 2/5] config_tools: refine virtio gpu in launch script


Yang, Yu-chu
 

From: Kunhui-Li <kunhuix.li@...>

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"

v2->v3
1. replace dimension(s) to resolution(s)

Tracked-On: #7970
Signed-off-by: Kunhui-Li <kunhuix.li@...>
Signed-off-by: Yang,Yu-chu <yu-chu.yang@...>
---
.../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)
--
2.25.1


Junjie Mao
 

-----Original Message-----
From: Yang, Yu-chu <yu-chu.yang@...>
Sent: Friday, October 7, 2022 5:01 AM
To: acrn-dev@...
Cc: Mao, Junjie <junjie.mao@...>
Subject: [PATCH v3 2/5] config_tools: refine virtio gpu in launch script

From: Kunhui-Li <kunhuix.li@...>

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"

v2->v3
1. replace dimension(s) to resolution(s)

Tracked-On: #7970
Signed-off-by: Kunhui-Li <kunhuix.li@...>
Signed-off-by: Yang,Yu-chu <yu-chu.yang@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

Since you assume the precense of a `display_type` node here, making that node optional in 1/5 no longer makes sense. A default values shall be specified there instead.

---
Best Regards
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)
--
2.25.1