patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Demi Marie Obenour <demiobenour@gmail.com>
To: Spectrum OS Development <devel@spectrum-os.org>
Cc: Alyssa Ross <hi@alyssa.is>, Demi Marie Obenour <demiobenour@gmail.com>
Subject: [PATCH] host/rootfs: Add scripts to access a VM by name
Date: Fri, 05 Dec 2025 05:06:35 -0500	[thread overview]
Message-ID: <20251205-vm-ops-by-name-v1-1-68617d6b48bb@gmail.com> (raw)

This is much more convenient than having to find a VM's ID.

In the future, the programs that take a VM ID should be the suffixed
ones, but this change avoids having to change any tests and so is
simpler.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
 host/rootfs/file-list.mk                     | 3 +++
 host/rootfs/image/usr/bin/vm-console-by-name | 9 +++++++++
 host/rootfs/image/usr/bin/vm-start-by-name   | 9 +++++++++
 host/rootfs/image/usr/bin/vm-stop-by-name    | 9 +++++++++
 4 files changed, 30 insertions(+)

diff --git a/host/rootfs/file-list.mk b/host/rootfs/file-list.mk
index df22bce87f4685eda26382b4e0b0b6fd21025c7a..fd21034320a3de6f96a8eb229214b041612709e8 100644
--- a/host/rootfs/file-list.mk
+++ b/host/rootfs/file-list.mk
@@ -59,9 +59,12 @@ FILES = \
 	image/usr/bin/run-vmm \
 	image/usr/bin/spectrum-update \
 	image/usr/bin/vm-console \
+	image/usr/bin/vm-console-by-name \
 	image/usr/bin/vm-import \
 	image/usr/bin/vm-start \
+	image/usr/bin/vm-start-by-name \
 	image/usr/bin/vm-stop \
+	image/usr/bin/vm-stop-by-name \
 	image/usr/bin/xdg-open \
 	image/usr/libexec/net-add \
 	image/usr/share/dbus-1/services/org.freedesktop.portal.Documents.service
diff --git a/host/rootfs/image/usr/bin/vm-console-by-name b/host/rootfs/image/usr/bin/vm-console-by-name
new file mode 100755
index 0000000000000000000000000000000000000000..a302b463ef1bd2c9ae180b6b2b9eae45a26856d6
--- /dev/null
+++ b/host/rootfs/image/usr/bin/vm-console-by-name
@@ -0,0 +1,9 @@
+#!/bin/execlineb -WS1
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
+# SPDX-FileCopyrightText: 2022-2023, 2025 Alyssa Ross <hi@alyssa.is>
+backtick -E vm_id {
+  backtick -E id_path { readlink /run/vm/by-name/${1} }
+  basename -- $id_path
+}
+vm-console $vm_id
diff --git a/host/rootfs/image/usr/bin/vm-start-by-name b/host/rootfs/image/usr/bin/vm-start-by-name
new file mode 100755
index 0000000000000000000000000000000000000000..438a4a4610ddc9dea3394503e8d5e635468fbddd
--- /dev/null
+++ b/host/rootfs/image/usr/bin/vm-start-by-name
@@ -0,0 +1,9 @@
+#!/bin/execlineb -WS1
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
+# SPDX-FileCopyrightText: 2022-2023, 2025 Alyssa Ross <hi@alyssa.is>
+backtick -E vm_id {
+  backtick -E id_path { readlink /run/vm/by-name/${1} }
+  basename -- $id_path
+}
+vm-start $vm_id
diff --git a/host/rootfs/image/usr/bin/vm-stop-by-name b/host/rootfs/image/usr/bin/vm-stop-by-name
new file mode 100755
index 0000000000000000000000000000000000000000..07ca686b5ace86aceb0fdc0f9ace8ff3859f2b37
--- /dev/null
+++ b/host/rootfs/image/usr/bin/vm-stop-by-name
@@ -0,0 +1,9 @@
+#!/bin/execlineb -WS1
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
+# SPDX-FileCopyrightText: 2022-2023, 2025 Alyssa Ross <hi@alyssa.is>
+backtick -E vm_id {
+  backtick -E id_path { readlink /run/vm/by-name/${1} }
+  basename -- $id_path
+}
+vm-stop $vm_id

---
base-commit: a13d3403c1ddbb8dbbbdb05416350b2846162ed1
change-id: 20251201-vm-ops-by-name-6a5cb600f726

-- 
Sincerely,
Demi Marie Obenour (she/her/hers)


             reply	other threads:[~2025-12-05 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-05 10:06 Demi Marie Obenour [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-12-01 22:13 [PATCH] host/rootfs: Add scripts to access a VM by name Demi Marie Obenour

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=20251205-vm-ops-by-name-v1-1-68617d6b48bb@gmail.com \
    --to=demiobenour@gmail.com \
    --cc=devel@spectrum-os.org \
    --cc=hi@alyssa.is \
    /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).