File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,18 +79,18 @@ impl KvmVm {
7979 }
8080
8181 pub fn create_guest_memfd ( config : & VmConfig , fd : & OwnedFd ) -> Result < Option < OwnedFd > > {
82- let memfd = if let Some ( Coco :: AmdSnp { .. } ) = & config. coco {
83- let mut request = KvmCreateGuestMemfd {
84- size : 1 << 48 ,
85- ..Default :: default ( )
86- } ;
87- let ret = unsafe { kvm_create_guest_memfd ( fd, & mut request) }
88- . context ( kvm_error:: GuestMemfd ) ?;
89- Some ( unsafe { OwnedFd :: from_raw_fd ( ret) } )
90- } else {
91- None
82+ let Some ( coco) = & config. coco else {
83+ return Ok ( None ) ;
84+ } ;
85+ if !matches ! ( coco, Coco :: AmdSnp { .. } | Coco :: IntelTdx { .. } ) {
86+ return Ok ( None ) ;
87+ }
88+ let mut gmem = KvmCreateGuestMemfd {
89+ size : 1 << 48 ,
90+ ..Default :: default ( )
9291 } ;
93- Ok ( memfd)
92+ let fd = unsafe { kvm_create_guest_memfd ( fd, & mut gmem) } . context ( kvm_error:: GuestMemfd ) ?;
93+ Ok ( Some ( unsafe { OwnedFd :: from_raw_fd ( fd) } ) )
9494 }
9595
9696 pub fn init ( & self , config : & VmConfig ) -> Result < ( ) > {
You can’t perform that action at this time.
0 commit comments