From 413976d8cbace072c5a2d39b304234e207dab65c Mon Sep 17 00:00:00 2001 From: Prashanth Suresh Date: Mon, 8 Apr 2024 08:15:48 +0000 Subject: [PATCH] Enable HW Spice support on Android. Enable HW Spice support for Android from vm-manager Tracked-On: OAM-117157 Signed-off-by: Suresh, Prashanth --- .../0054-Enable-support-for-HW-Spcie.patch | 30 ++++++++ .../0010-Enable-support-for-HW-Spice.patch | 72 +++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 bsp_diff/caas/device/intel/civ/host/vm-manager/0054-Enable-support-for-HW-Spcie.patch create mode 100644 host/vm-manager/0010-Enable-support-for-HW-Spice.patch diff --git a/bsp_diff/caas/device/intel/civ/host/vm-manager/0054-Enable-support-for-HW-Spcie.patch b/bsp_diff/caas/device/intel/civ/host/vm-manager/0054-Enable-support-for-HW-Spcie.patch new file mode 100644 index 0000000..e38ea95 --- /dev/null +++ b/bsp_diff/caas/device/intel/civ/host/vm-manager/0054-Enable-support-for-HW-Spcie.patch @@ -0,0 +1,30 @@ +From d4903b3ff1b3749223e926467d11bf8e6c444f9c Mon Sep 17 00:00:00 2001 +From: Prashanth Suresh +Date: Mon, 8 Apr 2024 06:57:58 +0000 +Subject: [PATCH] Enable support for HW Spcie + +Enable HW Spice support for Android through vm-manager +--- + sample/guest01.ini | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/sample/guest01.ini b/sample/guest01.ini +index d2c687d..afd9c14 100644 +--- a/sample/guest01.ini ++++ b/sample/guest01.ini +@@ -79,6 +79,12 @@ audio_type=legacy-hda + #show_fps= + #disable_host_input=no + ++#Set hw_spice=true to view VM over HW Spice. false by default. Please add IP address and ++#port for Spice display to work ++#hw_spice=true ++#ip_addr=10.49.4.30 ++#port=3001 ++ + [passthrough] + #specified the PCI id here if you want to passthrough it to guest, seperate them with comma + passthrough_pci=0000:00:14.0, +-- +2.34.1 + diff --git a/host/vm-manager/0010-Enable-support-for-HW-Spice.patch b/host/vm-manager/0010-Enable-support-for-HW-Spice.patch new file mode 100644 index 0000000..3a739e6 --- /dev/null +++ b/host/vm-manager/0010-Enable-support-for-HW-Spice.patch @@ -0,0 +1,72 @@ +From 4679dbb55533b3474d8356d82741e06e4a47efac Mon Sep 17 00:00:00 2001 +From: Prashanth suresh +Date: Mon, 8 Apr 2024 12:21:15 +0530 +Subject: [PATCH] Enable support for HW Spice + +Enable HW Spice support for Android through vm-manager +--- + src/guest/config_parser.cc | 2 +- + src/guest/config_parser.h | 3 +++ + src/guest/vm_builder_qemu.cc | 16 +++++++++++++++- + 3 files changed, 19 insertions(+), 2 deletions(-) + +diff --git a/src/guest/config_parser.cc b/src/guest/config_parser.cc +index 6cfaae5..c8fb5bc 100644 +--- a/src/guest/config_parser.cc ++++ b/src/guest/config_parser.cc +@@ -35,7 +35,7 @@ map> kConfigMap = { + { kGroupFirm, { kFirmType, kFirmPath, kFirmCode, kFirmVars } }, + { kGroupDisk, { kDiskSize, kDiskPath } }, + { kGroupVgpu, { kVgpuType, kVgpuGvtgVer, kVgpuUuid, kVgpuMonId, kVgpuOutputs } }, +- { kGroupDisplay, { kDispOptions, kDispConnector0, kDispConnector1, kDispShowFps, kDisableHostInput } }, ++ { kGroupDisplay, { kDispOptions, kDispConnector0, kDispConnector1, kDispShowFps, kDisableHostInput, kHwSpice, kHwSpiceIp, kHwSpicePort } }, + { kGroupNet, { kNetModel, kNetAdbPort, kNetFastbootPort } }, + { kGroupVtpm, { kVtpmBinPath, kVtpmDataDir } }, + { kGroupRpmb, { kRpmbBinPath, kRpmbDataDir } }, +diff --git a/src/guest/config_parser.h b/src/guest/config_parser.h +index 80d8a12..7be9848 100644 +--- a/src/guest/config_parser.h ++++ b/src/guest/config_parser.h +@@ -65,6 +65,9 @@ constexpr char kDispConnector0[] = "connectors_0"; + constexpr char kDispConnector1[] = "connectors_1"; + constexpr char kDispShowFps[] = "show_fps"; + constexpr char kDisableHostInput[] = "disable_host_input"; ++constexpr char kHwSpice[] = "hw_spice"; ++constexpr char kHwSpiceIp[] = "ip_addr"; ++constexpr char kHwSpicePort[] = "port"; + + constexpr char kNetModel[] = "model"; + constexpr char kNetAdbPort[] = "adb_port"; +diff --git a/src/guest/vm_builder_qemu.cc b/src/guest/vm_builder_qemu.cc +index 3406a45..558240f 100644 +--- a/src/guest/vm_builder_qemu.cc ++++ b/src/guest/vm_builder_qemu.cc +@@ -411,10 +411,24 @@ bool VmBuilderQemu::SetupSriov(void) { + return false; + } + +- emul_cmd_.append(" -device virtio-vga,max_outputs=" + ((numberOfDisplays > 0 ) ? std::to_string(numberOfDisplays) : "1") + ",blob=true" ++ std::string hw_spice = cfg_.GetValue(kGroupDisplay, kHwSpice); ++ std::string spice_ip = cfg_.GetValue(kGroupDisplay, kHwSpiceIp); ++ std::string spice_port = cfg_.GetValue(kGroupDisplay, kHwSpicePort); ++ if((!hw_spice.empty()) && hw_spice.compare("true") == 0) { ++ LOG(info) << "Enabling hw spice display"; ++ emul_cmd_.append(" -device virtio-gpu-pci,max_outputs=" + ((numberOfDisplays > 0 ) ? std::to_string(numberOfDisplays) : "1") + ",blob=true" ++ ",xres=1920,yres=1080" + + " -device vfio-pci,host=0000:00:02." + std::to_string(vf) + + " -object memory-backend-memfd,hugetlb=on,id=mem_sriov,size=" + mem_size + + " -machine memory-backend=mem_sriov"); ++ ++ emul_cmd_.append(" -spice gl=on,addr=" + spice_ip + ",port=" + spice_port + ",disable-ticketing=on,streaming-video=filter,preferred-codec=gstreamer:h264"); ++ } else { ++ emul_cmd_.append(" -device virtio-vga,max_outputs=" + ((numberOfDisplays > 0 ) ? std::to_string(numberOfDisplays) : "1") + ",blob=true" ++ " -device vfio-pci,host=0000:00:02." + std::to_string(vf) + ++ " -object memory-backend-memfd,hugetlb=on,id=mem_sriov,size=" + mem_size + ++ " -machine memory-backend=mem_sriov"); ++ } + return true; + } + +-- +2.34.1 +