sebastiano.tronto.net

Source files and build scripts for my personal website
git clone https://git.tronto.net/sebastiano.tronto.net
Download | Log | Files | Refs | README

vmm-failure.md (5622B)


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