File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ pub struct NitroEnclave {
6161
6262impl NitroEnclave {
6363 /// Run an application within a nitro enclave.
64- pub fn run ( mut self ) -> Result < ( ) , Error > {
64+ pub fn run ( mut self ) -> Result < i32 , Error > {
6565 // Collect all launch parameters (rootfs, execution arguments, device proxies) and establish
6666 // an enclave argument writer to write this data to the nitro enclave when started.
6767 let rootfs_archive = self . rootfs_archive ( ) . map_err ( Error :: RootFsArchive ) ?;
@@ -98,21 +98,11 @@ impl NitroEnclave {
9898 // terminated by the enclave (by closing the vsock connection).
9999 proxies. run ( cid) . map_err ( Error :: DeviceProxy ) ?;
100100
101- // In debug mode, the console device doesn't shut down until the enclave itself exits. Thus,
102- // libkrun will be unable to retrieve the shutdown code from the enclave.
103- if !self . debug {
104- // Retrieve the application return code from the enclave.
105- let ret = self
106- . shutdown_ret ( retcode_listener)
107- . map_err ( Error :: ReturnCodeListener ) ?;
108-
109- // A non-zero return code indicates an error. Wrap this code within an Error object.
110- if ret != 0 {
111- return Err ( Error :: AppReturn ( ret) ) ;
112- }
113- }
101+ let ret = self
102+ . shutdown_ret ( retcode_listener)
103+ . map_err ( Error :: ReturnCodeListener ) ?;
114104
115- Ok ( ( ) )
105+ Ok ( ret )
116106 }
117107
118108 /// Start a nitro enclave.
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use std::{fmt, io};
66/// Error in the running of a nitro enclave.
77#[ derive( Debug ) ]
88pub enum Error {
9- // Application running within the enclave returned a non-zero return code.
10- AppReturn ( i32 ) ,
119 // Argument writing process.
1210 ArgsWrite ( args_writer:: Error ) ,
1311 // Error in device proxy execution.
@@ -23,7 +21,6 @@ pub enum Error {
2321impl fmt:: Display for Error {
2422 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
2523 let msg = match self {
26- Self :: AppReturn ( ret) => format ! ( "app returned non-zero return code: {ret}" ) ,
2724 Self :: ArgsWrite ( e) => format ! ( "enclave VM argument writer error: {e}" ) ,
2825 Self :: DeviceProxy ( e) => format ! ( "device proxy error: {e}" ) ,
2926 Self :: ReturnCodeListener ( e) => {
Original file line number Diff line number Diff line change @@ -2703,7 +2703,7 @@ fn krun_start_enter_nitro(ctx_id: u32) -> i32 {
27032703 } ;
27042704
27052705 match enclave. run ( ) {
2706- Ok ( ( ) ) => KRUN_SUCCESS ,
2706+ Ok ( ret ) => ret ,
27072707 Err ( e) => {
27082708 error ! ( "Error running nitro enclave: {e}" ) ;
27092709
You can’t perform that action at this time.
0 commit comments