vmm: Move balloon code from MemoryManager to DeviceManager

Now that we have a new dedicated way of asking for a balloon through the
CLI and the REST API, we can move all the balloon code to the device
manager. This allows us to simplify the memory manager, which is already
quite complex.

It also simplifies the behavior of the balloon resizing command. Instead
of providing the expected size for the RAM, which is complex when memory
zones are involved, it now expects the balloon size. This is a much more
straightforward behavior as it really resizes the balloon to the desired
size. Additionally to the simplication, the benefit of this approach is
that it does not need to be tied to the memory manager at all.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-10-14 12:04:42 +02:00
parent 1d479e5e08
commit 3594685279
6 changed files with 55 additions and 57 deletions
+4 -4
View File
@@ -469,7 +469,7 @@ impl Vmm {
let mut memory_actual_size = config.lock().unwrap().memory.total_size();
if let Some(vm) = &self.vm {
memory_actual_size -= vm.get_balloon_actual();
memory_actual_size -= vm.balloon_size();
}
Ok(VmInfo {
@@ -511,10 +511,10 @@ impl Vmm {
&mut self,
desired_vcpus: Option<u8>,
desired_ram: Option<u64>,
desired_ram_w_balloon: Option<u64>,
desired_balloon: Option<u64>,
) -> result::Result<(), VmError> {
if let Some(ref mut vm) = self.vm {
if let Err(e) = vm.resize(desired_vcpus, desired_ram, desired_ram_w_balloon) {
if let Err(e) = vm.resize(desired_vcpus, desired_ram, desired_balloon) {
error!("Error when resizing VM: {:?}", e);
Err(e)
} else {
@@ -801,7 +801,7 @@ impl Vmm {
.vm_resize(
resize_data.desired_vcpus,
resize_data.desired_ram,
resize_data.desired_ram_w_balloon,
resize_data.desired_balloon,
)
.map_err(ApiError::VmResize)
.map(|_| ApiResponsePayload::Empty);