Skip to content

Commit 74a4d3a

Browse files
committed
fix(balloon): fix balloon not found when pci is enabled
The code managing the balloon logic is only looking at the mmio device manager. Make it use the generic device manager to find the device. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent af28de9 commit 74a4d3a

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/vmm/src/lib.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ use std::time::Duration;
123123

124124
use device_manager::DeviceManager;
125125
use devices::acpi::vmgenid::VmGenIdError;
126-
use devices::virtio::device::VirtioDevice;
127126
use event_manager::{EventManager as BaseEventManager, EventOps, Events, MutEventSubscriber};
128127
use seccomp::BpfProgram;
129128
use snapshot::Persist;
@@ -329,20 +328,6 @@ impl Vmm {
329328
self.shutdown_exit_code
330329
}
331330

332-
/// Gets the specified bus device.
333-
pub fn get_virtio_device(
334-
&self,
335-
device_type: u32,
336-
device_id: &str,
337-
) -> Option<Arc<Mutex<dyn VirtioDevice>>> {
338-
let device = self
339-
.device_manager
340-
.mmio_devices
341-
.get_virtio_device(device_type, device_id)?;
342-
343-
Some(device.inner.lock().expect("Poisoned lock").device().clone())
344-
}
345-
346331
/// Starts the microVM vcpus.
347332
///
348333
/// # Errors
@@ -591,7 +576,10 @@ impl Vmm {
591576

592577
/// Returns a reference to the balloon device if present.
593578
pub fn balloon_config(&self) -> Result<BalloonConfig, BalloonError> {
594-
if let Some(virtio_device) = self.get_virtio_device(TYPE_BALLOON, BALLOON_DEV_ID) {
579+
if let Some(virtio_device) = self
580+
.device_manager
581+
.get_virtio_device(TYPE_BALLOON, BALLOON_DEV_ID)
582+
{
595583
let config = virtio_device
596584
.lock()
597585
.expect("Poisoned lock")
@@ -608,7 +596,10 @@ impl Vmm {
608596

609597
/// Returns the latest balloon statistics if they are enabled.
610598
pub fn latest_balloon_stats(&self) -> Result<BalloonStats, BalloonError> {
611-
if let Some(virtio_device) = self.get_virtio_device(TYPE_BALLOON, BALLOON_DEV_ID) {
599+
if let Some(virtio_device) = self
600+
.device_manager
601+
.get_virtio_device(TYPE_BALLOON, BALLOON_DEV_ID)
602+
{
612603
let latest_stats = virtio_device
613604
.lock()
614605
.expect("Poisoned lock")
@@ -633,7 +624,10 @@ impl Vmm {
633624
return Err(BalloonError::TooManyPagesRequested);
634625
}
635626

636-
if let Some(virtio_device) = self.get_virtio_device(TYPE_BALLOON, BALLOON_DEV_ID) {
627+
if let Some(virtio_device) = self
628+
.device_manager
629+
.get_virtio_device(TYPE_BALLOON, BALLOON_DEV_ID)
630+
{
637631
{
638632
virtio_device
639633
.lock()
@@ -655,7 +649,10 @@ impl Vmm {
655649
&mut self,
656650
stats_polling_interval_s: u16,
657651
) -> Result<(), BalloonError> {
658-
if let Some(virtio_device) = self.get_virtio_device(TYPE_BALLOON, BALLOON_DEV_ID) {
652+
if let Some(virtio_device) = self
653+
.device_manager
654+
.get_virtio_device(TYPE_BALLOON, BALLOON_DEV_ID)
655+
{
659656
{
660657
virtio_device
661658
.lock()

0 commit comments

Comments
 (0)