From: Alyssa Ross <alyssa.ross@unikie.com>
To: devel@spectrum-os.org
Cc: Puck Meerburg <puck@puckipedia.com>,
Ville Ilvonen <ville.ilvonen@unikie.com>
Subject: [RFC PATCH v2 02/10] img/app: don't block app startup on network online
Date: Fri, 30 Sep 2022 21:35:25 +0000 [thread overview]
Message-ID: <20220930213533.1710618-3-alyssa.ross@unikie.com> (raw)
In-Reply-To: <20220930213533.1710618-1-alyssa.ross@unikie.com>
From: Alyssa Ross <hi@alyssa.is>
Not all VMs will even have networking! So it makes more sense to put
waiting for the network in the application-specific part.
The "listen" and "wait" scripts are copied from the host system.
Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com>
---
This patch comes from before I started working on this at Unikie,
hence the non-Unikie author email.
img/app/Makefile | 2 ++
img/app/etc/mdev/iface | 2 +-
img/app/etc/mdev/listen | 12 ++++++++++++
img/app/etc/mdev/wait | 15 +++++++++++++++
img/app/etc/s6-rc/ok-all/contents | 1 +
vm/app/catgirl.nix | 1 +
vm/app/lynx.nix | 1 +
7 files changed, 33 insertions(+), 1 deletion(-)
create mode 100755 img/app/etc/mdev/listen
create mode 100755 img/app/etc/mdev/wait
diff --git a/img/app/Makefile b/img/app/Makefile
index c5a4684..a3fefc3 100644
--- a/img/app/Makefile
+++ b/img/app/Makefile
@@ -47,6 +47,8 @@ VM_FILES = \
etc/init \
etc/mdev.conf \
etc/mdev/iface \
+ etc/mdev/listen \
+ etc/mdev/wait \
etc/passwd \
etc/resolv.conf \
etc/s6-linux-init/scripts/rc.init
diff --git a/img/app/etc/mdev/iface b/img/app/etc/mdev/iface
index d8ceda5..4cdc112 100755
--- a/img/app/etc/mdev/iface
+++ b/img/app/etc/mdev/iface
@@ -33,4 +33,4 @@ foreground {
}
}
-s6-rc -u change app
+/etc/mdev/listen network-online
diff --git a/img/app/etc/mdev/listen b/img/app/etc/mdev/listen
new file mode 100755
index 0000000..6bc6f2c
--- /dev/null
+++ b/img/app/etc/mdev/listen
@@ -0,0 +1,12 @@
+#!/bin/execlineb -s1
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+
+foreground {
+ redirfd -w 2 /dev/null
+ foreground { mkdir /run/wait }
+ mkfifo /run/wait/${1}
+}
+
+redirfd -w 1 /run/wait/${1}
+echo
diff --git a/img/app/etc/mdev/wait b/img/app/etc/mdev/wait
new file mode 100755
index 0000000..3b85de8
--- /dev/null
+++ b/img/app/etc/mdev/wait
@@ -0,0 +1,15 @@
+#!/bin/execlineb -s1
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+
+foreground {
+ redirfd -w 2 /dev/null
+ foreground { mkdir /run/wait }
+ mkfifo /run/wait/${1}
+}
+
+foreground {
+ redirfd -w 1 /dev/null
+ head -1 /run/wait/${1}
+}
+rm /run/wait/${1}
diff --git a/img/app/etc/s6-rc/ok-all/contents b/img/app/etc/s6-rc/ok-all/contents
index c4ea84f..92f3ef1 100644
--- a/img/app/etc/s6-rc/ok-all/contents
+++ b/img/app/etc/s6-rc/ok-all/contents
@@ -2,3 +2,4 @@
# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
#
mdevd-coldplug
+app
diff --git a/vm/app/catgirl.nix b/vm/app/catgirl.nix
index 107ff82..79c5d8b 100644
--- a/vm/app/catgirl.nix
+++ b/vm/app/catgirl.nix
@@ -10,6 +10,7 @@ import ../../vm-lib/make-vm.nix { inherit config; } {
{ writeScript, catgirl }:
writeScript "run-catgirl" ''
#!/bin/execlineb -P
+ if { /etc/mdev/wait network-online }
foreground { printf "IRC nick (to join #spectrum): " }
backtick -E nick { head -1 }
${catgirl}/bin/catgirl -h irc.libera.chat -j "#spectrum" -n $nick
diff --git a/vm/app/lynx.nix b/vm/app/lynx.nix
index 8fc3bd6..6abaf9b 100644
--- a/vm/app/lynx.nix
+++ b/vm/app/lynx.nix
@@ -10,6 +10,7 @@ import ../../vm-lib/make-vm.nix { inherit config; } {
{ writeScript, lynx }:
writeScript "run-lynx" ''
#!/bin/execlineb -P
+ if { /etc/mdev/wait network-online }
${lynx}/bin/lynx https://spectrum-os.org
''
) { };
--
2.37.1
next prev parent reply other threads:[~2022-09-30 21:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 21:35 [RFC PATCH v2 00/10] Initial support for VM Wayland Alyssa Ross
2022-09-30 21:35 ` [RFC PATCH v2 01/10] host/start-vm: use MAP_SHARED memory for VMs Alyssa Ross
2022-09-30 21:35 ` Alyssa Ross [this message]
2022-09-30 21:35 ` [RFC PATCH v2 03/10] img/app: add Wayland over virtio-gpu support to kernel Alyssa Ross
2022-09-30 21:35 ` [RFC PATCH v2 04/10] vm-lib: add mesa drivers to VM Alyssa Ross
2022-09-30 21:35 ` [RFC PATCH v2 05/10] img/app: add support for testing virtio-gpu Alyssa Ross
2022-09-30 21:35 ` [RFC PATCH v2 06/10] img/app: add support for testing in crosvm Alyssa Ross
2022-09-30 21:35 ` [RFC PATCH v2 07/10] host/start-vm: factor out VM definition path Alyssa Ross
2022-09-30 21:35 ` [RFC PATCH v2 08/10] host: add support for Wayland in VMs Alyssa Ross
2022-09-30 21:35 ` [RFC PATCH v2 09/10] vm/app: add hello-wayland demo VM Alyssa Ross
2022-09-30 21:38 ` [RFC PATCH v2 10/10] host/start-vm: disable cloud-hypervisor sandbox Alyssa Ross
2022-09-30 21:44 ` Alyssa Ross
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=20220930213533.1710618-3-alyssa.ross@unikie.com \
--to=alyssa.ross@unikie.com \
--cc=devel@spectrum-os.org \
--cc=puck@puckipedia.com \
--cc=ville.ilvonen@unikie.com \
/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://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
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 NNTP newsgroup(s).