@@ -61,13 +61,13 @@ impl std::fmt::Display for VhostUserHandlerError {
61
61
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
62
62
match self {
63
63
VhostUserHandlerError :: CreateVring ( e) => {
64
- write ! ( f, "failed to create vring: {}" , e )
64
+ write ! ( f, "failed to create vring: {e}" )
65
65
}
66
66
VhostUserHandlerError :: CreateEpollHandler ( e) => {
67
- write ! ( f, "failed to create vring epoll handler: {}" , e )
67
+ write ! ( f, "failed to create vring epoll handler: {e}" )
68
68
}
69
69
VhostUserHandlerError :: SpawnVringWorker ( e) => {
70
- write ! ( f, "failed spawning the vring worker: {}" , e )
70
+ write ! ( f, "failed spawning the vring worker: {e}" )
71
71
}
72
72
VhostUserHandlerError :: MissingMemoryMapping => write ! ( f, "Missing memory mapping" ) ,
73
73
}
@@ -318,9 +318,7 @@ where
318
318
region. mmap_region ( file) ?,
319
319
GuestAddress ( region. guest_phys_addr ) ,
320
320
)
321
- . map_err ( |e| {
322
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
323
- } ) ?;
321
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
324
322
mappings. push ( AddrMapping {
325
323
#[ cfg( feature = "postcopy" ) ]
326
324
local_addr : guest_region. as_ptr ( ) as u64 ,
@@ -331,19 +329,16 @@ where
331
329
regions. push ( guest_region) ;
332
330
}
333
331
334
- let mem = GuestMemoryMmap :: from_regions ( regions) . map_err ( |e| {
335
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
336
- } ) ?;
332
+ let mem = GuestMemoryMmap :: from_regions ( regions)
333
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
337
334
338
335
// Updating the inner GuestMemory object here will cause all our vrings to
339
336
// see the new one the next time they call to `atomic_mem.memory()`.
340
337
self . atomic_mem . lock ( ) . unwrap ( ) . replace ( mem) ;
341
338
342
339
self . backend
343
340
. update_memory ( self . atomic_mem . clone ( ) )
344
- . map_err ( |e| {
345
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
346
- } ) ?;
341
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
347
342
self . mappings = mappings;
348
343
349
344
Ok ( ( ) )
@@ -377,15 +372,15 @@ where
377
372
. ok_or ( VhostUserError :: InvalidParam ) ?;
378
373
379
374
if !self . mappings . is_empty ( ) {
380
- let desc_table = self . vmm_va_to_gpa ( descriptor ) . map_err ( |e| {
381
- VhostUserError :: ReqHandlerError ( io :: Error :: new ( io :: ErrorKind :: Other , e ) )
382
- } ) ?;
383
- let avail_ring = self . vmm_va_to_gpa ( available ) . map_err ( |e| {
384
- VhostUserError :: ReqHandlerError ( io :: Error :: new ( io :: ErrorKind :: Other , e ) )
385
- } ) ?;
386
- let used_ring = self . vmm_va_to_gpa ( used ) . map_err ( |e| {
387
- VhostUserError :: ReqHandlerError ( io :: Error :: new ( io :: ErrorKind :: Other , e ) )
388
- } ) ?;
375
+ let desc_table = self
376
+ . vmm_va_to_gpa ( descriptor )
377
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io :: Error :: other ( e ) ) ) ?;
378
+ let avail_ring = self
379
+ . vmm_va_to_gpa ( available )
380
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io :: Error :: other ( e ) ) ) ?;
381
+ let used_ring = self
382
+ . vmm_va_to_gpa ( used )
383
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io :: Error :: other ( e ) ) ) ?;
389
384
vring
390
385
. set_queue_info ( desc_table, avail_ring, used_ring)
391
386
. map_err ( |_| VhostUserError :: InvalidParam ) ?;
@@ -575,10 +570,7 @@ where
575
570
fn get_shared_object ( & mut self , uuid : VhostUserSharedMsg ) -> VhostUserResult < File > {
576
571
match self . backend . get_shared_object ( uuid) {
577
572
Ok ( shared_file) => Ok ( shared_file) ,
578
- Err ( e) => Err ( VhostUserError :: ReqHandlerError ( io:: Error :: new (
579
- io:: ErrorKind :: Other ,
580
- e,
581
- ) ) ) ,
573
+ Err ( e) => Err ( VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ,
582
574
}
583
575
}
584
576
@@ -614,9 +606,7 @@ where
614
606
region. mmap_region ( file) ?,
615
607
GuestAddress ( region. guest_phys_addr ) ,
616
608
)
617
- . map_err ( |e| {
618
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
619
- } ) ?,
609
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?,
620
610
) ;
621
611
622
612
let addr_mapping = AddrMapping {
@@ -631,17 +621,13 @@ where
631
621
. atomic_mem
632
622
. memory ( )
633
623
. insert_region ( guest_region)
634
- . map_err ( |e| {
635
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
636
- } ) ?;
624
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
637
625
638
626
self . atomic_mem . lock ( ) . unwrap ( ) . replace ( mem) ;
639
627
640
628
self . backend
641
629
. update_memory ( self . atomic_mem . clone ( ) )
642
- . map_err ( |e| {
643
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
644
- } ) ?;
630
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
645
631
646
632
self . mappings . push ( addr_mapping) ;
647
633
@@ -653,17 +639,13 @@ where
653
639
. atomic_mem
654
640
. memory ( )
655
641
. remove_region ( GuestAddress ( region. guest_phys_addr ) , region. memory_size )
656
- . map_err ( |e| {
657
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
658
- } ) ?;
642
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
659
643
660
644
self . atomic_mem . lock ( ) . unwrap ( ) . replace ( mem) ;
661
645
662
646
self . backend
663
647
. update_memory ( self . atomic_mem . clone ( ) )
664
- . map_err ( |e| {
665
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
666
- } ) ?;
648
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
667
649
668
650
self . mappings
669
651
. retain ( |mapping| mapping. gpa_base != region. guest_phys_addr ) ;
@@ -697,9 +679,7 @@ where
697
679
. non_blocking ( true )
698
680
. user_mode_only ( false )
699
681
. create ( )
700
- . map_err ( |e| {
701
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
702
- } ) ?;
682
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
703
683
704
684
// We need to duplicate the uffd fd because we need both
705
685
// to return File with fd and store fd inside uffd.
@@ -725,8 +705,7 @@ where
725
705
#[ cfg( feature = "postcopy" ) ]
726
706
fn postcopy_listen ( & mut self ) -> VhostUserResult < ( ) > {
727
707
let Some ( ref uffd) = self . uffd else {
728
- return Err ( VhostUserError :: ReqHandlerError ( io:: Error :: new (
729
- io:: ErrorKind :: Other ,
708
+ return Err ( VhostUserError :: ReqHandlerError ( io:: Error :: other (
730
709
"No registered UFFD handler" ,
731
710
) ) ) ;
732
711
} ;
@@ -736,9 +715,7 @@ where
736
715
mapping. local_addr as * mut libc:: c_void ,
737
716
mapping. size as usize ,
738
717
)
739
- . map_err ( |e| {
740
- VhostUserError :: ReqHandlerError ( io:: Error :: new ( io:: ErrorKind :: Other , e) )
741
- } ) ?;
718
+ . map_err ( |e| VhostUserError :: ReqHandlerError ( io:: Error :: other ( e) ) ) ?;
742
719
}
743
720
744
721
Ok ( ( ) )
0 commit comments