[PATCH] host/rootfs: Add scripts to access a VM by name
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)
participants (1)
-
Demi Marie Obenour