@@ -313,10 +313,14 @@ def kill(self):
313313 if self .screen_pid :
314314 os .kill (self .screen_pid , signal .SIGKILL )
315315 except :
316- LOG . error (
316+ msg = (
317317 "Failed to kill Firecracker Process. Did it already die (or did the UFFD handler process die and take it down)?"
318+ if self .uffd_handler
319+ else "Failed to kill Firecracker Process. Did it already die?"
318320 )
319- LOG .error (self .log_data )
321+
322+ self ._dump_debug_information (msg )
323+
320324 raise
321325
322326 # if microvm was spawned then check if it gets killed
@@ -1058,7 +1062,9 @@ def ssh_iface(self, iface_idx=0):
10581062 user = "root" ,
10591063 host = guest_ip ,
10601064 control_path = Path (self .chroot ()) / f"ssh-{ iface_idx } .sock" ,
1061- on_error = self ._dump_debug_information ,
1065+ on_error = lambda exc : self ._dump_debug_information (
1066+ f"Failure executing command via SSH in microVM: { exc } "
1067+ ),
10621068 )
10631069 self ._connections .append (connection )
10641070 return connection
@@ -1080,17 +1086,18 @@ def thread_backtraces(self):
10801086 )
10811087 return "\n " .join (backtraces )
10821088
1083- def _dump_debug_information (self , exc : Exception ):
1089+ def _dump_debug_information (self , what : str ):
10841090 """
10851091 Dumps debug information about this microvm
10861092
10871093 Used for example when running a command inside the guest via `SSHConnection.check_output` fails.
10881094 """
1089- print (
1090- f"Failure executing command via SSH in microVM: { exc } \n \n "
1091- f"Firecracker logs:\n { self .log_data } \n "
1092- f"Thread backtraces:\n { self .thread_backtraces } "
1093- )
1095+ LOG .error (what )
1096+ LOG .error ("Firecracker logs:\n %s" , self .log_data )
1097+ if self .uffd_handler :
1098+ LOG .error ("Uffd logs:\n %s" , self .uffd_handler .log_data )
1099+ if not self ._killed :
1100+ LOG .error ("Thread backtraces:\n %s" , self .thread_backtraces )
10941101
10951102 def wait_for_ssh_up (self ):
10961103 """Wait for guest running inside the microVM to come up and respond."""
0 commit comments