-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbind_interfaces.py
More file actions
executable file
·42 lines (30 loc) · 968 Bytes
/
bind_interfaces.py
File metadata and controls
executable file
·42 lines (30 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/python2
import sys
from os import popen as _popen
from time import sleep
HUGEPAGE_SCRIPT = "setup-hugetlbfs.sh"
def popen(a, b="r"):
sleep(1)
print("%s\n" % a)
return _popen(a, b)
def insert_kmods():
popen("./insert_kernel_modules.sh", "r")
def mount_hugepages():
popen("./%s" % HUGEPAGE_SCRIPT, "r")
def bind_iface(iface):
print("binding interface %s..\n" % iface)
popen("ip link set dev %s down" % iface, "r")
#popen('./run.sh "--bind=igb_uio %s"' % iface, "r")
popen('./run.sh "--bind=vfio_pci %s"' % iface, "r")
if __name__ == "__main__":
if len(sys.argv) == 1:
sys.exit(1)
args = sys.argv[1:]
if "--insert-kernel-modules" in args:
insert_kmods()
_ = args.pop(args.index("--insert-kernel-modules"))
if "--mount-hugepages" in args:
mount_hugepages()
_ = args.pop(args.index("--mount-hugepages"))
for iface in args:
bind_iface(iface)