mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-19 07:14:22 +01:00
runtim-rs: get guest memory details
get memory block size and guest mem hotplug probe Fixes:#6356 Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
@@ -8,7 +8,9 @@ use std::sync::Arc;
|
||||
|
||||
use agent::kata::KataAgent;
|
||||
use agent::types::KernelModule;
|
||||
use agent::{self, Agent, GetIPTablesRequest, SetIPTablesRequest, VolumeStatsRequest};
|
||||
use agent::{
|
||||
self, Agent, GetGuestDetailsRequest, GetIPTablesRequest, SetIPTablesRequest, VolumeStatsRequest,
|
||||
};
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use common::message::{Action, Message};
|
||||
@@ -18,6 +20,7 @@ use hypervisor::VsockConfig;
|
||||
use hypervisor::{dragonball::Dragonball, BlockConfig, Hypervisor, HYPERVISOR_DRAGONBALL};
|
||||
use hypervisor::{utils::get_hvsock_path, HybridVsockConfig, DEFAULT_GUEST_VSOCK_CID};
|
||||
use kata_sys_util::hooks::HookStates;
|
||||
use kata_types::capabilities::CapabilityBits;
|
||||
use kata_types::config::TomlConfig;
|
||||
use persist::{self, sandbox_persist::Persist};
|
||||
use resource::manager::ManagerArgs;
|
||||
@@ -196,7 +199,41 @@ impl VirtSandbox {
|
||||
// * spec details: https://github.com/opencontainers/runtime-spec/blob/c1662686cff159595277b79322d0272f5182941b/config.md#createruntime-hooks
|
||||
let mut create_runtime_hook_states = HookStates::new();
|
||||
create_runtime_hook_states.execute_hooks(create_runtime_hooks, Some(st.clone()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// store_guest_details will get the information from the guest OS, like memory block size, agent details and is memory hotplug probe support
|
||||
async fn store_guest_details(&self) -> Result<()> {
|
||||
// get the information from agent
|
||||
let guest_details = self
|
||||
.agent
|
||||
.get_guest_details(GetGuestDetailsRequest {
|
||||
mem_block_size: true,
|
||||
mem_hotplug_probe: true,
|
||||
})
|
||||
.await
|
||||
.context("failed to store guest details")?;
|
||||
|
||||
// set memory block size
|
||||
self.hypervisor
|
||||
.set_guest_memory_block_size(guest_details.mem_block_size_bytes as u32)
|
||||
.await;
|
||||
|
||||
// set memory hotplug probe
|
||||
if guest_details.support_mem_hotplug_probe {
|
||||
self.hypervisor
|
||||
.set_capabilities(CapabilityBits::GuestMemoryHotplugProbe)
|
||||
.await;
|
||||
}
|
||||
info!(
|
||||
sl!(),
|
||||
"memory block size is {}, memory probe support {}",
|
||||
self.hypervisor.guest_memory_block_size().await,
|
||||
self.hypervisor
|
||||
.capabilities()
|
||||
.await?
|
||||
.is_mem_hotplug_probe_supported()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -375,6 +412,12 @@ impl Sandbox for VirtSandbox {
|
||||
.context("create sandbox")?;
|
||||
|
||||
inner.state = SandboxState::Running;
|
||||
|
||||
// get and store guest details
|
||||
self.store_guest_details()
|
||||
.await
|
||||
.context("failed to store guest details")?;
|
||||
|
||||
let agent = self.agent.clone();
|
||||
let sender = self.msg_sender.clone();
|
||||
info!(sl!(), "oom watcher start");
|
||||
|
||||
Reference in New Issue
Block a user