@@ -123,7 +123,6 @@ use std::time::Duration;
123123
124124use device_manager:: DeviceManager ;
125125use devices:: acpi:: vmgenid:: VmGenIdError ;
126- use devices:: virtio:: device:: VirtioDevice ;
127126use event_manager:: { EventManager as BaseEventManager , EventOps , Events , MutEventSubscriber } ;
128127use seccomp:: BpfProgram ;
129128use 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
@@ -589,7 +574,10 @@ impl Vmm {
589574
590575 /// Returns a reference to the balloon device if present.
591576 pub fn balloon_config ( & self ) -> Result < BalloonConfig , BalloonError > {
592- if let Some ( virtio_device) = self . get_virtio_device ( TYPE_BALLOON , BALLOON_DEV_ID ) {
577+ if let Some ( virtio_device) = self
578+ . device_manager
579+ . get_virtio_device ( TYPE_BALLOON , BALLOON_DEV_ID )
580+ {
593581 let config = virtio_device
594582 . lock ( )
595583 . expect ( "Poisoned lock" )
@@ -606,7 +594,10 @@ impl Vmm {
606594
607595 /// Returns the latest balloon statistics if they are enabled.
608596 pub fn latest_balloon_stats ( & self ) -> Result < BalloonStats , BalloonError > {
609- if let Some ( virtio_device) = self . get_virtio_device ( TYPE_BALLOON , BALLOON_DEV_ID ) {
597+ if let Some ( virtio_device) = self
598+ . device_manager
599+ . get_virtio_device ( TYPE_BALLOON , BALLOON_DEV_ID )
600+ {
610601 let latest_stats = virtio_device
611602 . lock ( )
612603 . expect ( "Poisoned lock" )
@@ -631,7 +622,10 @@ impl Vmm {
631622 return Err ( BalloonError :: TooManyPagesRequested ) ;
632623 }
633624
634- if let Some ( virtio_device) = self . get_virtio_device ( TYPE_BALLOON , BALLOON_DEV_ID ) {
625+ if let Some ( virtio_device) = self
626+ . device_manager
627+ . get_virtio_device ( TYPE_BALLOON , BALLOON_DEV_ID )
628+ {
635629 {
636630 virtio_device
637631 . lock ( )
@@ -653,7 +647,10 @@ impl Vmm {
653647 & mut self ,
654648 stats_polling_interval_s : u16 ,
655649 ) -> Result < ( ) , BalloonError > {
656- if let Some ( virtio_device) = self . get_virtio_device ( TYPE_BALLOON , BALLOON_DEV_ID ) {
650+ if let Some ( virtio_device) = self
651+ . device_manager
652+ . get_virtio_device ( TYPE_BALLOON , BALLOON_DEV_ID )
653+ {
657654 {
658655 virtio_device
659656 . lock ( )
0 commit comments