<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>dave eddy</title>
		<description>All Dropped Packets go to Heaven</description>
		<link type="application/atom+xml" href="https://blog.daveeddy.com" rel="self"/>
		<link type="text" href="https://blog.daveeddy.com" rel="alternate"/>
		<atom:link href="https://blog.daveeddy.com/rss.xml" rel="self" type="application/rss+xml" />
		<updated>2026-10-15T01:28:06-04:00</updated>
		<id>https://blog.daveeddy.com</id>
		<rights>Copyright (c) 2026 dave eddy</rights>
		
		<item>
			<title>illumos Doors</title>
			<link>https://blog.daveeddy.com/2026/07/06/illumos-doors/</link>
			<updated>2026-07-06T00:00:00-04:00</updated>
			<pubDate>2026-07-06T00:00:00-04:00</pubDate>
			<id>https://blog.daveeddy.com/2026/07/06/illumos-doors/</id>
			<gid>https://blog.daveeddy.com/2026/07/06/illumos-doors/</gid>
			<guid>https://blog.daveeddy.com/2026/07/06/illumos-doors/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;&lt;a href=&quot;/static/media/2026/doors/illumos-doors.jpg&quot;&gt;&lt;img src=&quot;/static/media/2026/doors/illumos-doors.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://illumos.org&quot;&gt;illumos&lt;/a&gt; has an IPC mechanism called &lt;a href=&quot;https://man.omnios.org/man3c/door_create&quot;&gt;doors&lt;/a&gt;.  At a high
level, doors allow a process to expose a procedure that another process can
call.  The client calls into the door, the kernel transfers control to a server
thread in the server process, and the server returns a response back to the
client.  In practice, it feels like simply making a function call that works
across process boundaries.&lt;/p&gt;

&lt;p&gt;I have known about doors for a while mostly because they show up all over the
system.  For example, name resolution and user lookups, among other things, may
use doors to talk to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nscd&lt;/code&gt; daemon.  I thought it would be fun to write a
small example program to see how the API works and use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dtrace&lt;/code&gt; to spy on our
program a bit.&lt;/p&gt;

&lt;p&gt;This blog post also exists as a video if that format is what you prefer:&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/Zq9V8fvE_B0?si=V3Z6aYtAJnfIL3m9&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay;
clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;!-- more --&gt;

&lt;h1 id=&quot;what-are-doors&quot;&gt;What are doors?&lt;/h1&gt;

&lt;p&gt;Doors are an RPC-Style IPC mechanism available on illumos.  A server creates a
door with &lt;a href=&quot;https://man.omnios.org/man3c/door_create&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_create(3C)&lt;/code&gt;&lt;/a&gt; and gives the kernel a function
pointer.  A client then opens a door descriptor and calls it with
&lt;a href=&quot;https://man.omnios.org/man3c/door_call&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_call(3C)&lt;/code&gt;&lt;/a&gt;.  When the call reaches the server process, the
server function runs and eventually returns data back to the client with
&lt;a href=&quot;https://man.omnios.org/man3c/door_return&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_return(3C)&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One thing that makes doors interesting is that a door can be attached to a path
on the filesystem with &lt;a href=&quot;https://man.omnios.org/man3c/fattach&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fattach(3C)&lt;/code&gt;&lt;/a&gt;.  This makes the door available by filename
- similar to something like &lt;a href=&quot;https://man.omnios.org/man8/mkfifo&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkfifo(8)&lt;/code&gt;&lt;/a&gt; but with more features provided by
the kernel.  This means that the client doesn’t need to inherit a file
descriptor or connect to a socket - it can simply open a path and make a call.&lt;/p&gt;

&lt;h1 id=&quot;a-simple-door-server&quot;&gt;A simple door server&lt;/h1&gt;

&lt;p&gt;Here is a simple example to get us started - a server and client where the
client can call the door in the server and the server will print that a request
was received:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.c&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;door.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;fcntl.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stropts.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;sys/stat.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;door_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;size_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_desc_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uint_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ndesc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;hello from door_func&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;./my-file.door&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// create the file&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;unlink&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;O_RDWR&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;O_CREAT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mo&quot;&gt;0644&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;perror&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;open&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// create the door&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;door&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;door_create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;perror&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;door_create&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// attach the door to the file&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fattach&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;perror&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;fattach&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;door created: %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;waiting for requests...&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// run forever&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pause&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// not reached&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client.c&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;door.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;fcntl.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;door&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;./my-file.door&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;O_RDONLY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;perror&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;open&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// call the door (this is like calling &quot;door_func&quot; in the server)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;calling door&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;door_call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;perror&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;door_call&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;door called successfully&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Compile the examples:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cc -ldoor client.c -o client
cc -ldoor server.c -o server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, test the code by running the server and client in separate terminals:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./server
door created: ./my-file.door
waiting for requests...
... (after the client is run) ...
hello from door_func
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./client
calling door
door called successfully
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It works! Notice that the output from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_func&lt;/code&gt; appears in the server.  This
is because the function runs inside the server and the client just receives
whatever data is sent back.  In our example, no data is sent back to the
client… so let’s fix that:&lt;/p&gt;

&lt;p&gt;Make the following changes to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_func&lt;/code&gt; function in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.c&lt;/code&gt; and
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client.c&lt;/code&gt; respectively:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.c&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;door_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;size_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_desc_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uint_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ndesc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello from door_func&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client.c&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;calling door&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;door_arg_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;door_call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;perror&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;door_call&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;door called successfully&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;got data: %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_ptr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, recompile and run them again like above:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./server
door created: ./my-file.door
waiting for requests...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./client
calling door
door called successfully
got data: hello from door_func
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It works again! This time notice that the server did not print any output when
the door was called - this is because we removed the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;printf&lt;/code&gt; call from the
server and instead returned that character data over to the client.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;args&lt;/code&gt; variable we created is really neat - we passed it into the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_call&lt;/code&gt; function completely zeroed-out but got it back with the data
populated by the server.  We can &lt;em&gt;also&lt;/em&gt; set that before we call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_call&lt;/code&gt; and
our server can receive it.&lt;/p&gt;

&lt;p&gt;Let’s make that change by updating both the server and client programs again:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.c&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;door_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;size_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_desc_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uint_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ndesc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;got data from client: %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello from door_func&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client.c&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// call the door (this is like calling &quot;door_func&quot; in the server)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;calling door&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hi from client&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;door_arg_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_ptr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;door_call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;perror&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;door_call&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Recompile the code and run it to see:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./server
door created: ./my-file.door
waiting for requests...
got data from client: hi from client
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./client
calling door
door called successfully
got data: hello from door_func
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Perfect! The client can receive data from the server like before and the server
can &lt;em&gt;also&lt;/em&gt; receive data from the client.&lt;/p&gt;

&lt;p&gt;In this example our data is null-terminated strings so we can easily format
them, but you are also able to pass any bytes or structs (represented as bytes).&lt;/p&gt;

&lt;p&gt;For the next example I want to show that the server process is able to
“interrogate” the client - by which I mean gather information about the caller
such as its PID, user info, and zone information.&lt;/p&gt;

&lt;p&gt;Update just the server code this time:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;door_func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;size_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_desc_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uint_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ndesc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// interrogate our client&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ucred_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door_ucred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;uid_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;euid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ucred_geteuid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;pid_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ucred_getpid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;zoneid_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;zoneid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ucred_getzoneid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;client request received from pid %d uid %d zone %d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;pid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;euid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;zoneid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;ucred_free&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;got data from client: %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;hello from door_func&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Recompile the server and re-run the code:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./server
door created: ./my-file.door
waiting for requests...
client request received from pid 25833 uid 1000 zone 13
got data from client: hi from client
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And there we go! We can see that the client request came from zone 13, uid 1000,
and pid 25833.  In this example we were running both the server and client in
the same zone but they don’t have to be - we could share the door file and have
something like the server in the global zone while the client (or clients!)
are in a non-global zone.&lt;/p&gt;

