pub fn update_balloon_config(
        &mut self,
        amount_mib: u32,
    ) -> std::result::Result<(), BalloonError> {
        // The balloon cannot have a target size greater than the size of
        // the guest memory.
        if amount_mib as u64 > mem_size_mib(self.guest_memory()) {
            return Err(BalloonError::TooManyPagesRequested);
        }

        if let Some(busdev) = self.get_bus_device(DeviceType::Virtio(TYPE_BALLOON), BALLOON_DEV_ID)
        {
            {
                let virtio_device = busdev
                    .lock()
                    .expect("Poisoned lock")
                    .as_any()
                    .downcast_ref::<MmioTransport>()
                    // Only MmioTransport implements BusDevice at this point.
                    .expect("Unexpected BusDevice type")
                    .device();

                virtio_device
                    .lock()
                    .expect("Poisoned lock")
                    .as_mut_any()
                    .downcast_mut::<Balloon>()
                    .unwrap()
                    .update_size(amount_mib)?;

                Ok(())
            }
        } else {
            Err(BalloonError::DeviceNotFound)
        }
    }
/// Updates configuration for the balloon device target size.
Updates configuration for the balloon device target size.
Updates configuration for the balloon device target size .
pub fn update_balloon_config(
        &mut self,
        amount_mib: u32,
    ) -> std::result::Result<(), BalloonError> {
        // The balloon cannot have a target size greater than the size of
        // the guest memory.
        if amount_mib as u64 > mem_size_mib(self.guest_memory()) {
            return Err(BalloonError::TooManyPagesRequested);
        }
        if let Some(busdev) = self.get_bus_device(DeviceType::Virtio(TYPE_BALLOON), BALLOON_DEV_ID)
        {
            {
                let virtio_device = busdev
                    .lock()
                    .expect("Poisoned lock")
                    .as_any()
                    .downcast_ref::<MmioTransport>()
                    // Only MmioTransport implements BusDevice at this point.
                    .expect("Unexpected BusDevice type")
                    .device();
                virtio_device
                    .lock()
                    .expect("Poisoned lock")
                    .as_mut_any()
                    .downcast_mut::<Balloon>()
                    .unwrap()
                    .update_size(amount_mib)?;
                Ok(())
            }
        } else {
            Err(BalloonError::DeviceNotFound)
        }
    }
pub fn update_balloon_config ( & mut self , amount_mib : u32 , ) -> std :: result :: Result < ( ) , BalloonError > { // The balloon cannot have a target size greater than the size of // the guest memory. if amount_mib as u64 > mem_size_mib ( self . guest_memory ( ) ) { return Err ( BalloonError :: TooManyPagesRequested ) ; } if let Some ( busdev ) = self . get_bus_device ( DeviceType :: Virtio ( TYPE_BALLOON ) , BALLOON_DEV_ID ) { { let virtio_device = busdev . lock ( ) . expect ( " " ) . as_any ( ) . downcast_ref :: < MmioTransport > ( ) // Only MmioTransport implements BusDevice at this point. . expect ( " " ) . device ( ) ; virtio_device . lock ( ) . expect ( " " ) . as_mut_any ( ) . downcast_mut :: < Balloon > ( ) . unwrap ( ) . update_size ( amount_mib ) ? ; Ok ( ( ) ) } } else { Err ( BalloonError :: DeviceNotFound ) } }
Updates configuration for the balloon device target size.
Updates configuration for the balloon device target size .
&mut self
amount_mib
u32
&mut self
amount_mib
u32