From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 00DAB5A026E for ; Thu, 6 Apr 2023 05:28:23 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PsRm55gPJz4xDt; Thu, 6 Apr 2023 13:28:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1680751701; bh=4BoiZo49wct/63A+FVIcWnEaijHdIGiDxVh0CFkWOBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TOGUSURwLdXNOm5ioRnmDmEmpENT7oSK5pBzS7w7n3Nv7Rgk4fCFKmjr9AgN3wanO MNcJX1CmwKXETJezymat0OtnkT1dNFwOvbDPpcQn2sMaBG0jpU7WNNVk03Bmo4WEDG 0/VBBWB+iDh8BwXdKoes7jWsBp3H3I29vekwwfsU= From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 01/14] nstool: Rename nsholder to nstool Date: Thu, 6 Apr 2023 13:28:06 +1000 Message-Id: <20230406032819.707441-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406032819.707441-1-david@gibson.dropbear.id.au> References: <20230406032819.707441-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: JWXSECJC3X2CGUURNP2IQ5IWP2X55ODL X-Message-ID-Hash: JWXSECJC3X2CGUURNP2IQ5IWP2X55ODL X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In preparation for extending what it does. Signed-off-by: David Gibson --- test/.gitignore | 2 +- test/Makefile | 4 ++-- test/lib/setup | 30 +++++++++++++++--------------- test/{nsholder.c => nstool.c} | 22 +++++++++++----------- 4 files changed, 29 insertions(+), 29 deletions(-) rename test/{nsholder.c => nstool.c} (82%) diff --git a/test/.gitignore b/test/.gitignore index fbee491..4837402 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -6,6 +6,6 @@ QEMU_EFI.fd *.raw *.raw.xz *.bin -nsholder +nstool guest-key guest-key.pub diff --git a/test/Makefile b/test/Makefile index 1341677..50d283e 100644 --- a/test/Makefile +++ b/test/Makefile @@ -58,7 +58,7 @@ TESTDATA_ASSETS = small.bin big.bin medium.bin LOCAL_ASSETS = mbuto.img mbuto.mem.img QEMU_EFI.fd \ $(DEBIAN_IMGS:%=prepared-%) $(FEDORA_IMGS:%=prepared-%) \ $(UBUNTU_NEW_IMGS:%=prepared-%) \ - nsholder guest-key guest-key.pub \ + nstool guest-key guest-key.pub \ $(TESTDATA_ASSETS) ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS) @@ -79,7 +79,7 @@ mbuto.img: passt.mbuto mbuto guest-key.pub $(TESTDATA_ASSETS) mbuto.mem.img: passt.mem.mbuto mbuto ../passt.avx2 ./mbuto/mbuto -p ./$< -c lz4 -f $@ -nsholder: nsholder.c +nstool: nstool.c $(CC) $(CFLAGS) -o $@ $^ QEMU_EFI.fd: diff --git a/test/lib/setup b/test/lib/setup index 5f8ce26..3bd434b 100755 --- a/test/lib/setup +++ b/test/lib/setup @@ -17,7 +17,7 @@ INITRAMFS="${BASEPATH}/mbuto.img" VCPUS="$( [ $(nproc) -ge 8 ] && echo 6 || echo $(( $(nproc) / 2 + 1 )) )" __mem_kib="$(sed -n 's/MemTotal:[ ]*\([0-9]*\) kB/\1/p' /proc/meminfo)" VMEM="$((${__mem_kib} / 1024 / 4))" -NSHOLDER="${BASEPATH}/nsholder" +NSTOOL="${BASEPATH}/nstool" # setup_build() - Set up pane layout for build tests setup_build() { @@ -77,8 +77,8 @@ setup_pasta() { layout_pasta - context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ${STATESETUP}/ns.hold hold" - __target_pid=$(${NSHOLDER} ${STATESETUP}/ns.hold pid) + context_run_bg unshare "unshare -rUnpf ${NSTOOL} ${STATESETUP}/ns.hold hold" + __target_pid=$(${NSTOOL} ${STATESETUP}/ns.hold pid) context_setup_nsenter ns -U -n -p --preserve-credentials -t ${__target_pid} @@ -126,9 +126,9 @@ setup_passt_in_ns() { [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P ${STATESETUP}/pasta.pid --config-net ${NSHOLDER} ${STATESETUP}/ns.hold hold" + context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P ${STATESETUP}/pasta.pid --config-net ${NSTOOL} ${STATESETUP}/ns.hold hold" wait_for [ -f "${STATESETUP}/pasta.pid" ] - __ns_pid=$(${NSHOLDER} ${STATESETUP}/ns.hold pid) + __ns_pid=$(${NSTOOL} ${STATESETUP}/ns.hold pid) context_setup_nsenter qemu "-t ${__ns_pid} -U -n -p --preserve-credentials" context_setup_nsenter ns "-t ${__ns_pid} -U -n -p --preserve-credentials" @@ -189,16 +189,16 @@ setup_two_guests() { [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_1.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg pasta_1 "./pasta ${__opts} --trace -l /tmp/pasta1.log -P ${STATESETUP}/pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 --config-net ${NSHOLDER} ${STATESETUP}/ns1.hold hold" - __ns1_pid=$(${NSHOLDER} ${STATESETUP}/ns1.hold pid) + context_run_bg pasta_1 "./pasta ${__opts} --trace -l /tmp/pasta1.log -P ${STATESETUP}/pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 --config-net ${NSTOOL} ${STATESETUP}/ns1.hold hold" + __ns1_pid=$(${NSTOOL} ${STATESETUP}/ns1.hold pid) context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pid} __opts= [ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_2.pcap" [ ${DEBUG} -eq 1 ] && __opts="${__opts} -d" [ ${TRACE} -eq 1 ] && __opts="${__opts} --trace" - context_run_bg pasta_2 "./pasta ${__opts} --trace -l /tmp/pasta2.log -P ${STATESETUP}/pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 --config-net ${NSHOLDER} ${STATESETUP}/ns2.hold hold" - __ns2_pid=$(${NSHOLDER} ${STATESETUP}/ns2.hold pid) + context_run_bg pasta_2 "./pasta ${__opts} --trace -l /tmp/pasta2.log -P ${STATESETUP}/pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 --config-net ${NSTOOL} ${STATESETUP}/ns2.hold hold" + __ns2_pid=$(${NSTOOL} ${STATESETUP}/ns2.hold pid) context_setup_nsenter passt_2 -U -n -p --preserve-credentials -t ${__ns2_pid} context_setup_nsenter qemu_1 -U -n -p --preserve-credentials -t ${__ns1_pid} @@ -284,7 +284,7 @@ teardown_passt() { # teardown_pasta() - Exit namespace, kill pasta process teardown_pasta() { - ${NSHOLDER} "${STATESETUP}/ns.hold" stop + ${NSTOOL} "${STATESETUP}/ns.hold" stop context_wait unshare teardown_context_watch ${PANE_HOST} host @@ -297,7 +297,7 @@ teardown_passt_in_ns() { context_run ns kill $(cat "${STATESETUP}/qemu.pid") context_wait qemu - ${NSHOLDER} "${STATESETUP}/ns.hold" stop + ${NSTOOL} "${STATESETUP}/ns.hold" stop context_wait pasta rm "${STATESETUP}/passt.pid" "${STATESETUP}/pasta.pid" @@ -310,8 +310,8 @@ teardown_passt_in_ns() { # teardown_two_guests() - Exit namespaces, kill qemu processes, passt and pasta teardown_two_guests() { - __ns1_pid=$(${NSHOLDER} "${STATESETUP}/ns1.hold" pid) - __ns2_pid=$(${NSHOLDER} "${STATESETUP}/ns2.hold" pid) + __ns1_pid=$(${NSTOOL} "${STATESETUP}/ns1.hold" pid) + __ns2_pid=$(${NSTOOL} "${STATESETUP}/ns2.hold" pid) nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${STATESETUP}/qemu_1.pid") nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESETUP}/qemu_2.pid") context_wait qemu_1 @@ -321,8 +321,8 @@ teardown_two_guests() { nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESETUP}/passt_2.pid") context_wait passt_1 context_wait passt_2 - ${NSHOLDER} "${STATESETUP}/ns1.hold" stop - ${NSHOLDER} "${STATESETUP}/ns2.hold" stop + ${NSTOOL} "${STATESETUP}/ns1.hold" stop + ${NSTOOL} "${STATESETUP}/ns2.hold" stop context_wait pasta_1 context_wait pasta_2 diff --git a/test/nsholder.c b/test/nstool.c similarity index 82% rename from test/nsholder.c rename to test/nstool.c index 010a051..958ece7 100644 --- a/test/nsholder.c +++ b/test/nstool.c @@ -1,23 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -/* nsholder - maintain a namespace to be entered by other processes +/* nstool - maintain a namespace to be entered by other processes * * Copyright Red Hat * Author: David Gibson * * Can run in 3 modes: * - * nsholder hold + * nstool hold * Designed to be run inside a namespace, opens a Unix domain * control socket at and waits until instructed to stop - * with "nsholder stop" - * nsholder pid - * Prints the PID of the nsholder hold process with control + * with "nstool stop" + * nstool pid + * Prints the PID of the nstool hold process with control * socket . This is given in the PID namespace where - * nsholder pid is executed, not the one where nsholder hold is + * nstool pid is executed, not the one where nstool hold is * running - * nsholder stop - * Instruct the nsholder hold with control socket at to exit. + * nstool stop + * Instruct the nstool hold with control socket at to exit. */ #define _GNU_SOURCE @@ -38,7 +38,7 @@ static void usage(void) { - die("Usage: holder hold|pid\n"); + die("Usage: nstool hold|pid\n"); } static void hold(int fd, const struct sockaddr_un *addr) @@ -53,7 +53,7 @@ static void hold(int fd, const struct sockaddr_un *addr) if (rc < 0) die("listen(): %s\n", strerror(errno)); - printf("nsholder: local PID=%d local UID=%u local GID=%u\n", + printf("nstool: local PID=%d local UID=%u local GID=%u\n", getpid(), getuid(), getgid()); do { int afd = accept(fd, NULL, NULL); @@ -103,7 +103,7 @@ static void stop(int fd, const struct sockaddr_un *addr) rc = write(fd, &buf, sizeof(buf)); if (rc < 0) - die("write(): %s\n", strerror(errno)); + die("write(): %s\n", strerror(errno)); close(fd); } -- 2.39.2