Skip to content

Commit dbbfdf1

Browse files
committed
docs: add sequence diagram
Signed-off-by: Samuel Karp <[email protected]>
1 parent 01ce318 commit dbbfdf1

File tree

4 files changed

+111
-1
lines changed

4 files changed

+111
-1
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ PREFIX ?= /usr/local
33
DEST := $(shell echo "$(DESTDIR)/$(PREFIX)" | sed 's:///*:/:g; s://*$$::')
44

55
GO ?= go
6-
76
TAR ?= tar
7+
PLANTUML ?= plantuml # may also be "java -jar plantuml.jar" if installed elsewhere
88

99
PACKAGE := github.com/lima-vm/lima
1010

@@ -53,6 +53,11 @@ _output/share/lima/lima-guestagent.Linux-aarch64:
5353
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 $(GO_BUILD) -o $@ ./cmd/lima-guestagent
5454
chmod 644 $@
5555

56+
.PHONY: diagrams
57+
diagrams: docs/lima-sequence-diagram.png
58+
docs/lima-sequence-diagram.png: docs/lima-sequence-diagram.puml
59+
$(PLANTUML) ./docs/lima-sequence-diagram.puml
60+
5661
.PHONY: install
5762
install:
5863
mkdir -p "$(DEST)"

docs/internal.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,9 @@ The volume label is "cidata", as defined by [cloud-init NoCloud](https://cloudin
115115
- `LIMA_CIDATA_SLIRP_IP_ADDRESS`: set to the IP address of the guest on the SLIRP network. `192.168.5.15`.
116116
- `LIMA_CIDATA_UDP_DNS_LOCAL_PORT`: set to the udp port number of the hostagent dns server (or 0 when not enabled).
117117
- `LIMA_CIDATA_TCP_DNS_LOCAL_PORT`: set to the tcp port number of the hostagent dns server (or 0 when not enabled).
118+
119+
# VM lifecycle
120+
121+
![](./lima-sequence-diagram.png)
122+
123+
(based on Lima 0.8.3)

docs/lima-sequence-diagram.png

149 KB
Loading

docs/lima-sequence-diagram.puml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
@startuml
2+
'https://plantuml.com/sequence-diagram
3+
4+
autonumber
5+
6+
actor User
7+
participant limactl
8+
participant "lima hostagent"
9+
participant qemu
10+
participant "guest os"
11+
participant "lima guestagent"
12+
participant nerdctl
13+
14+
== start ==
15+
16+
User -> limactl: start
17+
activate limactl
18+
limactl -> "lima hostagent": launch host agent
19+
activate "lima hostagent"
20+
deactivate limactl
21+
"lima hostagent" -> "lima hostagent": find free ports
22+
"lima hostagent" -> "lima hostagent": generate cloud-init data & CD-ROM image
23+
"lima hostagent" -> "lima hostagent": generate QEMU command line
24+
"lima hostagent" -> "lima hostagent": set up port forwarding
25+
"lima hostagent" -> qemu: start
26+
activate qemu
27+
qemu -> "guest os": boot
28+
activate "guest os"
29+
"guest os" -> "guest os": run setup commands from CD-ROM
30+
"guest os" -> "lima guestagent": start
31+
activate "lima guestagent"
32+
"lima hostagent" -> "guest os": set up sshfs mounts
33+
"lima hostagent" -> "guest os": set up socket forwarding with SSH
34+
loop periodically
35+
"lima guestagent" -> "guest os": read /proc/net/tcp* and iptables
36+
end loop
37+
loop periodically
38+
"lima hostagent" -> "lima guestagent": connect to guest agent (query info)
39+
"lima guestagent" -> "lima hostagent": IP/port pairs (from /proc/net/tcp* and iptables)
40+
"lima hostagent" -> "lima guestagent": subscribe to port add/remove events
41+
"lima guestagent" -> "lima hostagent": (ongoing) return port add/remove events
42+
end loop
43+
"lima hostagent" -> "guest os": query for requirements/boot status/readiness probes
44+
45+
== command execution ==
46+
47+
User -> limactl: shell "command"
48+
activate limactl
49+
limactl -> "guest os": ssh "command"
50+
"guest os" -> limactl: command output
51+
limactl -> User: command output
52+
deactivate limactl
53+
54+
== nerdctl run ==
55+
56+
User -> limactl: "nerdctl run"
57+
activate limactl
58+
limactl -> "guest os": ssh "nerdctl run"
59+
"guest os" -> nerdctl: run container
60+
activate nerdctl
61+
loop periodically
62+
"lima guestagent" -> "guest os": read /proc/net/tcp* and iptables
63+
end loop
64+
loop periodically
65+
"lima hostagent" -> "lima guestagent": query events
66+
"lima guestagent" -> "lima hostagent": return port add/remove events
67+
"lima hostagent" -> "lima hostagent": set up new port forwarding
68+
end loop
69+
nerdctl -> nerdctl: container exits
70+
nerdctl -> limactl: container output
71+
deactivate nerdctl
72+
limactl -> User: container output
73+
deactivate limactl
74+
loop periodically
75+
"lima guestagent" -> "guest os": read /proc/net/tcp* and iptables
76+
end loop
77+
loop periodically
78+
"lima hostagent" -> "lima guestagent": query events
79+
"lima guestagent" -> "lima hostagent": return port add/remove events
80+
"lima hostagent" -> "lima hostagent": remove old port forwarding
81+
end loop
82+
83+
== stop ==
84+
85+
User -> limactl: stop
86+
activate limactl
87+
limactl -> "lima hostagent": SIGINT
88+
"lima hostagent" -> qemu: ACPI shutdown
89+
qemu -> "guest os": ACPI shutdown
90+
"guest os" -> "lima guestagent": SIGTERM
91+
deactivate "lima guestagent"
92+
deactivate "guest os"
93+
"lima hostagent" -> "lima hostagent": wait up to 3 minutes for shutdown
94+
deactivate qemu
95+
"lima hostagent" -> limactl: emit exit event
96+
deactivate "lima hostagent"
97+
limactl -> User: stopped
98+
deactivate limactl
99+
@enduml

0 commit comments

Comments
 (0)