aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/blog/2024-02-04-vmm-failure/vmm-failure.md172
1 files changed, 172 insertions, 0 deletions
diff --git a/src/blog/2024-02-04-vmm-failure/vmm-failure.md b/src/blog/2024-02-04-vmm-failure/vmm-failure.md
new file mode 100644
index 0000000..0521056
--- /dev/null
+++ b/src/blog/2024-02-04-vmm-failure/vmm-failure.md
@@ -0,0 +1,172 @@
1# Virtualization with vmm: brief history of a failure
2
3I have been wanting to play around with OpenBSD's native virtualization
4solution (vmm / vmd) for a while. It is what my VPS host
5[openbsd.amsterdam](https://openbsd.amsterdam) uses, and I figured
6having some minimal knowledge of how that works could come in handy
7in case I mess something up with my virtual machine.
8
9My goal was to set up a FreeBSD VM on an OpenBSD host, preferably
10relying only official documentation - no DuckDuckGoing.
11
12I am quite a noob when it comes to virtualization. I have used
13VirtualBox ages ago, and a couple of months back I managed to spin
14up a qemu VM mostly by copy-pasting commands from the internet.
15All I know about vmm is that it consists of 3 pieces:
16[vmm(4)](http://man.openbsd.org/vmm),
17[vmd(8)](http://man.openbsd.org/vmd)
18and [vmctl(8)](http://man.openbsd.org/vmctl).
19After a quick scan of the man pages I figured out that vmm is the
20device driver (whatever that means), vmd is the deamon and vmctl
21the actual program I want to use to create, start up and shut down
22the VM.
23
24Keep in mind that this post *does not* contain instructions to be followed.
25This is just the cronicle of my first attempt at using this tool.
26
27## First steps
28
29The first thing I did was heading to the
30[FreeBSD website](https://www.freebsd.org)
31and download an image of the recently released FreeBSD 14. I started
32downloading the .iso image, but I soon realized that telling my VM
33to boot from it would be yet one more thing to figure out. FreeBSD
34also offers
35[VM images](https://download.FreeBSD.org/releases/VM-IMAGES/14.0-RELEASE/amd64/Latest)
36in [qcow2](https://en.wikipedia.org/wiki/Qcow2) format, the one
37used by vmm, so I got one of these instead.
38
39Following the examples in vmctl(8), I tried:
40
41```
42$ vmctl start -d frr.qcow2 freebsd
43vmctl: connect: /var/run/vmd.sock: No such file or directory
44```
45
46Mmh, ok. There is a missing (socket) file. I don't know how to create
47it, and I don't think I should do it. After a little thinking I realize
48I should probably start the deamon:
49
50```
51# rcctl -f start vmd
52vmd(failed)
53```
54
55That's not good, and the error message does not say much. As an
56aside, I have to point out that this is a constant annoyance I have
57with OpenBSD: the tools are generally good, the documentation is
58amazing, but oh god the feedback on error is terrible.
59
60Anyways, after some more man page reading I realize I probably need
61to install some firmware with fw_update(8) with
62
63```
64fw_update vmm
65```
66
67It was a bit of a guess game to figure out what driver I had to
68install, but I got it on my second attempt (my first try was
69`vmm-bios`).
70
71The command indeed does something, so I try starting the deamon
72again:
73
74```
75# rcctl -f start vmd
76vmd(failed)
77```
78
79I took me relatively long to learn that `rcctl` has a `-d` option
80to turn on some diagnostics (`-d` is for "debug", but why not a more
81familiar `-v` for "verbose"?). So I try:
82
83```
84# rcctl -f start vmd
85doing _rc_parse_conf
86vmd_flags empty, using default ><
87doing rc_check
88vmd
89doing rc_configtest
90configuration OK
91doing rc_start
92doing _rc_wait_for_start
93doing rc_check
94doing _rc_rm_runfile
95(failed)
96```
97
98That is a bit cryptic, but at least it's something.
99
100## Walking in circles
101
102At this point I stopped making progress. It looks like the output
103above is just generic service-starting stuff, and it has nothing
104to do with my specific problem.
105
106I tried rebooting, but nothing changed. After reading the man pages
107more carefully, I thought that maybe enabling the service to start
108automatically at boot instead starting it manually could do something.
109It would be weird if it worked, but it was worth a shot. So I enabled
110it with
111
112```
113# rcctl enable vmd
114```
115
116And rebooted. But still:
117
118```
119vmd(failed)
120```
121
122I found out about yet another man page,
123[vm.conf(5)](http://man.openbsd.org/vm.conf).
124I read some of it, but I quickly convinced myself that my error was
125not related to configuration. It looks like anything you can do
126from vm.conf you can also do by providing the correct options and
127arguments to vmctl.
128
129As a last resort, I looked at
130[intro(4)](http://man.openbsd.org/man4/amd64/intro.4),
131but I did not find anything useful.
132
133## The FAQ
134
135I finally gave up and decided to read the
136[official online FAQ](https://www.openbsd.org/faq/index.html).
137I don't like relying on them, because it is not something I always
138have access to - for example if I am travelling and don't have an
139internet connection.
140
141The [Virtualization section](https://www.openbsd.org/faq/faq16.html)
142gave me an answer:
143
144```
145Prerequisites
146
147A CPU with nested paging support is required to use vmm(4). Support can be
148checked by looking at the processor feature flags: SLAT for AMD or EPT for
149Intel. In some cases, virtualization capabilities must be manually enabled in
150the system's BIOS. Be sure to run the fw_update(8) command after doing so to
151get the required vmm-firmware package.
152
153Processor compatibility can be checked with the following command:
154
155$ dmesg | egrep '(VMX/EPT|SVM/RVI)'
156```
157
158And sure enough that command returns nothing on my machine. That is
159is because I am doing this experiment on my
160[Netbook](../2022-09-10-netbooks),
161and its old
162[Intel Atom N450 CPU](https://ark.intel.com/content/www/us/en/ark/products/42503/intel-atom-processor-n450-512k-cache-1-66-ghz.html)
163does not support virtualization. Bummer.
164
165## Conclusion
166
167In the end, I was not able to set up my virtual machine, but that
168was neither my fault nor OpenBSD's. At least I did not waste much
169time with this - I did all of the above in little more than one
170hour. I guess this is what they call "fail fast?"
171
172status: (failed)

Generated with cgit - Back to sebastiano.tronto.net