mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-18 17:33:02 +00:00
Merge pull request #10253 from teawater/enable_balloon_f_reporting
Add support of dragonball virtio-balloon free page reporting
This commit is contained in:
commit
f31839af63
@ -491,6 +491,12 @@ pub struct DeviceInfo {
|
|||||||
/// Enabling this will result in the VM device having iommu_platform=on set
|
/// Enabling this will result in the VM device having iommu_platform=on set
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub enable_iommu_platform: bool,
|
pub enable_iommu_platform: bool,
|
||||||
|
|
||||||
|
/// Enable balloon f_reporting, default false
|
||||||
|
///
|
||||||
|
/// Enabling this will result in the VM balloon device having f_reporting=on set
|
||||||
|
#[serde(default)]
|
||||||
|
pub enable_balloon_f_reporting: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceInfo {
|
impl DeviceInfo {
|
||||||
|
@ -98,6 +98,12 @@ default_maxvcpus = @DEFMAXVCPUS_DB@
|
|||||||
# > 5 --> will be set to 5
|
# > 5 --> will be set to 5
|
||||||
default_bridges = @DEFBRIDGES@
|
default_bridges = @DEFBRIDGES@
|
||||||
|
|
||||||
|
# Enable balloon f_reporting, default false
|
||||||
|
# Enabling this will result in the VM balloon device having f_reporting=on set
|
||||||
|
#
|
||||||
|
# Default false
|
||||||
|
#enable_balloon_f_reporting = true
|
||||||
|
|
||||||
# Default memory size in MiB for SB/VM.
|
# Default memory size in MiB for SB/VM.
|
||||||
# If unspecified then it will be set @DEFMEMSZ@ MiB.
|
# If unspecified then it will be set @DEFMEMSZ@ MiB.
|
||||||
default_memory = @DEFMEMSZ@
|
default_memory = @DEFMEMSZ@
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
|
|
||||||
use super::vmm_instance::VmmInstance;
|
use super::vmm_instance::VmmInstance;
|
||||||
use crate::{
|
use crate::{
|
||||||
device::DeviceType, hypervisor_persist::HypervisorState, kernel_param::KernelParams,
|
device::DeviceType, firecracker::sl, hypervisor_persist::HypervisorState,
|
||||||
MemoryConfig, VmmState, DEV_HUGEPAGES, HUGETLBFS, HUGE_SHMEM, HYPERVISOR_DRAGONBALL, SHMEM,
|
kernel_param::KernelParams, MemoryConfig, VmmState, DEV_HUGEPAGES, HUGETLBFS, HUGE_SHMEM,
|
||||||
|
HYPERVISOR_DRAGONBALL, SHMEM,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@ -118,6 +119,20 @@ impl DragonballInner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn try_insert_balloon_f_reporting(&mut self) {
|
||||||
|
let balloon_config = BalloonDeviceConfigInfo {
|
||||||
|
balloon_id: BALLOON_DEVICE_ID.to_owned(),
|
||||||
|
size_mib: 0,
|
||||||
|
use_shared_irq: None,
|
||||||
|
use_generic_irq: None,
|
||||||
|
f_deflate_on_oom: false,
|
||||||
|
f_reporting: true,
|
||||||
|
};
|
||||||
|
if let Err(e) = self.vmm_instance.insert_balloon_device(balloon_config) {
|
||||||
|
error!(sl(), "failed to insert f_reporting balloon device: {:?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) async fn cold_start_vm(&mut self, timeout: i32) -> Result<()> {
|
pub(crate) async fn cold_start_vm(&mut self, timeout: i32) -> Result<()> {
|
||||||
info!(sl!(), "start sandbox cold");
|
info!(sl!(), "start sandbox cold");
|
||||||
|
|
||||||
@ -415,7 +430,7 @@ impl DragonballInner {
|
|||||||
use_shared_irq: None,
|
use_shared_irq: None,
|
||||||
use_generic_irq: None,
|
use_generic_irq: None,
|
||||||
f_deflate_on_oom: false,
|
f_deflate_on_oom: false,
|
||||||
f_reporting: false,
|
f_reporting: self.config.device_info.enable_balloon_f_reporting,
|
||||||
};
|
};
|
||||||
self.vmm_instance
|
self.vmm_instance
|
||||||
.insert_balloon_device(balloon_config)
|
.insert_balloon_device(balloon_config)
|
||||||
@ -447,7 +462,7 @@ impl DragonballInner {
|
|||||||
use_shared_irq: None,
|
use_shared_irq: None,
|
||||||
use_generic_irq: None,
|
use_generic_irq: None,
|
||||||
f_deflate_on_oom: false,
|
f_deflate_on_oom: false,
|
||||||
f_reporting: false,
|
f_reporting: self.config.device_info.enable_balloon_f_reporting,
|
||||||
};
|
};
|
||||||
self.balloon_size = had_mem_mb - new_mem_mb;
|
self.balloon_size = had_mem_mb - new_mem_mb;
|
||||||
self.vmm_instance
|
self.vmm_instance
|
||||||
|
@ -77,7 +77,26 @@ impl Hypervisor for Dragonball {
|
|||||||
#[instrument]
|
#[instrument]
|
||||||
async fn start_vm(&self, timeout: i32) -> Result<()> {
|
async fn start_vm(&self, timeout: i32) -> Result<()> {
|
||||||
let mut inner = self.inner.write().await;
|
let mut inner = self.inner.write().await;
|
||||||
inner.start_vm(timeout).await
|
let ret = inner.start_vm(timeout).await;
|
||||||
|
|
||||||
|
if ret.is_ok() && inner.config.device_info.enable_balloon_f_reporting {
|
||||||
|
// The virtio-balloon device must be inserted into dragonball and
|
||||||
|
// recognized by the guest kernel only after the dragonball upcall is ready.
|
||||||
|
// The dragonball upcall is not ready immediately after the VM starts,
|
||||||
|
// so here we create an asynchronous task that waits for 5 seconds before
|
||||||
|
// inserting the virtio-balloon device.
|
||||||
|
let inner_clone = self.inner.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||||
|
inner_clone
|
||||||
|
.write()
|
||||||
|
.await
|
||||||
|
.try_insert_balloon_f_reporting()
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn stop_vm(&self) -> Result<()> {
|
async fn stop_vm(&self) -> Result<()> {
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
CONFIG_BALLOON_COMPACTION=y
|
||||||
|
CONFIG_PAGE_REPORTING=y
|
@ -0,0 +1 @@
|
|||||||
|
CONFIG_VIRTIO_BALLOON=y
|
@ -1 +1 @@
|
|||||||
135
|
136
|
||||||
|
Loading…
Reference in New Issue
Block a user