[PATCH V2 2/7] config-tools: genertate performance policy parameter


Zhou, Wu
 

This patch is to generate an ACRN CPU performance policy type boot
parameter.

The generated parameter is either 'cpu_perf_policy=Performance’ or
‘cpu_perf_policy=Nominal’, according to the 'CPU performance policy type'
config item in configurator.

It will then be packed into acrn-hypervisor deb file, and will be
automatically added to grub cfg file through installation.

Signed-off-by: Wu Zhou <wu.zhou@...>
---
misc/packaging/acrn-hypervisor.postinst | 15 +++++++++++----
misc/packaging/gen_acrn_deb.py | 15 +++++++++++++++
2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/misc/packaging/acrn-hypervisor.postinst b/misc/packaging/acrn-hypervisor.postinst
index ebac07aa7..d61f0908e 100644
--- a/misc/packaging/acrn-hypervisor.postinst
+++ b/misc/packaging/acrn-hypervisor.postinst
@@ -13,6 +13,13 @@ BOARD=(nuc11tnbi5)

#Build info End

+
+#ACRN parameters Start
+
+GENERATED_PARAMS=(cpu_perf_policy=Performance)
+
+#ACRN parameters End
+
ACRNBIN="/boot/acrn.${SCENARIO}.${BOARD}.bin"
type=$(lsblk -l |awk '$NF == "/" {print $1}')

@@ -45,7 +52,7 @@ menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set $uuid
-multiboot2 $ACRNBIN root=PARTUUID=$partuuid
+multiboot2 $ACRNBIN root=PARTUUID=$partuuid $GENERATED_PARAMS
$kernelimg
module2 /boot/zephyr64.elf Zephyr_ElfImage
module2 /boot/ACPI_VM0.bin ACPI_VM0
@@ -64,7 +71,7 @@ menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set $uuid
-multiboot2 $ACRNBIN root=PARTUUID=$partuuid
+multiboot2 $ACRNBIN root=PARTUUID=$partuuid $GENERATED_PARAMS
$kernelimg
module2 /boot/bzImage_RT RT_bzImage
module2 /boot/ACPI_VM0.bin ACPI_VM0
@@ -82,7 +89,7 @@ menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
insmod ext2
search --no-floppy --fs-uuid --set $uuid
echo 'loading ACRN...'
-multiboot2 $ACRNBIN root=PARTUUID=$partuuid
+multiboot2 $ACRNBIN root=PARTUUID=$partuuid $GENERATED_PARAMS
$kernelimg
module2 /boot/ACPI_VM0.bin ACPI_VM0
module2 /boot/ACPI_VM1.bin ACPI_VM1
@@ -99,7 +106,7 @@ menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
insmod part_gpt
insmod ext2
search --no-floppy --fs-uuid --set $uuid
-multiboot2 $ACRNBIN root=PARTUUID=$partuuid
+multiboot2 $ACRNBIN root=PARTUUID=$partuuid $GENERATED_PARAMS
$kernelimg

}
diff --git a/misc/packaging/gen_acrn_deb.py b/misc/packaging/gen_acrn_deb.py
index eb57e7e00..bf44fff5b 100644
--- a/misc/packaging/gen_acrn_deb.py
+++ b/misc/packaging/gen_acrn_deb.py
@@ -13,6 +13,7 @@ import shlex
import shutil
import subprocess
import argparse
+import re

from pathlib import Path

@@ -81,6 +82,20 @@ def create_acrn_deb(board, scenario, version, build_dir):
del lines[(start + 1):(end - 1)]
lines.insert(start + 1, "\nSCENARIO=(%s)\n" % scenario)
lines.insert(start + 2, "\nBOARD=(%s)\n" % board)
+
+ a_f = open(build_dir + "/hypervisor/configs/allocation.xml", 'r')
+ for a_line in a_f:
+ l = re.search("<CPU_PERFORMANCE_POLICY>(\w*)</CPU_PERFORMANCE_POLICY>", a_line)
+ if l != None:
+ break;
+ start = lines.index('#ACRN parameters Start\n')
+ end = lines.index('#ACRN parameters End\n')
+ del lines[(start + 1):(end - 1)]
+ if l == None:
+ lines.insert(start + 1, "\nGENERATED_PARAMS=(cpu_perf_policy=%s)\n" % "Performance")
+ else:
+ lines.insert(start + 1, "\nGENERATED_PARAMS=(cpu_perf_policy=%s)\n" % l.group(1))
+
with open(cur_dir + "/misc/packaging/acrn-hypervisor.postinst", "w") as f:
for line in lines:
f.write(line)
--
2.25.1