patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob ade1ee86527813b171e458961fadb5fb936e358d 1118 bytes (raw)
name: host/rootfs/image/usr/bin/vm-import 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
#!/bin/execlineb -WS2
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2023-2024 Alyssa Ross <hi@alyssa.is>

cd $2
elglob -0 names *

forx -po0 -E name { $names }

backtick -E id {
  backtick -E dir { mktemp -d /run/vm/by-id/XXXXXX }
  basename -- $dir
}
if { useradd -P /run -Urd / -s /bin/nologin gpu-${id} }
if { useradd -P /run -Urd / -s /bin/nologin -G tty,vmm vmm-${id} }
if { useradd -P /run -Urd / -s /bin/nologin xdp-spectrum-${id} }
if { mkdir /run/vsock/${id} }
if { chown vmm-${id} /run/vm/by-id/${id} /run/vsock/${id} }

if { ln -s -- /run/vm/by-id/${id} /run/vm/by-name/${1}.${name} }
if { ln -s -- ${2}/${name} /run/vm/by-id/${id}/config }
if { ln -s -- /run/service/vmm/instance/${id} /run/vm/by-id/${id}/service }

if { create-vm-dependencies $id }

if {
  case $# {
    3 {
      s6-envuidgid fs
      s6-applyuidgid -Uzu 0
      nsenter --preserve-credentials -S0
	--mount=/run/vm/by-id/${id}/ns/mnt
	--user=/run/vm/by-id/${id}/ns/user

      if { mkdir -p -- ${3}/${name} }
      mount --bind -- ${3}/${name} /run/fs/${id}/disk
    }
  }
}

s6-instance-create -- /run/service/vmm $id

debug log:

solving ade1ee86527813b171e458961fadb5fb936e358d ...
found ade1ee86527813b171e458961fadb5fb936e358d in https://spectrum-os.org/git/spectrum

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock

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).