@@ -243,7 +243,10 @@ def __init__(
243
243
self .vcpus_count = None
244
244
self .mem_size_bytes = None
245
245
246
- self ._numa_node = numa_node
246
+ self ._pre_cmd = []
247
+ if numa_node :
248
+ node_str = str (numa_node )
249
+ self .add_pre_cmd ([["numactl" , "-N" , node_str , "-m" , node_str ]])
247
250
248
251
# MMDS content from file
249
252
self .metadata_file = None
@@ -552,6 +555,13 @@ def pin_threads(self, first_cpu):
552
555
553
556
return first_cpu + self .vcpus_count + 2
554
557
558
+ def add_pre_cmd (self , pre_cmd ):
559
+ """Prepends commands to the command line to launch the microVM
560
+
561
+ For example, this can be used to pin the VM to a NUMA node or to trace the VM with strace.
562
+ """
563
+ self ._pre_cmd = pre_cmd + self ._pre_cmd
564
+
555
565
def spawn (
556
566
self ,
557
567
log_file = "fc.log" ,
@@ -600,10 +610,11 @@ def spawn(
600
610
# Checking the timings requires DEBUG level log messages
601
611
self .time_api_requests = False
602
612
603
- cmd = [str (self .jailer_binary_path )] + self .jailer .construct_param_list ()
604
- if self ._numa_node is not None :
605
- node = str (self ._numa_node )
606
- cmd = ["numactl" , "-N" , node , "-m" , node ] + cmd
613
+ cmd = [
614
+ * self ._pre_cmd ,
615
+ str (self .jailer_binary_path ),
616
+ * self .jailer .construct_param_list (),
617
+ ]
607
618
608
619
# When the daemonize flag is on, we want to clone-exec into the
609
620
# jailer rather than executing it via spawning a shell.
0 commit comments