aboutgitcodebugslistschat
path: root/test/Makefile
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-12 20:56:20 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-13 05:32:00 +0200
commita8c32c85d5f3847a1f9ea0030beb0c338af53cd5 (patch)
tree6bc14542094830909d0c0c3f1ca127f71bef9af8 /test/Makefile
parent2f87265d8b25cbeeadfb662f2a46db00795747a3 (diff)
downloadpasst-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.gz
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.bz2
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.lz
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.xz
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.zst
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.zip
test: Add nsholder utility
In our test scripts we need to do some ugly parsing of /proc and/or pstree output in order to get the PIDs of processes running in namespaces so that we can connect to those namespaces with nsenter or pasta. This is actually a pretty tricky problem with standard tools. To determine the PID from the outside of the namespace we need to know how the process of interest is related to the unshare or pasta process (child? one of several children? grandchild?) as well as then parsing /proc or ps output. This is slightly awkward now, and will get worse with future changes I'd like to make to have processes are dispatched. The obvious solution would be to have the process of interest (which we control) report its own PID, but that doesn't work easily, because it is in a PID namepace and sees only its local PID not the global PID we need to address it from outside. To handle this, add a small custom tool, "nsholder". This takes a path and a mode parameter. In "hold" mode it will create a unix domain socket bound to the path and listening. In "pid" mode it will get the "hold"ing process's pid via the unix socket using SO_PEERCRED, which translates between PID namespaces. In "stop" mode it will send a message to the socket causing the "hold"ing process to clean up and exit. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'test/Makefile')
-rw-r--r--test/Makefile8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/Makefile b/test/Makefile
index f11c4b5..e0dc7ac 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -56,10 +56,13 @@ DOWNLOAD_ASSETS = mbuto \
$(DEBIAN_IMGS) $(FEDORA_IMGS) $(OPENSUSE_IMGS) $(UBUNTU_IMGS)
LOCAL_ASSETS = mbuto.img QEMU_EFI.fd \
$(DEBIAN_IMGS:%=prepared-%) $(FEDORA_IMGS:%=prepared-%) \
- $(UBUNTU_NEW_IMGS:%=prepared-%)
+ $(UBUNTU_NEW_IMGS:%=prepared-%) \
+ nsholder
ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS)
+CFLAGS = -Wall -Werror
+
assets: $(ASSETS)
mbuto:
@@ -68,6 +71,9 @@ mbuto:
mbuto.img: passt.mbuto mbuto
./mbuto/mbuto -p ./$< -c lz4 -f $@
+nsholder: nsholder.c
+ $(CC) $(CFLAGS) -o $@ $^
+
QEMU_EFI.fd:
./find-arm64-firmware.sh $@