mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-balloon: Store the balloon size to support reboot
This commit store balloon size to MemoryConfig. After reboot, virtio-balloon can use this size to inflate back to the size before reboot. Signed-off-by: Hui Zhu <teawater@antfin.com>
This commit is contained in:
@@ -799,13 +799,12 @@ impl MemoryManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn balloon_resize(&mut self, expected_ram: u64) -> Result<(), Error> {
|
||||
pub fn balloon_resize(&mut self, expected_ram: u64) -> Result<u64, Error> {
|
||||
let mut balloon_size = 0;
|
||||
if let Some(balloon) = &self.balloon {
|
||||
let balloon_size = if expected_ram < self.current_ram {
|
||||
self.current_ram - expected_ram
|
||||
} else {
|
||||
0
|
||||
};
|
||||
if expected_ram < self.current_ram {
|
||||
balloon_size = self.current_ram - expected_ram;
|
||||
}
|
||||
balloon
|
||||
.lock()
|
||||
.unwrap()
|
||||
@@ -813,7 +812,7 @@ impl MemoryManager {
|
||||
.map_err(Error::VirtioBalloonResizeFail)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(balloon_size)
|
||||
}
|
||||
|
||||
/// In case this function resulted in adding a new memory region to the
|
||||
|
||||
Reference in New Issue
Block a user