From 7da6d0a84563ec6f320204bb5cfbe66b085fcce5 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 14 Dec 2023 16:00:55 +0000 Subject: [PATCH] runtime-rs: ch: Implement missing thread/pid APIs Add implementations for the following `Hypervisor` trait methods which simply return the same details as the `get_vmm_master_tid()` method: - `get_thread_ids()` - `get_pids()` Fixes: #6438. Signed-off-by: James O. D. Hunt --- .../crates/hypervisor/src/ch/inner_hypervisor.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs b/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs index dcc61afa1..bda416f8f 100644 --- a/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs +++ b/src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs @@ -28,6 +28,7 @@ use lazy_static::lazy_static; use nix::sched::{setns, CloneFlags}; use serde::{Deserialize, Serialize}; use serde_json::Value; +use std::collections::HashMap; use std::convert::TryFrom; use std::fs::create_dir_all; use std::os::unix::io::AsRawFd; @@ -676,7 +677,16 @@ impl CloudHypervisorInner { } pub(crate) async fn get_thread_ids(&self) -> Result { - Ok(VcpuThreadIds::default()) + let mut vcpus = HashMap::new(); + + let vcpu = 0; + let thread_id = self.get_vmm_master_tid().await?; + + vcpus.insert(vcpu, thread_id); + + let vcpu_thread_ids = VcpuThreadIds { vcpus }; + + Ok(vcpu_thread_ids) } pub(crate) async fn cleanup(&self) -> Result<()> { @@ -688,7 +698,9 @@ impl CloudHypervisorInner { } pub(crate) async fn get_pids(&self) -> Result> { - Ok(Vec::::new()) + let pid = self.get_vmm_master_tid().await?; + + Ok(vec![pid]) } pub(crate) async fn get_vmm_master_tid(&self) -> Result {