@@ -10,17 +10,23 @@ extern crate alloc;
1010use  core:: future:: poll_fn; 
1111use  core:: task:: Poll ; 
1212
13+ #[ cfg( feature = "vmcall-raw" ) ]  
14+ use  alloc:: format; 
1315#[ cfg( feature = "policy_v2" ) ]  
1416use  alloc:: string:: String ; 
1517#[ cfg( feature = "vmcall-raw" ) ]  
1618use  alloc:: vec:: Vec ; 
1719use  log:: info; 
20+ #[ cfg( feature = "vmcall-raw" ) ]  
21+ use  log:: Level ; 
1822use  migtd:: event_log:: * ; 
1923#[ cfg( not( feature = "vmcall-raw" ) ) ]  
2024use  migtd:: migration:: data:: MigrationInformation ; 
2125#[ cfg( feature = "vmcall-raw" ) ]  
2226use  migtd:: migration:: data:: WaitForRequestResponse ; 
2327use  migtd:: migration:: session:: * ; 
28+ #[ cfg( feature = "vmcall-raw" ) ]  
29+ use  migtd:: migration:: logging:: * ; 
2430use  migtd:: migration:: MigrationResult ; 
2531use  migtd:: { config,  event_log,  migration} ; 
2632use  spin:: Mutex ; 
@@ -39,6 +45,12 @@ pub extern "C" fn main() {
3945pub  fn  runtime_main ( )  { 
4046    let  _ = td_logger:: init ( ) ; 
4147
48+     // Create LogArea per vCPU 
49+     #[ cfg( feature = "vmcall-raw" ) ]  
50+     { 
51+         let  _ = create_logarea ( ) ; 
52+     } 
53+ 
4254    // Dump basic information of MigTD 
4355    basic_info ( ) ; 
4456
@@ -230,28 +242,106 @@ fn handle_pre_mig() {
230242                                . await 
231243                                . map ( |_| MigrationResult :: Success ) 
232244                                . unwrap_or_else ( |e| e) ; 
245+                             if  status == MigrationResult :: Success  { 
246+                                 entrylog ( 
247+                                     & format ! ( "Successfully completed key exchange\n " ) . into_bytes ( ) , 
248+                                     Level :: Trace , 
249+                                     wfr_info. mig_info . mig_request_id , 
250+                                 ) ; 
251+                             }  else  { 
252+                                 entrylog ( 
253+                                     & format ! ( 
254+                                         "Failure during key exchange, status code: {:x}\n " , 
255+                                         status. clone( )  as  u8 
256+                                     ) 
257+                                     . into_bytes ( ) , 
258+                                     Level :: Error , 
259+                                     wfr_info. mig_info . mig_request_id , 
260+                                 ) ; 
261+                             } 
233262                            let  _ = report_status ( 
234263                                status as  u8 , 
235264                                wfr_info. mig_info . mig_request_id , 
236265                                & data, 
237266                            ) 
238267                            . await ; 
268+                             entrylog ( 
269+                                 & format ! ( "ReportStatus for key exchange completed\n " ) . into_bytes ( ) , 
270+                                 Level :: Trace , 
271+                                 wfr_info. mig_info . mig_request_id , 
272+                             ) ; 
239273                            REQUESTS . lock ( ) . remove ( & wfr_info. mig_info . mig_request_id ) ; 
240274                        } 
241275                        WaitForRequestResponse :: GetTdReport ( wfr_info)  => { 
242-                             let  status = get_tdreport ( & wfr_info. reportdata ,  & mut  data) 
243-                                 . await 
244-                                 . map ( |_| MigrationResult :: Success ) 
245-                                 . unwrap_or_else ( |e| e) ; 
276+                             let  status = get_tdreport ( 
277+                                 & wfr_info. reportdata , 
278+                                 & mut  data, 
279+                                 wfr_info. mig_request_id , 
280+                             ) 
281+                             . await 
282+                             . map ( |_| MigrationResult :: Success ) 
283+                             . unwrap_or_else ( |e| e) ; 
284+                             if  status == MigrationResult :: Success  { 
285+                                 entrylog ( 
286+                                     & format ! ( "Successfully completed get TDREPORT\n " ) . into_bytes ( ) , 
287+                                     Level :: Trace , 
288+                                     wfr_info. mig_request_id , 
289+                                 ) ; 
290+                             }  else  { 
291+                                 entrylog ( 
292+                                     & format ! ( 
293+                                         "Failure during get TDREPORT, status code: {:x}\n " , 
294+                                         status. clone( )  as  u8 
295+                                     ) 
296+                                     . into_bytes ( ) , 
297+                                     Level :: Error , 
298+                                     wfr_info. mig_request_id , 
299+                                 ) ; 
300+                             } 
246301                            let  _ =
247302                                report_status ( status as  u8 ,  wfr_info. mig_request_id ,  & data) . await ; 
303+                             entrylog ( 
304+                                 & format ! ( "ReportStatus for get TDREPORT completed\n " ) . into_bytes ( ) , 
305+                                 Level :: Trace , 
306+                                 wfr_info. mig_request_id , 
307+                             ) ; 
248308                            REQUESTS . lock ( ) . remove ( & wfr_info. mig_request_id ) ; 
249309                        } 
250310                        WaitForRequestResponse :: EnableLogArea ( wfr_info)  => { 
251-                             // TODO: support this feature 
252-                             let  status = MigrationResult :: UnsupportedOperationError ; 
311+                             let  status = enable_logarea ( 
312+                                 wfr_info. log_max_level , 
313+                                 wfr_info. mig_request_id , 
314+                                 & mut  data, 
315+                             ) 
316+                             . await 
317+                             . map ( |_| MigrationResult :: Success ) 
318+                             . unwrap_or_else ( |e| e) ; 
319+                             if  status == MigrationResult :: Success  { 
320+                                 entrylog ( 
321+                                     & format ! ( "Successfully completed Enable LogArea\n " ) 
322+                                         . into_bytes ( ) , 
323+                                     Level :: Trace , 
324+                                     wfr_info. mig_request_id , 
325+                                 ) ; 
326+                             }  else  { 
327+                                 entrylog ( 
328+                                     & format ! ( 
329+                                         "Failure during Enable LogArea, status code: {:x}\n " , 
330+                                         status. clone( )  as  u8 
331+                                     ) 
332+                                     . into_bytes ( ) , 
333+                                     Level :: Error , 
334+                                     wfr_info. mig_request_id , 
335+                                 ) ; 
336+                             } 
253337                            let  _ =
254338                                report_status ( status as  u8 ,  wfr_info. mig_request_id ,  & data) . await ; 
339+                             entrylog ( 
340+                                 & format ! ( "ReportStatus for Enable LogArea completed\n " ) 
341+                                     . into_bytes ( ) , 
342+                                 Level :: Trace , 
343+                                 wfr_info. mig_request_id , 
344+                             ) ; 
255345                            REQUESTS . lock ( ) . remove ( & wfr_info. mig_request_id ) ; 
256346                        } 
257347                    } 
0 commit comments