From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 49A145A026F for ; Thu, 6 Apr 2023 04:50:15 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PsQvz6Y41z4xFk; Thu, 6 Apr 2023 12:50:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1680749407; bh=25DcgCHUMH0CbWvbCKRcgQy1Ls2xyvzsQgF56n9yPCE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ks028GVGPlaVIraKYKCIbnWfM2s/RMrzoB1lD4qRtz0dyrpbD+zjpe83QEAlaWszh 20bBSRFSqi01AJeLkbMd9k5CcPoxd8jqMbPkvQQDvwBw/Xhm6W5ugE7xLbMKZ2CGOR FPVeOC7teALtJ3WMWm/Ql+MCGFsBSPbpjKpwx/GA= Date: Thu, 6 Apr 2023 11:14:38 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 12/14] test: Use "nstool exec" to slightly simplify tests Message-ID: References: <20230404014638.3225556-1-david@gibson.dropbear.id.au> <20230404014638.3225556-13-david@gibson.dropbear.id.au> <20230405135912.4b40c5a0@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="J5ibMOSVcayC3zUf" Content-Disposition: inline In-Reply-To: <20230405135912.4b40c5a0@elisabeth> Message-ID-Hash: 4ORF5D62ZEJYTGQE2XPDZLRJ6EMOJLS2 X-Message-ID-Hash: 4ORF5D62ZEJYTGQE2XPDZLRJ6EMOJLS2 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: passt-dev@passt.top 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: --J5ibMOSVcayC3zUf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 05, 2023 at 01:59:12PM +0200, Stefano Brivio wrote: > On Tue, 4 Apr 2023 11:46:36 +1000 > David Gibson wrote: >=20 > > Using this, rather than using "nstool info" to get the pid then manually > > connecting with nsenter makes things a little simpler. > >=20 > > Signed-off-by: David Gibson > > --- > > test/lib/context | 14 +++++++++----- > > test/lib/setup | 33 +++++++++++++-------------------- > > test/run | 2 +- > > 3 files changed, 23 insertions(+), 26 deletions(-) > >=20 > > diff --git a/test/lib/context b/test/lib/context > > index ee6b683..d9d8260 100644 > > --- a/test/lib/context > > +++ b/test/lib/context > > @@ -13,6 +13,8 @@ > > # Copyright Red Hat > > # Author: David Gibson > > =20 > > +NSTOOL=3D"${BASEPATH}/nstool" > > + > > # context_setup_common() - Create outline of a new context > > # $1: Context name > > context_setup_common() { > > @@ -30,15 +32,17 @@ context_setup_host() { > > echo sh -c > "${__enter}" > > } > > =20 > > -# context_setup_nsenter() - Create a new context for running commands = in a namespace > > +# context_setup_nstool() - Create a new context for running commands w= ith nstool exec > > # $1: Context name > > -# $2: Namespace PID > > -context_setup_nsenter() { > > +# $2: nstool control socket > > +context_setup_nstool() { > > __name=3D"$1" > > - shift > > + __sock=3D"$2" > > __enter=3D"${STATESETUP}/context_${__name}.enter" > > + # Wait for the ns to be ready > > + ${NSTOOL} info -w "${__sock}" > /dev/null >=20 > Bad indentation here. Fixed. Drat, emacs isn't doing what I expected here. [snip] > > =20 > > # teardown_two_guests() - Exit namespaces, kill qemu processes, passt = and pasta > > teardown_two_guests() { > > - __ns1_pid=3D$(${NSTOOL} info -pw "${STATESETUP}/ns1.hold") > > - __ns2_pid=3D$(${NSTOOL} info -pw "${STATESETUP}/ns2.hold") > > - nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${ST= ATESETUP}/qemu_1.pid") > > - nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${ST= ATESETUP}/qemu_2.pid") > > + ${NSTOOL} exec ${STATESETUP}/ns1.hold -- kill $(cat "${STATESE= TUP}/qemu_1.pid") > > + ${NSTOOL} exec ${STATESETUP}/ns2.hold -- kill $(cat "${STATESE= TUP}/qemu_2.pid") > > context_wait qemu_1 > > context_wait qemu_2 > > =20 > > - nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${ST= ATESETUP}/passt_1.pid") > > - nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${ST= ATESETUP}/passt_2.pid") > > + ${NSTOOL} exec ${STATESETUP}/ns1.hold -- kill $(cat "${STATESE= TUP}/passt_1.pid") > > + ${NSTOOL} exec ${STATESETUP}/ns2.hold -- kill $(cat "${STATESE= TUP}/passt_2.pid") >=20 > ...and here. Fixed here as well. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --J5ibMOSVcayC3zUf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmQuHPgACgkQzQJF27ox 2Gd4uA/+OR/9JFtNra/GoPlNzCLF2iae/JTan75VintQ7K4gVDga0qBFCcsRsZeO 9+50mMFx0oHu/e2bL17GAt2lQQqmil4izEqBxJXt2XYTW77btY1EASwuGv2es2DO ZjKGn5CKXutyPusqpDrbg04meeKC0YT00VMuBklamcy8peoNYBCkfN6v7hmdR55e YTtxjgf6hELkcLvMlRTA7AzbZShxFJpMmqc4C5o2JVXMQMQrw16TtkeS9F0+j2dV kuDB0ylrP37XhZ4CtzG415Jm6At+YQlnbfqLJQEXyIw+5aVvN1ADIVG5MhocNlUH wiweCWX7jFTdT9ZxCnY4soepfSVzFAJ7KFLqGcOPqVRx/HGe9gYVe6PQYVRtoRt1 uFBz85e6UbTugVcBXB4hfX80Q/i4Gh7q3aA3FRZaGqwA4pKaW5C9yJXOYhDYFWRh zrdYH9eXA95LhhpiNOJv1oDGv9JP9JvbmbEGIVrLKKUSuHj458Bp9Okj5griG3vc wZBIJzuPTn4PbBuhETK8Y6GOymCTzdsxsnArFkWmYyMpI+MR0g44xPIjBJAiS59o iCzMXXjobtxUImISBEtK3TJY3+cJCH6x87R45s/UxCNIqtL2B2c6a2UL44mS2MgD yXLBNWxHDlTIR5HSDjdSsiTeEj1cevIpRfSc4zN3buiFaaqfiqQ= =iZtz -----END PGP SIGNATURE----- --J5ibMOSVcayC3zUf--