patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 5649674c51b29b08532fc2cd985a5b20a78c3764 1391 bytes (raw)
name: host/rootfs/image/usr/bin/run-vmm 	 # 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
 
#!/bin/execlineb -s0
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2024-2025 Alyssa Ross <hi@alyssa.is>

s6-ipcserver-socketbinder -B /run/vm/by-id/${1}/vmm

getpid -E vmm_pid
background -d {
  ifelse -n { start-vmm $@ }
  { kill $vmm_pid }

  if {
    if -t {
      backtick -E netvm_id {
        backtick -E link_path { readlink /run/vm/by-name/sys.netvm }
        basename -- $link_path
      }
      test $1 = $netvm_id
    }
    assign-devices
  }

  cd /run/vm/by-id
  elglob -0 providers */config/providers/net/*
  forx -pE path { $providers }
  backtick -E client_id {
   awk -v path=${path} -F / "BEGIN { split(path, p); print p[1] }"
  }
  backtick -E router_id {
    backtick -E router { basename -- $path }
    backtick -E link_path { readlink /run/vm/by-name/${router} }
    basename -- $link_path
  }

  if -n {
    if { test $client_id != $1 }
    test $router_id != $1
  }

  backtick -E mac {
    pipeline { ip -j link show client-${client_id} }
    pipeline { jq -r ".[].ifindex" }
    awk "{
      printf \"02:01:%02X:%02X:%02X:%02X\", $0 / 256 ^ 3 % 256,
	$0 / 256 ^ 2 % 256, $0 / 256 % 256, $0 % 256
    }"
  }

  ch-remote --api-socket /run/vm/by-id/${router_id}/vmm add-net
    id=router-${client_id},tap=router-${client_id},mac=${mac}
}
unexport !
fdmove -c 3 0
redirfd -r 0 /dev/null

if { udevadm wait /dev/kvm }
cloud-hypervisor --api-socket fd=3

debug log:

solving 5649674 ...
found 5649674 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).