| image-garden(1) | General Commands Manual (prm) | image-garden(1) |
image-garden —
construct and operate test virtual machines
image-garden |
make [-n]
[GOAL] |
image-garden |
[--premade] [--nice]
[--spread] SYSTEM.ARCH |
image-garden |
image-garden |
image-garden |
image-garden
|
image-garden |
image-garden
|
image-garden
|
image-garden
|
image-garden |
image-garden downloads, initializes and
optionally operates virtual machine images for popular operating systems.
All the systems are designed for
testing
and come configured with
well-known
username and password, usually matching the name of the system.
Options recognized by image-garden
make
-nWhen using download helper commands with an explicit
FILENAME, the local cached file may have a different
name than basename of URL. For
checksum-list based helpers download-with-sha256sums
and download-with-sha512sums, checksum verification
supports this mode and validates the downloaded local file against checksum
entries keyed by upstream filename.
Options recognized by image-garden
allocate
-p
PORT--premade--nicenice, so
that it does not compete for CPU with other applications. This is
implicitly set when XDG_SESSION_TYPE is either
wayland
or
x11.--spreadimage-garden allocate prints plain
"localhost:PORT" output.Options recognized by image-garden
discard
-aOptions recognized by image-garden ps
--all--staleThe image-garden make sub-command allows
building one or more
goals
corresponding to virtual machine images and their support files.
The following goals are documented. Note that ARCH and SYSTEM are placeholders for CPU architecture as named by the Linux kernel and standardized distribution name, respectively. Please see the table for a complete list of valid SYSTEM-ARCH combinations.
image-gardenimage-garden qemu-system-$ARCH . Recognized
environment variables are described in a dedicated section below.Systems are identifiers for a particular operating system,
variant, release and CPU architecture. The following list contains all the
systems recognized by image-garden.
image-garden make.
This file is designed for defining cloud-init user-data
templates with project-specific build and test dependencies.Environment variables are split into sections to indicate which of the sub-commands uses them.
XDG_CACHE_HOMEGARDEN_CACHE_DIRGARDEN_DL_DIRQEMU_ENV_QUIRKSQEMU_MEM_SIZEQEMU_MEM_OPTION.QEMU_IMG_SIZEimage-garden. The default value
is "64G". Note that images use a format with internal
representation of sparse areas. The required disk space is much smaller
than this size.QEMU_SMP_X86_64QEMU_SMP_OPTION.QEMU_SMP_AARCH64QEMU_SMP_OPTION.QEMU_SMP_RISCV64QEMU_SMP_OPTION.QEMU_SYSTEM_X86_64qemu-system-x86_64 program to use
instead of the one found on PATH.QEMU_SYSTEM_AARCH64qemu-system-aarch64 program to
use instead of the one found on PATH.QEMU_SYSTEM_RISCV64qemu-system-riscv64 program to
use instead of the one found on PATH.QEMU_CPU_RISCV64QEMU_CPU_X86_64QEMU_CPU_AARCH64QEMU_IMGqemu-img program to use instead
of the one found on PATH.XORRISOxorriso program to use instead of
the one found on PATH.WGETwget program to use instead of
the one found on PATH.XDG_RUNTIME_DIRimage-garden program, when used as a back-end for
the spread(1) test system uses this directory to keep
track of running virtual machines and their TCP port numbers.QEMU_SNAPSHOT_OPTIONGARDEN_MEMORY_RESERVEallocate
command to warn users if VM memory requirements may exceed available
resources.
When unset, the default value depends on
XDG_SESSION_TYPE: 2048MB is reserved for
graphical sessions (x11 or wayland), and 1024MB is reserved for other
session types (including headless servers).
The memory check accounts for QEMU overhead by applying a 1.5x multiplier to the VM memory requirement, then adding the reserve. A warning is issued if:
VM_memory × 1.5 + GARDEN_MEMORY_RESERVE > MemAvailable
For example, a VM requesting 2048MB with 1024MB reserve requires 2048 × 1.5 + 1024 = 4096MB of available system memory.
Example values: "512" (minimal reserve), "3072" (extra reserve for memory-intensive desktop).
Discard one or more virtual machines.
When invoked with -a, discard all
allocated virtual machines. When invoked with an
ADDRESS argument, discard the specific machine at that
address. The address format is "localhost:PORT" where PORT is the
forwarded SSH port allocated by image-garden
allocate.
Discard removes the pidfile and metadata file for the machine, then kills its process. This is useful for cleanup after testing sessions or in CI/CD environments.
List running virtual machines recorded in the per-user runtime directory. The command reads pidfiles named `port.<PORT>.pid` from `$XDG_RUNTIME_DIR/image-garden`, validates that the PIDs are numeric and correspond to running processes, and prints a human-friendly table with `ADDRESS`, `PID`, `RSS(MB)`, and `SYSTEM` columns.
The `SYSTEM` column displays the system name that was allocated. For virtual machines allocated before this feature was added, a dash (`-`) is displayed instead.
See the EXAMPLES section for sample output.
Notes: use `--all` to show stale or malformed pidfiles.
The following environment variables are used by generated .run scripts.
QEMU_MEM_OPTIONQEMU_SMP_OPTIONQEMU_DISPLAY_OPTIONQEMU_BOOT_FIRMWARE_OPTIONQEMU_RNG_OPTIONQEMU_NET_OPTION_X86_64QEMU_NET_OPTION_AARCH64QEMU_NET_OPTION_RISCV64To create a bootable image of cloud variant of Debian 13 (trixie) for x86_64 architecture run:
image-garden make debian-cloud-13.x86_64.run
To use image-garden together with
spread(1)
put the following snippet into your spread.yaml file. Note that using exec allows image-garden to automatically perform the equivalent of calling spread shell functions ADDRESS, FATAL or ERROR.
backends:
garden:
type: adhoc
allocate: exec image-garden allocate --spread "$SPREAD_SYSTEM"."$(uname -m)"
discard: exec image-garden discard "$SPREAD_SYSTEM_ADDRESS"
systems:
- debian-cloud-13:
username: debian
password: debian
To customize the virtual machine to a particular project create a
.image-garden.mk file in the root of the project and
define one or more cloud-init user-data templates which
contain list of packages to install or commands to run. Make sure to include
the default template that is essential for
image-garden operation. You can assume that the
default template ends with a section that runs one or more commands and
append your commands as a YAML list. Other cloud-init features must be used
explicitly.
A single base system can be instantiated multiple times with distinct disk images, cloud-init profiles, and hostnames using the define-instance macro in .image-garden.mk:
$(eval $(call define-instance,ubuntu-cloud-24.04,webserver)) $(eval $(call define-instance,ubuntu-cloud-24.04.x86_64,database))
The architecture suffix can be omitted;
$(GARDEN_ARCH) is used automatically. Each instance
creates a new system base@name.arch with its own
.qcow2, .run,
.meta-data, .user-data, and
.seed.iso files. The instance inherits the base
system's boot type (EFI/BIOS/platform) and the hostname follows the
base-release-name convention.
Templates are looked up in the following order (most specific first):
GROUP_RELEASE@instance_CLOUD_INIT_USER_DATA_TEMPLATE
(e.g.
UBUNTU_24.04@webserver_CLOUD_INIT_USER_DATA_TEMPLATE)GROUP@instance_CLOUD_INIT_USER_DATA_TEMPLATE (e.g.
UBUNTU@webserver_CLOUD_INIT_USER_DATA_TEMPLATE)GROUP_RELEASE_CLOUD_INIT_USER_DATA_TEMPLATE (e.g.
DEBIAN_13_CLOUD_INIT_USER_DATA_TEMPLATE)GROUP_CLOUD_INIT_USER_DATA_TEMPLATE (e.g.
UBUNTU_CLOUD_INIT_USER_DATA_TEMPLATE)CLOUD_INIT_USER_DATA_TEMPLATE# Per-release template for Debian 13 (Trixie). define DEBIAN_13_CLOUD_INIT_USER_DATA_TEMPLATE $(CLOUD_INIT_USER_DATA_TEMPLATE) packages: - build-essential - libfoo-dev endef # Per-group template for all versions of Ubuntu. define UBUNTU_CLOUD_INIT_USER_DATA_TEMPLATE $(CLOUD_INIT_USER_DATA_TEMPLATE) packages: - build-essential - libfoo-dev endef # Per-release-instance template. define UBUNTU_24.04@webserver_CLOUD_INIT_USER_DATA_TEMPLATE $(CLOUD_INIT_USER_DATA_TEMPLATE) packages: - nginx endef # Per-group-instance template (any Ubuntu release). define UBUNTU@webserver_CLOUD_INIT_USER_DATA_TEMPLATE $(CLOUD_INIT_USER_DATA_TEMPLATE) packages: - nginx endef
image-garden ps ADDRESS PID RSS(MB) SYSTEM localhost:5023 12345 640 ubuntu-cloud-24.04.x86_64
Image garden was developed in stages throughout late 2023, with first commits appearing in early 2024.
Known bugs can be listed by looking at GitLab issues.
Zygmunt Krynicki <me@zygoon.pl>
| January 19, 2026 | image-garden 0.6.3 |