public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH 2/2] doc/demo: Clone and use mbuto in init namespace
Date: Sat, 17 Sep 2022 01:55:19 +0200	[thread overview]
Message-ID: <20220916235519.2399943-3-sbrivio@redhat.com> (raw)
In-Reply-To: <20220916235519.2399943-1-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1949 bytes --]

...and not in pasta's namespace: the fakeroot(1) version shipping
with (at least) Fedora 36 assumes "nested" operation as it sees that
the UID is 0, and claims it's not supported.

Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
 doc/demo.sh | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/doc/demo.sh b/doc/demo.sh
index f704ed4..ed71ffb 100755
--- a/doc/demo.sh
+++ b/doc/demo.sh
@@ -128,6 +128,19 @@ start_pasta_delayed() {
 	exit 0
 }
 
+# start_mbuto_delayed() - Run mbuto once, and if, $DEMO_DIR/mbuto.wait is gone
+start_mbuto_delayed() {
+	trap '' EXIT
+	while [ -d "${DEMO_DIR}/mbuto.wait" ]; do sleep 1; done
+	cmd git -C "${DEMO_DIR}" clone git://mbuto.sh/mbuto
+	echo
+	cmd "${DEMO_DIR}/mbuto/mbuto" \
+		-p "$(realpath "${0}")" -f "${DEMO_DIR}/demo.img"
+
+	mkdir "${DEMO_DIR}/mbuto.done"
+	exit 0
+}
+
 # into_ns() - Entry point and demo script to run inside new namespace
 into_ns() {
 	echo "We're in the new namespace now."
@@ -204,11 +217,8 @@ into_ns() {
 		exit 0
 	fi
 
-	cmd git -C "${DEMO_DIR}" clone git://mbuto.sh/mbuto
-	echo
-	cmd "${DEMO_DIR}/mbuto/mbuto" \
-		-p "$(realpath "${0}")" -f "${DEMO_DIR}/demo.img"
-	echo
+	rmdir "${DEMO_DIR}/mbuto.wait"
+	while [ ! -d "${DEMO_DIR}/mbuto.done" ]; do sleep 1; done
 	echo "The guest image is ready. The next step will start the guest."
 	echo "Use ^C to terminate it."
 	next
@@ -229,6 +239,7 @@ trap cleanup EXIT INT
 
 DEMO_DIR="$(mktemp -d)"
 mkdir "${DEMO_DIR}/pasta.wait"
+mkdir "${DEMO_DIR}/mbuto.wait"
 
 echo "This script sets up a network and user namespace using pasta(1), then"
 echo "starts a virtual machine in it, connected via passt(1), pausing at every"
@@ -242,6 +253,7 @@ echo "of this script from there."
 next
 
 start_pasta_delayed &
+start_mbuto_delayed &
 DEMO_DIR="${DEMO_DIR}" cmd unshare -rUn "${0}" into_ns
 
 exit 0
-- 
@@ -128,6 +128,19 @@ start_pasta_delayed() {
 	exit 0
 }
 
+# start_mbuto_delayed() - Run mbuto once, and if, $DEMO_DIR/mbuto.wait is gone
+start_mbuto_delayed() {
+	trap '' EXIT
+	while [ -d "${DEMO_DIR}/mbuto.wait" ]; do sleep 1; done
+	cmd git -C "${DEMO_DIR}" clone git://mbuto.sh/mbuto
+	echo
+	cmd "${DEMO_DIR}/mbuto/mbuto" \
+		-p "$(realpath "${0}")" -f "${DEMO_DIR}/demo.img"
+
+	mkdir "${DEMO_DIR}/mbuto.done"
+	exit 0
+}
+
 # into_ns() - Entry point and demo script to run inside new namespace
 into_ns() {
 	echo "We're in the new namespace now."
@@ -204,11 +217,8 @@ into_ns() {
 		exit 0
 	fi
 
-	cmd git -C "${DEMO_DIR}" clone git://mbuto.sh/mbuto
-	echo
-	cmd "${DEMO_DIR}/mbuto/mbuto" \
-		-p "$(realpath "${0}")" -f "${DEMO_DIR}/demo.img"
-	echo
+	rmdir "${DEMO_DIR}/mbuto.wait"
+	while [ ! -d "${DEMO_DIR}/mbuto.done" ]; do sleep 1; done
 	echo "The guest image is ready. The next step will start the guest."
 	echo "Use ^C to terminate it."
 	next
@@ -229,6 +239,7 @@ trap cleanup EXIT INT
 
 DEMO_DIR="$(mktemp -d)"
 mkdir "${DEMO_DIR}/pasta.wait"
+mkdir "${DEMO_DIR}/mbuto.wait"
 
 echo "This script sets up a network and user namespace using pasta(1), then"
 echo "starts a virtual machine in it, connected via passt(1), pausing at every"
@@ -242,6 +253,7 @@ echo "of this script from there."
 next
 
 start_pasta_delayed &
+start_mbuto_delayed &
 DEMO_DIR="${DEMO_DIR}" cmd unshare -rUn "${0}" into_ns
 
 exit 0
-- 
2.35.1


      parent reply	other threads:[~2022-09-16 23:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 23:55 [PATCH 0/2] doc/demo: Fix two issues seen on Fedora 36 Stefano Brivio
2022-09-16 23:55 ` [PATCH 1/2] doc/demo: Drop /sbin from dhclient command, pass script file explicitly Stefano Brivio
2022-09-17  3:23   ` David Gibson
2022-09-17  8:44     ` Stefano Brivio
2022-09-17  9:50       ` David Gibson
2022-09-16 23:55 ` Stefano Brivio [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220916235519.2399943-3-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).