patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 03020c89b02f295844f5ed814034ba66be741f4b 2301 bytes (raw)
name: host/rootfs/image/usr/bin/run-appimage 	 # 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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
 
#!/bin/execlineb -W
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2024-2025 Alyssa Ross <hi@alyssa.is>

backtick id {
  backtick -E dir { mktemp -d /run/vm/by-id/XXXXXX }
  basename -- $dir
}

if {
  importas -Siu id

  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 { install -do fs /run/configs/${id}/fs }

  if {
    ln -s /usr/lib/spectrum/img/appvm/blk /usr/lib/spectrum/img/appvm/vmlinux
      /run/configs/${id}
  }

  if { ln -s /run/configs/${id} /run/vm/by-id/${id}/config }

  if { create-vm-dependencies $id }
}

backtick diskdir {
  backtick mountpoint {
    importas -Siu 1
    findmnt -no TARGET -T $1
  }

  if -tn {
    redirfd -w 2 /dev/null
    multisubstitute {
      importas -Siu mountpoint
      importas -Siu 2
    }
    printf "%s/Spectrum/data/spectrum/storage/persist.%s\n" $mountpoint $2
  }

  s6-setuidgid fs

  importas -Siu mountpoint
  if { mkdir -p -- ${mountpoint}/Spectrum/data/spectrum/storage }
  mktemp -d -- ${mountpoint}/Spectrum/data/spectrum/storage/tmp.XXXXXX
}

if {
  s6-envuidgid fs
  s6-applyuidgid -Uzu 0

  multisubstitute {
    importas -Siu id
    importas -Siu 1
    importas -Siu diskdir
  }

  nsenter --preserve-credentials -S0
    --mount=/run/vm/by-id/${id}/ns/mnt
    --user=/run/vm/by-id/${id}/ns/user
  cd /run/fs/${id}
  if { redirfd -w 1 config/type echo appimage }
  if { touch config/run }
  if { mount --bind $1 config/run }
  mount --bind -- $diskdir disk
}

multisubstitute {
  importas -Siu diskdir
  importas -Siu id
}

piperw 4 3
background {
  fdclose 3
  fdmove 0 4

  # Wait for the VMM to be up, then start the VM.
  if { redirfd -w 1 /dev/null head -1 }
  vm-start $id
}
fdclose 4

foreground { run-vmm $id }
fdclose 3

if {
  # Even if s6-instance-delete fails, cgroup-purge is enough
  # to ensure that the VMM and all per-VM services are killed.
  foreground { s6-instance-delete /run/service/vm-services $id }
  cgroup-purge /vm-services.slice/vm-${id}.slice
}

if { umount -R /run/vm/by-id/${id}/ns }
rm -r -- $diskdir /run/vm/by-id/${id} /run/configs/${id}

debug log:

solving 03020c89b02f295844f5ed814034ba66be741f4b ...
found 03020c89b02f295844f5ed814034ba66be741f4b in https://inbox.spectrum-os.org/spectrum-devel/20260805-cgroups-v6-13-086c0f00f55f@gmail.com/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20260731-cgroups-v5-13-b325bac9d34f@gmail.com/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20260721-cgroups-v4-12-46b2e5fff7b6@gmail.com/
found 672ec22d4b815fb9c2940e13ae08ed4093baee4e in https://spectrum-os.org/git/spectrum
preparing index
index prepared:
100755 672ec22d4b815fb9c2940e13ae08ed4093baee4e	host/rootfs/image/usr/bin/run-appimage

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20260805-cgroups-v6-13-086c0f00f55f@gmail.com/
diff --git a/host/rootfs/image/usr/bin/run-appimage b/host/rootfs/image/usr/bin/run-appimage
index 672ec22d4b815fb9c2940e13ae08ed4093baee4e..03020c89b02f295844f5ed814034ba66be741f4b 100755

Checking patch host/rootfs/image/usr/bin/run-appimage...
Applied patch host/rootfs/image/usr/bin/run-appimage cleanly.

skipping https://inbox.spectrum-os.org/spectrum-devel/20260731-cgroups-v5-13-b325bac9d34f@gmail.com/ for 03020c89b02f295844f5ed814034ba66be741f4b
skipping https://inbox.spectrum-os.org/spectrum-devel/20260721-cgroups-v4-12-46b2e5fff7b6@gmail.com/ for 03020c89b02f295844f5ed814034ba66be741f4b
index at:
100755 03020c89b02f295844f5ed814034ba66be741f4b	host/rootfs/image/usr/bin/run-appimage

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