From a0b02880e2ce41917d7513418367fb3ebc910f8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lars=20Sj=C3=B6strom?= <lars@radicore.se>
Date: Wed, 8 Jan 2025 11:09:34 +0100
Subject: [PATCH 1/2] feat(hostd): varlink interfaced host controller to manage
 machine configuration and boot mgmt

---
 Cargo.lock                                    | 719 ++++++++++++++++--
 Cargo.toml                                    |   4 +-
 hostd/.gitignore                              |   1 +
 hostd/Cargo.toml                              |  23 +
 hostd/src/api.rs                              |  17 +
 hostd/src/bin/hostd-controller.rs             |  75 ++
 hostd/src/context.rs                          |   9 +
 hostd/src/lib.rs                              |   4 +
 hostd/src/machine.rs                          |  43 ++
 hostd/src/sysupdate.rs                        |  52 ++
 systemd-ipc/.gitignore                        |   1 +
 systemd-ipc/Cargo.toml                        |  17 +
 systemd-ipc/build.rs                          |  12 +
 systemd-ipc/src/addrs.rs                      |   3 +
 .../src/io.systemd.bootcontrol.varlink        |  70 ++
 systemd-ipc/src/io.systemd.hostname.varlink   |  32 +
 systemd-ipc/src/io_systemd_bootcontrol.rs     | 356 +++++++++
 systemd-ipc/src/io_systemd_hostname.rs        | 295 +++++++
 systemd-ipc/src/lib.rs                        |   2 +
 19 files changed, 1679 insertions(+), 56 deletions(-)
 create mode 100644 hostd/.gitignore
 create mode 100644 hostd/Cargo.toml
 create mode 100644 hostd/src/api.rs
 create mode 100644 hostd/src/bin/hostd-controller.rs
 create mode 100644 hostd/src/context.rs
 create mode 100644 hostd/src/lib.rs
 create mode 100644 hostd/src/machine.rs
 create mode 100644 hostd/src/sysupdate.rs
 create mode 100644 systemd-ipc/.gitignore
 create mode 100644 systemd-ipc/Cargo.toml
 create mode 100644 systemd-ipc/build.rs
 create mode 100644 systemd-ipc/src/addrs.rs
 create mode 100644 systemd-ipc/src/io.systemd.bootcontrol.varlink
 create mode 100644 systemd-ipc/src/io.systemd.hostname.varlink
 create mode 100644 systemd-ipc/src/io_systemd_bootcontrol.rs
 create mode 100644 systemd-ipc/src/io_systemd_hostname.rs
 create mode 100644 systemd-ipc/src/lib.rs

diff --git a/Cargo.lock b/Cargo.lock
index e2d7e26..a604d12 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -47,6 +47,15 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+dependencies = [
+ "winapi",
+]
+
 [[package]]
 name = "anstream"
 version = "0.6.18"
@@ -103,6 +112,132 @@ version = "1.0.95"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
 
