@@ -526,10 +526,9 @@ impl Vmm {
526526 path_on_host : String ,
527527 ) -> Result < ( ) , VmmError > {
528528 self . device_manager
529- . try_with_virtio_device_with_id ( drive_id, |block : & mut Block | {
529+ . with_virtio_device ( drive_id, |block : & mut Block | {
530530 block. update_disk_image ( path_on_host)
531- } )
532- . map_err ( VmmError :: FindDeviceError ) ??;
531+ } ) ??;
533532 Ok ( ( ) )
534533 }
535534
@@ -541,18 +540,16 @@ impl Vmm {
541540 rl_ops : BucketUpdate ,
542541 ) -> Result < ( ) , VmmError > {
543542 self . device_manager
544- . try_with_virtio_device_with_id ( drive_id, |block : & mut Block | {
543+ . with_virtio_device ( drive_id, |block : & mut Block | {
545544 block. update_rate_limiter ( rl_bytes, rl_ops)
546- } )
547- . map_err ( VmmError :: FindDeviceError ) ??;
545+ } ) ??;
548546 Ok ( ( ) )
549547 }
550548
551549 /// Updates the rate limiter parameters for block device with `drive_id` id.
552550 pub fn update_vhost_user_block_config ( & mut self , drive_id : & str ) -> Result < ( ) , VmmError > {
553551 self . device_manager
554- . try_with_virtio_device_with_id ( drive_id, |block : & mut Block | block. update_config ( ) )
555- . map_err ( VmmError :: FindDeviceError ) ??;
552+ . with_virtio_device ( drive_id, |block : & mut Block | block. update_config ( ) ) ??;
556553 Ok ( ( ) )
557554 }
558555
@@ -566,35 +563,34 @@ impl Vmm {
566563 tx_ops : BucketUpdate ,
567564 ) -> Result < ( ) , VmmError > {
568565 self . device_manager
569- . with_virtio_device_with_id ( net_id, |net : & mut Net | {
566+ . with_virtio_device ( net_id, |net : & mut Net | {
570567 net. patch_rate_limiters ( rx_bytes, rx_ops, tx_bytes, tx_ops)
571- } )
572- . map_err ( VmmError :: FindDeviceError )
568+ } ) ? ;
569+ Ok ( ( ) )
573570 }
574571
575572 /// Returns a reference to the balloon device if present.
576573 pub fn balloon_config ( & self ) -> Result < BalloonConfig , VmmError > {
577- self . device_manager
578- . with_virtio_device_with_id ( BALLOON_DEV_ID , |dev : & mut Balloon | dev. config ( ) )
579- . map_err ( VmmError :: FindDeviceError )
574+ let config = self
575+ . device_manager
576+ . with_virtio_device ( BALLOON_DEV_ID , |dev : & mut Balloon | dev. config ( ) ) ?;
577+ Ok ( config)
580578 }
581579
582580 /// Returns the latest balloon statistics if they are enabled.
583581 pub fn latest_balloon_stats ( & self ) -> Result < BalloonStats , VmmError > {
584582 let stats = self
585583 . device_manager
586- . try_with_virtio_device_with_id ( BALLOON_DEV_ID , |dev : & mut Balloon | dev. latest_stats ( ) )
587- . map_err ( VmmError :: FindDeviceError ) ??;
584+ . with_virtio_device ( BALLOON_DEV_ID , |dev : & mut Balloon | dev. latest_stats ( ) ) ??;
588585 Ok ( stats)
589586 }
590587
591588 /// Updates configuration for the balloon device target size.
592589 pub fn update_balloon_config ( & mut self , amount_mib : u32 ) -> Result < ( ) , VmmError > {
593590 self . device_manager
594- . try_with_virtio_device_with_id ( BALLOON_DEV_ID , |dev : & mut Balloon | {
591+ . with_virtio_device ( BALLOON_DEV_ID , |dev : & mut Balloon | {
595592 dev. update_size ( amount_mib)
596- } )
597- . map_err ( VmmError :: FindDeviceError ) ??;
593+ } ) ??;
598594 Ok ( ( ) )
599595 }
600596
@@ -604,10 +600,9 @@ impl Vmm {
604600 stats_polling_interval_s : u16 ,
605601 ) -> Result < ( ) , VmmError > {
606602 self . device_manager
607- . try_with_virtio_device_with_id ( BALLOON_DEV_ID , |dev : & mut Balloon | {
603+ . with_virtio_device ( BALLOON_DEV_ID , |dev : & mut Balloon | {
608604 dev. update_stats_polling_interval ( stats_polling_interval_s)
609- } )
610- . map_err ( VmmError :: FindDeviceError ) ??;
605+ } ) ??;
611606 Ok ( ( ) )
612607 }
613608
0 commit comments