&lt;h2 id=&quot;security-concerns&quot;&gt;Security Concerns&lt;/h2&gt;

&lt;p&gt;I should briefly touch on the concerns when crossing the zone boundary (though
this broadly applies to doors used and accessed in the same zone as well).&lt;/p&gt;

&lt;p&gt;The first thing to consider is the filesystem path.  If a door is attached to
a path that gets mounted into a zone, then processes in that zone may be able to
call it.  Normal file permissions still matter because the client has to open
the door, but the server should not treat the path alone as the security
boundary.&lt;/p&gt;

&lt;p&gt;The second thing to consider is credentials.  As shown above, the door server
can call &lt;a href=&quot;https://man.omnios.org/man3c/door_ucred&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_ucred(3C)&lt;/code&gt;&lt;/a&gt; during a door invocation to get
information about the immediate caller.  From there you can inspect things like
the effective uid, pid, privileges, and zone id using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ucred_get*()&lt;/code&gt;
functions.&lt;/p&gt;

&lt;p&gt;For example, if the server should only accept calls from the global zone we
could do something like:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;ucred_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door_ucred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;no credentials&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ucred_getzoneid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GLOBAL_ZONEID&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;bad zone&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;door_return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Or, if the server is meant to be called from a specific zone, it could check for
that zone id explicitly.&lt;/p&gt;

&lt;p&gt;Finally, a door call can pass data and file descriptors to the server.  If the
door is reachable by a less trusted client, then the server should treat
everything in the call as untrusted input.  In the small example above, the
server prints the client-provided string directly, but a real server should
validate the input size and make sure string data is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;'\0'&lt;/code&gt; terminated before
using it (or ideally pass structured data rather than C strings).&lt;/p&gt;

&lt;h1 id=&quot;finding-doors-with-dtrace&quot;&gt;Finding doors with DTrace&lt;/h1&gt;

&lt;p&gt;One of the reasons I wanted to play with doors is that illumos uses them all
over the system.  We can trace them all with (run from the global zone):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo dtrace -qn 'fbt::door_return:entry { printf(&quot;[%s] %s\n&quot;, zonename, execname); }'
[arbiter] svc.configd
[arbiter] svc.configd
... trimmed ...
[arbiter] svc.configd
[arbiter] svc.configd
[arbiter] server # &amp;lt;--- that's us!
[nagios] nscd
[nagios] nscd
[nagios] pfexecd
[vault] svc.configd
[tunnel] nscd
[tunnel] nscd
^C
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I had to trim a lot of output - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;svc.configd&lt;/code&gt; is particularly noisy! For my
example I am running from the arbiter zone (zone 13) and the name of our program
is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server&lt;/code&gt;.  We can tighten up our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dtrace&lt;/code&gt; invocation to just look for that
program by name and zone:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo dtrace -qn 'fbt::door_return:entry
/zonename == &quot;arbiter&quot; &amp;amp;&amp;amp; execname == &quot;server&quot;/
{ printf(&quot;[%s] %s\n&quot;, zonename, execname); }'

[arbiter] server
[arbiter] server
[arbiter] server
[arbiter] server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You should see one line for every time the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client&lt;/code&gt; program is run.  Because we
know it’s our program, we can be liberal in how we handle processing the
arguments.  For example, we know the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_return&lt;/code&gt; function gets called like
this:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;door_return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can pull out &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;arg0&lt;/code&gt; as a string with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dtrace&lt;/code&gt; since we know it is a string
suitable for printing:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo dtrace -qn 'fbt::door_return:entry
/zonename == &quot;arbiter&quot; &amp;amp;&amp;amp; execname == &quot;server&quot;/
{ printf(&quot;got data: %s\n&quot;, copyinstr(arg0)); }'

got data: hello from door_func
got data: hello from door_func
got data: hello from door_func
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Beautiful! We can basically &lt;em&gt;spy&lt;/em&gt; on our doors with this.  There are other
probes we can look at as well, but I will leave that as an exercise for the
reader - there are a lot!&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo dtrace -l | grep doorfs | wc -l
     144
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;using-rust&quot;&gt;Using Rust&lt;/h1&gt;

&lt;p&gt;Switching gears a bit, a really neat thing I want to showcase about doors is
they can allow for interoperability between languages.  Using the Rust &lt;a href=&quot;https://crates.io/crates/doors&quot;&gt;doors
crate&lt;/a&gt; we can create a client that will talk to our existing C
server and transfer data with it.&lt;/p&gt;

