@@ -123,7 +123,6 @@ use std::time::Duration;
123
123
124
124
use device_manager:: DeviceManager ;
125
125
use devices:: acpi:: vmgenid:: VmGenIdError ;
126
- use devices:: virtio:: device:: VirtioDevice ;
127
126
use event_manager:: { EventManager as BaseEventManager , EventOps , Events , MutEventSubscriber } ;
128
127
use seccomp:: BpfProgram ;
129
128
use snapshot:: Persist ;
@@ -329,20 +328,6 @@ impl Vmm {
329
328
self . shutdown_exit_code
330
329
}
331
330
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
-
346
331
/// Starts the microVM vcpus.
347
332
///
348
333
/// # Errors
@@ -589,7 +574,10 @@ impl Vmm {
589
574
590
575
/// Returns a reference to the balloon device if present.
591
576
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
+ {
593
581
let config = virtio_device
594
582
. lock ( )
595
583
. expect ( "Poisoned lock" )
@@ -606,7 +594,10 @@ impl Vmm {
606
594
607
595
/// Returns the latest balloon statistics if they are enabled.
608
596
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
+ {
610
601
let latest_stats = virtio_device
611
602
. lock ( )
612
603
. expect ( "Poisoned lock" )
@@ -631,7 +622,10 @@ impl Vmm {
631
622
return Err ( BalloonError :: TooManyPagesRequested ) ;
632
623
}
633
624
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
+ {
635
629
{
636
630
virtio_device
637
631
. lock ( )
@@ -653,7 +647,10 @@ impl Vmm {
653
647
& mut self ,
654
648
stats_polling_interval_s : u16 ,
655
649
) -> 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
+ {
657
654
{
658
655
virtio_device
659
656
. lock ( )
0 commit comments