Skip to main content
In this guide you will install the Ozone library, create a JSON VM configuration file, parse it with the vmparser package, and boot your first QEMU virtual machine using qemu.Start() — all from a single Go program.
1

Prerequisites

Before you begin, make sure the following tools are installed on your system:
  • Go 1.21 or laterDownload Go
  • qemu-system-x86_64 — Install via your system’s package manager, for example:
The Ozone module path is github.com/stratosphere-ve/ozone. Your own module must be initialised with go mod init before adding Ozone as a dependency.
2

Install Ozone

Add Ozone to your Go module:
This fetches both the qemu and vmparser packages and records the dependency in your go.mod and go.sum files.
3

Create a VM config file

Ozone reads VM definitions from JSON files stored in a vms/ directory relative to your working directory. Create the directory and add a config file for your first VM:
Save this file as vms/myvm.json. The file name without the .json extension is the VM name you will pass to vmparser.VMParser.
See the VM Configuration page for a full description of every field, including all supported CPU types, network modes, and disk formats.
4

Parse the VM config

Use vmparser.VMParser to load the full VM definition into a strongly-typed *vmparser.VM struct:
VMParser constructs the file path as vms/<vmname>.json and unmarshals the JSON into the VM struct, which contains nested VMInfo, CPU, Memory, Network, and Disk fields.
5

Start the VM

Call qemu.Start() to boot the virtual machine. The function prompts you for the VM name via stdin, parses its config with vmparser.VMParser, and launches qemu-system-x86_64 with the q35 machine type, four vCPUs (-smp 4), and a QMP socket on port 4444:
Run your program:
You will see the prompt:
Type your VM name (e.g. myvm) and press Enter. Ozone will parse vms/myvm.json, print the resolved VM struct, and execute the QEMU process.
qemu.Start() reads the VM name interactively from standard input using fmt.Scanln. If you need non-interactive or programmatic startup, call vmparser.VMParser directly with your VM name and construct the exec.Command yourself based on the returned config.

Next Steps

Now that your first VM is running, explore the rest of the Ozone documentation:
  • VM Configuration — Learn every field in the VM JSON schema and how the per-resource writer functions (VMParserWriterCPU, VMParserWriterMemory, etc.) let you update config files in place.
  • QEMU Management — Understand how qemu.Stop() runs system_powerdown and how Ozone exposes a QMP socket for communicating with a running VM.
  • API Reference — Full reference for all exported functions and types in the qemu and vmparser packages.