&lt;p&gt;To create this Rust client we can run this in the current directory:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cargo new rust-door-client
cd rust-door-client
cargo add doors
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then we can use this code which has been slightly modified from the crate
documentation.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/main.rs&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;doors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;../my-file.door&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;b&quot;Hello From Rust!!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\0&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.call_with_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{:#?}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice that we are able to pass data into the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;client.call_with_data()&lt;/code&gt;
function - the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&quot;...&quot;&lt;/code&gt; notation allows us to store a string as bytes (as a
slice of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u8&lt;/code&gt;s, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;[u8]&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;We can run the server and this new Rust client with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./server
door created: ./my-file.door
waiting for requests...
client request received from pid 4880 uid 1000 zone 13
got data from client: Hello From Rust!!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cargo run -q
[
    104,
    101,
    108,
    108,
    111,
    32,
    102,
    114,
    111,
    109,
    32,
    100,
    111,
    111,
    114,
    95,
    102,
    117,
    110,
    99,
    0,
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ok great! We are almost there - our client was able to receive bytes from the
server.  The nice thing here is that we know our data is a null-terminated
string (notice the last element of the output is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0&lt;/code&gt;) so we can convert it to a
string.  Change the client code to:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.call_with_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from_utf8_lossy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;got data: {}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run the client again and we see:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cargo run -q
got data: hello from door_func
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And there we go! We’ve successfully moved strings between the Rust client and C
server, through the kernel!&lt;/p&gt;

&lt;p&gt;But wait… one last thing.&lt;/p&gt;

&lt;p&gt;Let’s take a deeper look at the Rust output:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cargo run -q --
got data: hello from door_func
$ cargo run -q -- | xxd
00000000: 676f 7420 6461 7461 3a20 6865 6c6c 6f20  got data: hello
00000010: 6672 6f6d 2064 6f6f 725f 6675 6e63 000a  from door_func..
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The last 2 bytes are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;00&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0a&lt;/code&gt;.  The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0a&lt;/code&gt; makes sense since
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;println!()&lt;/code&gt; emits a newline, but the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;00&lt;/code&gt; is caused by our string being
null-terminated coming from C.  This is nothing specific to doors but I think
it’s a good thing to remember that we are just transferring bytes to and from
the server and we just so happened to make those strings suitable for our C
programs to print to the user.  Now that we are in Rust we don’t need to
null-terminate our strings.&lt;/p&gt;

&lt;p&gt;We can easily fix this bug by removing the last byte from the slice, or
stripping the suffix of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;[0]&lt;/code&gt;, but I think the best way will be to tell Rust
exactly what type of data this is: a C string.&lt;/p&gt;

&lt;p&gt;We can do this by using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;std::ffi::CStr&lt;/code&gt; type which represents a borrowed C
string.  Since the data from the C server is null-terminated,
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CStr::from_bytes_with_nul()&lt;/code&gt; can validate it and give us a string view without
the trailing NUL.  Update our client code to look like this:&lt;/p&gt;

&lt;div class=&quot;language-rust highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;doors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;std&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;ffi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CStr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;../my-file.door&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;b&quot;Hello From Rust!!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\0&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.call_with_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c_str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;CStr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from_bytes_with_nul&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.unwrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c_str&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;.to_string_lossy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;println!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;got data: {}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run the client again and verify:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cargo run -q --
got data: hello from door_func
$ cargo run -q -- | xxd
00000000: 676f 7420 6461 7461 3a20 6865 6c6c 6f20  got data: hello
00000010: 6672 6f6d 2064 6f6f 725f 6675 6e63 0a    from door_func.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And there we go! No stray &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\0&lt;/code&gt; bytes in the printed output.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;Doors are a pretty neat illumos feature.  The API is small enough that a simple
example can be written in a couple of short C programs, but it is powerful
enough to be used by core parts of the system.  Having all of the underlying
logic such as thread creation, handling multiple requests, etc. abstracted for
you means it’s very easy to hit the ground running with them.&lt;/p&gt;

&lt;p&gt;I don’t know how often I’ll reach for doors in my own programs, but after
writing this I understand them a lot better.  Like a lot of these operating
system features, specifically on illumos, once you know about them you
start seeing them show up in &lt;em&gt;a lot&lt;/em&gt; of places throughout the system.&lt;/p&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;update&quot;&gt;Update&lt;/h1&gt;

&lt;p&gt;This blog post absolutely has a memory leak.  The system will allocate space for
the data returned via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;door_call&lt;/code&gt; if no pointer is passed in via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;args.rbuf&lt;/code&gt; -
this means it is our job to free (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;munmap&lt;/code&gt;) the data returned.&lt;/p&gt;

&lt;p&gt;Update the client with:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;sys/mman.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;door called successfully&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;got data: %s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_ptr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;munmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rbuf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rsize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;door&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</summary>
		</item>
		
		<item>
			<title>The Complete Bash Scripting Course</title>
			<link>https://blog.daveeddy.com/2025/12/15/the-complete-bash-scripting-course/</link>
			<updated>2025-12-15T00:00:00-05:00</updated>
			<pubDate>2025-12-15T00:00:00-05:00</pubDate>
			<id>https://blog.daveeddy.com/2025/12/15/the-complete-bash-scripting-course/</id>
			<gid>https://blog.daveeddy.com/2025/12/15/the-complete-bash-scripting-course/</gid>
			<guid>https://blog.daveeddy.com/2025/12/15/the-complete-bash-scripting-course/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/Sx9zG7wa4FA&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay;
clipboard-write; encrypted-media; gyroscope;
picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;It’s been in the works for over a year now but &lt;em&gt;The Complete Bash Scripting
Course&lt;/em&gt; is here!&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Learn the Bash Shell and master beginner all the way up to advanced Bash
scripting techniques.
7+ Hours of content, 60+ Sections, all free.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Check out the YouTube video above or check out the courses website here:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://course.ysap.sh&quot;&gt;https://course.ysap.sh&lt;/a&gt;&lt;/p&gt;
</summary>
		</item>
		
		<item>
			<title>Running a DHCP Server on illumos</title>
			<link>https://blog.daveeddy.com/2024/11/12/running-a-dhcp-server-on-illumos/</link>
			<updated>2024-11-12T00:00:00-05:00</updated>
			<pubDate>2024-11-12T00:00:00-05:00</pubDate>
			<id>https://blog.daveeddy.com/2024/11/12/running-a-dhcp-server-on-illumos/</id>
			<gid>https://blog.daveeddy.com/2024/11/12/running-a-dhcp-server-on-illumos/</gid>
			<guid>https://blog.daveeddy.com/2024/11/12/running-a-dhcp-server-on-illumos/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;&lt;a href=&quot;/static/media/2024/illumos-dhcpd/dhcpd-on-omnios.jpg&quot;&gt;&lt;img src=&quot;/static/media/2024/illumos-dhcpd/dhcpd-on-omnios.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post will guide you through installing &lt;a href=&quot;https://www.isc.org/dhcp/&quot;&gt;isc-dhcpd&lt;/a&gt; on
&lt;a href=&quot;https://omnios.org&quot;&gt;OmniOS&lt;/a&gt; inside a zone (software virtualized container).&lt;/p&gt;

&lt;h1 id=&quot;configuring-the-system&quot;&gt;Configuring the system&lt;/h1&gt;

&lt;p&gt;To get started, first install &lt;a href=&quot;https://github.com/omniosorg/zadm&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt;&lt;/a&gt; on OmniOS inside the global zone.
This tool makes creating and managing zones simple and is reminiscent of the
&lt;a href=&quot;https://wiki.smartos.org/managing-instances-with-vmamd/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vmadm&lt;/code&gt;&lt;/a&gt; command on &lt;a href=&quot;https://smartos.org&quot;&gt;SmartOS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pkg install zadm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I personally use this config for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt; (shoutouts to
&lt;a href=&quot;http://mikezeller.net&quot;&gt;@papertigers&lt;/a&gt; for this), but feel free to customize this as you
like.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/opt/ooce/zadm/zadm.conf&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;CONFIG&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;format&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;toml&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;CONSOLE&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;auto_connect&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;off&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;auto_disconnect&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;on&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;escape_char&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;_&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;SNAPSHOT&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;prefix&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;zadm__&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Test that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt; was installed and works as expected by running:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dave - GZ:amon sunos ~ $ zadm list
NAME              STATUS     BRAND       RAM    CPUS  SHARES
global            running    ipkg        16G       4       1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that for this blog post I ran all of these commands on a fresh system so
only 1 zone is running (the global zone).&lt;/p&gt;

&lt;p&gt;Create the datasets needed, and you can customize these if you’d like but for
the sake of this post I’ll be using these datasets:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;zfs create -o mountpoint=/zones rpool/zones
zfs create rpool/zones/config
zfs create rpool/zones/root
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/config&lt;/code&gt; toml files for each zone used during zone creation.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/root&lt;/code&gt; zone root FS data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, a zone named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;foo&lt;/code&gt; would have files like:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/config/foo.toml&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/zones/foo&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;creating-the-nics&quot;&gt;Creating the NICs&lt;/h1&gt;

&lt;p&gt;To get started we must create the NICs in the global zone before creating the
zone that will house the DHCP server.  It is possible to have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt; create NICs
for us for simple zone deployments but we need more control here to ensure the
NICs are persistent and can process DHCP traffic on multiple VLANs.&lt;/p&gt;

&lt;p&gt;My physical server has 2 physical NICs - I plan on using this as my home router
eventually.  Until then, only 1 NIC is in use so we must find it by name to use
for our zone NICs:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ dladm show-phys
LINK         MEDIA                STATE      SPEED    DUPLEX   DEVICE
rge0         Ethernet             up         1000     full     rge0
rge1         Ethernet             unknown    0        unknown  rge1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can see that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rge0&lt;/code&gt; is the interface that is currently in use, so we will use
that to create the NICs for the zone.&lt;/p&gt;

&lt;p&gt;My home network has multiple VLANs - this DHCP server will sit on all of them
and properly tag them.  A quick synopsis of my network looks like:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.1.0/24&lt;/code&gt; - untagged&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.2.0/24&lt;/code&gt; - vlan 3&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.3.0/24&lt;/code&gt; - vlan 4&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.4.0/24&lt;/code&gt; - vlan 5&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.5.0/24&lt;/code&gt; - vlan 6&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;“But Dave, your VLAN IDs are off-by-one… isn’t that confusing?” YES. Yes it
is, lol, I’ll get around to it a swear.&lt;/p&gt;

&lt;p&gt;Now that we now the physical NIC we are going to create these NICs on and the
VLAN IDs we can create them with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dladm&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo dladm create-vnic -l rge0 dhcp_0
sudo dladm create-vnic -l rge0 -v 3 dhcp_3
sudo dladm create-vnic -l rge0 -v 4 dhcp_4
sudo dladm create-vnic -l rge0 -v 5 dhcp_5
sudo dladm create-vnic -l rge0 -v 6 dhcp_6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can verify their creation with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo dladm show-vnic | grep dhcp
dhcp_0       rge0       1000     2:8:20:fb:a1:19   random      0    --
dhcp_3       rge0       1000     2:8:20:cf:fd:7e   random      3    --
dhcp_4       rge0       1000     2:8:20:81:1d:d3   random      4    --
dhcp_5       rge0       1000     2:8:20:30:d3:f6   random      5    --
dhcp_6       rge0       1000     2:8:20:46:c0:ca   random      6    --
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;creating-the-zone&quot;&gt;Creating the zone&lt;/h1&gt;

&lt;p&gt;Now we are ready to create the zone!  Start by creating a toml file to represent
the zone:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/config/dhcp.toml&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;py&quot;&gt;autoboot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;brand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;lipkg&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;dns-domain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rapture.com&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;ip-type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;exclusive&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;limitpriv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;default&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;zonename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;dhcp&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;zonepath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/zones/root/dhcp&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;resolvers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=[&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;10.0.1.3&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;10.0.1.2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[net]]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;global-nic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rge0&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;dhcp_0&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[net]]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;global-nic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rge0&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;dhcp_3&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;vlan-id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;3&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[net]]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;global-nic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rge0&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;dhcp_4&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;vlan-id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;4&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[net]]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;global-nic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rge0&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;dhcp_5&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;vlan-id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;5&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[net]]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;global-nic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rge0&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;dhcp_6&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;vlan-id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;6&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[capped-memory]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;512M&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2G&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm create&lt;/code&gt; to create the zone!&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo zadm create -b lipkg -t dhcp.toml dhcp
A ZFS file system has been created for this zone.
Sanity Check: Looking for 'entire' incorporation.
       Image: Preparing at /zones/root/dhcp/root.

       Cache: Using /var/pkg/publisher.
  Installing: Packages (output follows)
   Publisher: Using omnios (https://pkg.omnios.org/r151052/core/).
   Publisher: Using omnios (https://us-west.mirror.omnios.org/r151052/core/).
   Publisher: Using extra.omnios (https://pkg.omnios.org/r151052/extra/).
   Publisher: Using extra.omnios (https://us-west.mirror.omnios.org/r151052/extra/).
Packages to install: 392
Mediators to change:   8
 Services to change:   7

DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
Completed                            392/392   32972/32972  307.2/307.2      --

PHASE                                          ITEMS
Installing new actions                   66485/66485
Updating package state database                 Done
Updating package cache                           0/0
Updating image state                            Done
Creating fast lookup database                   Done
 Postinstall: Copying SMF seed repository ... done.
        Done: Installation completed in 142.004 seconds.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can now boot the zone and login to it.  You may have to wait a second or two
after booting the zone to login to it:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo zadm boot dhcp
sudo zlogin dhcp
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Once we are inside the zone we can verify we see the interfaces with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dhcp:~# dladm
LINK        CLASS     MTU    STATE    BRIDGE     OVER
dhcp_0      vnic      1500   up       --         ?
dhcp_3      vnic      1500   up       --         ?
dhcp_4      vnic      1500   up       --         ?
dhcp_5      vnic      1500   up       --         ?
dhcp_6      vnic      1500   up       --         ?
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;configuring-networking-in-the-zone&quot;&gt;Configuring networking in the zone&lt;/h1&gt;

&lt;p&gt;We can go through and manually set the IP addresses to each interface in the
zone - these will be persistent so you only need to run these commands once.
For my setup I’m using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.4&lt;/code&gt; as the last octet for this server on each network it
lives on.&lt;/p&gt;

&lt;p&gt;Inside the zone run these commands:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ipadm create-addr -T static -a 10.0.1.4/24 dhcp_0/v4
ipadm create-addr -T static -a 10.0.2.4/24 dhcp_3/v4
ipadm create-addr -T static -a 10.0.3.4/24 dhcp_4/v4
ipadm create-addr -T static -a 10.0.4.4/24 dhcp_5/v4
ipadm create-addr -T static -a 10.0.5.4/24 dhcp_6/v4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The last step is to add the default gateway so we can hit the internet from the
zone:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;route -p add default 10.0.1.1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;installing-the-software&quot;&gt;Installing the software&lt;/h1&gt;

&lt;p&gt;Now we can install the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;isc-dhcp&lt;/code&gt; package to get the DHCP server:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dhcp:~# pkg install isc-dhcp
           Packages to install:  1
            Services to change:  7
       Create boot environment: No
Create backup boot environment: No

DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
Completed                                1/1         20/20      4.7/4.7  2.0M/s

PHASE                                          ITEMS
Installing new actions                         34/34
Updating package state database                 Done
Updating package cache                           0/0
Updating image state                            Done
Creating fast lookup database                   Done
Updating package cache                           2/2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will install the package and create an SMF manifest for the service without
actually starting it for us.  We can get the service ready by copying the
example config into place, editing it, and starting the service!&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cp /usr/share/isc-dhcp/examples/dhcpd.conf.example /etc/dhcpd.conf
vim /etc/dhcpd.conf
# edit, edit, edit, :wq
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Start the service with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;svcadm enable dhcp:ipv4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And that’s it! You now have a working DHCP server on OmniOS.  You can verify it
is running with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@dhcp:~# svcs dhcp:ipv4
STATE          STIME    FMRI
online          0:45:51 svc:/network/service/dhcp:ipv4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;helpful-hints&quot;&gt;Helpful hints&lt;/h1&gt;

&lt;p&gt;It took me a bit to find the example config until I remember I could ask the
package manager what files it installed:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dave@dhcp:~$ pkg contents isc-dhcp
PATH
etc/security/auth_attr.d/network%2Fservice%2Fdhcp
lib/svc/manifest/network/isc-dhcp.xml
lib/svc/method/isc-dhcp
usr/bin/omshell
usr/sbin/dhcpd
usr/sbin/dhcrelay
usr/share/isc-dhcp
usr/share/isc-dhcp/examples
usr/share/isc-dhcp/examples/dhcpd.conf.example
usr/share/man/man1/omshell.1
usr/share/man/man5/dhcp-eval.5
usr/share/man/man5/dhcp-options.5
usr/share/man/man5/dhcpd.conf.5
usr/share/man/man5/dhcpd.leases.5
usr/share/man/man8/dhcpd.8
usr/share/man/man8/dhcrelay.8
var/db
var/db/dhcpd.leases
var/db/dhcpd.leases~
var/db/dhcpd6.leases
var/db/dhcpd6.leases~
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This clarified where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pkg&lt;/code&gt; placed the package files during installation.&lt;/p&gt;

</summary>
		</item>
		
		<item>
			<title>My Appearance on the Ship It! Podcast</title>
			<link>https://blog.daveeddy.com/2024/10/05/my-appearance-on-the-ship-it-podcast/</link>
			<updated>2024-10-05T00:00:00-04:00</updated>
			<pubDate>2024-10-05T00:00:00-04:00</pubDate>
			<id>https://blog.daveeddy.com/2024/10/05/my-appearance-on-the-ship-it-podcast/</id>
			<gid>https://blog.daveeddy.com/2024/10/05/my-appearance-on-the-ship-it-podcast/</gid>
			<guid>https://blog.daveeddy.com/2024/10/05/my-appearance-on-the-ship-it-podcast/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;Check it out, I made an appearance on the &lt;a href=&quot;https://changelog.com/shipit&quot;&gt;Ship It!&lt;/a&gt; podcast!  It was a
great time chatting with Justin and Autumn and I hope this will kick start my
podcast-era 😎.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Dave Eddy has learned systems programming the traditional way with books and man pages. Now he’s sharing what he’s learned, starting with bash.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;audio data-theme=&quot;night&quot; data-src=&quot;https://changelog.com/shipit/124/embed&quot; src=&quot;https://op3.dev/e/https://cdn.changelog.com/uploads/shipit/124/ship-it-124.mp3&quot; preload=&quot;none&quot; class=&quot;changelog-episode&quot; controls=&quot;&quot;&gt;&lt;/audio&gt;
&lt;p&gt;&lt;a href=&quot;https://changelog.com/shipit/124&quot;&gt;Ship It! 124: You suck at programming&lt;/a&gt; – Listen on &lt;a href=&quot;https://changelog.com/&quot;&gt;Changelog.com&lt;/a&gt;&lt;/p&gt;
&lt;script async=&quot;&quot; src=&quot;//cdn.changelog.com/embed.js&quot;&gt;&lt;/script&gt;

</summary>
		</item>
		
		<item>
			<title>New Album - Nightfall</title>
			<link>https://blog.daveeddy.com/2024/05/17/new-album-nightfall/</link>
			<updated>2024-05-17T00:00:00-04:00</updated>
			<pubDate>2024-05-17T00:00:00-04:00</pubDate>
			<id>https://blog.daveeddy.com/2024/05/17/new-album-nightfall/</id>
			<gid>https://blog.daveeddy.com/2024/05/17/new-album-nightfall/</gid>
			<guid>https://blog.daveeddy.com/2024/05/17/new-album-nightfall/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;I released my latest album on May 17th, 2024!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://music.daveeddy.com/albums/nightfall&quot;&gt;&lt;img src=&quot;/static/media/2024/nightfall/nightfall.jpg&quot; style=&quot;max-width: 600px; width: 100%; &quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My 6th album (5th full-length). Nightfall consists of songs written mostly
between 2021 and 2024 with a few notable exceptions capturing the feeling of a
long night with an eventual dawn at the end.&lt;/p&gt;

&lt;p&gt;Download or stream &lt;a href=&quot;https://music.daveeddy.com/albums/nightfall&quot;&gt;Nightfall&lt;/a&gt;.&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/usocnehtnlA?si=UkBxQvQk2paCQluB&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay;
clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&quot; referrerpolicy=&quot;strict-origin-when-cross-origin&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;!-- more --&gt;

&lt;h3 id=&quot;tracklist&quot;&gt;Tracklist&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Before the Night &lt;small&gt;3:15&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Snowfall Serenade &lt;small&gt;3:12&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Tears Unspoken &lt;small&gt;3:36&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Colors &lt;small&gt;2:58&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Gone &lt;small&gt;3:26&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Safe House &lt;small&gt;3:02&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;B♭ Song (2024 Version) &lt;small&gt;3:05&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Drifted Away &lt;small&gt;3:21&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Piano Improvisation &lt;small&gt;5:26&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Reverie Amidst Ruins &lt;small&gt;1:07&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Echoes of Solace &lt;small&gt;4:08&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Song for an Empty World &lt;small&gt;3:43&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;The Final Storm &lt;small&gt;4:30&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
</summary>
		</item>
		
		<item>
			<title>You Suck at Programming</title>
			<link>https://blog.daveeddy.com/2024/03/23/you-suck-at-programming/</link>
			<updated>2024-03-23T00:00:00-04:00</updated>
			<pubDate>2024-03-23T00:00:00-04:00</pubDate>
			<id>https://blog.daveeddy.com/2024/03/23/you-suck-at-programming/</id>
			<gid>https://blog.daveeddy.com/2024/03/23/you-suck-at-programming/</gid>
			<guid>https://blog.daveeddy.com/2024/03/23/you-suck-at-programming/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;In late 2022 I started a new series on TikTok called You Suck at Programming.
In it I mostly talk about really cool Bash and Unix tricks and pitfalls and just
general advice.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://ysap.daveeddy.com&quot;&gt;&lt;img src=&quot;/static/media/2024/ysap.png&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;I recently went through and cataloged all of the episodes and made them
available on a new website that you can view in the browser, or on your
terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://ysap.daveeddy.com&quot;&gt;&lt;img src=&quot;/static/media/2024/ysap-tiktok.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To pull the episodes run:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ curl ysap.daveeddy.com
 _   _ ___  __ _ _ __
| | | / __|/ _` | '_ \   You suck at programming
| |_| \__ \ (_| | |_) |  Episodes and guide by dave eddy
 \__, |___/\__,_| .__/   https://www.daveeddy.com
  __/ |         | |
 |___/          |_|      Source: https://github.com/bahamas10/you-suck-at-programming

...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</summary>
		</item>
		
		<item>
			<title>Void Linux Bhyve Image on OmniOS</title>
			<link>https://blog.daveeddy.com/2022/09/19/void-linux-bhyve-image-on-omnios/</link>
			<updated>2022-09-19T00:00:00-04:00</updated>
			<pubDate>2022-09-19T00:00:00-04:00</pubDate>
			<id>https://blog.daveeddy.com/2022/09/19/void-linux-bhyve-image-on-omnios/</id>
			<gid>https://blog.daveeddy.com/2022/09/19/void-linux-bhyve-image-on-omnios/</gid>
			<guid>https://blog.daveeddy.com/2022/09/19/void-linux-bhyve-image-on-omnios/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;&lt;a href=&quot;/static/media/2022/bhyve-void/omnios-on-void.jpg&quot;&gt;&lt;img src=&quot;/static/media/2022/bhyve-void/omnios-on-void.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This guide will show how to install &lt;a href=&quot;https://voidlinux.org&quot;&gt;Void Linux&lt;/a&gt; as a guest on
&lt;a href=&quot;https://omnios.org&quot;&gt;OmniOS&lt;/a&gt; using hardware virtualization with &lt;a href=&quot;https://bhyve.org&quot;&gt;bhyve&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;configure-the-system&quot;&gt;Configure the system&lt;/h1&gt;

&lt;p&gt;To get started, first install &lt;a href=&quot;https://github.com/omniosorg/zadm&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt;&lt;/a&gt; on OmniOS inside the global zone.
This tool makes creating and managing zones simple and is reminiscent of the
&lt;a href=&quot;https://wiki.smartos.org/managing-instances-with-vmamd/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vmadm&lt;/code&gt;&lt;/a&gt; command on &lt;a href=&quot;https://smartos.org&quot;&gt;SmartOS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pkg install zadm
pkg install zones/brand/bhyve
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I personally use this config for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt; (shoutouts to
&lt;a href=&quot;http://mikezeller.net&quot;&gt;@papertigers&lt;/a&gt; for this), but feel free to customize this as you
like.&lt;/p&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/opt/ooce/zadm/zadm.conf&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;CONFIG&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;format&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;toml&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;CONSOLE&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;auto_connect&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;off&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;auto_disconnect&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;on&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;escape_char&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;_&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;SNAPSHOT&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;prefix&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;zadm__&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Test that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt; was installed and works as expected by running:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@datadyne:~# zadm list
NAME              STATUS     BRAND       RAM    CPUS  SHARES
global            running    ipkg       256G      64       1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that for this blog post I ran all of these commands on a fresh system so
only 1 zone is running (the global zone).&lt;/p&gt;

&lt;p&gt;Create the datasets needed.  You can customize these if you’d like but for the
sake of this post I’ll be using these datasets:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;zfs create -o mountpoint=/zones rpool/zones
zfs create rpool/zones/config
zfs create rpool/zones/data
zfs create rpool/zones/zones
mkdir /zones/config/iso
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/config&lt;/code&gt; toml files for each zone used during zone creation.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/data&lt;/code&gt; dataset to store persistent data for each zone that can be LOFS
mounted into the zone.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/zones&lt;/code&gt; confusingly named, but each zones root data will live in this
  directory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, a zone named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;foo&lt;/code&gt; would have files like:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/config/foo.toml&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/data/foo&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/zones/foo&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;create-the-initial-void-vm&quot;&gt;Create the initial void VM&lt;/h1&gt;

&lt;p&gt;Pull the full ISO from the void Linux download page.  I’m using the “Base Live
Image x86_64 glibc” for this:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://voidlinux.org/download/&quot;&gt;https://voidlinux.org/download/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Download this ISO (yours might be named differently) to the machine:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd /zones/config/iso
wget https://alpha.de.repo.voidlinux.org/live/current/void-live-x86_64-20210930.iso
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create the zone toml file:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/config/void-golden-image.toml&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;py&quot;&gt;zonename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;void-golden-image&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;cdrom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/zones/config/iso/void-live-x86_64-20210930.iso&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;zonepath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/zones/zones/void-golden-image&quot;&lt;/span&gt;

&lt;span class=&quot;py&quot;&gt;ram&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2G&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;vcpus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;4&quot;&lt;/span&gt;

&lt;span class=&quot;py&quot;&gt;dns-domain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rapture.com&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;resolvers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=[&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;10.0.1.2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;10.0.1.3&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;py&quot;&gt;acpi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;on&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;xhci&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;on&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;autoboot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;bootorder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;cd&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;brand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;bhyve&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;ip-type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;exclusive&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;limitpriv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;default&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[capped-memory]&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# should match global &quot;ram&quot; key above&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2G&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2G&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[net]]&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# will use DHCP when creating the golden image&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;global-nic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;e1000g0&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;voidgoldenimage0&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[bootdisk]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;blocksize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;8K&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rpool/zones/zones/void-golden-image/root&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;50G&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;sparse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[vnc]&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# needed for installation&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;enabled&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;on&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There are a lot of options in this toml file, but hopefully most of them are
self-explanatory - just make sure to update options like the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dns-domain&lt;/code&gt; and
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;global-nic&lt;/code&gt; to match your environment.&lt;/p&gt;

&lt;p&gt;Create the zone:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo zadm create create -b bhyve -t void-golden-image.toml void-golden-image
sudo zadm boot void-golden-image
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Verify with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo zadm list void-golden-image
NAME              STATUS     BRAND       RAM    CPUS  SHARES
void-golden-image running    bhyve        2G       4       1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;At this point the zone should be running, and inside the zone is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bhyve&lt;/code&gt;
process, which is responsible for booting the Void Linux image.  We can’t quite
connect to the console using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm console&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zlogin -C&lt;/code&gt;, so for now we must
use VNC.  Luckily, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt; comes with a simple VNC server built-in.&lt;/p&gt;

&lt;p&gt;Create VNC server (leave this command running):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo zadm webvnc 0.0.0.0:8080 void-golden-image
Web application available at http://0.0.0.0:8080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you are quick enough you may be able to see this grub menu!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/static/media/2022/bhyve-void/void-grub.jpg&quot;&gt;&lt;img src=&quot;/static/media/2022/bhyve-void/void-grub.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If not don’t worry, grub will automatically pick the top option which is what we
want.&lt;/p&gt;

&lt;p&gt;You should end up with a screen that looks something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/static/media/2022/bhyve-void/void-installer-console.jpg&quot;&gt;&lt;img src=&quot;/static/media/2022/bhyve-void/void-installer-console.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As it says in the output, you can now login with the user &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; and the
password &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;voidlinux&lt;/code&gt;.  At this point I prefer to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt;, so I’m using the
bash shell for the installation process as opposed to just &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/bin/sh&lt;/code&gt;.&lt;/p&gt;

&lt;h1 id=&quot;install-void-linux&quot;&gt;Install Void Linux&lt;/h1&gt;

&lt;p&gt;Now, run the command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;void-installer&lt;/code&gt; to bring up the graphical installer - it
should look like:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/static/media/2022/bhyve-void/void-installer.jpg&quot;&gt;&lt;img src=&quot;/static/media/2022/bhyve-void/void-installer.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;void-installer&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;setup&quot;&gt;Setup&lt;/h2&gt;

&lt;p&gt;In the installer make sure to set these options:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RootPassword&lt;/code&gt; - set to something you’ll remember&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;BootLoader&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;Set “use graphical terminal?” to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;no&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Partition&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cfdisk&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gpt&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;disk-partitions&quot;&gt;Disk Partitions&lt;/h2&gt;

&lt;p&gt;Now, you should be inside &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cfdisk&lt;/code&gt; to set up the underlying hard drive (the 50G
disk created in the toml file) for Void.  Create the following:&lt;/p&gt;

&lt;p&gt;3 partitions&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/vda1&lt;/code&gt;: 1G, EFI System&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/vda2&lt;/code&gt;: 2G, Linux swap&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/vda3&lt;/code&gt;: 47G (remaining), Linux filesystem&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your output should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/static/media/2022/bhyve-void/void-cfdisk.jpg&quot;&gt;&lt;img src=&quot;/static/media/2022/bhyve-void/void-cfdisk.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Make sure to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;write&lt;/code&gt; before &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;quit&lt;/code&gt; - otherwise your changes won’t be
saved.&lt;/p&gt;

&lt;h2 id=&quot;file-systems&quot;&gt;File Systems&lt;/h2&gt;

&lt;p&gt;With the partitions created you can now create the file systems in the
installer, they should be this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FileSystems&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/vda1&lt;/code&gt;: vfat (FAT32) - mounted at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/boot/efi&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/vda1&lt;/code&gt;: swap (Linux Swap)&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/vda1&lt;/code&gt;: xfs (SGI’s XFS) - mounted at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xfs&lt;/code&gt; is optional - pick whatever filesystem you prefer.&lt;/p&gt;

&lt;p&gt;Finally, click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Install&lt;/code&gt; and everything should just work.&lt;/p&gt;

&lt;h2 id=&quot;efi-configuration&quot;&gt;EFI Configuration&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;DON’T REBOOT - we’re not done yet!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Back in the live system and outside of the installer, mount the newly installed
boot partition:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mount /dev/vda1 /mnt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Move the grub efi file into the proper location (from
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/boot/efi/EFI/void_grub/grubx64.efi&lt;/code&gt; -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/boot/efi/EFI/BOOT/bootx64.efi&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mv /mnt/EFI/void_grub /mnt/EFI/BOOT
mv /mnt/EFI/BOOT/grubx64.efi /mnt/EFI/BOOT/bootx64.efi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Unmount the filesystem and power off the machine:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;umount /mnt
poweroff
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;configure-serial-console&quot;&gt;Configure serial console&lt;/h2&gt;

&lt;p&gt;Inside the global zone, edit the zones config file with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt; to remove the CD
device (I just commented the lines out for my system):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo zadm edit void-golden-image
...
# cdrom=[
#   &quot;/zones/config/iso/void-live-x86_64-20210930.iso&quot;
# ]
...
$ sudo zadm boot void-golden-image
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This way, the machine will boot from the newly installed OS from the hard drive
and not the CD ROM (where the installer ISO was mounted).&lt;/p&gt;

&lt;p&gt;You may have to refresh the VNC webpage to access the zone, if it all works you
should see a login prompt.  You can use the user &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; with the root password
you setup earlier:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/static/media/2022/bhyve-void/void-console.jpg&quot;&gt;&lt;img src=&quot;/static/media/2022/bhyve-void/void-console.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before going any further, we can make our lives easier by enabling the serial
console:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ln -s /etc/sv/agetty-ttyS0 /var/service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, instruct grub to work over the serial console as well.  Add these lines
(or modify the existing lines) in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/default/grub&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;GRUB_CMDLINE_LINUX_DEFAULT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;loglevel=4 console=ttyS0,115200n8&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GRUB_TERMINAL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;serial
&lt;span class=&quot;nv&quot;&gt;GRUB_SERIAL_COMMAND&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And run:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;update-grub
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, power off the machine again:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;poweroff
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, from the global zone, boot the machine and connect to the console.  We can
do this all in one single command so we don’t miss anything on the console when
the machine powers on:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo zadm boot -C void-golden-image
[Connected to zone 'void-golden-image' console]

[NOTICE: Zone booting up]
Loading Linux 5.13.19_1 ...
Loading initial ramdisk ...
- runit: $Id: 25da3b86f7bed4038b8a039d2f8e8c9bbcf0822b $: booting.
- runit: enter stage: /etc/runit/1
=&amp;gt; Welcome to Void!
...
_.
$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Use the escape sequence defined in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zadm&lt;/code&gt; config to break out of the console
(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_.&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;If everything works, then you should see the kernel messages via the console on
the terminal and not have to rely on VNC.&lt;/p&gt;

&lt;h2 id=&quot;setup-the-vm-image&quot;&gt;Setup the VM image&lt;/h2&gt;

&lt;p&gt;From here you are able to setup this machine however you’d like!  I’d recommend
running updates and installing some optional tools like:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xbps-install -Syu
xbps-install jq htop bwm-ng vim vsv vpm bat fd ripgrep
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Check running services with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vsv&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/static/media/2022/bhyve-void/void-vsv.jpg&quot;&gt;&lt;img src=&quot;/static/media/2022/bhyve-void/void-vsv.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also remove the existing virtual terminals if you just plan on using the
serial console.  I personally leave one active in the event that I need to VNC
back in for whatever reason.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rm /var/service/agetty-tty{2..6}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After you do whatever setup you’d like for the base image, we can get this
prepared to be cloned for future VMs.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd&lt;/code&gt; is configured on Void Linux to generate new host keys if none exist when
the service is started.  These commands will make it so new keys will be
generated on the next
reboot:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sv down sshd
rm /etc/ssh/*_host_*
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next, optionally setup the skeleton for a static IP address (if you don’t want
to use DHCP):&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/rc.local&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-conf highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#ip link set dev eth0 up
#ip addr add 10.0.1.53/24 brd + dev eth0
#ip route add default via 10.0.1.1
&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# mkdir -p /data
# mount /data
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I leave these commented out in the golden image so I can simply uncomment them
and modify them when I create a new machine.&lt;/p&gt;

&lt;p&gt;The last thing I like to do is a put a text file like this in the root home
directory - this is for future me so I can quickly remember how to setup a new
machine that I clone from this image:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[root@void-golden-image ~]# cat getting-started.txt
1. run `hostname` and edit `/etc/hostname`
2. disable `dhcpcd`
3. put IP info in `/etc/rc.local`
4. put DNS info in `/etc/resolv.conf`
5. reboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Break out of the console using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_.&lt;/code&gt; or whatever you’ve defined.&lt;/p&gt;

&lt;h2 id=&quot;create-the-image&quot;&gt;Create the image&lt;/h2&gt;

&lt;p&gt;Snapshot the image root disk:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo zfs snapshot rpool/zones/zones/void-golden-image/root@golden-2022-05-23
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, we have this image which is ready to be cloned for new VMs to make the
installation process way easier for us!&lt;/p&gt;

&lt;h2 id=&quot;create-a-new-instance-of-the-vm&quot;&gt;Create a new instance of the VM&lt;/h2&gt;

&lt;p&gt;We’re going to create a new VM named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;void-test&lt;/code&gt; using this image.  Create a new
toml file:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/config/void-test.toml&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-toml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;py&quot;&gt;zonename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;void-test&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;zonepath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/zones/zones/void-test&quot;&lt;/span&gt;

&lt;span class=&quot;py&quot;&gt;ram&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2G&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;vcpus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;4&quot;&lt;/span&gt;

&lt;span class=&quot;py&quot;&gt;dns-domain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rapture.com&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;resolvers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=[&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;10.0.1.2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&quot;10.0.1.3&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;py&quot;&gt;acpi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;on&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;xhci&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;on&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;autoboot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;bootorder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;cd&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;brand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;bhyve&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;ip-type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;exclusive&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;limitpriv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;default&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[capped-memory]&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# should match global &quot;ram&quot; key above&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2G&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;2G&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[net]]&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# using static IP for this instance&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;allowed-address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;10.0.1.54/24&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;defrouter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;10.0.1.1&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;global-nic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;e1000g0&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;physical&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;voidtest0&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[bootdisk]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;blocksize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;8K&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;rpool/zones/zones/void-test/root&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;50G&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;sparse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[vnc]&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# needed for installation&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;enabled&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;on&quot;&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[fs]]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/data&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;special&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/zones/data/void-test&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;lofs&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=[]&lt;/span&gt;

&lt;span class=&quot;nn&quot;&gt;[[virtfs]]&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;data&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/data&quot;&lt;/span&gt;
&lt;span class=&quot;py&quot;&gt;ro&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;false&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There is a lot of new stuff in this toml - I’ll go through all of it below.
Create a new dataset for the VMs persistent storage and then create the zone&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo zfs create rpool/zones/data/void-test
sudo zadm create create -b bhyve -t void-test.toml void-test
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Before booting the machine, we destroy the created root disk and clone the
golden image into the same location:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo zfs destroy rpool/zones/zones/void-test/root
sudo zfs clone rpool/zones/zones/void-golden-image/root@golden-2022-05-23 rpool/zones/zones/void-test/root
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This means that we have a brand new zone and VM created, but the root disk is a
clone of the golden image we created above.  Boot the VM with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo zadm boot -C void-test
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The username and password are the same as we set above for the image we created.
To configure this new instance we have instructions waiting for us:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cat getting-started.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Following those instructions I simply ran:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hostname void-test
hostname &amp;gt; /etc/hostname
rm /var/service/dhcpcd
vim /etc/rc.local
vim /etc/resolv.conf
reboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;persistent-data&quot;&gt;Persistent data&lt;/h2&gt;

&lt;p&gt;It may be confusing that I keep talking about persistent data in
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zone/data/void-test&lt;/code&gt; when all of the data on the VM is technically persistent.
The point of this is to a have a mount that exists in the zone that won’t be
tied to the VM itself and won’t contain any OS installation files.&lt;/p&gt;

&lt;p&gt;When just using zones, we accomplish this by LOFS mounting (analogous to bind
mounts in Linux) files from the global zone into the zone.  We are going to do
that as well here (in fact, we do that in the toml file in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[[fs]]&lt;/code&gt;
sections).  But, we must go a step further because of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bhyve&lt;/code&gt; and expose those
mounts inside the zone into the hardware VM itself.&lt;/p&gt;

&lt;p&gt;We accomplish this through 9pfs.&lt;/p&gt;

&lt;p&gt;In the void VM you have newly created you must install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;9mount&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xbps-install 9mount
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, you can add this line to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/fstab&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;data /data 9p rw,relatime,dirsync,uname=root,cache=mmap,access=client,trans=virtio,_netdev 0 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And make sure the mount point exists:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir /data
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With all of this in place, you can finally run:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mount /data
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And that directory inside the VM will now be the same as the directory in
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/zones/data/void-test&lt;/code&gt; on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rpool&lt;/code&gt; zpool!  This allows for easy file sharing
between the guest and the host, as well as persisting data in the event that you
want to reprovision the VM from a new image. Make sure to uncomment the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkdir&lt;/code&gt;
and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; commands in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/rc.local&lt;/code&gt; so the directory mounts at boot.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Running void under LX is great, but some software really doesn’t like running
under LX virtualization and it’s just easier to use hardware virtualization at
that point.  bhyve makes it super nice and easy to accomplish this on OmniOS!&lt;/p&gt;

</summary>
		</item>
		
		<item>
			<title>Programmatically Generated Piano Music</title>
			<link>https://blog.daveeddy.com/2021/12/17/programmatically-generated-piano-music/</link>
			<updated>2021-12-17T00:00:00-05:00</updated>
			<pubDate>2021-12-17T00:00:00-05:00</pubDate>
			<id>https://blog.daveeddy.com/2021/12/17/programmatically-generated-piano-music/</id>
			<gid>https://blog.daveeddy.com/2021/12/17/programmatically-generated-piano-music/</gid>
			<guid>https://blog.daveeddy.com/2021/12/17/programmatically-generated-piano-music/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;I wrote a computer program to generate piano music on the command line.  The
generation is done with a simple algorithm to create patterns in MIDI format,
which is then imported into my DAW to process the data and turn it into music.
There is no AI or Machine Learning in this algorithm - the music is
programmatically generated and this video covers the algorithm that I created
in detail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I Made a Computer Program to Generate Piano Music&lt;/strong&gt;&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/v4oRZaSU5E0&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write;
encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;!-- more --&gt;

&lt;p&gt;&lt;strong&gt;5 HOURS of ALGORITHMICALLY GENERATED Piano Music&lt;/strong&gt;&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/rUKQYtI4Yaw&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write;
encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;The source code can be found on GitHub:
&lt;a href=&quot;https://github.com/bahamas10/music-generator&quot;&gt;https://github.com/bahamas10/music-generator&lt;/a&gt;&lt;/p&gt;
</summary>
		</item>
		
		<item>
			<title>Plex Media Server on Void Linux</title>
			<link>https://blog.daveeddy.com/2021/11/15/plex-media-server-on-void-linux/</link>
			<updated>2021-11-15T00:00:00-05:00</updated>
			<pubDate>2021-11-15T00:00:00-05:00</pubDate>
			<id>https://blog.daveeddy.com/2021/11/15/plex-media-server-on-void-linux/</id>
			<gid>https://blog.daveeddy.com/2021/11/15/plex-media-server-on-void-linux/</gid>
			<guid>https://blog.daveeddy.com/2021/11/15/plex-media-server-on-void-linux/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;&lt;img src=&quot;/static/media/2021/plex-on-void/plex-on-void.jpg&quot; alt=&quot;plex-on-void&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;how-to-install-plex-on-void&quot;&gt;How to install Plex on Void&lt;/h2&gt;

&lt;p&gt;Download &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plex-install-manager&lt;/code&gt; from:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/bahamas10/plex-install-manager&quot;&gt;https://github.com/bahamas10/plex-install-manager&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install deps:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xbps-install -S binutils tar curl xz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create user and directories needed:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;useradd -s /bin/false -d /var/empty _plex
mkdir /opt/plex /opt/plex/src /opt/plex/data
chown _plex:_plex /opt/plex/data
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Install Plex:&lt;/p&gt;

&lt;!-- more --&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./plex-install-manager -a -d /opt/plex/src
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Verify Plex installed:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ls -lh /opt/plex/src
total 2.0K
lrwxrwxrwx 1 root root 43 Nov 15 02:44 active -&amp;gt; plexmediaserver_1.24.5.5173-8dcc73a59_amd64/
drwxr-xr-x 4 root root  4 Nov 15 02:44 plexmediaserver_1.24.5.5173-8dcc73a59_amd64/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create Plex service:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir /etc/sv/plex
vim /etc/sv/plex/run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# label=Plex Media Serever&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;exec &lt;/span&gt;2&amp;gt;&amp;amp;1
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'/opt/plex/src/active/root/usr/lib/plexmediaserver'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;1
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PLEX_MEDIA_SERVER_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/plex/src/active/root/usr/lib/plexmediaserver
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/plex/data
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
&lt;span class=&quot;nb&quot;&gt;exec &lt;/span&gt;chpst &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; _plex:_plex ./Plex&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Media&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ln -s /etc/sv/plex /var/service/plex
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;how-to-upgrade&quot;&gt;How to upgrade&lt;/h2&gt;

&lt;p&gt;To upgrade plex you simply need to run the following commands:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./plex-install-manager -a -d /opt/plex/src
sv restart plex
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</summary>
		</item>
		
		<item>
			<title>New Album - Inspired</title>
			<link>https://blog.daveeddy.com/2021/06/01/new-album-inspired/</link>
			<updated>2021-06-01T00:00:00-04:00</updated>
			<pubDate>2021-06-01T00:00:00-04:00</pubDate>
			<id>https://blog.daveeddy.com/2021/06/01/new-album-inspired/</id>
			<gid>https://blog.daveeddy.com/2021/06/01/new-album-inspired/</gid>
			<guid>https://blog.daveeddy.com/2021/06/01/new-album-inspired/</guid>
			<author>Dave Eddy</author>
			<summary type="html">&lt;p&gt;I released my latest album on June 1st, 2021!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://music.daveeddy.com/albums/inspired&quot;&gt;&lt;img src=&quot;/static/media/2021/inspired/inspired.jpg&quot; style=&quot;max-width: 600px; width: 100%; &quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My 5th album (4th full-length). Inspired consists of songs mostly written
during 2020 and 2021 - when I decided to quit my job and focus more on music
creation. It’s comprised of piano and instrumental tracks.&lt;/p&gt;

&lt;p&gt;Download or stream &lt;a href=&quot;https://music.daveeddy.com/albums/inspired&quot;&gt;Inspired&lt;/a&gt;.&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/IzFz_5WqmeQ&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay;
clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;!-- more --&gt;

&lt;h3 id=&quot;tracklist&quot;&gt;Tracklist&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Journey Ahead &lt;small&gt;0:52&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Morning Sun &lt;small&gt;3:23&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Piano Night &lt;small&gt;4:08&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;In My Dream &lt;small&gt;3:33&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Accordance &lt;small&gt;3:20&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Sis Puella Magica (Piano Cover) &lt;small&gt;2:38&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Hidden Away &lt;small&gt;3:18&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;I’m With You &lt;small&gt;4:58&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Something Beautiful &lt;small&gt;3:48&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Lost Corridors &lt;small&gt;3:57&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Frozen &lt;small&gt;3:47&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Secret Place &lt;small&gt;3:15&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Undercurrents &lt;small&gt;4:00&lt;/small&gt;&lt;/li&gt;
  &lt;li&gt;Letting Go &lt;small&gt;3:41&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
</summary>
		</item>
		
	</channel>
</rss>