+[[package]]
+name = "async-broadcast"
+version = "0.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532"
+dependencies = [
+ "event-listener",
+ "event-listener-strategy",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-channel"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a"
+dependencies = [
+ "concurrent-queue",
+ "event-listener-strategy",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-executor"
+version = "1.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec"
+dependencies = [
+ "async-task",
+ "concurrent-queue",
+ "fastrand",
+ "futures-lite",
+ "slab",
+]
+
+[[package]]
+name = "async-fs"
+version = "2.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a"
+dependencies = [
+ "async-lock",
+ "blocking",
+ "futures-lite",
+]
+
+[[package]]
+name = "async-io"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059"
+dependencies = [
+ "async-lock",
+ "cfg-if 1.0.0",
+ "concurrent-queue",
+ "futures-io",
+ "futures-lite",
+ "parking",
+ "polling",
+ "rustix",
+ "slab",
+ "tracing",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "async-lock"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18"
+dependencies = [
+ "event-listener",
+ "event-listener-strategy",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-process"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb"
+dependencies = [
+ "async-channel",
+ "async-io",
+ "async-lock",
+ "async-signal",
+ "async-task",
+ "blocking",
+ "cfg-if 1.0.0",
+ "event-listener",
+ "futures-lite",
+ "rustix",
+ "tracing",
+]
+
+[[package]]
+name = "async-recursion"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.95",
+]
+
+[[package]]
+name = "async-signal"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3"
+dependencies = [
+ "async-io",
+ "async-lock",
+ "atomic-waker",
+ "cfg-if 1.0.0",
+ "futures-core",
+ "futures-io",
+ "rustix",
+ "signal-hook-registry",
+ "slab",
+ "windows-sys 0.59.0",
+]
+
 [[package]]
 name = "async-stream"
 version = "0.3.6"
@@ -122,9 +257,15 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
+[[package]]
+name = "async-task"
+version = "4.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
+
 [[package]]
 name = "async-trait"
 version = "0.1.85"
@@ -133,7 +274,7 @@ checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -211,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
 dependencies = [
  "addr2line",
- "cfg-if",
+ "cfg-if 1.0.0",
  "libc",
  "miniz_oxide",
  "object",
@@ -249,6 +390,19 @@ dependencies = [
  "generic-array",
 ]
 
+[[package]]
+name = "blocking"
+version = "1.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea"
+dependencies = [
+ "async-channel",
+ "async-task",
+ "futures-io",
+ "futures-lite",
+ "piper",
+]
+
 [[package]]
 name = "bumpalo"
 version = "3.16.0"
@@ -287,6 +441,12 @@ dependencies = [
  "shlex",
 ]
 
+[[package]]
+name = "cfg-if"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
+
 [[package]]
 name = "cfg-if"
 version = "1.0.0"
@@ -299,6 +459,12 @@ version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
 
+[[package]]
+name = "chainerror"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ce1bb7fb0c258a6600d699950da347a7a9dad66c3ce815769b5f11cf8fce78e"
+
 [[package]]
 name = "chrono"
 version = "0.4.39"
@@ -344,7 +510,7 @@ dependencies = [
  "heck",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -430,7 +596,7 @@ version = "1.4.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
 ]
 
 [[package]]
@@ -511,7 +677,7 @@ version = "2.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "dirs-sys-next",
 ]
 
@@ -534,7 +700,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -605,7 +771,7 @@ dependencies = [
  "semver",
  "serde",
  "serde_tokenstream",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -629,7 +795,34 @@ version = "0.8.35"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
+]
+
+[[package]]
+name = "endi"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf"
+
+[[package]]
+name = "enumflags2"
+version = "0.7.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147"
+dependencies = [
+ "enumflags2_derive",
+ "serde",
+]
+
+[[package]]
+name = "enumflags2_derive"
+version = "0.7.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -654,7 +847,7 @@ version = "0.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "home",
  "windows-sys 0.48.0",
 ]
@@ -670,6 +863,16 @@ dependencies = [
  "pin-project-lite",
 ]
 
+[[package]]
+name = "event-listener-strategy"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2"
+dependencies = [
+ "event-listener",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "fastrand"
 version = "2.3.0"
@@ -792,6 +995,19 @@ version = "0.3.31"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
 
+[[package]]
+name = "futures-lite"
+version = "2.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532"
+dependencies = [
+ "fastrand",
+ "futures-core",
+ "futures-io",
+ "parking",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "futures-macro"
 version = "0.3.31"
@@ -800,7 +1016,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -843,13 +1059,22 @@ dependencies = [
  "version_check",
 ]
 
+[[package]]
+name = "getopts"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
+dependencies = [
+ "unicode-width",
+]
+
 [[package]]
 name = "getrandom"
 version = "0.2.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "js-sys",
  "libc",
  "wasi",
@@ -958,6 +1183,27 @@ dependencies = [
  "windows-sys 0.59.0",
 ]
 
+[[package]]
+name = "hostd"
+version = "0.2.0"
+dependencies = [
+ "anyhow",
+ "clap",
+ "dropshot",
+ "http",
+ "schemars",
+ "serde",
+ "slog",
+ "slog-async",
+ "sqlx",
+ "tokio",
+ "trace-request",
+ "tracing",
+ "tracing-slog",
+ "zbus",
+ "zbus_systemd",
+]
+
 [[package]]
 name = "hostname"
 version = "0.3.1"
@@ -975,7 +1221,7 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f9c7c7c8ac16c798734b8a24560c1362120597c40d5e1459f09498f8f6c8f2ba"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "libc",
  "windows",
 ]
@@ -1251,7 +1497,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -1467,7 +1713,7 @@ version = "0.10.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "digest",
 ]
 
@@ -1477,6 +1723,15 @@ version = "2.7.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
 
+[[package]]
+name = "memoffset"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
+dependencies = [
+ "autocfg",
+]
+
 [[package]]
 name = "mime"
 version = "0.3.17"
@@ -1537,6 +1792,19 @@ dependencies = [
  "tempfile",
 ]
 
+[[package]]
+name = "nix"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
+dependencies = [
+ "bitflags",
+ "cfg-if 1.0.0",
+ "cfg_aliases",
+ "libc",
+ "memoffset",
+]
+
 [[package]]
 name = "nu-ansi-term"
 version = "0.46.0"
@@ -1642,7 +1910,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5"
 dependencies = [
  "bitflags",
- "cfg-if",
+ "cfg-if 1.0.0",
  "foreign-types",
  "libc",
  "once_cell",
@@ -1658,7 +1926,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -1776,6 +2044,16 @@ dependencies = [
  "tracing",
 ]
 
+[[package]]
+name = "ordered-stream"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "overload"
 version = "0.1.1"
@@ -1804,7 +2082,7 @@ version = "0.9.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "libc",
  "redox_syscall",
  "smallvec",
@@ -1855,6 +2133,33 @@ dependencies = [
  "uuid",
 ]
 
+[[package]]
+name = "peg"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f76678828272f177ac33b7e2ac2e3e73cc6c1cd1e3e387928aa69562fa51367"
+dependencies = [
+ "peg-macros",
+ "peg-runtime",
+]
+
+[[package]]
+name = "peg-macros"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "636d60acf97633e48d266d7415a9355d4389cea327a193f87df395d88cd2b14d"
+dependencies = [
+ "peg-runtime",
+ "proc-macro2",
+ "quote",
+]
+
+[[package]]
+name = "peg-runtime"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9555b1514d2d99d78150d3c799d4c357a3e2c2a8062cd108e93a06d9057629c5"
+
 [[package]]
 name = "pem-rfc7468"
 version = "0.7.0"
@@ -1887,7 +2192,7 @@ checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -1902,6 +2207,17 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
 
+[[package]]
+name = "piper"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066"
+dependencies = [
+ "atomic-waker",
+ "fastrand",
+ "futures-io",
+]
+
 [[package]]
 name = "pkcs1"
 version = "0.7.5"
@@ -1929,6 +2245,21 @@ version = "0.3.31"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
 
+[[package]]
+name = "polling"
+version = "3.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f"
+dependencies = [
+ "cfg-if 1.0.0",
+ "concurrent-queue",
+ "hermit-abi",
+ "pin-project-lite",
+ "rustix",
+ "tracing",
+ "windows-sys 0.59.0",
+]
+
 [[package]]
 name = "powerfmt"
 version = "0.2.0"
@@ -1944,6 +2275,15 @@ dependencies = [
  "zerocopy",
 ]
 
+[[package]]
+name = "proc-macro-crate"
+version = "3.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b"
+dependencies = [
+ "toml_edit",
+]
+
 [[package]]
 name = "proc-macro2"
 version = "1.0.93"
@@ -1995,7 +2335,7 @@ dependencies = [
  "schemars",
  "serde",
  "serde_json",
- "syn",
+ "syn 2.0.95",
  "thiserror 2.0.11",
  "typify",
  "unicode-ident",
@@ -2016,7 +2356,7 @@ dependencies = [
  "serde_json",
  "serde_tokenstream",
  "serde_yaml",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -2039,7 +2379,7 @@ dependencies = [
  "itertools",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -2265,7 +2605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
 dependencies = [
  "cc",
- "cfg-if",
+ "cfg-if 1.0.0",
  "getrandom",
  "libc",
  "spin",
@@ -2400,6 +2740,15 @@ version = "1.0.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
 
+[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
 [[package]]
 name = "schannel"
 version = "0.1.27"
@@ -2432,7 +2781,7 @@ dependencies = [
  "proc-macro2",
  "quote",
  "serde_derive_internals",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -2503,7 +2852,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -2514,14 +2863,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
 name = "serde_json"
-version = "1.0.135"
+version = "1.0.138"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
+checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
 dependencies = [
  "itoa",
  "memchr",
@@ -2539,6 +2888,17 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "serde_repr"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.95",
+]
+
 [[package]]
 name = "serde_spanned"
 version = "0.6.8"
@@ -2557,7 +2917,7 @@ dependencies = [
  "proc-macro2",
  "quote",
  "serde",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -2591,7 +2951,7 @@ version = "0.10.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "cpufeatures",
  "digest",
 ]
@@ -2602,7 +2962,7 @@ version = "0.10.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "cpufeatures",
  "digest",
 ]
@@ -2804,7 +3164,7 @@ dependencies = [
  "quote",
  "sqlx-core",
  "sqlx-macros-core",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -2827,7 +3187,7 @@ dependencies = [
  "sqlx-mysql",
  "sqlx-postgres",
  "sqlx-sqlite",
- "syn",
+ "syn 2.0.95",
  "tempfile",
  "tokio",
  "url",
@@ -2947,6 +3307,12 @@ version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
 
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
 [[package]]
 name = "stringprep"
 version = "0.1.5"
@@ -2972,9 +3338,20 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
 
 [[package]]
 name = "syn"
-version = "2.0.96"
+version = "1.0.109"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.95"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -2998,7 +3375,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -3022,6 +3399,18 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "systemd-ipc"
+version = "0.2.0"
+dependencies = [
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "varlink",
+ "varlink_generator",
+ "walkdir",
+]
+
 [[package]]
 name = "take_mut"
 version = "0.2.2"
@@ -3034,7 +3423,7 @@ version = "3.15.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "fastrand",
  "getrandom",
  "once_cell",
@@ -3089,7 +3478,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -3100,7 +3489,7 @@ checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -3109,7 +3498,7 @@ version = "1.1.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "once_cell",
 ]
 
@@ -3197,7 +3586,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -3286,7 +3675,7 @@ dependencies = [
  "serde",
  "serde_spanned",
  "toml_datetime",
- "winnow",
+ "winnow 0.6.24",
 ]
 
 [[package]]
@@ -3379,7 +3768,7 @@ dependencies = [
  "http",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
  "tracing",
 ]
 
@@ -3403,7 +3792,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -3507,7 +3896,7 @@ dependencies = [
  "semver",
  "serde",
  "serde_json",
- "syn",
+ "syn 2.0.95",
  "thiserror 2.0.11",
  "unicode-ident",
 ]
@@ -3525,10 +3914,21 @@ dependencies = [
  "serde",
  "serde_json",
  "serde_tokenstream",
- "syn",
+ "syn 2.0.95",
  "typify-impl",
 ]
 
+[[package]]
+name = "uds_windows"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9"
+dependencies = [
+ "memoffset",
+ "tempfile",
+ "winapi",
+]
+
 [[package]]
 name = "unicode-bidi"
 version = "0.3.18"
@@ -3556,6 +3956,22 @@ version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0"
 
+[[package]]
+name = "unicode-width"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
+
+[[package]]
+name = "unix_socket"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6aa2700417c405c38f5e6902d699345241c28c0b7ade4abaad71e35a87eb1564"
+dependencies = [
+ "cfg-if 0.1.10",
+ "libc",
+]
+
 [[package]]
 name = "unsafe-libyaml"
 version = "0.2.11"
@@ -3613,6 +4029,47 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
 
+[[package]]
+name = "varlink"
+version = "11.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "409e275987d74665c23610c0959c133360cafd761c1a6ddb1ca6d0685c8cef5d"
+dependencies = [
+ "libc",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "tempfile",
+ "uds_windows",
+ "unix_socket",
+ "winapi",
+]
+
+[[package]]
+name = "varlink_generator"
+version = "10.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d8ff746c5b65d4bfb3a50f630b85cfb6a9d59f18720126e3ebd6bc98527fa51"
+dependencies = [
+ "chainerror",
+ "getopts",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
+ "varlink_parser",
+]
+
+[[package]]
+name = "varlink_parser"
+version = "4.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35fb9f3c1e8ccb33cdb6c84a4477ef3f3884ce6f4b70514ef1fbf7686eae921e"
+dependencies = [
+ "ansi_term",
+ "chainerror",
+ "peg",
+]
+
 [[package]]
 name = "vcpkg"
 version = "0.2.15"
@@ -3634,6 +4091,16 @@ dependencies = [
  "atomic-waker",
 ]
 
+[[package]]
+name = "walkdir"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
+dependencies = [
+ "same-file",
+ "winapi-util",
+]
+
 [[package]]
 name = "want"
 version = "0.3.1"
@@ -3661,7 +4128,7 @@ version = "0.2.100"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "once_cell",
  "rustversion",
  "wasm-bindgen-macro",
@@ -3677,7 +4144,7 @@ dependencies = [
  "log",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
  "wasm-bindgen-shared",
 ]
 
@@ -3687,7 +4154,7 @@ version = "0.4.50"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61"
 dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
  "js-sys",
  "once_cell",
  "wasm-bindgen",
@@ -3712,7 +4179,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
@@ -3794,6 +4261,15 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
 
+[[package]]
+name = "winapi-util"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
+dependencies = [
+ "windows-sys 0.59.0",
+]
+
 [[package]]
 name = "winapi-x86_64-pc-windows-gnu"
 version = "0.4.0"
@@ -4006,6 +4482,15 @@ dependencies = [
  "memchr",
 ]
 
+[[package]]
+name = "winnow"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f"
+dependencies = [
+ "memchr",
+]
+
 [[package]]
 name = "write16"
 version = "1.0.0"
@@ -4018,6 +4503,16 @@ version = "0.5.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
 
+[[package]]
+name = "xdg-home"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6"
+dependencies = [
+ "libc",
+ "windows-sys 0.59.0",
+]
+
 [[package]]
 name = "xtask"
 version = "0.2.0"
@@ -4048,10 +4543,84 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
  "synstructure",
 ]
 
+[[package]]
+name = "zbus"
+version = "5.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cbddd8b6cb25d5d8ec1b23277b45299a98bfb220f1761ca11e186d5c702507f8"
+dependencies = [
+ "async-broadcast",
+ "async-executor",
+ "async-fs",
+ "async-io",
+ "async-lock",
+ "async-process",
+ "async-recursion",
+ "async-task",
+ "async-trait",
+ "blocking",
+ "enumflags2",
+ "event-listener",
+ "futures-core",
+ "futures-util",
+ "hex",
+ "nix",
+ "ordered-stream",
+ "serde",
+ "serde_repr",
+ "static_assertions",
+ "tracing",
+ "uds_windows",
+ "windows-sys 0.59.0",
+ "winnow 0.7.1",
+ "xdg-home",
+ "zbus_macros",
+ "zbus_names",
+ "zvariant",
+]
+
+[[package]]
+name = "zbus_macros"
+version = "5.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dac404d48b4e9cf193c8b49589f3280ceca5ff63519e7e64f55b4cf9c47ce146"
+dependencies = [
+ "proc-macro-crate",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.95",
+ "zbus_names",
+ "zvariant",
+ "zvariant_utils",
+]
+
+[[package]]
+name = "zbus_names"
+version = "4.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97"
+dependencies = [
+ "serde",
+ "static_assertions",
+ "winnow 0.7.1",
+ "zvariant",
+]
+
+[[package]]
+name = "zbus_systemd"
+version = "0.25701.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b772577120750e5a5ab5a5530f38fd462a35fafd9ed475098714afd1b1855ec"
+dependencies = [
+ "futures",
+ "serde",
+ "zbus",
+]
+
 [[package]]
 name = "zerocopy"
 version = "0.7.35"
@@ -4070,7 +4639,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -4090,7 +4659,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
  "synstructure",
 ]
 
@@ -4119,7 +4688,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 2.0.95",
 ]
 
 [[package]]
@@ -4149,3 +4718,45 @@ dependencies = [
  "cc",
  "pkg-config",
 ]
+
+[[package]]
+name = "zvariant"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "31c951c21879c6e1d46ac5adfc34f698fefb465d498cf4ac87545849bd71bb5a"
+dependencies = [
+ "endi",
+ "enumflags2",
+ "serde",
+ "static_assertions",
+ "winnow 0.7.1",
+ "zvariant_derive",
+ "zvariant_utils",
+]
+
+[[package]]
+name = "zvariant_derive"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9eeb539471af098d9e63faf428c71ac4cd4efe0b5baa3c8a6b991c5f2543b70e"
+dependencies = [
+ "proc-macro-crate",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.95",
+ "zvariant_utils",
+]
+
+[[package]]
+name = "zvariant_utils"
+version = "3.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e16edfee43e5d7b553b77872d99bc36afdda75c223ca7ad5e3fbecd82ca5fc34"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "serde",
+ "static_assertions",
+ "syn 2.0.95",
+ "winnow 0.7.1",
+]
diff --git a/Cargo.toml b/Cargo.toml
index d61baf6..d1a0b96 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,8 +4,10 @@ members = [
   "agent",
   "controller",
   "instrumentation",
+  "hostd",
   "trace-request",
   "xtask",
+  "systemd-ipc",
 ]
 default-members = [
   "agent",
@@ -44,7 +46,5 @@ slog = "2.7.0"
 slog-async = "2.8.0"
 tokio = { version = "1.43.0", features = ["full"] }
 tracing = "0.1.41"
-tracing-core = "0.1.33"
-tracing-chrome = "0.7.2"
 tracing-slog = { git = "https://github.com/oxidecomputer/tracing-slog", default-features = false }
 uuid = { version = "1", features = [ "serde", "v4" ] }
diff --git a/hostd/.gitignore b/hostd/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/hostd/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/hostd/Cargo.toml b/hostd/Cargo.toml
new file mode 100644
index 0000000..f3322c7
--- /dev/null
+++ b/hostd/Cargo.toml
@@ -0,0 +1,23 @@
+[package]
+name = "hostd"
+version.workspace = true
+edition.workspace = true
+
+[dependencies]
+anyhow.workspace = true
+tokio.workspace = true
+sqlx = { version = "0.8.3", default-features = false, features = [
+    "macros", "migrate", "postgres", "runtime-tokio", "tls-rustls", "time", "uuid"
+  ] }
+dropshot.workspace = true
+clap.workspace = true
+slog.workspace = true
+slog-async.workspace = true
+tracing-slog.workspace = true
+tracing.workspace = true
+trace-request = { path = "../trace-request" }
+schemars.workspace = true
+serde.workspace = true
+http.workspace = true
+zbus_systemd = { version = "0.25701.0", features = ["hostname1", "sysupdate1", "network1", "portable1", "resolve1", "systemd1"] }
+zbus = "5.4.0"
diff --git a/hostd/src/api.rs b/hostd/src/api.rs
new file mode 100644
index 0000000..7f68d70
--- /dev/null
+++ b/hostd/src/api.rs
@@ -0,0 +1,17 @@
+use anyhow::Result;
+use dropshot::ApiDescription;
+
+use std::sync::Arc;
+
+use crate::context::ControllerContext;
+use crate::machine;
+use crate::sysupdate;
+
+type ControllerApiDescription = ApiDescription<Arc<ControllerContext>>;
+
+pub fn api() -> Result<ControllerApiDescription> {
+    let mut api = ControllerApiDescription::new();
+    api.register(machine::describe)?;
+    api.register(sysupdate::list_versions)?;
+    Ok(api)
+}
diff --git a/hostd/src/bin/hostd-controller.rs b/hostd/src/bin/hostd-controller.rs
new file mode 100644
index 0000000..003671e
--- /dev/null
+++ b/hostd/src/bin/hostd-controller.rs
@@ -0,0 +1,75 @@
+use anyhow::{anyhow, Result};
+
+use clap::Parser;
+use dropshot::{ConfigDropshot, ServerBuilder};
+use slog::Drain;
+use std::net::SocketAddr;
+use std::str::FromStr;
+use std::sync::Arc;
+use tracing_slog::TracingSlogDrain;
+
+use hostd::api;
+use hostd::context::ControllerContext;
+
+#[derive(Parser, Debug)]
+#[command(version, about, long_about = None)]
+struct Cli {
+    #[arg(
+        long = "telemetry-otlp-endpoint",
+        default_value = "http://localhost:4317",
+        env = "OTEL_EXPORTER_OTLP_ENDPOINT"
+    )]
+    otlp_endpoint: Option<String>,
+
+    #[arg(
+        long = "log-stderr",
+        short = 'v',
+        default_value = "false",
+        env = "LOG_TO_STDERR"
+    )]
+    log_stderr: bool,
+
+    #[arg(
+        long = "listen-address",
+        default_value = "127.0.0.1:9478",
+        env = "LISTEN_ADDRESS"
+    )]
+    listen_address: String,
+
+    #[arg(
+        long = "database-url",
+        default_value = "postgresql://localhost/patagia",
+        env = "DATABASE_URL"
+    )]
+    database_url: Option<String>,
+}
+
+#[tokio::main]
+async fn main() -> Result<()> {
+    let args = Cli::parse();
+
+    let config = ConfigDropshot {
+        bind_address: SocketAddr::from_str(&args.listen_address).unwrap(),
+        ..Default::default()
+    };
+
+    let logger = {
+        let level_drain = slog::LevelFilter(TracingSlogDrain, slog::Level::Debug).fuse();
+        let async_drain = slog_async::Async::new(level_drain).build().fuse();
+        slog::Logger::root(async_drain, slog::o!())
+    };
+
+    let dbus = zbus::Connection::system().await.unwrap();
+    let ctx = ControllerContext::new(dbus);
+
+    let api = api::api()?;
+
+    println!("Listening on http://{}", config.bind_address);
+
+    ServerBuilder::new(api, Arc::new(ctx), logger)
+        .config(config)
+        .start()
+        .map_err(|e| anyhow!("Error starting server: {:?}", e))?
+        .await
+        .map_err(|e| anyhow!(e))
+}
diff --git a/hostd/src/context.rs b/hostd/src/context.rs
new file mode 100644
index 0000000..de20783
--- /dev/null
+++ b/hostd/src/context.rs
@@ -0,0 +1,9 @@
+pub struct ControllerContext {
+    pub dbus: zbus::Connection,
+}
+
+impl ControllerContext {
+    pub fn new(dbus: zbus::Connection) -> ControllerContext {
+        ControllerContext { dbus }
+    }
+}
diff --git a/hostd/src/lib.rs b/hostd/src/lib.rs
new file mode 100644
index 0000000..3b7a5eb
--- /dev/null
+++ b/hostd/src/lib.rs
@@ -0,0 +1,4 @@
+pub mod api;
+pub mod context;
+pub mod machine;
+pub mod sysupdate;
diff --git a/hostd/src/machine.rs b/hostd/src/machine.rs
new file mode 100644
index 0000000..a2926c2
--- /dev/null
+++ b/hostd/src/machine.rs
@@ -0,0 +1,43 @@
+use dropshot::{endpoint, HttpError, HttpResponseOk, RequestContext};
+use schemars::JsonSchema;
+use serde::Serialize;
+use std::sync::Arc;
+use trace_request::trace_request;
+
+use crate::context::ControllerContext;
+
+/// Machine information
+#[derive(Serialize, JsonSchema)]
+#[serde(rename_all = "camelCase")]
+struct MachineInfo {
+    machine_id: String,
+}
+
+/// Fetch machine info
+#[endpoint {
+    method = GET,
+    path = "/machine_info",
+}]
+#[trace_request]
+pub async fn describe(
+    rqctx: RequestContext<Arc<ControllerContext>>,
+) -> Result<HttpResponseOk<MachineInfo>, HttpError> {
+    let hostnamed = zbus_systemd::hostname1::HostnamedProxy::new(&rqctx.context().dbus)
+        .await
+        .unwrap();
+
+    let machine_id = hostnamed
+        .machine_id()
+        .await
+        .map_err(|e| match e {
+            err => HttpError::for_internal_error(format!("Error: {}", err)),
+        })?
+        // convert bytes to hex string
+        .iter()
+        .map(|&b| format!("{:02x}", b))
+        .collect();
+
+    let machine_info = MachineInfo { machine_id };
+
+    Ok(HttpResponseOk(machine_info))
+}
diff --git a/hostd/src/sysupdate.rs b/hostd/src/sysupdate.rs
new file mode 100644
index 0000000..43873cd
--- /dev/null
+++ b/hostd/src/sysupdate.rs
@@ -0,0 +1,52 @@
+use dropshot::{endpoint, HttpError, HttpResponseOk, RequestContext};
+use schemars::JsonSchema;
+use serde::Serialize;
+use std::sync::Arc;
+use trace_request::trace_request;
+
+use crate::context::ControllerContext;
+
+const SYSUPDATE_HOST_PATH: &str = "/org/freedesktop/sysupdate1/target/host";
+
+#[derive(Serialize, JsonSchema)]
+#[serde(rename_all = "camelCase")]
+struct SysUpdate {
+    current_version: String,
+    versions: Vec<String>,
+}
+
+#[endpoint {
+    method = GET,
+    path = "/list_versions",
+}]
+#[trace_request]
+pub async fn list_versions(
+    rqctx: RequestContext<Arc<ControllerContext>>,
+) -> Result<HttpResponseOk<SysUpdate>, HttpError> {
+    let sysupdate_target = zbus_systemd::sysupdate1::TargetProxy::builder(&rqctx.context().dbus)
+        .path(SYSUPDATE_HOST_PATH)
+        .unwrap()
+        .build()
+        .await
+        .map_err(|e| match e {
+            err => HttpError::for_internal_error(format!("Error: {}", err)),
+        })?;
+
+    let versions = sysupdate_target.list(0).await.map_err(|e| match e {
+        err => {
+            println!("Error: {}", err);
+            HttpError::for_internal_error(format!("Error: {}", err))
+        }
+    })?;
+
+    let current_version = sysupdate_target.get_version().await.map_err(|e| match e {
+        err => HttpError::for_internal_error(format!("Error: {}", err)),
+    })?;
+
+    let sysupdate = SysUpdate {
+        versions,
+        current_version,
+    };
+
+    Ok(HttpResponseOk(sysupdate))
+}
diff --git a/systemd-ipc/.gitignore b/systemd-ipc/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/systemd-ipc/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/systemd-ipc/Cargo.toml b/systemd-ipc/Cargo.toml
new file mode 100644
index 0000000..4667cf5
--- /dev/null
+++ b/systemd-ipc/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+name = "systemd-ipc"
+version.workspace = true
+edition.workspace = true
+
+[dependencies]
+serde.workspace = true
+serde_derive = "1.0.217"
+serde_json = "1.0.135"
+varlink = "11.0.1"
+
+[build-dependencies]
+varlink_generator = "10.1.0"
+walkdir = "2.5.0"
+
+[package.metadata.cargo-machete]
+ignored = ["serde"]
diff --git a/systemd-ipc/build.rs b/systemd-ipc/build.rs
new file mode 100644
index 0000000..fcec0de
--- /dev/null
+++ b/systemd-ipc/build.rs
@@ -0,0 +1,12 @@
+extern crate varlink_generator;
+
+use walkdir::WalkDir;
+
+fn main() {
+    println!("cargo:rerun-if-changed=src/*.varlink");
+    for entry in WalkDir::new("src").into_iter().filter_map(|e| e.ok()) {
+        if entry.file_name().to_str().unwrap().ends_with(".varlink") {
+            varlink_generator::cargo_build_tosource(&entry.path().display().to_string(), true);
+        }
+    }
+}
diff --git a/systemd-ipc/src/addrs.rs b/systemd-ipc/src/addrs.rs
new file mode 100644
index 0000000..1e6f888
--- /dev/null
+++ b/systemd-ipc/src/addrs.rs
@@ -0,0 +1,3 @@
+#[allow(dead_code)]
+pub const SYSTEMD_HOSTNAME: &str = "unix:/run/systemd/io.systemd.Hostname";
+pub const SYSTEMD_BOOTCONTROL: &str = "unix:/run/systemd/io.systemd.BootControl";
diff --git a/systemd-ipc/src/io.systemd.bootcontrol.varlink b/systemd-ipc/src/io.systemd.bootcontrol.varlink
new file mode 100644
index 0000000..871e560
--- /dev/null
+++ b/systemd-ipc/src/io.systemd.bootcontrol.varlink
@@ -0,0 +1,70 @@
+# Boot Loader control APIs
+interface io.systemd.BootControl
+
+# The type of a boot entry
+type BootEntryType(
+	# Boot Loader Specification Type #1 entries (.conf files)
+	type1,
+	# Boot Loader Specification Type #2 entries (UKIs)
+	type2,
+	# Additional entries reported by boot loader
+	loader,
+	# Automatically generated entries
+	auto
+)
+
+# A structure encapsulating a boot entry
+type BootEntry(
+	type: BootEntryType,
+	# The string identifier of the entry
+	id: ?string,
+	path: ?string,
+	root: ?string,
+	title: ?string,
+	showTitle: ?string,
+	sortKey: ?string,
+	version: ?string,
+	machineId: ?string,
+	architecture: ?string,
+	options: ?string,
+	linux: ?string,
+	efi: ?string,
+	initrd: ?[]string,
+	devicetree: ?string,
+	devicetreeOverlay: ?[]string,
+	# Indicates whether the boot loader reported this entry on the current boot
+	isReported: bool,
+	# Indicates the number of tries left for this boot entry before it is assumed to be not working.
+	triesLeft: ?int,
+	# Indicates the number of unsuccessful tries already made for this boot entry.
+	triesDone: ?int,
+	# Indicates whether this entry is the default entry.
+	isDefault: ?bool,
+	# Indicates whether this entry has been booted.
+	isSelected: ?bool
+)
+
+# Enumerates boot entries. Method call must be called with 'more' flag set. Each response returns one entry. If no entries are defined returns the NoSuchBootEntry error.
+# [Requires 'more' flag]
+method ListBootEntries() -> (
+	# A boot menu entry structure
+	entry: ?BootEntry
+)
+
+# Sets the reboot-to-firmware-UI flag of the firmware, if this concept exists. Returns the RebootToFirmwareNotSupported error if not.
+method SetRebootToFirmware(
+	# The new value of the reboot-to-firmware-UI flag
+	state: bool
+) -> ()
+
+# Gets the current state of the reboot-to-firmware-UI flag of the firmware, if this concept exists. Returns the RebootToFirmwareNotSupported error if not.
+method GetRebootToFirmware() -> (
+	# The current state of the reboot-to-firmware-UI flag
+	state: bool
+)
+
+# SetRebootToFirmware() and GetRebootToFirmware() return this if the firmware does not actually support the reboot-to-firmware-UI concept.
+error RebootToFirmwareNotSupported()
+
+# No boot entry defined.
+error NoSuchBootEntry()
diff --git a/systemd-ipc/src/io.systemd.hostname.varlink b/systemd-ipc/src/io.systemd.hostname.varlink
new file mode 100644
index 0000000..be4cf01
--- /dev/null
+++ b/systemd-ipc/src/io.systemd.hostname.varlink
@@ -0,0 +1,32 @@
+interface io.systemd.Hostname
+
+method Describe() -> (
+	Hostname: string,
+	StaticHostname: ?string,
+	PrettyHostname: ?string,
+	DefaultHostname: ?string,
+	HostnameSource: string,
+	IconName: ?string,
+	Chassis: ?string,
+	Deployment: ?string,
+	Location: ?string,
+	KernelName: string,
+	KernelRelease: string,
+	KernelVersion: string,
+	OperatingSystemPrettyName: ?string,
+	OperatingSystemCPEName: ?string,
+	OperatingSystemHomeURL: ?string,
+	OperatingSystemSupportEnd: ?int,
+	OperatingSystemReleaseData: ?[]string,
+	MachineInformationData: ?[]string,
+	HardwareVendor: ?string,
+	HardwareModel: ?string,
+	HardwareSerial: ?string,
+	FirmwareVersion: ?string,
+	FirmwareVendor: ?string,
+	FirmwareDate: ?int,
+	MachineID: string,
+	BootID: string,
+	ProductUUID: ?string,
+	VSockCID: ?int
+)
diff --git a/systemd-ipc/src/io_systemd_bootcontrol.rs b/systemd-ipc/src/io_systemd_bootcontrol.rs
new file mode 100644
index 0000000..e36709d
--- /dev/null
+++ b/systemd-ipc/src/io_systemd_bootcontrol.rs
@@ -0,0 +1,356 @@
+#![doc = "This file was automatically generated by the varlink rust generator"]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+use serde_derive::{Deserialize, Serialize};
+use std::io::BufRead;
+use std::sync::{Arc, RwLock};
+use varlink::{self, CallTrait};
+#[allow(dead_code)]
+#[derive(Clone, PartialEq, Debug)]
+#[allow(clippy::enum_variant_names)]
+pub enum ErrorKind {
+    Varlink_Error,
+    VarlinkReply_Error,
+    NoSuchBootEntry(Option<NoSuchBootEntry_Args>),
+    RebootToFirmwareNotSupported(Option<RebootToFirmwareNotSupported_Args>),
+}
+impl ::std::fmt::Display for ErrorKind {
+    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+        match self {
+            ErrorKind::Varlink_Error => write!(f, "Varlink Error"),
+            ErrorKind::VarlinkReply_Error => write!(f, "Varlink error reply"),
+            ErrorKind::NoSuchBootEntry(v) => {
+                write!(f, "io.systemd.BootControl.NoSuchBootEntry: {:#?}", v)
+            }
+            ErrorKind::RebootToFirmwareNotSupported(v) => write!(
+                f,
+                "io.systemd.BootControl.RebootToFirmwareNotSupported: {:#?}",
+                v
+            ),
+        }
+    }
+}
+pub struct Error(
+    pub ErrorKind,
+    pub Option<Box<dyn std::error::Error + 'static + Send + Sync>>,
+    pub Option<&'static str>,
+);
+impl Error {
+    #[allow(dead_code)]
+    pub fn kind(&self) -> &ErrorKind {
+        &self.0
+    }
+}
+impl From<ErrorKind> for Error {
+    fn from(e: ErrorKind) -> Self {
+        Error(e, None, None)
+    }
+}
+impl std::error::Error for Error {
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        self.1
+            .as_ref()
+            .map(|e| e.as_ref() as &(dyn std::error::Error + 'static))
+    }
+}
+impl std::fmt::Display for Error {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        std::fmt::Display::fmt(&self.0, f)
+    }
+}
+impl std::fmt::Debug for Error {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        use std::error::Error as StdError;
+        if let Some(ref o) = self.2 {
+            std::fmt::Display::fmt(o, f)?;
+        }
+        std::fmt::Debug::fmt(&self.0, f)?;
+        if let Some(e) = self.source() {
+            std::fmt::Display::fmt("\nCaused by:\n", f)?;
+            std::fmt::Debug::fmt(&e, f)?;
+        }
+        Ok(())
+    }
+}
+#[allow(dead_code)]
+pub type Result<T> = std::result::Result<T, Error>;
+impl From<varlink::Error> for Error {
+    fn from(e: varlink::Error) -> Self {
+        match e.kind() {
+            varlink::ErrorKind::VarlinkErrorReply(r) => Error(
+                ErrorKind::from(r),
+                Some(Box::from(e)),
+                Some(concat!(file!(), ":", line!(), ": ")),
+            ),
+            _ => Error(
+                ErrorKind::Varlink_Error,
+                Some(Box::from(e)),
+                Some(concat!(file!(), ":", line!(), ": ")),
+            ),
+        }
+    }
+}
+#[allow(dead_code)]
+impl Error {
+    pub fn source_varlink_kind(&self) -> Option<&varlink::ErrorKind> {
+        use std::error::Error as StdError;
+        let mut s: &dyn StdError = self;
+        while let Some(c) = s.source() {
+            let k = self
+                .source()
+                .and_then(|e| e.downcast_ref::<varlink::Error>())
+                .map(|e| e.kind());
+            if k.is_some() {
+                return k;
+            }
+            s = c;
+        }
+        None
+    }
+}
+impl From<&varlink::Reply> for ErrorKind {
+    #[allow(unused_variables)]
+    fn from(e: &varlink::Reply) -> Self {
+        match e {
+            varlink::Reply {
+                error: Some(ref t), ..
+            } if t == "io.systemd.BootControl.NoSuchBootEntry" => match e {
+                varlink::Reply {
+                    parameters: Some(p),
+                    ..
+                } => match serde_json::from_value(p.clone()) {
+                    Ok(v) => ErrorKind::NoSuchBootEntry(v),
+                    Err(_) => ErrorKind::NoSuchBootEntry(None),
+                },
+                _ => ErrorKind::NoSuchBootEntry(None),
+            },
+            varlink::Reply {
+                error: Some(ref t), ..
+            } if t == "io.systemd.BootControl.RebootToFirmwareNotSupported" => match e {
+                varlink::Reply {
+                    parameters: Some(p),
+                    ..
+                } => match serde_json::from_value(p.clone()) {
+                    Ok(v) => ErrorKind::RebootToFirmwareNotSupported(v),
+                    Err(_) => ErrorKind::RebootToFirmwareNotSupported(None),
+                },
+                _ => ErrorKind::RebootToFirmwareNotSupported(None),
+            },
+            _ => ErrorKind::VarlinkReply_Error,
+        }
+    }
+}
+pub trait VarlinkCallError: varlink::CallTrait {
+    fn reply_no_such_boot_entry(&mut self) -> varlink::Result<()> {
+        self.reply_struct(varlink::Reply::error(
+            "io.systemd.BootControl.NoSuchBootEntry",
+            None,
+        ))
+    }
+    fn reply_reboot_to_firmware_not_supported(&mut self) -> varlink::Result<()> {
+        self.reply_struct(varlink::Reply::error(
+            "io.systemd.BootControl.RebootToFirmwareNotSupported",
+            None,
+        ))
+    }
+}
+impl<'a> VarlinkCallError for varlink::Call<'a> {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct r#BootEntry {
+    pub r#type: BootEntryType,
+    pub r#id: Option<String>,
+    pub r#path: Option<String>,
+    pub r#root: Option<String>,
+    pub r#title: Option<String>,
+    pub r#showTitle: Option<String>,
+    pub r#sortKey: Option<String>,
+    pub r#version: Option<String>,
+    pub r#machineId: Option<String>,
+    pub r#architecture: Option<String>,
+    pub r#options: Option<String>,
+    pub r#linux: Option<String>,
+    pub r#efi: Option<String>,
+    pub r#initrd: Option<Vec<String>>,
+    pub r#devicetree: Option<String>,
+    pub r#devicetreeOverlay: Option<Vec<String>>,
+    pub r#isReported: bool,
+    pub r#triesLeft: Option<i64>,
+    pub r#triesDone: Option<i64>,
+    pub r#isDefault: Option<bool>,
+    pub r#isSelected: Option<bool>,
+}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub enum r#BootEntryType {
+    r#type1,
+    r#type2,
+    r#loader,
+    r#auto,
+}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct NoSuchBootEntry_Args {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct RebootToFirmwareNotSupported_Args {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct GetRebootToFirmware_Reply {
+    pub r#state: bool,
+}
+impl varlink::VarlinkReply for GetRebootToFirmware_Reply {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct GetRebootToFirmware_Args {}
+pub trait Call_GetRebootToFirmware: VarlinkCallError {
+    fn reply(&mut self, r#state: bool) -> varlink::Result<()> {
+        self.reply_struct(GetRebootToFirmware_Reply { r#state }.into())
+    }
+}
+impl<'a> Call_GetRebootToFirmware for varlink::Call<'a> {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct ListBootEntries_Reply {
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#entry: Option<BootEntry>,
+}
+impl varlink::VarlinkReply for ListBootEntries_Reply {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct ListBootEntries_Args {}
+pub trait Call_ListBootEntries: VarlinkCallError {
+    fn reply(&mut self, r#entry: Option<BootEntry>) -> varlink::Result<()> {
+        self.reply_struct(ListBootEntries_Reply { r#entry }.into())
+    }
+}
+impl<'a> Call_ListBootEntries for varlink::Call<'a> {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct SetRebootToFirmware_Reply {}
+impl varlink::VarlinkReply for SetRebootToFirmware_Reply {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct SetRebootToFirmware_Args {
+    pub r#state: bool,
+}
+pub trait Call_SetRebootToFirmware: VarlinkCallError {
+    fn reply(&mut self) -> varlink::Result<()> {
+        self.reply_struct(varlink::Reply::parameters(None))
+    }
+}
+impl<'a> Call_SetRebootToFirmware for varlink::Call<'a> {}
+pub trait VarlinkInterface {
+    fn get_reboot_to_firmware(
+        &self,
+        call: &mut dyn Call_GetRebootToFirmware,
+    ) -> varlink::Result<()>;
+    fn list_boot_entries(&self, call: &mut dyn Call_ListBootEntries) -> varlink::Result<()>;
+    fn set_reboot_to_firmware(
+        &self,
+        call: &mut dyn Call_SetRebootToFirmware,
+        r#state: bool,
+    ) -> varlink::Result<()>;
+    fn call_upgraded(
+        &self,
+        _call: &mut varlink::Call,
+        _bufreader: &mut dyn BufRead,
+    ) -> varlink::Result<Vec<u8>> {
+        Ok(Vec::new())
+    }
+}
+pub trait VarlinkClientInterface {
+    fn get_reboot_to_firmware(
+        &mut self,
+    ) -> varlink::MethodCall<GetRebootToFirmware_Args, GetRebootToFirmware_Reply, Error>;
+    fn list_boot_entries(
+        &mut self,
+    ) -> varlink::MethodCall<ListBootEntries_Args, ListBootEntries_Reply, Error>;
+    fn set_reboot_to_firmware(
+        &mut self,
+        r#state: bool,
+    ) -> varlink::MethodCall<SetRebootToFirmware_Args, SetRebootToFirmware_Reply, Error>;
+}
+#[allow(dead_code)]
+pub struct VarlinkClient {
+    connection: Arc<RwLock<varlink::Connection>>,
+}
+impl VarlinkClient {
+    #[allow(dead_code)]
+    pub fn new(connection: Arc<RwLock<varlink::Connection>>) -> Self {
+        VarlinkClient { connection }
+    }
+}
+impl VarlinkClientInterface for VarlinkClient {
+    fn get_reboot_to_firmware(
+        &mut self,
+    ) -> varlink::MethodCall<GetRebootToFirmware_Args, GetRebootToFirmware_Reply, Error> {
+        varlink::MethodCall::<GetRebootToFirmware_Args, GetRebootToFirmware_Reply, Error>::new(
+            self.connection.clone(),
+            "io.systemd.BootControl.GetRebootToFirmware",
+            GetRebootToFirmware_Args {},
+        )
+    }
+    fn list_boot_entries(
+        &mut self,
+    ) -> varlink::MethodCall<ListBootEntries_Args, ListBootEntries_Reply, Error> {
+        varlink::MethodCall::<ListBootEntries_Args, ListBootEntries_Reply, Error>::new(
+            self.connection.clone(),
+            "io.systemd.BootControl.ListBootEntries",
+            ListBootEntries_Args {},
+        )
+    }
+    fn set_reboot_to_firmware(
+        &mut self,
+        r#state: bool,
+    ) -> varlink::MethodCall<SetRebootToFirmware_Args, SetRebootToFirmware_Reply, Error> {
+        varlink::MethodCall::<SetRebootToFirmware_Args, SetRebootToFirmware_Reply, Error>::new(
+            self.connection.clone(),
+            "io.systemd.BootControl.SetRebootToFirmware",
+            SetRebootToFirmware_Args { r#state },
+        )
+    }
+}
+#[allow(dead_code)]
+pub struct VarlinkInterfaceProxy {
+    inner: Box<dyn VarlinkInterface + Send + Sync>,
+}
+#[allow(dead_code)]
+pub fn new(inner: Box<dyn VarlinkInterface + Send + Sync>) -> VarlinkInterfaceProxy {
+    VarlinkInterfaceProxy { inner }
+}
+impl varlink::Interface for VarlinkInterfaceProxy {
+    fn get_description(&self) -> &'static str {
+        "# Boot Loader control APIs\ninterface io.systemd.BootControl\n\n# The type of a boot entry\ntype BootEntryType(\n\t# Boot Loader Specification Type #1 entries (.conf files)\n\ttype1,\n\t# Boot Loader Specification Type #2 entries (UKIs)\n\ttype2,\n\t# Additional entries reported by boot loader\n\tloader,\n\t# Automatically generated entries\n\tauto\n)\n\n# A structure encapsulating a boot entry\ntype BootEntry(\n\ttype: BootEntryType,\n\t# The string identifier of the entry\n\tid: ?string,\n\tpath: ?string,\n\troot: ?string,\n\ttitle: ?string,\n\tshowTitle: ?string,\n\tsortKey: ?string,\n\tversion: ?string,\n\tmachineId: ?string,\n\tarchitecture: ?string,\n\toptions: ?string,\n\tlinux: ?string,\n\tefi: ?string,\n\tinitrd: ?[]string,\n\tdevicetree: ?string,\n\tdevicetreeOverlay: ?[]string,\n\t# Indicates whether the boot loader reported this entry on the current boot\n\tisReported: bool,\n\t# Indicates the number of tries left for this boot entry before it is assumed to be not working.\n\ttriesLeft: ?int,\n\t# Indicates the number of unsuccessful tries already made for this boot entry.\n\ttriesDone: ?int,\n\t# Indicates whether this entry is the default entry.\n\tisDefault: ?bool,\n\t# Indicates whether this entry has been booted.\n\tisSelected: ?bool\n)\n\n# Enumerates boot entries. Method call must be called with 'more' flag set. Each response returns one entry. If no entries are defined returns the NoSuchBootEntry error.\n# [Requires 'more' flag]\nmethod ListBootEntries() -> (\n\t# A boot menu entry structure\n\tentry: ?BootEntry\n)\n\n# Sets the reboot-to-firmware-UI flag of the firmware, if this concept exists. Returns the RebootToFirmwareNotSupported error if not.\nmethod SetRebootToFirmware(\n\t# The new value of the reboot-to-firmware-UI flag\n\tstate: bool\n) -> ()\n\n# Gets the current state of the reboot-to-firmware-UI flag of the firmware, if this concept exists. Returns the RebootToFirmwareNotSupported error if not.\nmethod GetRebootToFirmware() -> (\n\t# The current state of the reboot-to-firmware-UI flag\n\tstate: bool\n)\n\n# SetRebootToFirmware() and GetRebootToFirmware() return this if the firmware does not actually support the reboot-to-firmware-UI concept.\nerror RebootToFirmwareNotSupported()\n\n# No boot entry defined.\nerror NoSuchBootEntry()\n"
+    }
+    fn get_name(&self) -> &'static str {
+        "io.systemd.BootControl"
+    }
+    fn call_upgraded(
+        &self,
+        call: &mut varlink::Call,
+        bufreader: &mut dyn BufRead,
+    ) -> varlink::Result<Vec<u8>> {
+        self.inner.call_upgraded(call, bufreader)
+    }
+    fn call(&self, call: &mut varlink::Call) -> varlink::Result<()> {
+        let req = call.request.unwrap();
+        match req.method.as_ref() {
+            "io.systemd.BootControl.GetRebootToFirmware" => self
+                .inner
+                .get_reboot_to_firmware(call as &mut dyn Call_GetRebootToFirmware),
+            "io.systemd.BootControl.ListBootEntries" => self
+                .inner
+                .list_boot_entries(call as &mut dyn Call_ListBootEntries),
+            "io.systemd.BootControl.SetRebootToFirmware" => {
+                if let Some(args) = req.parameters.clone() {
+                    let args: SetRebootToFirmware_Args = match serde_json::from_value(args) {
+                        Ok(v) => v,
+                        Err(e) => {
+                            let es = format!("{}", e);
+                            let _ = call.reply_invalid_parameter(es.clone());
+                            return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es)));
+                        }
+                    };
+                    self.inner.set_reboot_to_firmware(
+                        call as &mut dyn Call_SetRebootToFirmware,
+                        args.r#state,
+                    )
+                } else {
+                    call.reply_invalid_parameter("parameters".into())
+                }
+            }
+            m => call.reply_method_not_found(String::from(m)),
+        }
+    }
+}
diff --git a/systemd-ipc/src/io_systemd_hostname.rs b/systemd-ipc/src/io_systemd_hostname.rs
new file mode 100644
index 0000000..e9fa185
--- /dev/null
+++ b/systemd-ipc/src/io_systemd_hostname.rs
@@ -0,0 +1,295 @@
+#![doc = "This file was automatically generated by the varlink rust generator"]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+use serde_derive::{Deserialize, Serialize};
+use std::io::BufRead;
+use std::sync::{Arc, RwLock};
+use varlink::{self, CallTrait};
+#[allow(dead_code)]
+#[derive(Clone, PartialEq, Debug)]
+#[allow(clippy::enum_variant_names)]
+pub enum ErrorKind {
+    Varlink_Error,
+    VarlinkReply_Error,
+}
+impl ::std::fmt::Display for ErrorKind {
+    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+        match self {
+            ErrorKind::Varlink_Error => write!(f, "Varlink Error"),
+            ErrorKind::VarlinkReply_Error => write!(f, "Varlink error reply"),
+        }
+    }
+}
+pub struct Error(
+    pub ErrorKind,
+    pub Option<Box<dyn std::error::Error + 'static + Send + Sync>>,
+    pub Option<&'static str>,
+);
+impl Error {
+    #[allow(dead_code)]
+    pub fn kind(&self) -> &ErrorKind {
+        &self.0
+    }
+}
+impl From<ErrorKind> for Error {
+    fn from(e: ErrorKind) -> Self {
+        Error(e, None, None)
+    }
+}
+impl std::error::Error for Error {
+    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+        self.1
+            .as_ref()
+            .map(|e| e.as_ref() as &(dyn std::error::Error + 'static))
+    }
+}
+impl std::fmt::Display for Error {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        std::fmt::Display::fmt(&self.0, f)
+    }
+}
+impl std::fmt::Debug for Error {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        use std::error::Error as StdError;
+        if let Some(ref o) = self.2 {
+            std::fmt::Display::fmt(o, f)?;
+        }
+        std::fmt::Debug::fmt(&self.0, f)?;
+        if let Some(e) = self.source() {
+            std::fmt::Display::fmt("\nCaused by:\n", f)?;
+            std::fmt::Debug::fmt(&e, f)?;
+        }
+        Ok(())
+    }
+}
+#[allow(dead_code)]
+pub type Result<T> = std::result::Result<T, Error>;
+impl From<varlink::Error> for Error {
+    fn from(e: varlink::Error) -> Self {
+        match e.kind() {
+            varlink::ErrorKind::VarlinkErrorReply(r) => Error(
+                ErrorKind::from(r),
+                Some(Box::from(e)),
+                Some(concat!(file!(), ":", line!(), ": ")),
+            ),
+            _ => Error(
+                ErrorKind::Varlink_Error,
+                Some(Box::from(e)),
+                Some(concat!(file!(), ":", line!(), ": ")),
+            ),
+        }
+    }
+}
+#[allow(dead_code)]
+impl Error {
+    pub fn source_varlink_kind(&self) -> Option<&varlink::ErrorKind> {
+        use std::error::Error as StdError;
+        let mut s: &dyn StdError = self;
+        while let Some(c) = s.source() {
+            let k = self
+                .source()
+                .and_then(|e| e.downcast_ref::<varlink::Error>())
+                .map(|e| e.kind());
+            if k.is_some() {
+                return k;
+            }
+            s = c;
+        }
+        None
+    }
+}
+impl From<&varlink::Reply> for ErrorKind {
+    #[allow(unused_variables)]
+    fn from(e: &varlink::Reply) -> Self {
+        match e {
+            _ => ErrorKind::VarlinkReply_Error,
+        }
+    }
+}
+pub trait VarlinkCallError: varlink::CallTrait {}
+impl<'a> VarlinkCallError for varlink::Call<'a> {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct Describe_Reply {
+    pub r#Hostname: String,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#StaticHostname: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#PrettyHostname: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#DefaultHostname: Option<String>,
+    pub r#HostnameSource: String,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#IconName: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#Chassis: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#Deployment: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#Location: Option<String>,
+    pub r#KernelName: String,
+    pub r#KernelRelease: String,
+    pub r#KernelVersion: String,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#OperatingSystemPrettyName: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#OperatingSystemCPEName: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#OperatingSystemHomeURL: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#OperatingSystemSupportEnd: Option<i64>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#OperatingSystemReleaseData: Option<Vec<String>>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#MachineInformationData: Option<Vec<String>>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#HardwareVendor: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#HardwareModel: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#HardwareSerial: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#FirmwareVersion: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#FirmwareVendor: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#FirmwareDate: Option<i64>,
+    pub r#MachineID: String,
+    pub r#BootID: String,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#ProductUUID: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub r#VSockCID: Option<i64>,
+}
+impl varlink::VarlinkReply for Describe_Reply {}
+#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
+pub struct Describe_Args {}
+pub trait Call_Describe: VarlinkCallError {
+    fn reply(
+        &mut self,
+        r#Hostname: String,
+        r#StaticHostname: Option<String>,
+        r#PrettyHostname: Option<String>,
+        r#DefaultHostname: Option<String>,
+        r#HostnameSource: String,
+        r#IconName: Option<String>,
+        r#Chassis: Option<String>,
+        r#Deployment: Option<String>,
+        r#Location: Option<String>,
+        r#KernelName: String,
+        r#KernelRelease: String,
+        r#KernelVersion: String,
+        r#OperatingSystemPrettyName: Option<String>,
+        r#OperatingSystemCPEName: Option<String>,
+        r#OperatingSystemHomeURL: Option<String>,
+        r#OperatingSystemSupportEnd: Option<i64>,
+        r#OperatingSystemReleaseData: Option<Vec<String>>,
+        r#MachineInformationData: Option<Vec<String>>,
+        r#HardwareVendor: Option<String>,
+        r#HardwareModel: Option<String>,
+        r#HardwareSerial: Option<String>,
+        r#FirmwareVersion: Option<String>,
+        r#FirmwareVendor: Option<String>,
+        r#FirmwareDate: Option<i64>,
+        r#MachineID: String,
+        r#BootID: String,
+        r#ProductUUID: Option<String>,
+        r#VSockCID: Option<i64>,
+    ) -> varlink::Result<()> {
+        self.reply_struct(
+            Describe_Reply {
+                r#Hostname,
+                r#StaticHostname,
+                r#PrettyHostname,
+                r#DefaultHostname,
+                r#HostnameSource,
+                r#IconName,
+                r#Chassis,
+                r#Deployment,
+                r#Location,
+                r#KernelName,
+                r#KernelRelease,
+                r#KernelVersion,
+                r#OperatingSystemPrettyName,
+                r#OperatingSystemCPEName,
+                r#OperatingSystemHomeURL,
+                r#OperatingSystemSupportEnd,
+                r#OperatingSystemReleaseData,
+                r#MachineInformationData,
+                r#HardwareVendor,
+                r#HardwareModel,
+                r#HardwareSerial,
+                r#FirmwareVersion,
+                r#FirmwareVendor,
+                r#FirmwareDate,
+                r#MachineID,
+                r#BootID,
+                r#ProductUUID,
+                r#VSockCID,
+            }
+            .into(),
+        )
+    }
+}
+impl<'a> Call_Describe for varlink::Call<'a> {}
+pub trait VarlinkInterface {
+    fn describe(&self, call: &mut dyn Call_Describe) -> varlink::Result<()>;
+    fn call_upgraded(
+        &self,
+        _call: &mut varlink::Call,
+        _bufreader: &mut dyn BufRead,
+    ) -> varlink::Result<Vec<u8>> {
+        Ok(Vec::new())
+    }
+}
+pub trait VarlinkClientInterface {
+    fn describe(&mut self) -> varlink::MethodCall<Describe_Args, Describe_Reply, Error>;
+}
+#[allow(dead_code)]
+pub struct VarlinkClient {
+    connection: Arc<RwLock<varlink::Connection>>,
+}
+impl VarlinkClient {
+    #[allow(dead_code)]
+    pub fn new(connection: Arc<RwLock<varlink::Connection>>) -> Self {
+        VarlinkClient { connection }
+    }
+}
+impl VarlinkClientInterface for VarlinkClient {
+    fn describe(&mut self) -> varlink::MethodCall<Describe_Args, Describe_Reply, Error> {
+        varlink::MethodCall::<Describe_Args, Describe_Reply, Error>::new(
+            self.connection.clone(),
+            "io.systemd.Hostname.Describe",
+            Describe_Args {},
+        )
+    }
+}
+#[allow(dead_code)]
+pub struct VarlinkInterfaceProxy {
+    inner: Box<dyn VarlinkInterface + Send + Sync>,
+}
+#[allow(dead_code)]
+pub fn new(inner: Box<dyn VarlinkInterface + Send + Sync>) -> VarlinkInterfaceProxy {
+    VarlinkInterfaceProxy { inner }
+}
+impl varlink::Interface for VarlinkInterfaceProxy {
+    fn get_description(&self) -> &'static str {
+        "interface io.systemd.Hostname\n\nmethod Describe() -> (\n\tHostname: string,\n\tStaticHostname: ?string,\n\tPrettyHostname: ?string,\n\tDefaultHostname: ?string,\n\tHostnameSource: string,\n\tIconName: ?string,\n\tChassis: ?string,\n\tDeployment: ?string,\n\tLocation: ?string,\n\tKernelName: string,\n\tKernelRelease: string,\n\tKernelVersion: string,\n\tOperatingSystemPrettyName: ?string,\n\tOperatingSystemCPEName: ?string,\n\tOperatingSystemHomeURL: ?string,\n\tOperatingSystemSupportEnd: ?int,\n\tOperatingSystemReleaseData: ?[]string,\n\tMachineInformationData: ?[]string,\n\tHardwareVendor: ?string,\n\tHardwareModel: ?string,\n\tHardwareSerial: ?string,\n\tFirmwareVersion: ?string,\n\tFirmwareVendor: ?string,\n\tFirmwareDate: ?int,\n\tMachineID: string,\n\tBootID: string,\n\tProductUUID: ?string,\n\tVSockCID: ?int\n)\n"
+    }
+    fn get_name(&self) -> &'static str {
+        "io.systemd.Hostname"
+    }
+    fn call_upgraded(
+        &self,
+        call: &mut varlink::Call,
+        bufreader: &mut dyn BufRead,
+    ) -> varlink::Result<Vec<u8>> {
+        self.inner.call_upgraded(call, bufreader)
+    }
+    fn call(&self, call: &mut varlink::Call) -> varlink::Result<()> {
+        let req = call.request.unwrap();
+        match req.method.as_ref() {
+            "io.systemd.Hostname.Describe" => self.inner.describe(call as &mut dyn Call_Describe),
+            m => call.reply_method_not_found(String::from(m)),
+        }
+    }
+}
diff --git a/systemd-ipc/src/lib.rs b/systemd-ipc/src/lib.rs
new file mode 100644
index 0000000..606c22e
--- /dev/null
+++ b/systemd-ipc/src/lib.rs
@@ -0,0 +1,2 @@
+pub mod addrs;
+pub mod io_systemd_hostname;

From e86a2dec69ce6ddccc46fdaa76573ddd22f30512 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lars=20Sj=C3=B6strom?= <lars@radicore.se>
Date: Wed, 8 Jan 2025 11:09:34 +0100
Subject: [PATCH 2/2] feat(hostd): varlink interfaced host controller to manage
 machine configuration and boot mgmt

---
 Cargo.lock                        | 456 +++++++++++++++++++++++++++++-
 Cargo.toml                        |   3 +-
 hostd/.gitignore                  |   1 +
 hostd/Cargo.toml                  |  23 ++
 hostd/src/api.rs                  |  17 ++
 hostd/src/bin/hostd-controller.rs |  75 +++++
 hostd/src/context.rs              |   9 +
 hostd/src/lib.rs                  |   4 +
 hostd/src/machine.rs              |  43 +++
 hostd/src/sysupdate.rs            |  52 ++++
 10 files changed, 676 insertions(+), 7 deletions(-)
 create mode 100644 hostd/.gitignore
 create mode 100644 hostd/Cargo.toml
 create mode 100644 hostd/src/api.rs
 create mode 100644 hostd/src/bin/hostd-controller.rs
 create mode 100644 hostd/src/context.rs
 create mode 100644 hostd/src/lib.rs
 create mode 100644 hostd/src/machine.rs
 create mode 100644 hostd/src/sysupdate.rs

diff --git a/Cargo.lock b/Cargo.lock
index e2d7e26..8885015 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -103,6 +103,132 @@ version = "1.0.95"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
 
+[[package]]
+name = "async-broadcast"
+version = "0.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532"
+dependencies = [
+ "event-listener",
+ "event-listener-strategy",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-channel"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a"
+dependencies = [
+ "concurrent-queue",
+ "event-listener-strategy",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-executor"
+version = "1.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec"
+dependencies = [
+ "async-task",
+ "concurrent-queue",
+ "fastrand",
+ "futures-lite",
+ "slab",
+]
+
+[[package]]
+name = "async-fs"
+version = "2.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a"
+dependencies = [
+ "async-lock",
+ "blocking",
+ "futures-lite",
+]
+
+[[package]]
+name = "async-io"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059"
+dependencies = [
+ "async-lock",
+ "cfg-if",
+ "concurrent-queue",
+ "futures-io",
+ "futures-lite",
+ "parking",
+ "polling",
+ "rustix",
+ "slab",
+ "tracing",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "async-lock"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18"
+dependencies = [
+ "event-listener",
+ "event-listener-strategy",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-process"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb"
+dependencies = [
+ "async-channel",
+ "async-io",
+ "async-lock",
+ "async-signal",
+ "async-task",
+ "blocking",
+ "cfg-if",
+ "event-listener",
+ "futures-lite",
+ "rustix",
+ "tracing",
+]
+
+[[package]]
+name = "async-recursion"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "async-signal"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3"
+dependencies = [
+ "async-io",
+ "async-lock",
+ "atomic-waker",
+ "cfg-if",
+ "futures-core",
+ "futures-io",
+ "rustix",
+ "signal-hook-registry",
+ "slab",
+ "windows-sys 0.59.0",
+]
+
 [[package]]
 name = "async-stream"
 version = "0.3.6"
@@ -125,6 +251,12 @@ dependencies = [
  "syn",
 ]
 
+[[package]]
+name = "async-task"
+version = "4.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
+
 [[package]]
 name = "async-trait"
 version = "0.1.85"
@@ -249,6 +381,19 @@ dependencies = [
  "generic-array",
 ]
 
+[[package]]
+name = "blocking"
+version = "1.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea"
+dependencies = [
+ "async-channel",
+ "async-task",
+ "futures-io",
+ "futures-lite",
+ "piper",
+]
+
 [[package]]
 name = "bumpalo"
 version = "3.16.0"
@@ -632,6 +777,33 @@ dependencies = [
  "cfg-if",
 ]
 
+[[package]]
+name = "endi"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf"
+
+[[package]]
+name = "enumflags2"
+version = "0.7.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147"
+dependencies = [
+ "enumflags2_derive",
+ "serde",
+]
+
+[[package]]
+name = "enumflags2_derive"
+version = "0.7.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "equivalent"
 version = "1.0.1"
@@ -670,6 +842,16 @@ dependencies = [
  "pin-project-lite",
 ]
 
+[[package]]
+name = "event-listener-strategy"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2"
+dependencies = [
+ "event-listener",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "fastrand"
 version = "2.3.0"
@@ -792,6 +974,19 @@ version = "0.3.31"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
 
+[[package]]
+name = "futures-lite"
+version = "2.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532"
+dependencies = [
+ "fastrand",
+ "futures-core",
+ "futures-io",
+ "parking",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "futures-macro"
 version = "0.3.31"
@@ -958,6 +1153,27 @@ dependencies = [
  "windows-sys 0.59.0",
 ]
 
+[[package]]
+name = "hostd"
+version = "0.2.0"
+dependencies = [
+ "anyhow",
+ "clap",
+ "dropshot",
+ "http",
+ "schemars",
+ "serde",
+ "slog",
+ "slog-async",
+ "sqlx",
+ "tokio",
+ "trace-request",
+ "tracing",
+ "tracing-slog",
+ "zbus",
+ "zbus_systemd",
+]
+
 [[package]]
 name = "hostname"
 version = "0.3.1"
@@ -1477,6 +1693,15 @@ version = "2.7.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
 
+[[package]]
+name = "memoffset"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
+dependencies = [
+ "autocfg",
+]
+
 [[package]]
 name = "mime"
 version = "0.3.17"
@@ -1537,6 +1762,19 @@ dependencies = [
  "tempfile",
 ]
 
+[[package]]
+name = "nix"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
+dependencies = [
+ "bitflags",
+ "cfg-if",
+ "cfg_aliases",
+ "libc",
+ "memoffset",
+]
+
 [[package]]
 name = "nu-ansi-term"
 version = "0.46.0"
@@ -1776,6 +2014,16 @@ dependencies = [
  "tracing",
 ]
 
+[[package]]
+name = "ordered-stream"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "overload"
 version = "0.1.1"
@@ -1902,6 +2150,17 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
 
+[[package]]
+name = "piper"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066"
+dependencies = [
+ "atomic-waker",
+ "fastrand",
+ "futures-io",
+]
+
 [[package]]
 name = "pkcs1"
 version = "0.7.5"
@@ -1929,6 +2188,21 @@ version = "0.3.31"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
 
+[[package]]
+name = "polling"
+version = "3.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f"
+dependencies = [
+ "cfg-if",
+ "concurrent-queue",
+ "hermit-abi",
+ "pin-project-lite",
+ "rustix",
+ "tracing",
+ "windows-sys 0.59.0",
+]
+
 [[package]]
 name = "powerfmt"
 version = "0.2.0"
@@ -1944,6 +2218,15 @@ dependencies = [
  "zerocopy",
 ]
 
+[[package]]
+name = "proc-macro-crate"
+version = "3.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b"
+dependencies = [
+ "toml_edit",
+]
+
 [[package]]
 name = "proc-macro2"
 version = "1.0.93"
@@ -2519,9 +2802,9 @@ dependencies = [
 
 [[package]]
 name = "serde_json"
-version = "1.0.135"
+version = "1.0.138"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
+checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
 dependencies = [
  "itoa",
  "memchr",
@@ -2539,6 +2822,17 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "serde_repr"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "serde_spanned"
 version = "0.6.8"
@@ -2947,6 +3241,12 @@ version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
 
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
 [[package]]
 name = "stringprep"
 version = "0.1.5"
@@ -2972,9 +3272,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
 
 [[package]]
 name = "syn"
-version = "2.0.96"
+version = "2.0.95"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80"
+checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -3286,7 +3586,7 @@ dependencies = [
  "serde",
  "serde_spanned",
  "toml_datetime",
- "winnow",
+ "winnow 0.6.24",
 ]
 
 [[package]]
@@ -3529,6 +3829,17 @@ dependencies = [
  "typify-impl",
 ]
 
+[[package]]
+name = "uds_windows"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9"
+dependencies = [
+ "memoffset",
+ "tempfile",
+ "winapi",
+]
+
 [[package]]
 name = "unicode-bidi"
 version = "0.3.18"
@@ -4006,6 +4317,15 @@ dependencies = [
  "memchr",
 ]
 
+[[package]]
+name = "winnow"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "86e376c75f4f43f44db463cf729e0d3acbf954d13e22c51e26e4c264b4ab545f"
+dependencies = [
+ "memchr",
+]
+
 [[package]]
 name = "write16"
 version = "1.0.0"
@@ -4018,6 +4338,16 @@ version = "0.5.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
 
+[[package]]
+name = "xdg-home"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6"
+dependencies = [
+ "libc",
+ "windows-sys 0.59.0",
+]
+
 [[package]]
 name = "xtask"
 version = "0.2.0"
@@ -4052,6 +4382,80 @@ dependencies = [
  "synstructure",
 ]
 
+[[package]]
+name = "zbus"
+version = "5.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cbddd8b6cb25d5d8ec1b23277b45299a98bfb220f1761ca11e186d5c702507f8"
+dependencies = [
+ "async-broadcast",
+ "async-executor",
+ "async-fs",
+ "async-io",
+ "async-lock",
+ "async-process",
+ "async-recursion",
+ "async-task",
+ "async-trait",
+ "blocking",
+ "enumflags2",
+ "event-listener",
+ "futures-core",
+ "futures-util",
+ "hex",
+ "nix",
+ "ordered-stream",
+ "serde",
+ "serde_repr",
+ "static_assertions",
+ "tracing",
+ "uds_windows",
+ "windows-sys 0.59.0",
+ "winnow 0.7.1",
+ "xdg-home",
+ "zbus_macros",
+ "zbus_names",
+ "zvariant",
+]
+
+[[package]]
+name = "zbus_macros"
+version = "5.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dac404d48b4e9cf193c8b49589f3280ceca5ff63519e7e64f55b4cf9c47ce146"
+dependencies = [
+ "proc-macro-crate",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "zbus_names",
+ "zvariant",
+ "zvariant_utils",
+]
+
+[[package]]
+name = "zbus_names"
+version = "4.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97"
+dependencies = [
+ "serde",
+ "static_assertions",
+ "winnow 0.7.1",
+ "zvariant",
+]
+
+[[package]]
+name = "zbus_systemd"
+version = "0.25701.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b772577120750e5a5ab5a5530f38fd462a35fafd9ed475098714afd1b1855ec"
+dependencies = [
+ "futures",
+ "serde",
+ "zbus",
+]
+
 [[package]]
 name = "zerocopy"
 version = "0.7.35"
@@ -4149,3 +4553,45 @@ dependencies = [
  "cc",
  "pkg-config",
 ]
+
+[[package]]
+name = "zvariant"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "31c951c21879c6e1d46ac5adfc34f698fefb465d498cf4ac87545849bd71bb5a"
+dependencies = [
+ "endi",
+ "enumflags2",
+ "serde",
+ "static_assertions",
+ "winnow 0.7.1",
+ "zvariant_derive",
+ "zvariant_utils",
+]
+
+[[package]]
+name = "zvariant_derive"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9eeb539471af098d9e63faf428c71ac4cd4efe0b5baa3c8a6b991c5f2543b70e"
+dependencies = [
+ "proc-macro-crate",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "zvariant_utils",
+]
+
+[[package]]
+name = "zvariant_utils"
+version = "3.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e16edfee43e5d7b553b77872d99bc36afdda75c223ca7ad5e3fbecd82ca5fc34"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "serde",
+ "static_assertions",
+ "syn",
+ "winnow 0.7.1",
+]
diff --git a/Cargo.toml b/Cargo.toml
index d61baf6..5afc72d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,6 +4,7 @@ members = [
   "agent",
   "controller",
   "instrumentation",
+  "hostd",
   "trace-request",
   "xtask",
 ]
@@ -44,7 +45,5 @@ slog = "2.7.0"
 slog-async = "2.8.0"
 tokio = { version = "1.43.0", features = ["full"] }
 tracing = "0.1.41"
-tracing-core = "0.1.33"
-tracing-chrome = "0.7.2"
 tracing-slog = { git = "https://github.com/oxidecomputer/tracing-slog", default-features = false }
 uuid = { version = "1", features = [ "serde", "v4" ] }
diff --git a/hostd/.gitignore b/hostd/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/hostd/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/hostd/Cargo.toml b/hostd/Cargo.toml
new file mode 100644
index 0000000..f3322c7
--- /dev/null
+++ b/hostd/Cargo.toml
@@ -0,0 +1,23 @@
+[package]
+name = "hostd"
+version.workspace = true
+edition.workspace = true
+
+[dependencies]
+anyhow.workspace = true
+tokio.workspace = true
+sqlx = { version = "0.8.3", default-features = false, features = [
+    "macros", "migrate", "postgres", "runtime-tokio", "tls-rustls", "time", "uuid"
+  ] }
+dropshot.workspace = true
+clap.workspace = true
+slog.workspace = true
+slog-async.workspace = true
+tracing-slog.workspace = true
+tracing.workspace = true
+trace-request = { path = "../trace-request" }
+schemars.workspace = true
+serde.workspace = true
+http.workspace = true
+zbus_systemd = { version = "0.25701.0", features = ["hostname1", "sysupdate1", "network1", "portable1", "resolve1", "systemd1"] }
+zbus = "5.4.0"
diff --git a/hostd/src/api.rs b/hostd/src/api.rs
new file mode 100644
index 0000000..7f68d70
--- /dev/null
+++ b/hostd/src/api.rs
@@ -0,0 +1,17 @@
+use anyhow::Result;
+use dropshot::ApiDescription;
+
+use std::sync::Arc;
+
+use crate::context::ControllerContext;
+use crate::machine;
+use crate::sysupdate;
+
+type ControllerApiDescription = ApiDescription<Arc<ControllerContext>>;
+
+pub fn api() -> Result<ControllerApiDescription> {
+    let mut api = ControllerApiDescription::new();
+    api.register(machine::describe)?;
+    api.register(sysupdate::list_versions)?;
+    Ok(api)
+}
diff --git a/hostd/src/bin/hostd-controller.rs b/hostd/src/bin/hostd-controller.rs
new file mode 100644
index 0000000..003671e
--- /dev/null
+++ b/hostd/src/bin/hostd-controller.rs
@@ -0,0 +1,75 @@
+use anyhow::{anyhow, Result};
+
+use clap::Parser;
+use dropshot::{ConfigDropshot, ServerBuilder};
+use slog::Drain;
+use std::net::SocketAddr;
+use std::str::FromStr;
+use std::sync::Arc;
+use tracing_slog::TracingSlogDrain;
+
+use hostd::api;
+use hostd::context::ControllerContext;
+
+#[derive(Parser, Debug)]
+#[command(version, about, long_about = None)]
+struct Cli {
+    #[arg(
+        long = "telemetry-otlp-endpoint",
+        default_value = "http://localhost:4317",
+        env = "OTEL_EXPORTER_OTLP_ENDPOINT"
+    )]
+    otlp_endpoint: Option<String>,
+
+    #[arg(
+        long = "log-stderr",
+        short = 'v',
+        default_value = "false",
+        env = "LOG_TO_STDERR"
+    )]
+    log_stderr: bool,
+
+    #[arg(
+        long = "listen-address",
+        default_value = "127.0.0.1:9478",
+        env = "LISTEN_ADDRESS"
+    )]
+    listen_address: String,
+
+    #[arg(
+        long = "database-url",
+        default_value = "postgresql://localhost/patagia",
+        env = "DATABASE_URL"
+    )]
+    database_url: Option<String>,
+}
+
+#[tokio::main]
+async fn main() -> Result<()> {
+    let args = Cli::parse();
+
+    let config = ConfigDropshot {
+        bind_address: SocketAddr::from_str(&args.listen_address).unwrap(),
+        ..Default::default()
+    };
+
+    let logger = {
+        let level_drain = slog::LevelFilter(TracingSlogDrain, slog::Level::Debug).fuse();
+        let async_drain = slog_async::Async::new(level_drain).build().fuse();
+        slog::Logger::root(async_drain, slog::o!())
+    };
+
+    let dbus = zbus::Connection::system().await.unwrap();
+    let ctx = ControllerContext::new(dbus);
+
+    let api = api::api()?;
+
+    println!("Listening on http://{}", config.bind_address);
+
+    ServerBuilder::new(api, Arc::new(ctx), logger)
+        .config(config)
+        .start()
+        .map_err(|e| anyhow!("Error starting server: {:?}", e))?
+        .await
+        .map_err(|e| anyhow!(e))
+}
diff --git a/hostd/src/context.rs b/hostd/src/context.rs
new file mode 100644
index 0000000..de20783
--- /dev/null
+++ b/hostd/src/context.rs
@@ -0,0 +1,9 @@
+pub struct ControllerContext {
+    pub dbus: zbus::Connection,
+}
+
+impl ControllerContext {
+    pub fn new(dbus: zbus::Connection) -> ControllerContext {
+        ControllerContext { dbus }
+    }
+}
diff --git a/hostd/src/lib.rs b/hostd/src/lib.rs
new file mode 100644
index 0000000..3b7a5eb
--- /dev/null
+++ b/hostd/src/lib.rs
@@ -0,0 +1,4 @@
+pub mod api;
+pub mod context;
+pub mod machine;
+pub mod sysupdate;
diff --git a/hostd/src/machine.rs b/hostd/src/machine.rs
new file mode 100644
index 0000000..a2926c2
--- /dev/null
+++ b/hostd/src/machine.rs
@@ -0,0 +1,43 @@
+use dropshot::{endpoint, HttpError, HttpResponseOk, RequestContext};
+use schemars::JsonSchema;
+use serde::Serialize;
+use std::sync::Arc;
+use trace_request::trace_request;
+
+use crate::context::ControllerContext;
+
+/// Machine information
+#[derive(Serialize, JsonSchema)]
+#[serde(rename_all = "camelCase")]
+struct MachineInfo {
+    machine_id: String,
+}
+
+/// Fetch machine info
+#[endpoint {
+    method = GET,
+    path = "/machine_info",
+}]
+#[trace_request]
+pub async fn describe(
+    rqctx: RequestContext<Arc<ControllerContext>>,
+) -> Result<HttpResponseOk<MachineInfo>, HttpError> {
+    let hostnamed = zbus_systemd::hostname1::HostnamedProxy::new(&rqctx.context().dbus)
+        .await
+        .unwrap();
+
+    let machine_id = hostnamed
+        .machine_id()
+        .await
+        .map_err(|e| match e {
+            err => HttpError::for_internal_error(format!("Error: {}", err)),
+        })?
+        // convert bytes to hex string
+        .iter()
+        .map(|&b| format!("{:02x}", b))
+        .collect();
+
+    let machine_info = MachineInfo { machine_id };
+
+    Ok(HttpResponseOk(machine_info))
+}
diff --git a/hostd/src/sysupdate.rs b/hostd/src/sysupdate.rs
new file mode 100644
index 0000000..43873cd
--- /dev/null
+++ b/hostd/src/sysupdate.rs
@@ -0,0 +1,52 @@
+use dropshot::{endpoint, HttpError, HttpResponseOk, RequestContext};
+use schemars::JsonSchema;
+use serde::Serialize;
+use std::sync::Arc;
+use trace_request::trace_request;
+
+use crate::context::ControllerContext;
+
+const SYSUPDATE_HOST_PATH: &str = "/org/freedesktop/sysupdate1/target/host";
+
+#[derive(Serialize, JsonSchema)]
+#[serde(rename_all = "camelCase")]
+struct SysUpdate {
+    current_version: String,
+    versions: Vec<String>,
+}
+
+#[endpoint {
+    method = GET,
+    path = "/list_versions",
+}]
+#[trace_request]
+pub async fn list_versions(
+    rqctx: RequestContext<Arc<ControllerContext>>,
+) -> Result<HttpResponseOk<SysUpdate>, HttpError> {
+    let sysupdate_target = zbus_systemd::sysupdate1::TargetProxy::builder(&rqctx.context().dbus)
+        .path(SYSUPDATE_HOST_PATH)
+        .unwrap()
+        .build()
+        .await
+        .map_err(|e| match e {
+            err => HttpError::for_internal_error(format!("Error: {}", err)),
+        })?;
+
+    let versions = sysupdate_target.list(0).await.map_err(|e| match e {
+        err => {
+            println!("Error: {}", err);
+            HttpError::for_internal_error(format!("Error: {}", err))
+        }
+    })?;
+
+    let current_version = sysupdate_target.get_version().await.map_err(|e| match e {
+        err => HttpError::for_internal_error(format!("Error: {}", err)),
+    })?;
+
+    let sysupdate = SysUpdate {
+        versions,
+        current_version,
+    };
+
+    Ok(HttpResponseOk(sysupdate))
+}