aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat
-rw-r--r--.dockerignore9+0 −9
-rw-r--r--.editorconfig26+0 −26
-rw-r--r--.github/workflows/build.yml83+0 −83
-rw-r--r--.github/workflows/legal.yml35+0 −35
-rw-r--r--.gitignore6+2 −4
-rw-r--r--.mailmap7+0 −7
-rw-r--r--CLA.md170+0 −170
-rw-r--r--CODEOWNERS4+0 −4
-rw-r--r--Cargo.lock125+4 −121
-rw-r--r--Cargo.toml6+3 −3
-rw-r--r--LICENSES/CC-BY-3.0.txt319+0 −319
-rw-r--r--LICENSES/CC-BY-4.0.txt156+0 −156
-rw-r--r--README.md46+0 −46
-rw-r--r--REUSE.toml26+2 −24
-rw-r--r--crates/hule-image/Cargo.toml (renamed from crates/hule-hmi/Cargo.toml)4+2 −2
-rw-r--r--crates/hule-image/src/lib.rs (renamed from crates/hule-hmi/src/lib.rs)2+1 −1
-rw-r--r--crates/hule-oci/Cargo.toml5+2 −3
-rw-r--r--crates/hule-oci/src/error.rs119+0 −119
-rw-r--r--crates/hule-oci/src/lib.rs719+346 −373
-rw-r--r--crates/hule-oci/src/storage.rs213+0 −213
-rw-r--r--crates/hule-vmm/Cargo.toml5+2 −3
-rw-r--r--crates/hule-vmm/src/backend/mod.rs2+1 −1
-rw-r--r--crates/hule-vmm/src/backend/qemu/cli.rs81+2 −79
-rw-r--r--crates/hule-vmm/src/backend/qemu/mod.rs122+18 −104
-rw-r--r--crates/hule-vmm/src/backend/qemu/qga.rs233+0 −233
-rw-r--r--crates/hule-vmm/src/backend/qemu/qmp.rs2+1 −1
-rw-r--r--crates/hule-vmm/src/backend/qemu/supervise.rs52+1 −51
-rw-r--r--crates/hule-vmm/src/hypervisor.rs4+2 −2
-rw-r--r--crates/hule-vmm/src/lib.rs4+2 −2
-rw-r--r--crates/hule-vmm/src/machine.rs10+6 −4
-rw-r--r--crates/hule-vmm/src/monitor.rs4+2 −2
-rw-r--r--crates/hule-vmm/tests/qemu_lifecycle.rs118+118 −0
-rw-r--r--crates/hule/Cargo.toml5+2 −3
-rw-r--r--crates/hule/src/main.rs167+59 −108
-rw-r--r--deny.toml18+0 −18
-rw-r--r--docs/landscape.md45+0 −45
-rw-r--r--docs/whitepaper.md224+0 −224
-rwxr-xr-ximages/alpine/genimg16+8 −8
-rwxr-xr-ximages/debian/genimg20+8 −12
-rwxr-xr-ximages/fedora/genimg11+2 −9
-rwxr-xr-ximages/freebsd/genimg2+1 −1
-rwxr-xr-ximages/ubuntu/genimg17+5 −12
-rw-r--r--mise.lock48+0 −48
-rw-r--r--mise.toml17+0 −17
44 files changed, 602 insertions, 2705 deletions
diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
--- a/.dockerignore
+++ /dev/null
@@ -1,9 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
-# SPDX-License-Identifier: Apache-2.0
-
-.git
-.github
-.recluse-state
-dist
-target
-*.lcov
diff --git a/.editorconfig b/.editorconfig
deleted file mode 100644
--- a/.editorconfig
+++ /dev/null
@@ -1,26 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
-# SPDX-License-Identifier: Apache-2.0
-
-root = true
-
-[*]
-charset = utf-8
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-indent_style = space
-indent_size = 4
-
-[*.md]
-# double whitespace at end of line
-# denotes a line break in Markdown
-trim_trailing_whitespace = false
-
-[*.rs]
-max_line_length = 100
-
-[*.yml]
-indent_size = 2
-
-[{Makefile,*.mk}]
-indent_style = tab
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,83 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
-# SPDX-License-Identifier: Apache-2.0
-
-name: Build
-
-on:
- push:
- branches: [main]
- tags: ["v*"]
- pull_request:
- branches: [main]
-
-permissions:
- contents: read
-
-concurrency:
- group: hule-build-${{ github.ref }}
- cancel-in-progress: true
-
-env:
- CARGO_TERM_COLOR: always
- RELEASE_TAG: nightly
-
-jobs:
- lint:
- name: Static checks
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
-
- - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3
- with:
- version: 2026.7.5
- experimental: true
- install: false
- - name: Install dependencies
- run: mise bootstrap --locked --yes --update
- - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
-
- - name: formatting
- run: cargo fmt --all --check
-
- - name: shellcheck
- run: shellcheck images/*/genimg
-
- - name: clippy
- run: cargo clippy --workspace --all-targets --all-features --release --locked -- -D warnings
-
- build:
- name: Build (${{ matrix.arch }})
- runs-on: ${{ matrix.runner }}
- needs: [lint]
- strategy:
- fail-fast: false
- matrix:
- include:
- - runner: ubuntu-24.04
- arch: amd64
- - runner: ubuntu-24.04-arm
- arch: arm64
- steps:
- - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
-
- - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3
- with:
- version: 2026.7.5
- experimental: true
- install: false
- - name: Install dependencies
- run: mise bootstrap --locked --yes
- - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
-
- - name: Build
- run: cargo build --workspace --all-features --release --locked
-
- - name: Run tests
- run: cargo test --workspace --all-features --release --locked
-
- - name: Upload binary
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
- with:
- name: hule-${{ matrix.arch }}
- path: target/release/hule
diff --git a/.github/workflows/legal.yml b/.github/workflows/legal.yml
deleted file mode 100644
--- a/.github/workflows/legal.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
-# SPDX-License-Identifier: Apache-2.0
-
-name: Legal
-
-on:
- push:
- branches: [main]
- tags: ["v*"]
- pull_request:
- branches: [main]
-
-permissions:
- contents: read
-
-jobs:
- legal:
- name: Legal checks
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- with:
- fetch-depth: 0
-
- - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3
- with:
- version: 2026.7.5
- experimental: true
- install: false
-
- - name: Check contribution sign-off
- run: mise run signoff
-
- - name: Check licensing policy
- run: mise run licenses
diff --git a/.gitignore b/.gitignore
index ea96d7d..4af8e00 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,8 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# Copyright (c) 2026 Nikolay Govorov
# SPDX-License-Identifier: Apache-2.0
-/dist
/target
-mise.local.toml
-mise.*.local.toml
+/dist
__pycache__
*.qcow2
diff --git a/.mailmap b/.mailmap
deleted file mode 100644
--- a/.mailmap
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
-# SPDX-License-Identifier: Apache-2.0
-#
-# Add new entries in alphabetical order
-
-Nikolay Govorov <me@govorov.online>
-Nikolay Govorov <mr@dimidiumlabs.io>
diff --git a/CLA.md b/CLA.md
deleted file mode 100644
--- a/CLA.md
+++ /dev/null
@@ -1,170 +0,0 @@
-# Hule Individual Contributor License Agreement
-
-Version 1.0
-
-> This agreement is based on the Harmony Individual Contributor License
-> Agreement Version 1.0 licensed under a
-> [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/).
-
-Thank you for your interest in contributing to Hule (the "Project"). In this
-Agreement, "We" and "Us" mean Nikolay Govorov.
-
-This contributor agreement ("Agreement") documents the rights granted by
-contributors to Us. To make this document effective, You must personally add
-the following trailers to every commit You Submit:
-
-```text
-CLA-Version: 1.0
-Signed-off-by: Your Name <your.email@example.com>
-```
-
-The name and email address in `Signed-off-by` must identify You and match the
-commit author. By Submitting a commit containing these trailers, You
-electronically sign and accept this Agreement. No other person or automated
-system may add the `Signed-off-by` trailer on Your behalf. This is a legally
-binding document, so please read it carefully before agreeing to it.
-
-## 1. Definitions
-
-"You" means the individual who Submits a Contribution to Us.
-
-"Contribution" means any work of authorship that is Submitted by You to Us in
-which You own or assert ownership of the Copyright. If You do not own the
-Copyright in the entire work of authorship, please follow the instructions in
-Section 3(d).
-
-"Copyright" means all rights protecting works of authorship owned or controlled
-by You, including copyright, moral and neighboring rights, as appropriate, for
-the full term of their existence including any extensions by You.
-
-"Material" means the work of authorship which is made available by Us to third
-parties as part of the Project. After You Submit the Contribution, it may be
-included in the Material.
-
-"Submit" means any form of electronic, verbal, or written communication sent to
-Us or our representatives, including but not limited to electronic mailing
-lists, source code control systems, and issue tracking systems that are managed
-by, or on behalf of, Us for the purpose of discussing and improving the
-Material, but excluding communication that is conspicuously marked or otherwise
-designated in writing by You as "Not a Contribution."
-
-"Submission Date" means the date on which You Submit a Contribution to Us.
-
-"Effective Date" means the date You execute this Agreement or the date You first
-Submit a Contribution to Us, whichever is earlier.
-
-"Media" means any portion of a Contribution which is not software.
-
-## 2. Grant of Rights
-
-### 2.1 Copyright License
-
-(a) You retain ownership of the Copyright in Your Contribution and have the same
-rights to use or license the Contribution which You would have had without
-entering into the Agreement.
-
-(b) To the maximum extent permitted by the relevant law, You grant to Us a
-perpetual, worldwide, non-exclusive, transferable, royalty-free, irrevocable
-license under the Copyright covering the Contribution, with the right to
-sublicense such rights through multiple tiers of sublicensees, to reproduce,
-modify, display, perform and distribute the Contribution as part of the
-Material; provided that this license is conditioned upon compliance with Section
-2.3.
-
-### 2.2 Patent License
-
-For patent claims including, without limitation, method, process, and apparatus
-claims which You own, control or have the right to grant,
-now or in the future, You grant to Us a perpetual, worldwide, non-exclusive,
-transferable, royalty-free, irrevocable patent license, with the right to
-sublicense these rights to multiple tiers of sublicensees, to make, have made,
-use, sell, offer for sale, import and otherwise transfer the Contribution and
-the Contribution in combination with the Material (and portions of such
-combination). This license is granted only to the extent that the exercise of
-the licensed rights infringes such patent claims; and provided that this license
-is conditioned upon compliance with Section 2.3.
-
-### 2.3 Outbound License
-
-Based on the grant of rights in Sections 2.1 and 2.2, if We include Your
-Contribution in a Material, We may license the Contribution under any license,
-including copyleft, permissive, commercial, or proprietary licenses. As a
-condition on the exercise of this right, We agree to also license the
-Contribution under the terms of the license or licenses which We are using for
-the Material on the Submission Date.
-
-### 2.4 Moral Rights
-
-If moral rights apply to the Contribution, to the maximum extent permitted by
-law, You waive and agree not to assert such moral rights against Us or our
-successors in interest, or any of our licensees, either direct or indirect.
-
-### 2.5 Our Rights
-
-You acknowledge that We are not obligated to use Your Contribution as part of
-the Material and may decide to include any Contribution We consider appropriate.
-
-### 2.6 Reservation of Rights
-
-Any rights not expressly licensed under this section are expressly
-reserved by You.
-
-## 3. Agreement
-
-You confirm that:
-
-(a) You have the legal authority to enter into this Agreement.
-
-(b) You own the Copyright and patent claims covering the
-Contribution which are required to grant the rights under Section 2.
-
-(c) The grant of rights under Section 2 does not violate any grant
-of rights which You have made to third parties, including Your employer. If You
-are an employee, You have had Your employer approve this Agreement or sign the
-Entity version of this document. If You are less than eighteen years old, please
-have Your parents or guardian sign the Agreement.
-
-(d) If You do not own the Copyright in the entire work of authorship Submitted,
-You have clearly identified the third-party work, its source, and its license in
-the Submission.
-
-## 4. Disclaimer
-
-EXCEPT FOR THE EXPRESS WARRANTIES IN SECTION 3, THE CONTRIBUTION IS PROVIDED "AS
-IS". MORE PARTICULARLY, ALL EXPRESS OR IMPLIED WARRANTIES INCLUDING, WITHOUT
-LIMITATION, ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY DISCLAIMED BY YOU TO US.
-TO THE EXTENT THAT ANY SUCH WARRANTIES CANNOT BE DISCLAIMED, SUCH WARRANTY
-IS LIMITED IN DURATION TO THE MINIMUM PERIOD PERMITTED BY LAW.
-
-## 5. Consequential Damage Waiver
-
-TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL YOU BE
-LIABLE FOR ANY LOSS OF PROFITS, LOSS OF ANTICIPATED SAVINGS, LOSS OF DATA,
-INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL AND EXEMPLARY DAMAGES ARISING OUT
-OF THIS AGREEMENT REGARDLESS OF THE LEGAL OR EQUITABLE THEORY (CONTRACT, TORT OR
-OTHERWISE) UPON WHICH THE CLAIM IS BASED.
-
-## 6. Miscellaneous
-
-6.1 This Agreement sets out the entire agreement between You and Us for Your
-Contributions to Us and overrides all other agreements or understandings.
-
-6.2 If You or We assign the rights or obligations received through this
-Agreement to a third party, as a condition of the assignment, that third party
-must agree in writing to abide by all the rights and obligations in the
-Agreement.
-
-6.3 The failure of either party to require performance by the other party of any
-provision of this Agreement in one situation shall not affect the right of a
-party to require such performance at any time in the future. A waiver of
-performance under a provision in one situation shall not be considered a waiver
-of the performance of the provision in the future or a waiver of the provision
-in its entirety.
-
-6.4 If any provision of this Agreement is found void and unenforceable, such
-provision will be replaced to the extent possible with a provision that comes
-closest to the meaning of the original provision and which is enforceable. The
-terms and conditions set forth in this Agreement shall apply notwithstanding any
-failure of essential purpose of this Agreement or any limited remedy to the
-maximum extent possible under law.
diff --git a/CODEOWNERS b/CODEOWNERS
deleted file mode 100644
--- a/CODEOWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
-# SPDX-License-Identifier: Apache-2.0
-
-* @mrdimidium
diff --git a/Cargo.lock b/Cargo.lock
index d2d38d6..f9ecd44 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -21,56 +21,6 @@ dependencies = [
]
[[package]]
-name = "anstream"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
-dependencies = [
- "anstyle",
- "anstyle-parse",
- "anstyle-query",
- "anstyle-wincon",
- "colorchoice",
- "is_terminal_polyfill",
- "utf8parse",
-]
-
-[[package]]
-name = "anstyle"
-version = "1.0.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
-
-[[package]]
-name = "anstyle-parse"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
-dependencies = [
- "utf8parse",
-]
-
-[[package]]
-name = "anstyle-query"
-version = "1.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
-dependencies = [
- "windows-sys 0.61.2",
-]
-
-[[package]]
-name = "anstyle-wincon"
-version = "3.0.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
-dependencies = [
- "anstyle",
- "once_cell_polyfill",
- "windows-sys 0.61.2",
-]
-
-[[package]]
name = "async-trait"
version = "0.1.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -209,46 +159,6 @@ dependencies = [
]
[[package]]
-name = "clap"
-version = "4.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51"
-dependencies = [
- "clap_builder",
- "clap_derive",
-]
-
-[[package]]
-name = "clap_builder"
-version = "4.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f"
-dependencies = [
- "anstream",
- "anstyle",
- "clap_lex",
- "strsim",
-]
-
-[[package]]
-name = "clap_derive"
-version = "4.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9"
-dependencies = [
- "heck",
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "clap_lex"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
-
-[[package]]
name = "cmake"
version = "0.1.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -258,12 +168,6 @@ dependencies = [
]
[[package]]
-name = "colorchoice"
-version = "1.0.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
-
-[[package]]
name = "combine"
version = "4.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -666,8 +570,7 @@ checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
name = "hule"
version = "0.1.0"
dependencies = [
- "clap",
- "hule-hmi",
+ "hule-image",
"hule-oci",
"hule-vmm",
"tokio",
@@ -675,7 +578,7 @@ dependencies = [
]
[[package]]
-name = "hule-hmi"
+name = "hule-image"
version = "0.1.0"
dependencies = [
"serde",
@@ -686,11 +589,10 @@ dependencies = [
name = "hule-oci"
version = "0.1.0"
dependencies = [
- "hule-hmi",
+ "hule-image",
"oci-client",
"serde_json",
"sha2 0.10.9",
- "tokio",
"zstd",
]
@@ -699,8 +601,7 @@ name = "hule-vmm"
version = "0.1.0"
dependencies = [
"async-trait",
- "base64",
- "hule-hmi",
+ "hule-image",
"serde",
"serde_json",
"tokio",
@@ -914,12 +815,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2"
[[package]]
-name = "is_terminal_polyfill"
-version = "1.70.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
-
-[[package]]
name = "itoa"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1144,12 +1039,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
-name = "once_cell_polyfill"
-version = "1.70.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
-
-[[package]]
name = "openssl-probe"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1980,12 +1869,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
-name = "utf8parse"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
-
-[[package]]
name = "uuid"
version = "1.23.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 825ad03..c21c088 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: Apache-2.0
[workspace]
@@ -11,13 +11,13 @@ edition = "2024"
version = "0.1.0"
license = "Apache-2.0"
authors = ["Nikolay Govorov <me@govorov.online>"]
-repository = "https://git.dimidiumlabs.io/hule"
+repository = "https://github.com/dimidiumlabs/hule"
[workspace.dependencies]
# local dependencies
-hule-hmi = { path = "crates/hule-hmi" }
hule-oci = { path = "crates/hule-oci" }
hule-vmm = { path = "crates/hule-vmm" }
+hule-image = { path = "crates/hule-image" }
# external dependencies
serde = { version = "1", features = ["derive"] }
diff --git a/LICENSES/CC-BY-3.0.txt b/LICENSES/CC-BY-3.0.txt
deleted file mode 100644
--- a/LICENSES/CC-BY-3.0.txt
+++ /dev/null
@@ -1,319 +0,0 @@
-Creative Commons Legal Code
-
-Attribution 3.0 Unported
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
- DAMAGES RESULTING FROM ITS USE.
-
-License
-
-THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
-COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
-COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
-AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
-
-BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
-TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
-BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
-CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
-CONDITIONS.
-
-1. Definitions
-
- a. "Adaptation" means a work based upon the Work, or upon the Work and
- other pre-existing works, such as a translation, adaptation,
- derivative work, arrangement of music or other alterations of a
- literary or artistic work, or phonogram or performance and includes
- cinematographic adaptations or any other form in which the Work may be
- recast, transformed, or adapted including in any form recognizably
- derived from the original, except that a work that constitutes a
- Collection will not be considered an Adaptation for the purpose of
- this License. For the avoidance of doubt, where the Work is a musical
- work, performance or phonogram, the synchronization of the Work in
- timed-relation with a moving image ("synching") will be considered an
- Adaptation for the purpose of this License.
- b. "Collection" means a collection of literary or artistic works, such as
- encyclopedias and anthologies, or performances, phonograms or
- broadcasts, or other works or subject matter other than works listed
- in Section 1(f) below, which, by reason of the selection and
- arrangement of their contents, constitute intellectual creations, in
- which the Work is included in its entirety in unmodified form along
- with one or more other contributions, each constituting separate and
- independent works in themselves, which together are assembled into a
- collective whole. A work that constitutes a Collection will not be
- considered an Adaptation (as defined above) for the purposes of this
- License.
- c. "Distribute" means to make available to the public the original and
- copies of the Work or Adaptation, as appropriate, through sale or
- other transfer of ownership.
- d. "Licensor" means the individual, individuals, entity or entities that
- offer(s) the Work under the terms of this License.
- e. "Original Author" means, in the case of a literary or artistic work,
- the individual, individuals, entity or entities who created the Work
- or if no individual or entity can be identified, the publisher; and in
- addition (i) in the case of a performance the actors, singers,
- musicians, dancers, and other persons who act, sing, deliver, declaim,
- play in, interpret or otherwise perform literary or artistic works or
- expressions of folklore; (ii) in the case of a phonogram the producer
- being the person or legal entity who first fixes the sounds of a
- performance or other sounds; and, (iii) in the case of broadcasts, the
- organization that transmits the broadcast.
- f. "Work" means the literary and/or artistic work offered under the terms
- of this License including without limitation any production in the
- literary, scientific and artistic domain, whatever may be the mode or
- form of its expression including digital form, such as a book,
- pamphlet and other writing; a lecture, address, sermon or other work
- of the same nature; a dramatic or dramatico-musical work; a
- choreographic work or entertainment in dumb show; a musical
- composition with or without words; a cinematographic work to which are
- assimilated works expressed by a process analogous to cinematography;
- a work of drawing, painting, architecture, sculpture, engraving or
- lithography; a photographic work to which are assimilated works
- expressed by a process analogous to photography; a work of applied
- art; an illustration, map, plan, sketch or three-dimensional work
- relative to geography, topography, architecture or science; a
- performance; a broadcast; a phonogram; a compilation of data to the
- extent it is protected as a copyrightable work; or a work performed by
- a variety or circus performer to the extent it is not otherwise
- considered a literary or artistic work.
- g. "You" means an individual or entity exercising rights under this
- License who has not previously violated the terms of this License with
- respect to the Work, or who has received express permission from the
- Licensor to exercise rights under this License despite a previous
- violation.
- h. "Publicly Perform" means to perform public recitations of the Work and
- to communicate to the public those public recitations, by any means or
- process, including by wire or wireless means or public digital
- performances; to make available to the public Works in such a way that
- members of the public may access these Works from a place and at a
- place individually chosen by them; to perform the Work to the public
- by any means or process and the communication to the public of the
- performances of the Work, including by public digital performance; to
- broadcast and rebroadcast the Work by any means including signs,
- sounds or images.
- i. "Reproduce" means to make copies of the Work by any means including
- without limitation by sound or visual recordings and the right of
- fixation and reproducing fixations of the Work, including storage of a
- protected performance or phonogram in digital form or other electronic
- medium.
-
-2. Fair Dealing Rights. Nothing in this License is intended to reduce,
-limit, or restrict any uses free from copyright or rights arising from
-limitations or exceptions that are provided for in connection with the
-copyright protection under copyright law or other applicable laws.
-
-3. License Grant. Subject to the terms and conditions of this License,
-Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
-perpetual (for the duration of the applicable copyright) license to
-exercise the rights in the Work as stated below:
-
- a. to Reproduce the Work, to incorporate the Work into one or more
- Collections, and to Reproduce the Work as incorporated in the
- Collections;
- b. to create and Reproduce Adaptations provided that any such Adaptation,
- including any translation in any medium, takes reasonable steps to
- clearly label, demarcate or otherwise identify that changes were made
- to the original Work. For example, a translation could be marked "The
- original work was translated from English to Spanish," or a
- modification could indicate "The original work has been modified.";
- c. to Distribute and Publicly Perform the Work including as incorporated
- in Collections; and,
- d. to Distribute and Publicly Perform Adaptations.
- e. For the avoidance of doubt:
-
- i. Non-waivable Compulsory License Schemes. In those jurisdictions in
- which the right to collect royalties through any statutory or
- compulsory licensing scheme cannot be waived, the Licensor
- reserves the exclusive right to collect such royalties for any
- exercise by You of the rights granted under this License;
- ii. Waivable Compulsory License Schemes. In those jurisdictions in
- which the right to collect royalties through any statutory or
- compulsory licensing scheme can be waived, the Licensor waives the
- exclusive right to collect such royalties for any exercise by You
- of the rights granted under this License; and,
- iii. Voluntary License Schemes. The Licensor waives the right to
- collect royalties, whether individually or, in the event that the
- Licensor is a member of a collecting society that administers
- voluntary licensing schemes, via that society, from any exercise
- by You of the rights granted under this License.
-
-The above rights may be exercised in all media and formats whether now
-known or hereafter devised. The above rights include the right to make
-such modifications as are technically necessary to exercise the rights in
-other media and formats. Subject to Section 8(f), all rights not expressly
-granted by Licensor are hereby reserved.
-
-4. Restrictions. The license granted in Section 3 above is expressly made
-subject to and limited by the following restrictions:
-
- a. You may Distribute or Publicly Perform the Work only under the terms
- of this License. You must include a copy of, or the Uniform Resource
- Identifier (URI) for, this License with every copy of the Work You
- Distribute or Publicly Perform. You may not offer or impose any terms
- on the Work that restrict the terms of this License or the ability of
- the recipient of the Work to exercise the rights granted to that
- recipient under the terms of the License. You may not sublicense the
- Work. You must keep intact all notices that refer to this License and
- to the disclaimer of warranties with every copy of the Work You
- Distribute or Publicly Perform. When You Distribute or Publicly
- Perform the Work, You may not impose any effective technological
- measures on the Work that restrict the ability of a recipient of the
- Work from You to exercise the rights granted to that recipient under
- the terms of the License. This Section 4(a) applies to the Work as
- incorporated in a Collection, but this does not require the Collection
- apart from the Work itself to be made subject to the terms of this
- License. If You create a Collection, upon notice from any Licensor You
- must, to the extent practicable, remove from the Collection any credit
- as required by Section 4(b), as requested. If You create an
- Adaptation, upon notice from any Licensor You must, to the extent
- practicable, remove from the Adaptation any credit as required by
- Section 4(b), as requested.
- b. If You Distribute, or Publicly Perform the Work or any Adaptations or
- Collections, You must, unless a request has been made pursuant to
- Section 4(a), keep intact all copyright notices for the Work and
- provide, reasonable to the medium or means You are utilizing: (i) the
- name of the Original Author (or pseudonym, if applicable) if supplied,
- and/or if the Original Author and/or Licensor designate another party
- or parties (e.g., a sponsor institute, publishing entity, journal) for
- attribution ("Attribution Parties") in Licensor's copyright notice,
- terms of service or by other reasonable means, the name of such party
- or parties; (ii) the title of the Work if supplied; (iii) to the
- extent reasonably practicable, the URI, if any, that Licensor
- specifies to be associated with the Work, unless such URI does not
- refer to the copyright notice or licensing information for the Work;
- and (iv) , consistent with Section 3(b), in the case of an Adaptation,
- a credit identifying the use of the Work in the Adaptation (e.g.,
- "French translation of the Work by Original Author," or "Screenplay
- based on original Work by Original Author"). The credit required by
- this Section 4 (b) may be implemented in any reasonable manner;
- provided, however, that in the case of a Adaptation or Collection, at
- a minimum such credit will appear, if a credit for all contributing
- authors of the Adaptation or Collection appears, then as part of these
- credits and in a manner at least as prominent as the credits for the
- other contributing authors. For the avoidance of doubt, You may only
- use the credit required by this Section for the purpose of attribution
- in the manner set out above and, by exercising Your rights under this
- License, You may not implicitly or explicitly assert or imply any
- connection with, sponsorship or endorsement by the Original Author,
- Licensor and/or Attribution Parties, as appropriate, of You or Your
- use of the Work, without the separate, express prior written
- permission of the Original Author, Licensor and/or Attribution
- Parties.
- c. Except as otherwise agreed in writing by the Licensor or as may be
- otherwise permitted by applicable law, if You Reproduce, Distribute or
- Publicly Perform the Work either by itself or as part of any
- Adaptations or Collections, You must not distort, mutilate, modify or
- take other derogatory action in relation to the Work which would be
- prejudicial to the Original Author's honor or reputation. Licensor
- agrees that in those jurisdictions (e.g. Japan), in which any exercise
- of the right granted in Section 3(b) of this License (the right to
- make Adaptations) would be deemed to be a distortion, mutilation,
- modification or other derogatory action prejudicial to the Original
- Author's honor and reputation, the Licensor will waive or not assert,
- as appropriate, this Section, to the fullest extent permitted by the
- applicable national law, to enable You to reasonably exercise Your
- right under Section 3(b) of this License (right to make Adaptations)
- but not otherwise.
-
-5. Representations, Warranties and Disclaimer
-
-UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
-OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
-KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
-INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
-FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
-LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
-WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
-OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
-
-6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
-LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
-ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
-ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
-BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-7. Termination
-
- a. This License and the rights granted hereunder will terminate
- automatically upon any breach by You of the terms of this License.
- Individuals or entities who have received Adaptations or Collections
- from You under this License, however, will not have their licenses
- terminated provided such individuals or entities remain in full
- compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
- survive any termination of this License.
- b. Subject to the above terms and conditions, the license granted here is
- perpetual (for the duration of the applicable copyright in the Work).
- Notwithstanding the above, Licensor reserves the right to release the
- Work under different license terms or to stop distributing the Work at
- any time; provided, however that any such election will not serve to
- withdraw this License (or any other license that has been, or is
- required to be, granted under the terms of this License), and this
- License will continue in full force and effect unless terminated as
- stated above.
-
-8. Miscellaneous
-
- a. Each time You Distribute or Publicly Perform the Work or a Collection,
- the Licensor offers to the recipient a license to the Work on the same
- terms and conditions as the license granted to You under this License.
- b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
- offers to the recipient a license to the original Work on the same
- terms and conditions as the license granted to You under this License.
- c. If any provision of this License is invalid or unenforceable under
- applicable law, it shall not affect the validity or enforceability of
- the remainder of the terms of this License, and without further action
- by the parties to this agreement, such provision shall be reformed to
- the minimum extent necessary to make such provision valid and
- enforceable.
- d. No term or provision of this License shall be deemed waived and no
- breach consented to unless such waiver or consent shall be in writing
- and signed by the party to be charged with such waiver or consent.
- e. This License constitutes the entire agreement between the parties with
- respect to the Work licensed here. There are no understandings,
- agreements or representations with respect to the Work not specified
- here. Licensor shall not be bound by any additional provisions that
- may appear in any communication from You. This License may not be
- modified without the mutual written agreement of the Licensor and You.
- f. The rights granted under, and the subject matter referenced, in this
- License were drafted utilizing the terminology of the Berne Convention
- for the Protection of Literary and Artistic Works (as amended on
- September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
- Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
- and the Universal Copyright Convention (as revised on July 24, 1971).
- These rights and subject matter take effect in the relevant
- jurisdiction in which the License terms are sought to be enforced
- according to the corresponding provisions of the implementation of
- those treaty provisions in the applicable national law. If the
- standard suite of rights granted under applicable copyright law
- includes additional rights not granted under this License, such
- additional rights are deemed to be included in the License; this
- License is not intended to restrict the license of any rights under
- applicable law.
-
-
-Creative Commons Notice
-
- Creative Commons is not a party to this License, and makes no warranty
- whatsoever in connection with the Work. Creative Commons will not be
- liable to You or any party on any legal theory for any damages
- whatsoever, including without limitation any general, special,
- incidental or consequential damages arising in connection to this
- license. Notwithstanding the foregoing two (2) sentences, if Creative
- Commons has expressly identified itself as the Licensor hereunder, it
- shall have all rights and obligations of Licensor.
-
- Except for the limited purpose of indicating to the public that the
- Work is licensed under the CCPL, Creative Commons does not authorize
- the use by either party of the trademark "Creative Commons" or any
- related trademark or logo of Creative Commons without the prior
- written consent of Creative Commons. Any permitted use will be in
- compliance with Creative Commons' then-current trademark usage
- guidelines, as may be published on its website or otherwise made
- available upon request from time to time. For the avoidance of doubt,
- this trademark restriction does not form part of this License.
-
- Creative Commons may be contacted at https://creativecommons.org/.
diff --git a/LICENSES/CC-BY-4.0.txt b/LICENSES/CC-BY-4.0.txt
deleted file mode 100644
--- a/LICENSES/CC-BY-4.0.txt
+++ /dev/null
@@ -1,156 +0,0 @@
-Creative Commons Attribution 4.0 International
-
- Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
-
-Using Creative Commons Public Licenses
-
-Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
-
-Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
-
-Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
-
-Creative Commons Attribution 4.0 International Public License
-
-By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
-
-Section 1 – Definitions.
-
- a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
-
- b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
-
- c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
-
- d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
-
- e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
-
- f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
-
- g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
-
- h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
-
- i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
-
- j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
-
- k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
-
-Section 2 – Scope.
-
- a. License grant.
-
- 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
-
- A. reproduce and Share the Licensed Material, in whole or in part; and
-
- B. produce, reproduce, and Share Adapted Material.
-
- 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
-
- 3. Term. The term of this Public License is specified in Section 6(a).
-
- 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
-
- 5. Downstream recipients.
-
- A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
-
- B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
-
- 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
-
-b. Other rights.
-
- 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
-
- 2. Patent and trademark rights are not licensed under this Public License.
-
- 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
-
-Section 3 – License Conditions.
-
-Your exercise of the Licensed Rights is expressly made subject to the following conditions.
-
- a. Attribution.
-
- 1. If You Share the Licensed Material (including in modified form), You must:
-
- A. retain the following if it is supplied by the Licensor with the Licensed Material:
-
- i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
-
- ii. a copyright notice;
-
- iii. a notice that refers to this Public License;
-
- iv. a notice that refers to the disclaimer of warranties;
-
- v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
-
- B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
-
- C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
-
- 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
-
- 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
-
- 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
-
-Section 4 – Sui Generis Database Rights.
-
-Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
-
- a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
-
- b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
-
- c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
-For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
-
-Section 5 – Disclaimer of Warranties and Limitation of Liability.
-
- a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
-
- b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
-
- c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
-
-Section 6 – Term and Termination.
-
- a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
-
- b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
-
- 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
-
- 2. upon express reinstatement by the Licensor.
-
- c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
-
- d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
-
- e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
-
-Section 7 – Other Terms and Conditions.
-
- a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
-
- b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
-
-Section 8 – Interpretation.
-
- a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
-
- b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
-
- c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
-
- d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
-
-Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
-
-Creative Commons may be contacted at creativecommons.org.
diff --git a/README.md b/README.md
index f335062..c91eb08 100644
--- a/README.md
+++ b/README.md
@@ -1,49 +1,3 @@
# Hule
OCI-compliant layer for virtual machines.
-
-## Contributing
-
-We welcome your contributions, including code, bug reports, ideas, and success
-stories.
-
-If you are making a contribution for the first time or from a new email, please
-add yourself to the `.mailmap`.
-
-### Signoff
-
-To include your code, we ask that you read and agree to the [CLA](./CLA.md). To
-sign, add a `CLA-Version: 1.0` and a `Signed-off-by` trailer to every commit
-(`git commit -s --trailer "CLA-Version: 1.0"`). Each commit in a pull request
-must carry a valid `Signed-off-by` line matching the commit author. Please use
-your real name. We cannot include code from anonymous contributors.
-
-AI agents MUST NOT add Signed-off-by tags. Only humans can legally certify the
-Contributor License Agreement.
-
-### AI policy
-
-You may use AI agents when writing code and documentation. AI is not allowed for
-media including images, videos, fonts at all. You must fully read, understand,
-and cleanup any code generated by the agent. We ask that you disclose the
-agent's use and indicate the tool, model, and extent of contribution.
-
-Contributions should include an Assisted-by tag in the following format:
-`Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]`, for example:
-`Assisted-by: Claude:claude-4.6-opus coccinelle sparse`
-
-Remember, AI agents should make software better, not worse.
-
-## Licensing
-
-Hule source code is licensed under Apache-2.0. Documentation is licensed under
-CC-BY-4.0.
-
-The image-generation scripts in `images/*/genimg` are derived from code
-originally published by Drew DeVault as part of [SourceHut](https://sr.ht) and
-remain licensed under AGPL-3.0-only. They are not linked into or included in
-Hule binaries or release artifacts. Other source code and scripts developed for
-Hule are licensed under Apache-2.0.
-
-Machine images remain subject to the licenses of their operating systems and
-included software.
diff --git a/REUSE.toml b/REUSE.toml
index 9ad56a8..b140299 100644
--- a/REUSE.toml
+++ b/REUSE.toml
@@ -1,35 +1,13 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: Apache-2.0
version = 1
[[annotations]]
path = [
+ "README.md",
"Cargo.toml",
"Cargo.lock",
- "mise.lock",
]
SPDX-FileCopyrightText = "2026 Nikolay Govorov"
SPDX-License-Identifier = "Apache-2.0"
-
-[[annotations]]
-path = [
- ".mailmap",
-]
-SPDX-FileCopyrightText = "2026 Nikolay Govorov"
-SPDX-License-Identifier = "Apache-2.0"
-
-[[annotations]]
-path = [
- "CLA.md",
-]
-SPDX-FileCopyrightText = "2026 Nikolay Govorov"
-SPDX-License-Identifier = "CC-BY-3.0"
-
-[[annotations]]
-path = [
- "README.md",
- "docs/*.md",
-]
-SPDX-FileCopyrightText = "2026 Nikolay Govorov"
-SPDX-License-Identifier = "CC-BY-4.0"
diff --git a/crates/hule-hmi/Cargo.toml b/crates/hule-image/Cargo.toml
index e315d00..3c6c20c 100644
--- a/crates/hule-hmi/Cargo.toml
+++ b/crates/hule-image/Cargo.toml
@@ -1,8 +1,8 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: Apache-2.0
[package]
-name = "hule-hmi"
+name = "hule-image"
description = "Types and validation for Hule machine images"
publish.workspace = true
diff --git a/crates/hule-hmi/src/lib.rs b/crates/hule-image/src/lib.rs
index dd78afc..6165294 100644
--- a/crates/hule-hmi/src/lib.rs
+++ b/crates/hule-image/src/lib.rs
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
//! Types and validation for a Hule machine image `config.json`.
diff --git a/crates/hule-oci/Cargo.toml b/crates/hule-oci/Cargo.toml
index 6b05ea5..76ba6ed 100644
--- a/crates/hule-oci/Cargo.toml
+++ b/crates/hule-oci/Cargo.toml
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: Apache-2.0
[package]
@@ -13,9 +13,8 @@ authors.workspace = true
repository.workspace = true
[dependencies]
-hule-hmi.workspace = true
+hule-image.workspace = true
serde_json.workspace = true
-tokio = { workspace = true, features = ["fs", "io-util", "rt"] }
oci-client = "0.17"
zstd = "0.13"
sha2 = "0.10"
diff --git a/crates/hule-oci/src/error.rs b/crates/hule-oci/src/error.rs
deleted file mode 100644
--- a/crates/hule-oci/src/error.rs
+++ /dev/null
@@ -1,119 +0,0 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
-// SPDX-License-Identifier: Apache-2.0
-
-use oci_client::errors::OciDistributionError;
-use std::fmt;
-use std::path::PathBuf;
-
-#[derive(Debug)]
-pub enum Error {
- Io(std::io::Error),
- Json(serde_json::Error),
- InvalidImage(hule_hmi::ParseError),
- InvalidReference {
- reference: String,
- source: oci_client::ParseError,
- },
- Registry(OciDistributionError),
- Task(tokio::task::JoinError),
- InvalidImagePath(PathBuf),
- MissingConfig(PathBuf),
- ImageNotFound(String),
- MissingManifest,
- InvalidLayer(&'static str),
- InvalidAnnotation {
- name: &'static str,
- value: String,
- },
- EmptyImageFile(PathBuf),
- InvalidStoragePath {
- kind: &'static str,
- value: String,
- },
-}
-
-impl fmt::Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self {
- Self::Io(error) => error.fmt(f),
- Self::Json(error) => error.fmt(f),
- Self::InvalidImage(error) => error.fmt(f),
- Self::InvalidReference { reference, source } => {
- write!(f, "invalid reference '{reference}': {source}")
- }
- Self::Registry(error) => error.fmt(f),
- Self::Task(error) => write!(f, "background task failed: {error}"),
- Self::InvalidImagePath(path) => {
- write!(f, "{} has no file name", path.display())
- }
- Self::MissingConfig(path) => {
- write!(f, "{} does not contain config.json", path.display())
- }
- Self::ImageNotFound(reference) => {
- write!(f, "no local image tagged '{reference}'")
- }
- Self::MissingManifest => f.write_str("registry returned no image manifest"),
- Self::InvalidLayer(reason) => write!(f, "invalid chunk layer: {reason}"),
- Self::InvalidAnnotation { name, value } => {
- write!(f, "invalid chunk {name} annotation '{value}'")
- }
- Self::EmptyImageFile(path) => write!(f, "{} is empty", path.display()),
- Self::InvalidStoragePath { kind, value } => {
- write!(f, "invalid {kind} '{value}'")
- }
- }
- }
-}
-
-impl std::error::Error for Error {
- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
- match self {
- Self::Io(error) => Some(error),
- Self::Json(error) => Some(error),
- Self::InvalidImage(error) => Some(error),
- Self::InvalidReference { source, .. } => Some(source),
- Self::Registry(error) => Some(error),
- Self::Task(error) => Some(error),
- Self::InvalidImagePath(_)
- | Self::MissingConfig(_)
- | Self::ImageNotFound(_)
- | Self::MissingManifest
- | Self::InvalidLayer(_)
- | Self::InvalidAnnotation { .. }
- | Self::EmptyImageFile(_)
- | Self::InvalidStoragePath { .. } => None,
- }
- }
-}
-
-impl From<std::io::Error> for Error {
- fn from(error: std::io::Error) -> Self {
- Self::Io(error)
- }
-}
-
-impl From<serde_json::Error> for Error {
- fn from(error: serde_json::Error) -> Self {
- Self::Json(error)
- }
-}
-
-impl From<hule_hmi::ParseError> for Error {
- fn from(error: hule_hmi::ParseError) -> Self {
- Self::InvalidImage(error)
- }
-}
-
-impl From<OciDistributionError> for Error {
- fn from(error: OciDistributionError) -> Self {
- Self::Registry(error)
- }
-}
-
-impl From<tokio::task::JoinError> for Error {
- fn from(error: tokio::task::JoinError) -> Self {
- Self::Task(error)
- }
-}
-
-pub type Result<T> = std::result::Result<T, Error>;
diff --git a/crates/hule-oci/src/lib.rs b/crates/hule-oci/src/lib.rs
index 819e05b..a63f448 100644
--- a/crates/hule-oci/src/lib.rs
+++ b/crates/hule-oci/src/lib.rs
@@ -1,12 +1,9 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
//! OCI image storage and registry operations for Hule machine images.
-mod error;
-mod storage;
-
-use hule_hmi::MachineImage;
+use hule_image::MachineImage;
use oci_client::annotations::{ORG_OPENCONTAINERS_IMAGE_REF_NAME, ORG_OPENCONTAINERS_IMAGE_TITLE};
use oci_client::client::{ClientConfig, ClientProtocol, Config, ImageLayer};
use oci_client::manifest::{
@@ -15,14 +12,9 @@ use oci_client::manifest::{
use oci_client::secrets::RegistryAuth;
use oci_client::{Client, Reference};
use std::collections::{BTreeMap, BTreeSet};
+use std::io::Read;
use std::path::{Path, PathBuf};
-use tokio::fs::{self, File};
-use tokio::io::AsyncReadExt;
-use tokio::task;
-
-pub use error::{Error, Result};
-pub use storage::Storage;
-
+pub type Result<T> = std::result::Result<T, String>;
type R<T> = Result<T>;
// ---- local OCI-layout store -------------------------------------------
@@ -33,6 +25,82 @@ const HULE_CONFIG_MEDIA_TYPE: &str = "application/vnd.hule.machine.config.v1+jso
const ANNOTATION_CHUNK_OFFSET: &str = "io.hule.chunk.offset";
const ANNOTATION_CHUNK_LENGTH: &str = "io.hule.chunk.length";
+fn store_root() -> R<PathBuf> {
+ let home = std::env::var("HOME").map_err(|_| "HOME is not set".to_string())?;
+ Ok(PathBuf::from(home).join(".hule").join("store"))
+}
+
+fn blobs_dir() -> R<PathBuf> {
+ Ok(store_root()?.join("blobs").join("sha256"))
+}
+
+fn materialized_dir(manifest_digest: &str) -> R<PathBuf> {
+ Ok(store_root()?
+ .join("materialized")
+ .join(strip_sha256(manifest_digest)))
+}
+
+fn index_path() -> R<PathBuf> {
+ Ok(store_root()?.join("index.json"))
+}
+
+fn strip_sha256(digest: &str) -> &str {
+ digest.strip_prefix("sha256:").unwrap_or(digest)
+}
+
+fn sha256_hex(data: &[u8]) -> String {
+ use sha2::{Digest, Sha256};
+ let mut hasher = Sha256::new();
+ hasher.update(data);
+ format!("sha256:{:x}", hasher.finalize())
+}
+
+fn ensure_store() -> R<()> {
+ std::fs::create_dir_all(blobs_dir()?).map_err(|e| e.to_string())?;
+ std::fs::create_dir_all(store_root()?.join("materialized")).map_err(|e| e.to_string())?;
+ let layout = store_root()?.join("oci-layout");
+ if !layout.exists() {
+ std::fs::write(&layout, br#"{"imageLayoutVersion":"1.0.0"}"#).map_err(|e| e.to_string())?;
+ }
+ Ok(())
+}
+
+/// Writes raw bytes as a content-addressed blob, no-op if already present.
+fn write_blob(data: &[u8]) -> R<String> {
+ let digest = sha256_hex(data);
+ let path = blobs_dir()?.join(strip_sha256(&digest));
+ if !path.exists() {
+ let tmp = path.with_extension("tmp");
+ std::fs::write(&tmp, data).map_err(|e| e.to_string())?;
+ std::fs::rename(&tmp, &path).map_err(|e| e.to_string())?;
+ }
+ Ok(digest)
+}
+
+fn read_blob(digest: &str) -> R<Vec<u8>> {
+ std::fs::read(blobs_dir()?.join(strip_sha256(digest))).map_err(|e| e.to_string())
+}
+
+fn read_index() -> R<OciImageIndex> {
+ let path = index_path()?;
+ if !path.exists() {
+ return Ok(OciImageIndex {
+ schema_version: 2,
+ media_type: None,
+ manifests: vec![],
+ artifact_type: None,
+ annotations: None,
+ });
+ }
+ let data = std::fs::read(&path).map_err(|e| e.to_string())?;
+ serde_json::from_slice(&data).map_err(|e| e.to_string())
+}
+
+fn write_index(index: &OciImageIndex) -> R<()> {
+ let data = serde_json::to_vec_pretty(index).map_err(|e| e.to_string())?;
+ std::fs::write(index_path()?, data).map_err(|e| e.to_string())
+}
+
fn index_lookup(index: &OciImageIndex, reference: &str) -> Option<String> {
index
.manifests
@@ -70,71 +138,79 @@ fn index_set(index: &mut OciImageIndex, reference: &str, digest: &str, size: u64
});
}
-/// Manages Hule images backed by a [`Storage`].
-#[derive(Clone, Debug)]
-pub struct ImageManager {
- storage: Storage,
-}
-
-impl ImageManager {
- pub fn new(storage: Storage) -> Self {
- Self { storage }
+fn hardlink_or_copy(src: &Path, dest: &Path) -> R<()> {
+ if std::fs::hard_link(src, dest).is_err() {
+ std::fs::copy(src, dest).map_err(|e| e.to_string())?;
}
+ Ok(())
+}
- pub fn storage(&self) -> &Storage {
- &self.storage
+fn write_at(file: &std::fs::File, offset: u64, data: &[u8]) -> R<()> {
+ use std::os::unix::fs::FileExt;
+ let mut written = 0usize;
+ while written < data.len() {
+ let n = file
+ .write_at(&data[written..], offset + written as u64)
+ .map_err(|e| e.to_string())?;
+ if n == 0 {
+ return Err("write_at wrote 0 bytes".to_string());
+ }
+ written += n;
}
+ Ok(())
+}
- /// Splits `path` into fixed-size chunks, compresses each independently
- /// and writes each as its own blob.
- async fn write_file_chunks(&self, path: &Path) -> R<Vec<OciDescriptor>> {
- let title = path
- .file_name()
- .ok_or_else(|| Error::InvalidImagePath(path.to_path_buf()))?
- .to_string_lossy()
- .to_string();
- let mut file = File::open(path).await?;
- let mut descriptors = Vec::new();
- let mut offset: u64 = 0;
- loop {
- let mut buf = Vec::with_capacity(CHUNK_SIZE);
- (&mut file)
- .take(CHUNK_SIZE as u64)
- .read_to_end(&mut buf)
- .await?;
- if buf.is_empty() {
- break;
- }
- let length = buf.len() as u64;
- let compressed =
- task::spawn_blocking(move || zstd::stream::encode_all(&buf[..], 0)).await??;
- let compressed_len = compressed.len();
- let (digest, _) = self.storage.write_blob(compressed).await?;
-
- let mut annotations = BTreeMap::new();
- annotations.insert(ORG_OPENCONTAINERS_IMAGE_TITLE.to_string(), title.clone());
- annotations.insert(ANNOTATION_CHUNK_OFFSET.to_string(), offset.to_string());
- annotations.insert(ANNOTATION_CHUNK_LENGTH.to_string(), length.to_string());
-
- descriptors.push(OciDescriptor {
- media_type: HULE_CHUNK_MEDIA_TYPE.to_string(),
- digest,
- size: compressed_len as i64,
- urls: None,
- annotations: Some(annotations),
- artifact_type: None,
- });
-
- offset += length;
- if length < CHUNK_SIZE as u64 {
- break;
- }
+/// Splits `path` into fixed-size chunks, compresses each independently
+/// (own zstd frame, no state shared between chunks -- see the design notes
+/// in the project plan on why this must not be done the other way around),
+/// and writes each as its own blob. Returns one descriptor per chunk, all
+/// sharing a title annotation plus a chunk offset/length in terms of the
+/// *uncompressed* file so pull can reassemble it.
+fn write_file_chunks(path: &Path) -> R<Vec<OciDescriptor>> {
+ let title = path
+ .file_name()
+ .ok_or_else(|| format!("{} has no file name", path.display()))?
+ .to_string_lossy()
+ .to_string();
+ let mut file = std::fs::File::open(path).map_err(|e| e.to_string())?;
+ let mut descriptors = Vec::new();
+ let mut offset: u64 = 0;
+ loop {
+ let mut buf = Vec::with_capacity(CHUNK_SIZE);
+ (&mut file)
+ .take(CHUNK_SIZE as u64)
+ .read_to_end(&mut buf)
+ .map_err(|e| e.to_string())?;
+ if buf.is_empty() {
+ break;
}
- if descriptors.is_empty() {
- return Err(Error::EmptyImageFile(path.to_path_buf()));
+ let length = buf.len() as u64;
+ let compressed = zstd::stream::encode_all(&buf[..], 0).map_err(|e| e.to_string())?;
+ let digest = write_blob(&compressed)?;
+
+ let mut annotations = BTreeMap::new();
+ annotations.insert(ORG_OPENCONTAINERS_IMAGE_TITLE.to_string(), title.clone());
+ annotations.insert(ANNOTATION_CHUNK_OFFSET.to_string(), offset.to_string());
+ annotations.insert(ANNOTATION_CHUNK_LENGTH.to_string(), length.to_string());
+
+ descriptors.push(OciDescriptor {
+ media_type: HULE_CHUNK_MEDIA_TYPE.to_string(),
+ digest,
+ size: compressed.len() as i64,
+ urls: None,
+ annotations: Some(annotations),
+ artifact_type: None,
+ });
+
+ offset += length;
+ if length < CHUNK_SIZE as u64 {
+ break;
}
- Ok(descriptors)
}
+ if descriptors.is_empty() {
+ return Err(format!("{} is empty", path.display()));
+ }
+ Ok(descriptors)
}
fn make_client(reference: &Reference) -> Client {
@@ -152,335 +228,232 @@ fn make_client(reference: &Reference) -> Client {
}
fn parse_reference(s: &str) -> R<Reference> {
- s.parse().map_err(|source| Error::InvalidReference {
- reference: s.to_string(),
- source,
- })
+ s.parse()
+ .map_err(|e| format!("invalid reference '{s}': {e}"))
}
-// ---- image operations -------------------------------------------------
-
-impl ImageManager {
- /// Loads a prepared HMI image directory and optionally tags it.
- pub async fn load(&self, path: &Path, reference: Option<&str>) -> R<String> {
- let config_path = path.join("config.json");
- match fs::metadata(&config_path).await {
- Ok(metadata) if metadata.is_file() => {}
- Ok(_) => return Err(Error::MissingConfig(path.to_path_buf())),
- Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
- return Err(Error::MissingConfig(path.to_path_buf()));
- }
- Err(error) => return Err(error.into()),
- }
- let config_bytes = fs::read(&config_path).await?;
- MachineImage::from_json(&config_bytes)?;
-
- let mut dir = fs::read_dir(path).await?;
- let mut entries = Vec::new();
- while let Some(entry) = dir.next_entry().await? {
- entries.push(entry);
- }
- entries.sort_by_key(|entry| entry.file_name());
-
- let mut layers = Vec::new();
- let mut sources: Vec<(String, PathBuf)> = Vec::new();
- for entry in entries {
- if !entry.file_type().await?.is_file() {
- continue;
- }
- let name = entry.file_name().to_string_lossy().to_string();
- if name == "config.json" {
- continue;
- }
- let file_path = entry.path();
- layers.extend(self.write_file_chunks(&file_path).await?);
- sources.push((name, file_path));
- }
+// ---- import / push / pull / run ---------------------------------------
- let config_size = config_bytes.len();
- let (config_digest, _) = self.storage.write_blob(config_bytes).await?;
- let config = OciDescriptor {
- media_type: HULE_CONFIG_MEDIA_TYPE.to_string(),
- digest: config_digest,
- size: config_size as i64,
- urls: None,
- annotations: None,
- artifact_type: None,
- };
-
- let manifest = OciImageManifest {
- schema_version: 2,
- media_type: Some(OCI_IMAGE_MEDIA_TYPE.to_string()),
- config,
- layers,
- subject: None,
- artifact_type: None,
- annotations: None,
- };
- let manifest_bytes = serde_json::to_vec(&manifest)?;
- let manifest_size = manifest_bytes.len();
- let (manifest_digest, _) = self.storage.write_blob(manifest_bytes).await?;
-
- self.storage.ensure_hmi_image(&manifest_digest).await?;
- for (title, source) in &sources {
- self.storage
- .cache_hmi_file(&manifest_digest, title, source)
- .await?;
- }
-
- if let Some(reference) = reference {
- let mut index = self.storage.read_index().await?;
- index_set(
- &mut index,
- reference,
- &manifest_digest,
- manifest_size as u64,
- );
- self.storage.write_index(&index).await?;
- }
- Ok(manifest_digest)
+/// Imports an image directory into the local OCI layout and optionally tags it.
+pub async fn import(path: &Path, reference: Option<&str>) -> R<String> {
+ ensure_store()?;
+ let config_path = path.join("config.json");
+ if !config_path.is_file() {
+ return Err(format!("{} does not contain config.json", path.display()));
}
-
- /// Pushes a locally tagged image to its registry reference.
- pub async fn push(&self, reference_str: &str) -> R<()> {
- let index = self.storage.read_index().await?;
- let manifest_digest = index_lookup(&index, reference_str)
- .ok_or_else(|| Error::ImageNotFound(reference_str.to_string()))?;
- let manifest_bytes = self.storage.read_blob(&manifest_digest).await?;
- let manifest: OciImageManifest = serde_json::from_slice(&manifest_bytes)?;
-
- let reference = parse_reference(reference_str)?;
- let client = make_client(&reference);
- let auth = RegistryAuth::Anonymous;
-
- let mut layers = Vec::new();
- for descriptor in &manifest.layers {
- let data = self.storage.read_blob(&descriptor.digest).await?;
- layers.push(ImageLayer::new(
- data,
- descriptor.media_type.clone(),
- descriptor.annotations.clone(),
- ));
+ let config_bytes = std::fs::read(&config_path).map_err(|e| e.to_string())?;
+ MachineImage::from_json(&config_bytes).map_err(|e| e.to_string())?;
+
+ let mut entries: Vec<_> = std::fs::read_dir(path)
+ .map_err(|e| e.to_string())?
+ .collect::<std::result::Result<Vec<_>, _>>()
+ .map_err(|e| e.to_string())?;
+ entries.sort_by_key(|e| e.file_name());
+
+ let mut layers = Vec::new();
+ let mut sources: Vec<(String, PathBuf)> = Vec::new();
+ for entry in entries {
+ if !entry.file_type().map_err(|e| e.to_string())?.is_file() {
+ continue;
}
- let config_bytes = self.storage.read_blob(&manifest.config.digest).await?;
- let config = Config::new(
- config_bytes,
- manifest.config.media_type.clone(),
- manifest.config.annotations.clone(),
- );
-
- client
- .push(&reference, &layers, config, &auth, Some(manifest))
- .await?;
-
- Ok(())
+ let name = entry.file_name().to_string_lossy().to_string();
+ if name == "config.json" {
+ continue;
+ }
+ let file_path = entry.path();
+ layers.extend(write_file_chunks(&file_path)?);
+ sources.push((name, file_path));
}
- /// Pulls an image into the OCI layout and materializes it in the HMI store.
- pub async fn pull(&self, reference_str: &str) -> R<String> {
- let reference = parse_reference(reference_str)?;
- let client = make_client(&reference);
- let auth = RegistryAuth::Anonymous;
-
- let mut image_data = client
- .pull(&reference, &auth, vec![HULE_CHUNK_MEDIA_TYPE])
- .await?;
- let manifest = image_data.manifest.ok_or(Error::MissingManifest)?;
-
- // `client.pull()` fetches layers via `buffer_unordered`, so `image_data.layers` is
- // in completion order, not manifest order. Each layer carries its own annotations.
- for layer in &mut image_data.layers {
- let data = std::mem::take(&mut layer.data);
- let (_, data) = self.storage.write_blob(data).await?;
- layer.data = data;
- }
- let config_data = std::mem::take(&mut image_data.config.data);
- let (_, config_data) = self.storage.write_blob(config_data).await?;
- image_data.config.data = config_data;
-
- let manifest_bytes = serde_json::to_vec(&manifest)?;
- let manifest_size = manifest_bytes.len();
- let (manifest_digest, _) = self.storage.write_blob(manifest_bytes).await?;
- self.storage.ensure_hmi_image(&manifest_digest).await?;
-
- let mut by_title: BTreeMap<String, Vec<(u64, ImageLayer)>> = BTreeMap::new();
- for layer in image_data.layers {
- let annotations = layer
- .annotations
- .as_ref()
- .ok_or(Error::InvalidLayer("missing annotations"))?;
- let title = annotations
- .get(ORG_OPENCONTAINERS_IMAGE_TITLE)
- .ok_or(Error::InvalidLayer("missing title annotation"))?;
- let offset_value = annotations
- .get(ANNOTATION_CHUNK_OFFSET)
- .ok_or(Error::InvalidLayer("missing offset annotation"))?;
- let offset: u64 = offset_value.parse().map_err(|_| Error::InvalidAnnotation {
- name: "offset",
- value: offset_value.clone(),
- })?;
- by_title
- .entry(title.clone())
- .or_default()
- .push((offset, layer));
- }
+ let config_digest = write_blob(&config_bytes)?;
+ let config = OciDescriptor {
+ media_type: HULE_CONFIG_MEDIA_TYPE.to_string(),
+ digest: config_digest,
+ size: config_bytes.len() as i64,
+ urls: None,
+ annotations: None,
+ artifact_type: None,
+ };
- for (title, chunks) in by_title {
- let mut decompressed_chunks = Vec::with_capacity(chunks.len());
- for (offset, layer) in chunks {
- let data = task::spawn_blocking(move || zstd::stream::decode_all(&layer.data[..]))
- .await??;
- decompressed_chunks.push((offset, data));
- }
- self.storage
- .write_hmi_file(&manifest_digest, &title, decompressed_chunks)
- .await?;
+ let manifest = OciImageManifest {
+ schema_version: 2,
+ media_type: Some(OCI_IMAGE_MEDIA_TYPE.to_string()),
+ config,
+ layers,
+ subject: None,
+ artifact_type: None,
+ annotations: None,
+ };
+ let manifest_bytes = serde_json::to_vec(&manifest).map_err(|e| e.to_string())?;
+ let manifest_digest = write_blob(&manifest_bytes)?;
+
+ let materialized = materialized_dir(&manifest_digest)?;
+ std::fs::create_dir_all(&materialized).map_err(|e| e.to_string())?;
+ for (title, source) in &sources {
+ let dest = materialized.join(title);
+ if !dest.exists() {
+ hardlink_or_copy(source, &dest)?;
}
+ }
- let mut index = self.storage.read_index().await?;
+ if let Some(reference) = reference {
+ let mut index = read_index()?;
index_set(
&mut index,
- reference_str,
+ reference,
&manifest_digest,
- manifest_size as u64,
+ manifest_bytes.len() as u64,
);
- self.storage.write_index(&index).await?;
+ write_index(&index)?;
+ }
+ Ok(manifest_digest)
+}
- Ok(manifest_digest)
+/// Pushes a locally tagged image to its registry reference.
+pub async fn push(reference_str: &str) -> R<()> {
+ ensure_store()?;
+ let index = read_index()?;
+ let manifest_digest = index_lookup(&index, reference_str)
+ .ok_or_else(|| format!("no local image tagged '{reference_str}'"))?;
+ let manifest_bytes = read_blob(&manifest_digest)?;
+ let manifest: OciImageManifest =
+ serde_json::from_slice(&manifest_bytes).map_err(|e| e.to_string())?;
+
+ let reference = parse_reference(reference_str)?;
+ let client = make_client(&reference);
+ let auth = RegistryAuth::Anonymous;
+
+ let mut layers = Vec::new();
+ for descriptor in &manifest.layers {
+ let data = read_blob(&descriptor.digest)?;
+ layers.push(ImageLayer::new(
+ data,
+ descriptor.media_type.clone(),
+ descriptor.annotations.clone(),
+ ));
}
+ let config_bytes = read_blob(&manifest.config.digest)?;
+ let config = Config::new(
+ config_bytes,
+ manifest.config.media_type.clone(),
+ manifest.config.annotations.clone(),
+ );
+
+ client
+ .push(&reference, &layers, config, &auth, Some(manifest))
+ .await
+ .map_err(|e| e.to_string())?;
- /// Returns whether a reference is present in the local OCI layout.
- pub async fn contains(&self, reference_str: &str) -> R<bool> {
- Ok(index_lookup(&self.storage.read_index().await?, reference_str).is_some())
+ Ok(())
+}
+
+/// Pulls an image into the local OCI layout and materializes its files.
+pub async fn pull(reference_str: &str) -> R<String> {
+ ensure_store()?;
+ let reference = parse_reference(reference_str)?;
+ let client = make_client(&reference);
+ let auth = RegistryAuth::Anonymous;
+
+ let image_data = client
+ .pull(&reference, &auth, vec![HULE_CHUNK_MEDIA_TYPE])
+ .await
+ .map_err(|e| e.to_string())?;
+ let manifest = image_data
+ .manifest
+ .ok_or("registry returned no image manifest")?;
+
+ // `client.pull()` fetches layers via `buffer_unordered`, so `image_data.layers` is in
+ // completion order, NOT `manifest.layers` order -- do not zip the two. Each `ImageLayer`
+ // already carries its own annotations, so it's self-describing without cross-referencing.
+ for layer in &image_data.layers {
+ write_blob(&layer.data)?;
}
+ write_blob(&image_data.config.data)?;
- /// Materializes a locally tagged image into `destination` and returns config.json.
- pub async fn materialize(&self, reference_str: &str, destination: &Path) -> R<Vec<u8>> {
- let manifest_digest = index_lookup(&self.storage.read_index().await?, reference_str)
- .ok_or_else(|| Error::ImageNotFound(reference_str.to_string()))?;
+ let manifest_bytes = serde_json::to_vec(&manifest).map_err(|e| e.to_string())?;
+ let manifest_digest = write_blob(&manifest_bytes)?;
- let manifest_bytes = self.storage.read_blob(&manifest_digest).await?;
- let manifest: OciImageManifest = serde_json::from_slice(&manifest_bytes)?;
- let config_bytes = self.storage.read_blob(&manifest.config.digest).await?;
+ let materialized = materialized_dir(&manifest_digest)?;
+ std::fs::create_dir_all(&materialized).map_err(|e| e.to_string())?;
- fs::create_dir_all(destination).await?;
- fs::write(destination.join("config.json"), &config_bytes).await?;
+ let mut by_title: BTreeMap<String, Vec<(u64, &[u8])>> = BTreeMap::new();
+ for layer in &image_data.layers {
+ let annotations = layer
+ .annotations
+ .as_ref()
+ .ok_or("chunk layer missing annotations")?;
+ let title = annotations
+ .get(ORG_OPENCONTAINERS_IMAGE_TITLE)
+ .ok_or("chunk layer missing title annotation")?;
+ let offset: u64 = annotations
+ .get(ANNOTATION_CHUNK_OFFSET)
+ .ok_or("chunk layer missing offset annotation")?
+ .parse()
+ .map_err(|_| "invalid chunk offset annotation".to_string())?;
+ by_title
+ .entry(title.clone())
+ .or_default()
+ .push((offset, &layer.data[..]));
+ }
- let mut titles: BTreeSet<String> = BTreeSet::new();
- for descriptor in &manifest.layers {
- if let Some(title) = descriptor
- .annotations
- .as_ref()
- .and_then(|annotations| annotations.get(ORG_OPENCONTAINERS_IMAGE_TITLE))
- {
- titles.insert(title.clone());
- }
- }
- for title in titles {
- self.storage
- .export_hmi_file(&manifest_digest, &title, &destination.join(&title))
- .await?;
+ for (title, mut chunks) in by_title {
+ chunks.sort_by_key(|(offset, _)| *offset);
+ let file = std::fs::File::create(materialized.join(&title)).map_err(|e| e.to_string())?;
+ for (offset, compressed) in chunks {
+ let decompressed = zstd::stream::decode_all(compressed).map_err(|e| e.to_string())?;
+ write_at(&file, offset, &decompressed)?;
}
-
- Ok(config_bytes)
}
+
+ let mut index = read_index()?;
+ index_set(
+ &mut index,
+ reference_str,
+ &manifest_digest,
+ manifest_bytes.len() as u64,
+ );
+ write_index(&index)?;
+
+ Ok(manifest_digest)
}
-#[cfg(test)]
-mod tests {
- use super::*;
- use std::sync::atomic::{AtomicU64, Ordering};
-
- const TEST_CONFIG: &[u8] = br#"{
- "schemaVersion": 1,
- "kind": "MachineImage",
- "system": {
- "os": "linux",
- "name": "test",
- "version": "1",
- "architecture": "amd64"
- },
- "machine": {
- "cpu": { "minimum": 1, "default": 1 },
- "ram": { "minimum": 268435456, "default": 268435456 },
- "boot": [{ "protocol": "firmware-disk/bios", "disk": "root" }],
- "access": [{
- "type": "ssh",
- "port": 22,
- "user": "root",
- "auth": "empty-password"
- }],
- "network": { "mode": "dhcp" }
- },
- "disks": [{
- "id": "root",
- "format": "qcow2",
- "path": "root.hmi",
- "digest": "sha256:372409142c91c51316a7ab2b055596e145de56d99aa0f5eb110068876cef0be4",
- "virtSize": 14,
- "diskSize": 14
- }]
- }"#;
-
- fn temporary_directory() -> PathBuf {
- static NEXT_ID: AtomicU64 = AtomicU64::new(0);
- std::env::temp_dir().join(format!(
- "hule-oci-test-{}-{}",
- std::process::id(),
- NEXT_ID.fetch_add(1, Ordering::Relaxed)
- ))
- }
+/// Returns whether a reference is present in the local OCI layout.
+pub fn contains(reference_str: &str) -> R<bool> {
+ ensure_store()?;
+ Ok(index_lookup(&read_index()?, reference_str).is_some())
+}
- #[test]
- fn manager_uses_separate_oci_and_hmi_roots() {
- tokio::runtime::Builder::new_current_thread()
- .build()
- .unwrap()
- .block_on(async {
- let root = temporary_directory();
- let source = root.join("source");
- let oci_root = root.join("oci");
- let hmi_root = root.join("hmi");
- let destination = root.join("destination");
- fs::create_dir_all(&source).await.unwrap();
- fs::write(source.join("config.json"), TEST_CONFIG)
- .await
- .unwrap();
- fs::write(source.join("root.hmi"), b"test hmi image")
- .await
- .unwrap();
-
- let storage = Storage::open(&oci_root, &hmi_root).await.unwrap();
- let images = ImageManager::new(storage);
- let reference = "example.test/hule:tokio";
- let digest = images.load(&source, Some(reference)).await.unwrap();
-
- assert!(images.contains(reference).await.unwrap());
- assert!(fs::try_exists(oci_root.join("index.json")).await.unwrap());
- assert!(
- fs::try_exists(
- hmi_root
- .join(digest.strip_prefix("sha256:").unwrap_or(&digest))
- .join("root.hmi")
- )
- .await
- .unwrap()
- );
-
- let config = images.materialize(reference, &destination).await.unwrap();
- assert!(!config.is_empty());
- assert_eq!(
- fs::read(destination.join("root.hmi")).await.unwrap(),
- b"test hmi image"
- );
-
- assert!(matches!(images.contains("missing").await, Ok(false)));
- assert!(matches!(
- images.materialize("missing", &destination).await,
- Err(Error::ImageNotFound(reference)) if reference == "missing"
- ));
-
- fs::remove_dir_all(root).await.unwrap();
- });
+/// Materializes a locally tagged image into `destination` and returns config.json.
+pub fn materialize(reference_str: &str, destination: &Path) -> R<Vec<u8>> {
+ ensure_store()?;
+ let manifest_digest = index_lookup(&read_index()?, reference_str)
+ .ok_or_else(|| format!("no local image tagged '{reference_str}'"))?;
+
+ let manifest_bytes = read_blob(&manifest_digest)?;
+ let manifest: OciImageManifest =
+ serde_json::from_slice(&manifest_bytes).map_err(|e| e.to_string())?;
+ let config_bytes = read_blob(&manifest.config.digest)?;
+
+ std::fs::create_dir_all(destination).map_err(|e| e.to_string())?;
+ std::fs::write(destination.join("config.json"), &config_bytes).map_err(|e| e.to_string())?;
+
+ let materialized = materialized_dir(&manifest_digest)?;
+ let mut titles: BTreeSet<String> = BTreeSet::new();
+ for descriptor in &manifest.layers {
+ if let Some(title) = descriptor
+ .annotations
+ .as_ref()
+ .and_then(|a| a.get(ORG_OPENCONTAINERS_IMAGE_TITLE))
+ {
+ titles.insert(title.clone());
+ }
}
+ for title in titles {
+ let dest = destination.join(&title);
+ if !dest.exists() {
+ hardlink_or_copy(&materialized.join(&title), &dest)?;
+ }
+ }
+
+ Ok(config_bytes)
}
diff --git a/crates/hule-oci/src/storage.rs b/crates/hule-oci/src/storage.rs
deleted file mode 100644
--- a/crates/hule-oci/src/storage.rs
+++ /dev/null
@@ -1,213 +0,0 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
-// SPDX-License-Identifier: Apache-2.0
-
-use crate::{Error, Result};
-use oci_client::manifest::OciImageIndex;
-use std::io::SeekFrom;
-use std::path::{Component, Path, PathBuf};
-use tokio::fs::{self, File};
-use tokio::io::{AsyncSeekExt, AsyncWriteExt};
-use tokio::task;
-
-/// Filesystem storage for OCI content and materialized HMI images.
-///
-/// The roots are independent so callers can place content-addressed OCI data
-/// and large materialized disks on different filesystems.
-#[derive(Clone, Debug)]
-pub struct Storage {
- oci_root: PathBuf,
- hmi_root: PathBuf,
-}
-
-impl Storage {
- /// Opens the storage and creates its filesystem layout when necessary.
- pub async fn open(oci_root: impl Into<PathBuf>, hmi_root: impl Into<PathBuf>) -> Result<Self> {
- let storage = Self {
- oci_root: oci_root.into(),
- hmi_root: hmi_root.into(),
- };
-
- fs::create_dir_all(&storage.hmi_root).await?;
- fs::create_dir_all(storage.blobs_dir()).await?;
-
- let layout = storage.oci_root.join("oci-layout");
- if !fs::try_exists(&layout).await? {
- fs::write(&layout, br#"{"imageLayoutVersion":"1.0.0"}"#).await?;
- }
-
- Ok(storage)
- }
-
- pub fn oci_root(&self) -> &Path {
- &self.oci_root
- }
-
- pub fn hmi_root(&self) -> &Path {
- &self.hmi_root
- }
-
- fn blobs_dir(&self) -> PathBuf {
- self.oci_root.join("blobs").join("sha256")
- }
-
- fn index_path(&self) -> PathBuf {
- self.oci_root.join("index.json")
- }
-
- fn hmi_image_dir(&self, manifest_digest: &str) -> Result<PathBuf> {
- let digest = safe_component(strip_sha256(manifest_digest), "manifest digest")?;
- Ok(self.hmi_root.join(digest))
- }
-
- fn hmi_file_path(&self, manifest_digest: &str, title: &str) -> Result<PathBuf> {
- let title = safe_component(title, "image file name")?;
- Ok(self.hmi_image_dir(manifest_digest)?.join(title))
- }
-
- fn blob_path(&self, digest: &str) -> Result<PathBuf> {
- let digest = safe_component(strip_sha256(digest), "blob digest")?;
- Ok(self.blobs_dir().join(digest))
- }
-
- pub(crate) async fn read_blob(&self, digest: &str) -> Result<Vec<u8>> {
- Ok(fs::read(self.blob_path(digest)?).await?)
- }
-
- /// Writes raw bytes as a content-addressed blob, no-op if already present.
- pub(crate) async fn write_blob<T>(&self, data: T) -> Result<(String, T)>
- where
- T: AsRef<[u8]> + Send + Sync + 'static,
- {
- let (digest, data) =
- task::spawn_blocking(move || (sha256_hex(data.as_ref()), data)).await?;
- let path = self.blob_path(&digest)?;
- if !fs::try_exists(&path).await? {
- let tmp = path.with_extension("tmp");
- fs::write(&tmp, data.as_ref()).await?;
- fs::rename(&tmp, &path).await?;
- }
- Ok((digest, data))
- }
-
- pub(crate) async fn read_index(&self) -> Result<OciImageIndex> {
- let path = self.index_path();
- if !fs::try_exists(&path).await? {
- return Ok(OciImageIndex {
- schema_version: 2,
- media_type: None,
- manifests: vec![],
- artifact_type: None,
- annotations: None,
- });
- }
- let data = fs::read(&path).await?;
- Ok(serde_json::from_slice(&data)?)
- }
-
- pub(crate) async fn write_index(&self, index: &OciImageIndex) -> Result<()> {
- let data = serde_json::to_vec_pretty(index)?;
- fs::write(self.index_path(), data).await?;
- Ok(())
- }
-
- pub(crate) async fn ensure_hmi_image(&self, manifest_digest: &str) -> Result<()> {
- fs::create_dir_all(self.hmi_image_dir(manifest_digest)?).await?;
- Ok(())
- }
-
- pub(crate) async fn cache_hmi_file(
- &self,
- manifest_digest: &str,
- title: &str,
- source: &Path,
- ) -> Result<()> {
- let destination = self.hmi_file_path(manifest_digest, title)?;
- if !fs::try_exists(&destination).await? {
- Self::hardlink_or_copy(source, &destination).await?;
- }
- Ok(())
- }
-
- pub(crate) async fn write_hmi_file(
- &self,
- manifest_digest: &str,
- title: &str,
- mut chunks: Vec<(u64, Vec<u8>)>,
- ) -> Result<()> {
- chunks.sort_by_key(|(offset, _)| *offset);
- let mut file = File::create(self.hmi_file_path(manifest_digest, title)?).await?;
- for (offset, data) in chunks {
- file.seek(SeekFrom::Start(offset)).await?;
- file.write_all(&data).await?;
- }
- file.flush().await?;
- Ok(())
- }
-
- pub(crate) async fn export_hmi_file(
- &self,
- manifest_digest: &str,
- title: &str,
- destination: &Path,
- ) -> Result<()> {
- let source = self.hmi_file_path(manifest_digest, title)?;
- if !fs::try_exists(destination).await? {
- Self::hardlink_or_copy(&source, destination).await?;
- }
- Ok(())
- }
-
- async fn hardlink_or_copy(source: &Path, destination: &Path) -> Result<()> {
- if fs::hard_link(source, destination).await.is_err() {
- fs::copy(source, destination).await?;
- }
- Ok(())
- }
-}
-
-fn safe_component<'a>(value: &'a str, kind: &'static str) -> Result<&'a str> {
- let mut components = Path::new(value).components();
- match (components.next(), components.next()) {
- (Some(Component::Normal(_)), None) => Ok(value),
- _ => Err(Error::InvalidStoragePath {
- kind,
- value: value.to_string(),
- }),
- }
-}
-
-fn strip_sha256(digest: &str) -> &str {
- digest.strip_prefix("sha256:").unwrap_or(digest)
-}
-
-fn sha256_hex(data: &[u8]) -> String {
- use sha2::{Digest, Sha256};
- let mut hasher = Sha256::new();
- hasher.update(data);
- format!("sha256:{:x}", hasher.finalize())
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn paths_cannot_escape_storage_roots() {
- let storage = Storage {
- oci_root: "oci".into(),
- hmi_root: "hmi".into(),
- };
- assert!(matches!(
- storage.blob_path("sha256:../../outside"),
- Err(Error::InvalidStoragePath { .. })
- ));
- assert!(matches!(
- storage.hmi_image_dir("sha256:../outside"),
- Err(Error::InvalidStoragePath { .. })
- ));
- assert!(matches!(
- storage.hmi_file_path("sha256:digest", "../outside"),
- Err(Error::InvalidStoragePath { .. })
- ));
- }
-}
diff --git a/crates/hule-vmm/Cargo.toml b/crates/hule-vmm/Cargo.toml
index 50170c9..acfc1bf 100644
--- a/crates/hule-vmm/Cargo.toml
+++ b/crates/hule-vmm/Cargo.toml
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: Apache-2.0
[package]
@@ -13,13 +13,12 @@ authors.workspace = true
repository.workspace = true
[dependencies]
-hule-hmi.workspace = true
+hule-image.workspace = true
uuid = { version = "1", features = ["v7"] }
tokio = { workspace = true, features = ["process", "fs", "io-util", "sync", "net", "time"] }
async-trait = "0.1"
serde.workspace = true
serde_json.workspace = true
-base64 = "0.22"
[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
diff --git a/crates/hule-vmm/src/backend/mod.rs b/crates/hule-vmm/src/backend/mod.rs
index 1109b59..e4e1984 100644
--- a/crates/hule-vmm/src/backend/mod.rs
+++ b/crates/hule-vmm/src/backend/mod.rs
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
pub mod qemu;
diff --git a/crates/hule-vmm/src/backend/qemu/cli.rs b/crates/hule-vmm/src/backend/qemu/cli.rs
index 68d7260..077c111 100644
--- a/crates/hule-vmm/src/backend/qemu/cli.rs
+++ b/crates/hule-vmm/src/backend/qemu/cli.rs
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
//! Typed wrapper over the `qemu-system-*` command line. One qemu concept
@@ -7,7 +7,7 @@
use std::path::PathBuf;
/// One of the architectures qemu ships a `qemu-system-*` binary for.
-/// Distinct from `hule_hmi::Architecture`: this is qemu's own set of
+/// Distinct from `hule_image::Architecture`: this is qemu's own set of
/// per-arch conventions (binary name, machine type, TCG cpu model), not
/// Hule's.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -114,8 +114,6 @@ pub enum Device {
VirtioBlkPci { drive: String },
VirtioRngPci,
VirtioBalloon,
- VirtioSerialPci,
- VirtSerialPort { chardev: String, name: String },
}
impl Device {
@@ -124,10 +122,6 @@ impl Device {
Self::VirtioBlkPci { drive } => format!("virtio-blk-pci,drive={drive}"),
Self::VirtioRngPci => "virtio-rng-pci".into(),
Self::VirtioBalloon => "virtio-balloon".into(),
- Self::VirtioSerialPci => "virtio-serial-pci".into(),
- Self::VirtSerialPort { chardev, name } => {
- format!("virtserialport,chardev={chardev},name={name}")
- }
}
}
}
@@ -158,10 +152,6 @@ pub struct Command {
/// Windows at all (`tokio::net::UnixStream` is unix-only), and this way
/// there's nothing to `#[cfg]` on the transport.
pub qmp_port: Option<u16>,
- /// Host side of the qemu-guest-agent virtio-serial channel.
- pub qga_port: Option<u16>,
- /// Interactive guest serial console and its persistent output log.
- pub console: Option<(u16, PathBuf)>,
}
impl Command {
@@ -208,31 +198,6 @@ impl Command {
format!("tcp:127.0.0.1:{port},server=on,wait=off"),
]);
}
- if let Some(port) = self.qga_port {
- argv.extend([
- "-chardev".into(),
- format!("socket,id=qga0,host=127.0.0.1,port={port},server=on,wait=off"),
- "-device".into(),
- Device::VirtioSerialPci.to_arg(),
- "-device".into(),
- Device::VirtSerialPort {
- chardev: "qga0".into(),
- name: "org.qemu.guest_agent.0".into(),
- }
- .to_arg(),
- ]);
- }
- if let Some((port, logfile)) = &self.console {
- argv.extend([
- "-chardev".into(),
- format!(
- "socket,id=console0,host=127.0.0.1,port={port},server=on,wait=off,logfile={},logappend=off",
- logfile.display()
- ),
- "-serial".into(),
- "chardev:console0".into(),
- ]);
- }
argv
}
}
@@ -343,46 +308,4 @@ mod tests {
.any(|w| w == ["-device", "virtio-blk-pci,drive=root"])
);
}
-
- #[test]
- fn qga_uses_a_dedicated_virtio_serial_channel() {
- let argv = Command {
- binary: "qemu-system-x86_64".into(),
- qga_port: Some(1234),
- ..Default::default()
- }
- .to_argv();
- assert!(argv.windows(2).any(|w| {
- w == [
- "-chardev",
- "socket,id=qga0,host=127.0.0.1,port=1234,server=on,wait=off",
- ]
- }));
- assert!(argv.windows(2).any(|w| {
- w == [
- "-device",
- "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0",
- ]
- }));
- }
-
- #[test]
- fn serial_console_has_an_attach_socket_and_log() {
- let argv = Command {
- binary: "qemu-system-x86_64".into(),
- console: Some((4321, "console.log".into())),
- ..Default::default()
- }
- .to_argv();
- assert!(argv.windows(2).any(|w| {
- w == [
- "-chardev",
- "socket,id=console0,host=127.0.0.1,port=4321,server=on,wait=off,logfile=console.log,logappend=off",
- ]
- }));
- assert!(
- argv.windows(2)
- .any(|w| w == ["-serial", "chardev:console0"])
- );
- }
}
diff --git a/crates/hule-vmm/src/backend/qemu/mod.rs b/crates/hule-vmm/src/backend/qemu/mod.rs
index be470e0..75f51c3 100644
--- a/crates/hule-vmm/src/backend/qemu/mod.rs
+++ b/crates/hule-vmm/src/backend/qemu/mod.rs
@@ -1,19 +1,16 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
-//! QMP is an unconditional implementation detail of this backend. Guest
-//! access is independent: an image may be a black box, or may promise QGA;
-//! a promised QGA channel must become ready for `start()` to succeed.
-//!
-//! `logs`/`attach` use a dedicated serial console; `exec` uses QGA.
-//! Console resizing and `reattach` are not implemented yet.
+//! QMP is an unconditional implementation detail of this backend and backs
+//! lifecycle operations that cannot be expressed through process signals.
+//! Guest access and console channels are separate concerns and are not wired
+//! up here yet.
//!
//! `cli` is the typed qemu CLI wrapper; `supervise` gets an exit code out of
//! a process even if we stop being its parent; this module only translates
//! Hule's image/machine types into both.
mod cli;
-mod qga;
mod qmp;
mod supervise;
@@ -22,7 +19,7 @@ use std::process::{ExitStatus, Output};
use std::time::Duration;
use async_trait::async_trait;
-use hule_hmi::{Access, Architecture, Boot, BootLinux, Disk, MachineImage};
+use hule_image::{Architecture, Boot, BootLinux, Disk, MachineImage};
use tokio::process::Child;
use tokio::sync::Mutex;
@@ -56,9 +53,7 @@ pub struct QemuMachine {
settings: Settings,
disk: Disk,
boot: QemuBoot,
- qga: bool,
child: Mutex<ChildState>,
- qga_lock: Mutex<()>,
qmp_client: Mutex<Option<qmp::Qmp>>,
}
@@ -81,35 +76,11 @@ impl QemuMachine {
self.dir.join("qemu.qmp-port")
}
- fn qga_port_path(&self) -> PathBuf {
- self.dir.join("qemu.qga-port")
- }
-
- fn console_port_path(&self) -> PathBuf {
- self.dir.join("qemu.console-port")
- }
-
- fn console_log_path(&self) -> PathBuf {
- self.dir.join("console.log")
- }
-
- async fn read_port(&self, path: &Path, name: &str) -> R<u16> {
- let data = tokio::fs::read_to_string(path).await?;
+ async fn qmp_port(&self) -> R<u16> {
+ let data = tokio::fs::read_to_string(self.qmp_port_path()).await?;
data.trim()
.parse()
- .map_err(|_| Error::InvalidState(format!("invalid {name} port contents")))
- }
-
- async fn qmp_port(&self) -> R<u16> {
- self.read_port(&self.qmp_port_path(), "qmp").await
- }
-
- async fn qga_port(&self) -> R<u16> {
- self.read_port(&self.qga_port_path(), "qga").await
- }
-
- async fn console_port(&self) -> R<u16> {
- self.read_port(&self.console_port_path(), "console").await
+ .map_err(|_| Error::InvalidState("invalid qemu.qmp-port contents".into()))
}
/// Connects on first use (there's a short window after spawn before
@@ -223,20 +194,11 @@ impl Machine for QemuMachine {
}
async fn stats(&self) -> R<Stats> {
- let pid = self.qemu_pid().await?;
- let (cpu_time_ns, memory_bytes) = supervise::process_stats(pid).await?;
- Ok(Stats {
- cpu_time_ns,
- memory_bytes,
- })
+ todo!("needs /proc or QMP query-blockstats wiring")
}
async fn logs(&self) -> R<Vec<u8>> {
- match tokio::fs::read(self.console_log_path()).await {
- Ok(logs) => Ok(logs),
- Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(Vec::new()),
- Err(error) => Err(error.into()),
- }
+ todo!("needs a captured serial console, not wired up yet")
}
async fn start(&mut self) -> R<()> {
@@ -247,28 +209,10 @@ impl Machine for QemuMachine {
let _ = tokio::fs::remove_file(self.pid_path()).await;
let _ = tokio::fs::remove_file(self.exit_code_path()).await;
let _ = tokio::fs::remove_file(self.qmp_port_path()).await;
- let _ = tokio::fs::remove_file(self.qga_port_path()).await;
- let _ = tokio::fs::remove_file(self.console_port_path()).await;
- let _ = tokio::fs::remove_file(self.console_log_path()).await;
*self.qmp_client.lock().await = None;
let qmp_port = qmp::free_port().await?;
tokio::fs::write(self.qmp_port_path(), qmp_port.to_string()).await?;
- let qga_port = if self.qga {
- let mut port = qmp::free_port().await?;
- while port == qmp_port {
- port = qmp::free_port().await?;
- }
- tokio::fs::write(self.qga_port_path(), port.to_string()).await?;
- Some(port)
- } else {
- None
- };
- let mut console_port = qmp::free_port().await?;
- while console_port == qmp_port || Some(console_port) == qga_port {
- console_port = qmp::free_port().await?;
- }
- tokio::fs::write(self.console_port_path(), console_port.to_string()).await?;
let kvm = Architecture::host() == Some(self.arch) && cli::kvm_available().await;
let sys_arch = match self.arch {
@@ -330,20 +274,10 @@ impl Machine for QemuMachine {
}
cmd.pidfile = Some(self.pid_path());
cmd.qmp_port = Some(qmp_port);
- cmd.qga_port = qga_port;
- cmd.console = Some((console_port, self.console_log_path()));
let argv = cmd.to_argv();
let wrapper = supervise::spawn(&argv, &self.exit_code_path())?;
*child = ChildState::Running(wrapper);
- drop(child);
-
- if let Some(port) = qga_port
- && let Err(error) = qga::wait_until_ready(port, Duration::from_secs(60)).await
- {
- let _ = self.kill().await;
- return Err(error);
- }
Ok(())
}
@@ -387,9 +321,6 @@ impl Machine for QemuMachine {
let _ = tokio::fs::remove_file(self.pid_path()).await;
let _ = tokio::fs::remove_file(self.exit_code_path()).await;
let _ = tokio::fs::remove_file(self.qmp_port_path()).await;
- let _ = tokio::fs::remove_file(self.qga_port_path()).await;
- let _ = tokio::fs::remove_file(self.console_port_path()).await;
- let _ = tokio::fs::remove_file(self.console_log_path()).await;
Ok(())
}
@@ -460,27 +391,16 @@ impl Machine for QemuMachine {
}
}
- async fn exec(&self, cmd: &[String]) -> R<Output> {
- if !self.qga {
- return Err(Error::Unsupported(
- "this image does not declare qga access".into(),
- ));
- }
- let _guard = self.qga_lock.lock().await;
- qga::exec(self.qga_port().await?, cmd).await
+ async fn exec(&self, _cmd: &[String]) -> R<Output> {
+ todo!("needs the access channel (ssh today) wired up here")
}
async fn attach(&self) -> R<Box<dyn Console>> {
- let port = self.console_port().await?;
- for _ in 0..50 {
- match tokio::net::TcpStream::connect(("127.0.0.1", port)).await {
- Ok(stream) => return Ok(Box::new(stream)),
- Err(_) => tokio::time::sleep(Duration::from_millis(20)).await,
- }
- }
- Err(Error::InvalidState(
- "qemu serial console did not become available".into(),
- ))
+ todo!("needs a serial console channel, not wired up yet")
+ }
+
+ async fn resize(&self, _cols: u16, _rows: u16) -> R<()> {
+ todo!("depends on attach")
}
}
@@ -540,13 +460,7 @@ impl Hypervisor for QemuHypervisor {
settings: settings.clone(),
disk,
boot: qemu_boot,
- qga: image
- .machine
- .access
- .iter()
- .any(|access| matches!(access, Access::Qga { .. })),
child: Mutex::new(ChildState::NotStarted),
- qga_lock: Mutex::new(()),
qmp_client: Mutex::new(None),
}))
}
diff --git a/crates/hule-vmm/src/backend/qemu/qga.rs b/crates/hule-vmm/src/backend/qemu/qga.rs
deleted file mode 100644
--- a/crates/hule-vmm/src/backend/qemu/qga.rs
+++ /dev/null
@@ -1,233 +0,0 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
-// SPDX-License-Identifier: Apache-2.0
-
-//! Minimal qemu-guest-agent client over qemu's host-side chardev socket.
-
-use std::time::{Duration, Instant};
-
-use base64::Engine;
-use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
-use tokio::net::TcpStream;
-
-use crate::{Error, R};
-
-async fn execute(
- port: u16,
- command: &str,
- arguments: Option<serde_json::Value>,
-) -> R<serde_json::Value> {
- tokio::time::timeout(
- Duration::from_secs(5),
- execute_without_timeout(port, command, arguments),
- )
- .await
- .map_err(|_| Error::InvalidState(format!("qga {command} timed out")))?
-}
-
-async fn execute_without_timeout(
- port: u16,
- command: &str,
- arguments: Option<serde_json::Value>,
-) -> R<serde_json::Value> {
- let stream = TcpStream::connect(("127.0.0.1", port)).await?;
- let mut stream = BufReader::new(stream);
- let mut request = serde_json::json!({ "execute": command });
- if let Some(arguments) = arguments {
- request["arguments"] = arguments;
- }
- stream
- .get_mut()
- .write_all(
- format!(
- "{}\n",
- serde_json::to_string(&request)
- .map_err(|error| Error::InvalidState(error.to_string()))?
- )
- .as_bytes(),
- )
- .await?;
-
- let mut response = String::new();
- stream.read_line(&mut response).await?;
- if response.is_empty() {
- return Err(Error::InvalidState(
- "qemu-guest-agent closed its channel without replying".into(),
- ));
- }
- validate_response(command, &response)
-}
-
-fn validate_response(command: &str, response: &str) -> R<serde_json::Value> {
- let response: serde_json::Value = serde_json::from_str(response)
- .map_err(|error| Error::InvalidState(format!("invalid qga response: {error}")))?;
- if let Some(error) = response.get("error") {
- return Err(Error::InvalidState(format!(
- "qga {command} failed: {error}"
- )));
- }
- response
- .get("return")
- .cloned()
- .ok_or_else(|| Error::InvalidState(format!("qga {command} response has no return value")))
-}
-
-async fn ping(port: u16) -> R<()> {
- execute(port, "guest-ping", None).await.map(|_| ())
-}
-
-pub async fn wait_until_ready(port: u16, timeout: Duration) -> R<()> {
- let deadline = Instant::now() + timeout;
- loop {
- let attempt = tokio::time::timeout(Duration::from_secs(1), ping(port)).await;
- if matches!(attempt, Ok(Ok(()))) {
- return Ok(());
- }
- if Instant::now() >= deadline {
- return Err(Error::InvalidState(format!(
- "declared qga access did not become ready within {} seconds",
- timeout.as_secs()
- )));
- }
- tokio::time::sleep(Duration::from_millis(100)).await;
- }
-}
-
-pub async fn exec(port: u16, command: &[String]) -> R<std::process::Output> {
- let (path, args) = command
- .split_first()
- .ok_or_else(|| Error::InvalidState("exec command must not be empty".into()))?;
- let started = execute(
- port,
- "guest-exec",
- Some(serde_json::json!({
- "path": path,
- "arg": args,
- "capture-output": true
- })),
- )
- .await?;
- let pid = started
- .get("pid")
- .and_then(serde_json::Value::as_u64)
- .ok_or_else(|| Error::InvalidState("qga guest-exec returned no pid".into()))?;
-
- loop {
- let status = execute(
- port,
- "guest-exec-status",
- Some(serde_json::json!({ "pid": pid })),
- )
- .await?;
- if !status
- .get("exited")
- .and_then(serde_json::Value::as_bool)
- .unwrap_or(false)
- {
- tokio::time::sleep(Duration::from_millis(20)).await;
- continue;
- }
-
- return output(&status);
- }
-}
-
-fn output(status: &serde_json::Value) -> R<std::process::Output> {
- for field in ["out-truncated", "err-truncated"] {
- if status
- .get(field)
- .and_then(serde_json::Value::as_bool)
- .unwrap_or(false)
- {
- return Err(Error::InvalidState(format!(
- "qga exec output was truncated ({field})"
- )));
- }
- }
- let decode = |field: &str| -> R<Vec<u8>> {
- let Some(encoded) = status.get(field).and_then(serde_json::Value::as_str) else {
- return Ok(Vec::new());
- };
- base64::engine::general_purpose::STANDARD
- .decode(encoded)
- .map_err(|error| Error::InvalidState(format!("invalid qga {field}: {error}")))
- };
- Ok(std::process::Output {
- status: exit_status(status)?,
- stdout: decode("out-data")?,
- stderr: decode("err-data")?,
- })
-}
-
-fn exit_status(status: &serde_json::Value) -> R<std::process::ExitStatus> {
- #[cfg(unix)]
- {
- use std::os::unix::process::ExitStatusExt;
- if let Some(code) = status.get("exitcode").and_then(serde_json::Value::as_i64) {
- let code: i32 = code
- .try_into()
- .map_err(|_| Error::InvalidState("qga returned an invalid exit code".into()))?;
- return Ok(std::process::ExitStatus::from_raw(code << 8));
- }
- if let Some(signal) = status.get("signal").and_then(serde_json::Value::as_i64) {
- let signal: i32 = signal
- .try_into()
- .map_err(|_| Error::InvalidState("qga returned an invalid signal".into()))?;
- return Ok(std::process::ExitStatus::from_raw(signal & 0x7f));
- }
- Err(Error::InvalidState(
- "qga exec status has neither exitcode nor signal".into(),
- ))
- }
- #[cfg(windows)]
- {
- use std::os::windows::process::ExitStatusExt;
- let code = status
- .get("exitcode")
- .and_then(serde_json::Value::as_i64)
- .ok_or_else(|| Error::InvalidState("qga exec status has no exitcode".into()))?;
- let code: u32 = code
- .try_into()
- .map_err(|_| Error::InvalidState("qga returned an invalid exit code".into()))?;
- Ok(std::process::ExitStatus::from_raw(code))
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn readiness_requires_a_successful_guest_ping_response() {
- validate_response("guest-ping", r#"{"return":{}}"#).unwrap();
- assert!(
- validate_response("guest-ping", r#"{"error":{"class":"CommandNotFound"}}"#).is_err()
- );
- assert!(validate_response("guest-ping", r#"{"event":"something"}"#).is_err());
- }
-
- #[test]
- fn exec_output_is_decoded_without_losing_exit_status() {
- let output = output(&serde_json::json!({
- "exited": true,
- "exitcode": 7,
- "out-data": "aGVsbG8K",
- "err-data": "b29wcwo="
- }))
- .unwrap();
- assert_eq!(output.status.code(), Some(7));
- assert_eq!(output.stdout, b"hello\n");
- assert_eq!(output.stderr, b"oops\n");
- }
-
- #[test]
- fn truncated_exec_output_is_an_error() {
- assert!(
- output(&serde_json::json!({
- "exited": true,
- "exitcode": 0,
- "out-truncated": true
- }))
- .is_err()
- );
- }
-}
diff --git a/crates/hule-vmm/src/backend/qemu/qmp.rs b/crates/hule-vmm/src/backend/qemu/qmp.rs
index f7d890b..1028289 100644
--- a/crates/hule-vmm/src/backend/qemu/qmp.rs
+++ b/crates/hule-vmm/src/backend/qemu/qmp.rs
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
//! Minimal QMP client: line-delimited JSON commands/responses over the TCP
diff --git a/crates/hule-vmm/src/backend/qemu/supervise.rs b/crates/hule-vmm/src/backend/qemu/supervise.rs
index 6eb38e8..53f890e 100644
--- a/crates/hule-vmm/src/backend/qemu/supervise.rs
+++ b/crates/hule-vmm/src/backend/qemu/supervise.rs
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
//! Runs a command so its exit code survives even once nobody is left to
@@ -54,9 +54,6 @@ pub fn spawn(argv: &[String], exit_code_file: &Path) -> io::Result<Child> {
.arg(&argv[0])
.arg(exit_code_file)
.args(&argv[1..])
- .stdin(std::process::Stdio::null())
- .stdout(std::process::Stdio::null())
- .stderr(std::process::Stdio::null())
.spawn()
}
#[cfg(windows)]
@@ -76,9 +73,6 @@ pub fn spawn(argv: &[String], exit_code_file: &Path) -> io::Result<Child> {
.arg(&argv[0])
.arg(exit_code_file)
.args(&argv[1..])
- .stdin(std::process::Stdio::null())
- .stdout(std::process::Stdio::null())
- .stderr(std::process::Stdio::null())
.spawn()
}
}
@@ -144,47 +138,3 @@ pub async fn kill(pid: Pid) -> io::Result<()> {
}
}
}
-
-/// (cpu_time_ns, memory_bytes) for `pid`, read straight from the host
-/// process -- no QMP/guest cooperation needed.
-pub async fn process_stats(pid: Pid) -> io::Result<(u64, u64)> {
- #[cfg(target_os = "linux")]
- {
- let stat = tokio::fs::read_to_string(format!("/proc/{pid}/stat")).await?;
- // `comm` (field 2) can itself contain spaces/parens; splitting after
- // the last ')' reliably skips past it regardless.
- let after_comm = stat
- .rsplit_once(')')
- .map(|(_, rest)| rest)
- .ok_or_else(|| io::Error::other("unexpected /proc/pid/stat format"))?;
- let fields: Vec<&str> = after_comm.split_whitespace().collect();
- let field = |i: usize| -> io::Result<u64> {
- fields
- .get(i)
- .and_then(|s| s.parse().ok())
- .ok_or_else(|| io::Error::other("unexpected /proc/pid/stat format"))
- };
- // Fields are 0-indexed from `state` (original field 3); utime/stime
- // are original fields 14/15. 100 (USER_HZ) is the practically
- // universal Linux clock tick rate.
- let cpu_time_ns = (field(11)? + field(12)?) * 10_000_000;
-
- let status = tokio::fs::read_to_string(format!("/proc/{pid}/status")).await?;
- let memory_bytes = status
- .lines()
- .find_map(|line| line.strip_prefix("VmRSS:"))
- .and_then(|rest| rest.split_whitespace().next())
- .and_then(|kb| kb.parse::<u64>().ok())
- .map(|kb| kb * 1024)
- .ok_or_else(|| io::Error::other("VmRSS not found in /proc/pid/status"))?;
-
- Ok((cpu_time_ns, memory_bytes))
- }
- #[cfg(not(target_os = "linux"))]
- {
- let _ = pid;
- Err(io::Error::other(
- "process stats aren't implemented for this host yet",
- ))
- }
-}
diff --git a/crates/hule-vmm/src/hypervisor.rs b/crates/hule-vmm/src/hypervisor.rs
index 9944660..149cd2a 100644
--- a/crates/hule-vmm/src/hypervisor.rs
+++ b/crates/hule-vmm/src/hypervisor.rs
@@ -1,11 +1,11 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
use std::fmt;
use std::path::Path;
use async_trait::async_trait;
-use hule_hmi::{Boot, MachineImage};
+use hule_image::{Boot, MachineImage};
use crate::{Machine, MachineId, R, Settings};
diff --git a/crates/hule-vmm/src/lib.rs b/crates/hule-vmm/src/lib.rs
index 681faa1..924193f 100644
--- a/crates/hule-vmm/src/lib.rs
+++ b/crates/hule-vmm/src/lib.rs
@@ -1,11 +1,11 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
//! Machine lifecycle: hypervisor plugins, machine handles, and the monitor
//! that tracks a fleet of them.
//!
//! No OCI, registry, or storage concerns -- callers hand in an
-//! already-resolved [`hule_hmi::MachineImage`] plus a directory of its
+//! already-resolved [`hule_image::MachineImage`] plus a directory of its
//! files.
//!
//! `Machine`/`Monitor` mirror Docker's container API term-for-term.
diff --git a/crates/hule-vmm/src/machine.rs b/crates/hule-vmm/src/machine.rs
index f1df0e5..914bd4d 100644
--- a/crates/hule-vmm/src/machine.rs
+++ b/crates/hule-vmm/src/machine.rs
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
use std::fmt;
@@ -38,10 +38,10 @@ pub trait Console: AsyncRead + AsyncWrite + Send + Unpin {}
impl<T: AsyncRead + AsyncWrite + Send + Unpin> Console for T {}
/// Deployment-time config of one instance -- distinct from
-/// [`hule_hmi::MachineImage`], which only declares a cpu/ram *range* and
+/// [`hule_image::MachineImage`], which only declares a cpu/ram *range* and
/// knows nothing about e.g. host ports. Always concrete: callers resolve
/// image defaults before constructing this.
-#[derive(Debug, Clone, PartialEq)]
+#[derive(Debug, Clone)]
pub struct Settings {
pub cpu: u32,
pub ram: u64, // megabytes
@@ -90,7 +90,9 @@ pub trait Machine: Send + Sync {
async fn update(&mut self, settings: Settings) -> R<()>;
async fn rename(&mut self, name: Option<&str>) -> R<()>;
- async fn exec(&self, cmd: &[String]) -> R<Output>;
async fn wait(&mut self) -> R<ExitStatus>;
+ async fn exec(&self, cmd: &[String]) -> R<Output>;
+
async fn attach(&self) -> R<Box<dyn Console>>;
+ async fn resize(&self, cols: u16, rows: u16) -> R<()>;
}
diff --git a/crates/hule-vmm/src/monitor.rs b/crates/hule-vmm/src/monitor.rs
index 825b07e..8e9c829 100644
--- a/crates/hule-vmm/src/monitor.rs
+++ b/crates/hule-vmm/src/monitor.rs
@@ -1,9 +1,9 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
use std::path::{Path, PathBuf};
-use hule_hmi::MachineImage;
+use hule_image::MachineImage;
use tokio::sync::mpsc::Receiver;
use uuid::Uuid;
diff --git a/crates/hule-vmm/tests/qemu_lifecycle.rs b/crates/hule-vmm/tests/qemu_lifecycle.rs
new file mode 100644
--- /dev/null
+++ b/crates/hule-vmm/tests/qemu_lifecycle.rs
@@ -0,0 +1,118 @@
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-License-Identifier: Apache-2.0
+
+//! Boots a real qemu VM against the repo's alpine fixture and drives it
+//! through QMP-backed lifecycle methods. Needs qemu-system-x86_64 and
+//! `images/alpine/3.24/amd64` on disk; `#[ignore]`d so a normal `cargo
+//! test` run doesn't depend on either.
+
+use std::path::Path;
+use std::time::Duration;
+
+use hule_image::MachineImage;
+use hule_vmm::backend::qemu::QemuHypervisor;
+use hule_vmm::{Hypervisor, MachineId, Settings, State};
+use uuid::Uuid;
+
+#[tokio::test]
+#[ignore = "needs qemu-system-x86_64 and the alpine fixture on disk"]
+async fn pause_unpause_restart_and_kill_track_a_real_qemu() {
+ let fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../images/alpine/3.24/amd64");
+ let config = std::fs::read(fixture.join("config.json")).expect("read fixture config.json");
+ let image = MachineImage::from_json(&config).expect("valid fixture config.json");
+
+ let scratch = std::env::temp_dir().join(format!("hule-vmm-test-{}", std::process::id()));
+ std::fs::create_dir_all(&scratch).unwrap();
+ for disk in &image.disks {
+ let src = fixture.join(&disk.path);
+ let dest = scratch.join(&disk.path);
+ std::fs::hard_link(&src, &dest)
+ .or_else(|_| std::fs::copy(&src, &dest).map(|_| ()))
+ .expect("stage disk into scratch dir");
+ }
+
+ let hv = QemuHypervisor;
+ let boot = image
+ .machine
+ .boot
+ .iter()
+ .find(|b| hv.supports(b))
+ .expect("fixture declares a boot protocol qemu supports");
+ let settings = Settings {
+ cpu: 1,
+ ram: 512,
+ port_forwards: vec![],
+ };
+
+ let mut machine = hv
+ .create(
+ MachineId(Uuid::now_v7()),
+ None,
+ &image,
+ &scratch,
+ boot,
+ &settings,
+ )
+ .await
+ .expect("create");
+
+ machine.start().await.expect("start");
+
+ assert_eq!(machine.state().await, State::Running);
+
+ machine.pause().await.expect("pause");
+ assert_eq!(machine.state().await, State::Paused);
+
+ machine.unpause().await.expect("unpause");
+ assert_eq!(machine.state().await, State::Running);
+
+ machine.restart().await.expect("restart");
+ tokio::time::sleep(Duration::from_millis(500)).await;
+ assert_eq!(machine.state().await, State::Running);
+
+ let mut new_settings = machine.settings();
+ new_settings.ram = 384;
+ machine
+ .update(new_settings)
+ .await
+ .expect("update (balloon)");
+ assert_eq!(machine.settings().ram, 384);
+
+ machine.kill().await.expect("kill");
+ assert!(matches!(machine.state().await, State::Exited(_)));
+
+ let _ = std::fs::remove_dir_all(&scratch);
+}
+
+/// QMP is internal to the qemu backend, so a black-box image is valid.
+#[tokio::test]
+async fn create_accepts_an_image_without_access() {
+ let fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../images/alpine/3.24/amd64");
+ let config = std::fs::read(fixture.join("config.json")).expect("read fixture config.json");
+ let mut image = MachineImage::from_json(&config).expect("valid fixture config.json");
+ image.machine.access.clear();
+
+ let hv = QemuHypervisor;
+ let boot = image
+ .machine
+ .boot
+ .iter()
+ .find(|b| hv.supports(b))
+ .expect("fixture declares a boot protocol qemu supports");
+ let settings = Settings {
+ cpu: 1,
+ ram: 512,
+ port_forwards: vec![],
+ };
+
+ hv.create(
+ MachineId(Uuid::now_v7()),
+ None,
+ &image,
+ &fixture,
+ boot,
+ &settings,
+ )
+ .await
+ .expect("black-box images don't need to declare qemu's QMP channel");
+}
diff --git a/crates/hule/Cargo.toml b/crates/hule/Cargo.toml
index 728df1e..a783fda 100644
--- a/crates/hule/Cargo.toml
+++ b/crates/hule/Cargo.toml
@@ -1,4 +1,4 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: Apache-2.0
[package]
@@ -13,9 +13,8 @@ authors.workspace = true
repository.workspace = true
[dependencies]
-clap = { version = "4.6.1", features = ["derive"] }
-hule-hmi.workspace = true
hule-oci.workspace = true
hule-vmm.workspace = true
+hule-image.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "fs"] }
uuid = { version = "1", features = ["v7"] }
diff --git a/crates/hule/src/main.rs b/crates/hule/src/main.rs
index a1be2bb..6af3d54 100644
--- a/crates/hule/src/main.rs
+++ b/crates/hule/src/main.rs
@@ -1,89 +1,29 @@
-// SPDX-FileCopyrightText: 2026 Nikolay Govorov
+// SPDX-FileCopyrightText: 2026 Nikolay Govorov
// SPDX-License-Identifier: Apache-2.0
-use std::fmt::Display;
-use std::path::{Path, PathBuf};
+use std::path::Path;
use std::process::exit;
-use clap::{Parser, Subcommand};
-use hule_hmi::{Access, MachineImage};
+use hule_image::{Access, MachineImage};
use hule_vmm::backend::qemu::QemuHypervisor;
use hule_vmm::{Hypervisor, MachineId, Settings};
use uuid::Uuid;
type R<T> = std::result::Result<T, String>;
-#[derive(Parser)]
-#[command(version, about)]
-#[command(propagate_version = true)]
-struct Cli {
- #[command(subcommand)]
- command: Commands,
-}
-
-#[derive(Subcommand)]
-enum Commands {
- Image {
- #[command(subcommand)]
- command: ImageCommands,
- },
-
- Machine {
- #[command(subcommand)]
- command: MachineCommands,
- },
-}
-
-#[derive(Subcommand)]
-enum ImageCommands {
- Pull {
- name: String,
- },
-
- Push {
- name: String,
- },
-
- Load {
- image: String,
-
- reference: Option<String>,
- },
-}
-
-#[derive(Subcommand)]
-enum MachineCommands {
- Run {
- image: String,
-
- #[arg(default_value_t = 8022)]
- port: u16,
- },
-}
-
-fn die(msg: impl Display) -> ! {
- eprintln!("hule: {msg}");
+fn die(msg: impl AsRef<str>) -> ! {
+ eprintln!("hule: {}", msg.as_ref());
exit(1);
}
-async fn cmd_run(images: &hule_oci::ImageManager, reference: &str, port: u16) -> R<()> {
- if !images
- .contains(reference)
- .await
- .map_err(|error| error.to_string())?
- {
+async fn cmd_run(reference: &str, port: u16) -> R<()> {
+ if !hule_oci::contains(reference)? {
eprintln!("hule: {reference} not found locally, pulling...");
- images
- .pull(reference)
- .await
- .map_err(|error| error.to_string())?;
+ hule_oci::pull(reference).await?;
}
let scratch = std::env::temp_dir().join(format!("hule-run-{}", std::process::id()));
- let config = images
- .materialize(reference, &scratch)
- .await
- .map_err(|error| error.to_string())?;
+ let config = hule_oci::materialize(reference, &scratch)?;
let image = MachineImage::from_json(&config).map_err(|e| e.to_string())?;
let hv = QemuHypervisor;
@@ -91,7 +31,7 @@ async fn cmd_run(images: &hule_oci::ImageManager, reference: &str, port: u16) ->
.machine
.boot
.iter()
- .find(|b| matches!(b, hule_hmi::Boot::Linux(_)) && hv.supports(b))
+ .find(|b| matches!(b, hule_image::Boot::Linux(_)) && hv.supports(b))
.or_else(|| image.machine.boot.iter().find(|b| hv.supports(b)))
.ok_or("no boot protocol in manifest is supported by the qemu backend")?;
@@ -134,49 +74,60 @@ async fn cmd_run(images: &hule_oci::ImageManager, reference: &str, port: u16) ->
#[tokio::main]
async fn main() {
- let cli = Cli::parse();
-
- let home = std::env::var("HOME").unwrap_or_else(|_| die("HOME is not set"));
- let root = PathBuf::from(home).join(".hule");
-
- let storage = hule_oci::Storage::open(root.join("oci"), root.join("hmi"))
- .await
- .unwrap_or_else(|e| die(e));
-
- let images = hule_oci::ImageManager::new(storage);
+ let args: Vec<String> = std::env::args().collect();
+ let usage = |prog: &str| -> ! {
+ eprintln!("usage:");
+ eprintln!(" {prog} import <image-dir> [ref]");
+ eprintln!(" {prog} push <ref>");
+ eprintln!(" {prog} pull <ref>");
+ eprintln!(" {prog} run <ref> [port]");
+ exit(2);
+ };
- match &cli.command {
- Commands::Image { command } => match &command {
- ImageCommands::Pull { name } => {
- let digest = images.pull(name).await.unwrap_or_else(|e| die(e));
- eprintln!("hule: pulled {} ({digest})", name);
- }
+ if args.len() < 2 {
+ usage(&args[0]);
+ }
- ImageCommands::Push { name } => {
- images.push(name).await.unwrap_or_else(|e| die(e));
- eprintln!("hule: pushed {}", name);
+ match args[1].as_str() {
+ "import" => {
+ if args.len() < 3 {
+ usage(&args[0]);
}
-
- ImageCommands::Load { reference, image } => {
- let digest = images
- .load(Path::new(image), reference.as_deref())
- .await
- .unwrap_or_else(|e| die(e));
-
- match reference {
- Some(reference) => {
- eprintln!("hule: loaded {} as {reference} ({digest})", image)
- }
- None => eprintln!("hule: loaded {} ({digest}, untagged)", image),
+ let reference = args.get(3).map(String::as_str);
+ let digest = hule_oci::import(Path::new(&args[2]), reference)
+ .await
+ .unwrap_or_else(|e| die(e));
+ match reference {
+ Some(reference) => {
+ eprintln!("hule: imported {} as {reference} ({digest})", args[2])
}
+ None => eprintln!("hule: imported {} ({digest}, untagged)", args[2]),
+ }
+ }
+ "push" => {
+ if args.len() < 3 {
+ usage(&args[0]);
+ }
+ hule_oci::push(&args[2]).await.unwrap_or_else(|e| die(e));
+ eprintln!("hule: pushed {}", args[2]);
+ }
+ "pull" => {
+ if args.len() < 3 {
+ usage(&args[0]);
}
- },
- Commands::Machine { command } => match &command {
- MachineCommands::Run { image, port } => {
- cmd_run(&images, image, *port)
- .await
- .unwrap_or_else(|e| die(e));
+ let digest = hule_oci::pull(&args[2]).await.unwrap_or_else(|e| die(e));
+ eprintln!("hule: pulled {} ({digest})", args[2]);
+ }
+ "run" => {
+ if args.len() < 3 {
+ usage(&args[0]);
}
- },
+ let port = args
+ .get(3)
+ .map_or(Ok(8022), |s| s.parse::<u16>())
+ .unwrap_or_else(|_| die(format!("invalid port '{}'", args[3])));
+ cmd_run(&args[2], port).await.unwrap_or_else(|e| die(e));
+ }
+ _ => usage(&args[0]),
}
}
diff --git a/deny.toml b/deny.toml
deleted file mode 100644
--- a/deny.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
-# SPDX-License-Identifier: Apache-2.0
-
-[licenses]
-allow = [
- "Apache-2.0",
- "Apache-2.0 WITH LLVM-exception",
- "BSD-2-Clause",
- "BSD-3-Clause",
- "BSL-1.0",
- "CDLA-Permissive-2.0",
- "ISC",
- "MIT",
- "MPL-2.0",
- "Unicode-3.0",
- "Zlib",
-]
-unused-allowed-license = "allow"
diff --git a/docs/landscape.md b/docs/landscape.md
deleted file mode 100644
--- a/docs/landscape.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# Isolation landscape
-
-A cursory overview of similar or related projects that caught the author's
-attention. There is no systematic approach, so great projects might be
-overlooked.
-
-**Containers:**
-
-- <https://podman.io>
-- <https://docker.com>
-- <https://colima.run>
-- <https://containerd.io>
-- <https://linuxcontainers.org/incus>
-- <https://github.com/apple/container>
-
-**Container build tools:**
-
-- <https://buildah.io>
-- <https://github.com/lxc/distrobuilder>
-
-**Micro VM:**
-
-- <https://lima-vm.io>
-- <https://microsandbox.dev>
-- <https://firecracker-microvm.io>
-- <https://github.com/libkrun/krunvm>
-
-**macOS VM:**
-
-- <https://tart.run>
-- <https://veertu.com>
-
-**VM image formats:**
-
-- <https://www.dmtf.org/standards/ovf>
-- <https://www.qemu.org/docs/master/interop/qcow2.html>
-
-**Hypervisor:**
-
-- [Xen](https://xenproject.org)
-- [QEMU](https://www.qemu.org)
-- [Linux KVM](https://docs.kernel.org/virt/kvm/index.html)
-- [Windows Hyper-V](https://learn.microsoft.com/windows-server/virtualization/hyper-v/)
-- [Apple Hypervisor.framework](https://developer.apple.com/documentation/hypervisor)
-- [Apple Virtualization.framework](https://developer.apple.com/documentation/virtualization)
diff --git a/docs/whitepaper.md b/docs/whitepaper.md
deleted file mode 100644
--- a/docs/whitepaper.md
+++ /dev/null
@@ -1,224 +0,0 @@
-# Hule Whitepaper
-
-> [!CAUTION]
-> This document describes the intended architecture and boundaries of Hule. The
-> implementation is still in progress and does not yet provide every capability
-> described here.
-
-Hule is a portable machine-image format and a set of tools for distributing,
-running, and deriving virtual machines.
-
-Containers made Linux user spaces easy to package and distribute, but they share
-the host kernel. They cannot represent a different kernel, an arbitrary
-operating system, or a machine built for another CPU architecture. Virtual
-machines can, but their images and configuration are commonly tied to one
-hypervisor or one cloud.
-
-Hule provides a common boundary between a prepared virtual machine, an OCI
-registry, and the hypervisor that runs it.
-
-## Design
-
-Hule is built on two existing technologies:
-
-- OCI solves distribution: content-addressed storage, large blobs, caching,
- deduplication, authentication, and multi-platform indexes.
-- Qcow2 backing files represent derived disks efficiently: a child image stores
- only the blocks that differ from an immutable parent.
-
-Hule connects them through a filesystem format rather than through a service
-API:
-
-```text
- OCI registry
- ↕
- hule-oci
- ↕
-external builders → machine directory → hule-vmm
- Packer, genimg, config.json ↓
- manual install, *.hmi files QEMU / native VMM
- existing VM
- ↓
- Hulefile runner
- (commands via exec)
- ↓
- derived machine directory
-```
-
-`hule-oci` and `hule-vmm` do not call each other. The materialized machine
-directory is their only contract. A directory may be created without OCI, and a
-pulled image may be inspected or copied without starting a hypervisor.
-
-## Machine Format
-
-A materialized machine is a directory containing a `config.json`, one or more
-Hule Machine Image (`.hmi`) disks, and optional boot resources such as a kernel
-or initrd.
-
-```text
-machine/
-├── config.json
-├── root.hmi
-├── kernel
-└── initrd
-```
-
-`config.json` describes the machine contract:
-
-- the guest operating system and CPU architecture;
-- minimum and default resources;
-- available boot protocols;
-- disks and other required files;
-- networking expectations;
-- ways to access the guest, such as SSH or a guest agent.
-
-It describes what the image requires and supports, not a hypervisor command
-line. Deployment-specific choices such as host port mappings, bridged networks,
-and instance names are runtime settings and are not part of the immutable image.
-
-### HMI
-
-HMI is a constrained form of qcow2 intended for portable disk chains. Its
-required invariant is semantic rather than byte-for-byte equivalence: given the
-complete backing chain, an HMI disk and its flattened raw representation have
-the same virtual size and expose the same bytes to the guest.
-
-This invariant enables two operations:
-
-1. Flatten an HMI chain into raw, then convert it if necessary for a hypervisor
- that cannot consume qcow2 natively.
-2. Convert a modified disk back to qcow2 and safely rebase it onto its original
- base, producing a small HMI that contains only the guest-visible difference.
-
-Qcow2 metadata such as physical cluster placement, compression, or internal
-allocation does not need to survive this round trip. The virtual disk contents
-do.
-
-Backing images are immutable. A running instance writes to a separate overlay;
-published images and shared cache entries are never used as writable instance
-state.
-
-## Distribution
-
-`hule-oci` maps a machine directory and all HMI files needed by its backing
-chains to OCI artifacts. Large files may be split into independently compressed
-chunks so they can be transferred and verified in parallel.
-
-It is responsible for:
-
-- loading and saving already prepared Hule machines;
-- pushing and pulling OCI artifacts;
-- maintaining a content-addressed local cache;
-- resolving complete backing chains;
-- materializing a machine directory on disk.
-
-OCI indexes can contain variants for different guest operating systems and CPU
-architectures. Native execution is an optimization, not a requirement: a user
-may intentionally select a foreign architecture and run it through emulation.
-
-`hule-oci` does not provision guests and does not know how a machine will be
-executed.
-
-## Runtime
-
-`hule-vmm` starts a materialized machine directory. Hypervisor backends
-translate the machine contract into their native configuration and expose a
-common machine lifecycle.
-
-QEMU is the tier-0 backend. It provides a widely available implementation of the
-machine model and, importantly, full-system CPU emulation. This makes scenarios
-such as a RISC-V NetBSD guest on an Arm macOS host valid even when they are not
-fast.
-
-Native backends may provide better integration and performance when the host and
-guest are compatible. They may flatten or convert HMI disks into their native
-storage format before starting the VM. This conversion is a runtime detail and
-does not change the distributed Hule image.
-
-`hule-vmm` does not know whether its input came from an OCI registry, a local
-builder, an exported VM, or a directory copied by the user.
-
-## Derivation with Hulefile
-
-A Hulefile is a recipe for deriving one Hule image from another. Unlike an
-external image builder, it does not install an operating system from scratch.
-Its input is an already loaded Hule machine that can be started and controlled
-through an `exec`-capable access method.
-
-Every Hulefile has exactly one parent image. There is no empty base and no
-equivalent of `FROM scratch`: creating the first bootable machine always happens
-outside the Hulefile workflow and enters Hule through load or import.
-
-The intended execution model is deliberately simple:
-
-1. Resolve and pin the immutable parent image.
-2. Start it with a persistent writable instance overlay.
-3. Execute the Hulefile commands sequentially inside the guest through `exec`.
-4. If every command succeeds, shut the guest down and flush its disk state.
-5. Rebase the resulting disk onto the parent and produce a new HMI and
- `config.json`.
-6. If any command fails, discard the temporary instance and produce no image.
-
-One Hulefile produces one image boundary. Individual commands do not create
-published layers or snapshots, and intermediate states are not part of the
-format. This keeps the backing chain tied to meaningful image derivations rather
-than to the number of provisioning commands.
-
-The exact Hulefile syntax is not defined yet. It is expected to be a small shell
-dialect for running arbitrary commands, with only the additional structure
-needed to identify the parent and describe changes to the resulting machine
-configuration. A Hulefile runs in the context of its parent guest and is not
-implicitly portable across operating systems.
-
-## Image Lifecycle
-
-### Prepare, Import, and Load
-
-Preparing a base guest operating system is outside Hule. Users may use Packer, a
-`genimg` script, an unattended installer, or a manually configured VM. A
-finished Hule machine with HMI disks and a `config.json` enters the local store
-through load and can be exported again through save. A qcow2 or raw disk image
-instead enters through import, which converts it to HMI and constructs the
-machine configuration where possible. The resulting Hule image can then be
-distributed or used as the parent of a Hulefile.
-
-This boundary is important for systems whose prebuilt images cannot be freely
-redistributed. A project can publish a recipe that downloads official
-installation media, builds an image on the user's machine, and pushes the result
-to the user's own OCI registry.
-
-### Publish
-
-The prepared Hule machine is loaded, validated, split into OCI blobs, and pushed
-to a registry. Tags provide convenient names; digests identify immutable
-versions.
-
-### Run
-
-The OCI artifact is pulled and materialized. `hule-vmm` selects a compatible
-backend and boot protocol, creates writable instance state, and starts the VM.
-
-### Derive
-
-A Hulefile is the standard path for reproducibly deriving an image. A modified
-instance disk may also be converted back to HMI and rebased onto the immutable
-image from which it originated. Only the resulting difference needs to be
-published; unchanged parent data is reused through the backing chain and OCI
-content store.
-
-## Scope
-
-Hule defines how a prepared machine is represented, distributed, materialized,
-run, and derived. It does not:
-
-- install a base guest operating system from installation media;
-- replace Packer, unattended installers, or other from-scratch image builders;
-- create a machine from an empty Hulefile parent;
-- serve as a general-purpose workload orchestrator inside the guest;
-- require a particular OCI registry;
-- promise native acceleration for every host and guest combination;
-- grant redistribution rights for operating systems or software contained in an
- image.
-
-The format is the product boundary. Builders produce it, registries transport
-it, and runtimes consume it independently.
diff --git a/images/alpine/genimg b/images/alpine/genimg
index f5446ce..76405a4 100755
--- a/images/alpine/genimg
+++ b/images/alpine/genimg
@@ -1,6 +1,6 @@
#!/bin/sh -eux
# SPDX-FileCopyrightText: 2017-2026 Drew DeVault
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: AGPL-3.0-only
self=$(dirname "$(readlink -f "$0")")
@@ -56,7 +56,7 @@ qemu-img create -f qcow2 -o compat=1.1 "$out"/root.hmi "${size_gib}G"
modprobe nbd max_part=16
qemu-nbd --connect=/dev/nbd0 "$out"/root.hmi
for i in $(seq 1 5); do
- sleep "0.$i"
+ sleep 0.$i
partprobe /dev/nbd0 && break
done
trap cleanup EXIT
@@ -82,13 +82,13 @@ swapon /dev/nbd0p2
# TODO: Remove bash
apk add -U \
- -X "http://dl-cdn.alpinelinux.org/alpine/$release/main/" \
- -X "http://dl-cdn.alpinelinux.org/alpine/$release/community/" \
+ -X http://dl-cdn.alpinelinux.org/alpine/$release/main/ \
+ -X http://dl-cdn.alpinelinux.org/alpine/$release/community/ \
--allow-untrusted \
--arch="$apk_arch" \
--root=/mnt \
--initdb \
- acct alpine-base alpine-conf alpine-sdk linux-firmware-none "$linux" \
+ acct alpine-base alpine-conf alpine-sdk linux-firmware-none $linux \
git mercurial openssh sudo syslinux tzdata gnupg haveged bash curl \
doas qemu-guest-agent
@@ -200,11 +200,11 @@ cat >/mnt/etc/docker/daemon.json <<EOF
EOF
pkg_version() {
- name=$(run_root apk list "$1" | grep installed | cut -d' ' -f1)
- echo "${name##"$1"-}"
+ name=$(run_root apk list $1 | grep installed | cut -d' ' -f1)
+ echo ${name##$1-}
}
-run_root apk add "$linux=$(pkg_version "$linux")"
+run_root apk add $linux=$(pkg_version $linux)
sync
diff --git a/images/debian/genimg b/images/debian/genimg
index 2dedba5..85e363a 100755
--- a/images/debian/genimg
+++ b/images/debian/genimg
@@ -1,6 +1,6 @@
#!/bin/sh -eux
# SPDX-FileCopyrightText: 2017-2026 Drew DeVault
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: AGPL-3.0-only
self=$(dirname "$(readlink -f "$0")")
@@ -21,16 +21,19 @@ case $arch in
amd64)
darch=amd64
iface=ens3
+ qarch=x86_64
kpkg=linux-image-amd64
;;
arm64)
darch=arm64
iface=enp0s1
+ qarch=aarch64
kpkg=linux-image-arm64
;;
ppc64le)
darch=ppc64el
iface=enp0s0
+ qarch=ppc64le
kpkg=linux-image-powerpc64le
;;
*)
@@ -64,7 +67,7 @@ qemu-img create -f qcow2 -o compat=1.1 "$out/root.hmi" "${size_gib}G"
modprobe nbd max_part=16
qemu-nbd --connect=/dev/nbd0 "$out/root.hmi"
for i in $(seq 1 5); do
- sleep "0.$i"
+ sleep 0.$i
partprobe /dev/nbd0 && break
done
trap cleanup EXIT
@@ -88,9 +91,9 @@ mkdir /mnt/boot
mount /dev/nbd0p1 /mnt/boot
if [ "$arch" = "amd64" ]; then
- debootstrap --include=gnupg2 --arch="$darch" "$release" /mnt
+ debootstrap --include=gnupg2 --arch=$darch $release /mnt
else
- ./qemu-debootstrap --include=gnupg2 --arch="$darch" "$release" /mnt
+ ./qemu-debootstrap --include=gnupg2 --arch=$darch $release /mnt
fi
mount --bind /dev /mnt/dev
@@ -156,14 +159,7 @@ EOF
run_root update-initramfs -u
-kernel_path=
-for candidate in /mnt/boot/vmlinuz-*; do
- [ -e "$candidate" ] || continue
- kernel_path=$candidate
- break
-done
-[ -n "$kernel_path" ]
-linuxver=${kernel_path##*/vmlinuz-}
+linuxver=$(ls /mnt/boot | grep vmlinuz | cut -d- -f2-)
# Reference partitions by PARTUUID so boot survives whatever the VMM names the
# disk. cmdline is canonical: identical for every boot protocol (extlinux append
diff --git a/images/fedora/genimg b/images/fedora/genimg
index 8215ec5..56e2a5d 100755
--- a/images/fedora/genimg
+++ b/images/fedora/genimg
@@ -1,6 +1,6 @@
#!/bin/sh -eux
# SPDX-FileCopyrightText: 2017-2026 Drew DeVault
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: AGPL-3.0-only
# Network Block Device used to interact with the QCOW2 image.
@@ -150,14 +150,7 @@ run_root dnf clean all
cat >/mnt/etc/dracut.conf.d/virtio-blk.conf <<EOF
add_drivers="virtio-blk"
EOF
-kernel_path=
-for candidate in /mnt/boot/vmlinuz-*."$fedora_arch"; do
- [ -e "$candidate" ] || continue
- kernel_path=$candidate
- break
-done
-[ -n "$kernel_path" ]
-kernel_version=${kernel_path##*/vmlinuz-}
+kernel_version=$(ls /mnt/boot | grep "vmlinuz.*.$fedora_arch" | cut -d- -f2-)
run_root dracut --force --kver "$kernel_version"
run_root grub2-install --target=i386-pc $NBD_DEVICE
diff --git a/images/freebsd/genimg b/images/freebsd/genimg
index 08a258c..4d40076 100755
--- a/images/freebsd/genimg
+++ b/images/freebsd/genimg
@@ -1,6 +1,6 @@
#!/bin/sh -eux
# SPDX-FileCopyrightText: 2017-2026 Drew DeVault
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: AGPL-3.0-only
self=$(dirname "$(readlink -f "$0")")
diff --git a/images/ubuntu/genimg b/images/ubuntu/genimg
index 1980803..28d6e08 100755
--- a/images/ubuntu/genimg
+++ b/images/ubuntu/genimg
@@ -1,6 +1,6 @@
#!/bin/sh -eux
# SPDX-FileCopyrightText: 2017-2026 Drew DeVault
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
# SPDX-License-Identifier: AGPL-3.0-only
self=$(dirname "$(readlink -f "$0")")
@@ -81,7 +81,7 @@ export DEBIAN_FRONTEND=noninteractive
debootstrap \
--include=gnupg,ubuntu-keyring \
- --arch="$arch" "$release" \
+ --arch=$arch $release \
/mnt http://archive.ubuntu.com/ubuntu/
mount --bind /dev /mnt/dev
@@ -111,9 +111,9 @@ echo 'nameserver 1.1.1.1' >>/mnt/etc/resolv.conf
net_mode=static
net_address=10.0.2.15/24
net_gateway=10.0.2.2
-cat >"/mnt/etc/systemd/network/25-$iface.network" <<EOF
+cat >/mnt/etc/systemd/network/25-ens3.network <<EOF
[Match]
-Name=$iface
+Name=ens3
[Network]
Address=$net_address
@@ -172,14 +172,7 @@ EOF
run_root update-initramfs -u
-kernel_path=
-for candidate in /mnt/boot/vmlinuz-[0-9]*; do
- [ -e "$candidate" ] || continue
- kernel_path=$candidate
- break
-done
-[ -n "$kernel_path" ]
-linuxver=${kernel_path##*/vmlinuz-}
+linuxver=$(ls /mnt/boot | grep 'vmlinuz-[0-9].*' | cut -d- -f2-)
# Reference partitions by PARTUUID so boot works regardless of how the VMM names
# the disk (vda/sda/nvme...). cmdline is canonical: identical for every boot
diff --git a/mise.lock b/mise.lock
deleted file mode 100644
--- a/mise.lock
+++ /dev/null
@@ -1,48 +0,0 @@
-# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html
-
-[[tools.rust]]
-version = "1.97.1"
-backend = "core:rust"
-
-[tools.rust.options]
-components = "clippy,llvm-tools-preview,rustfmt"
-profile = "minimal"
-
-[[tools.shellcheck]]
-version = "0.11.0"
-backend = "aqua:koalaman/shellcheck"
-
-[tools.shellcheck."platforms.linux-arm64"]
-checksum = "sha256:12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588"
-url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.aarch64.tar.xz"
-url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056934"
-
-[tools.shellcheck."platforms.linux-arm64-musl"]
-checksum = "sha256:12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588"
-url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.aarch64.tar.xz"
-url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056934"
-
-[tools.shellcheck."platforms.linux-x64"]
-checksum = "sha256:8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198"
-url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.x86_64.tar.xz"
-url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056942"
-
-[tools.shellcheck."platforms.linux-x64-musl"]
-checksum = "sha256:8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198"
-url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.x86_64.tar.xz"
-url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056942"
-
-[tools.shellcheck."platforms.macos-arm64"]
-checksum = "sha256:56affdd8de5527894dca6dc3d7e0a99a873b0f004d7aabc30ae407d3f48b0a79"
-url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.darwin.aarch64.tar.xz"
-url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056932"
-
-[tools.shellcheck."platforms.macos-x64"]
-checksum = "sha256:3c89db4edcab7cf1c27bff178882e0f6f27f7afdf54e859fa041fca10febe4c6"
-url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.darwin.x86_64.tar.xz"
-url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056930"
-
-[tools.shellcheck."platforms.windows-x64"]
-checksum = "sha256:8a4e35ab0b331c85d73567b12f2a444df187f483e5079ceffa6bda1faa2e740e"
-url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.zip"
-url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056944"
diff --git a/mise.toml b/mise.toml
deleted file mode 100644
--- a/mise.toml
+++ /dev/null
@@ -1,17 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Nikolay Govorov
-# SPDX-License-Identifier: Apache-2.0
-
-min_version = "2026.7.5"
-
-[settings]
-experimental = true
-
-[tools]
-rust = { version = "1.97.1", profile = "minimal", components = [ "clippy", "llvm-tools-preview", "rustfmt" ] }
-shellcheck = "0.11.0"
-
-[task_config]
-dir = "{{cwd}}"
-includes = [
- "git::https://git.dimidiumlabs.io/platform.git//tasks?ref=e5ca3be4349af3d1da2dde9d1165d52fb014a371",
-]