File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -222,3 +222,26 @@ def run_in_netns(cmd):
222222
223223 # add a route on the host for the clone address
224224 run (f"ip route add { ingress_ipv4 } via { veth_guest_ip } " )
225+
226+ def trace_cmd_guest (self , fns , cmd , port = 4321 ):
227+ """Run trace-cmd on the guest, but transfer the data directly to the host."""
228+ docker_apt_install ("trace-cmd" )
229+ print ("host> trace-cmd listen" )
230+ _proc = subprocess .Popen (
231+ [
232+ "ip" ,
233+ "netns" ,
234+ "exec" ,
235+ self .vm .netns .id ,
236+ "trace-cmd" ,
237+ "listen" ,
238+ "-p" ,
239+ str (port ),
240+ ]
241+ )
242+ print ("guest> trace-cmd record" )
243+ host_ip = self .vm .iface ["eth0" ]["iface" ].host_ip
244+ _guest_ps = self .vm .ssh .run (
245+ f"trace-cmd record -N { host_ip } :{ port } -p function { " " .join (fns )} { cmd } "
246+ )
247+ return list (Path ("." ).glob ("trace.*.dat" ))
Original file line number Diff line number Diff line change @@ -68,7 +68,6 @@ def parse_byte_size(param):
6868else :
6969 bins = get_firecracker_binaries ()
7070
71- print ("This step may take a while to compile Firecracker ..." )
7271cpu_template = None
7372if args .cpu_template_path is not None :
7473 cpu_template = json .loads (args .cpu_template_path .read_text ())
@@ -96,3 +95,6 @@ def parse_byte_size(param):
9695uvm2 .add_net_iface ()
9796uvm2 .basic_config (vcpu_count = args .vcpus , mem_size_mib = args .guest_mem_size // 2 ** 20 )
9897uvm2 .start ()
98+ # trace-cmd needs this (DNS resolution?)
99+ uvm2 .help .enable_ip_forwarding ()
100+ files = uvm2 .help .trace_cmd_guest (["-l" , "read_msr" ], cmd = "sleep 5" )
You can’t perform that action at this time.
0 commit comments