Documentation
¶
Overview ¶
Package vm builds the command lines of QEMU and virtiofsd for the aibox VM.
Index ¶
Constants ¶
const ( GuestUID uint32 = 1000 GuestGID uint32 = 1000 )
GuestUID and GuestGID are the user Claude Code runs as in the VM.
const ClipboardPort uint16 = 3132
ClipboardPort is the port on the loopback of the VM where xclip and wl-paste in the VM reach the clipboard of the host.
const GuestCID uint32 = 3
GuestCID is the vsock address of the VM. Every VM has the same one, because each has a vsock namespace of its own.
const RootCmdline = "root=/dev/vda rootfstype=ext4 ro console=hvc0 quiet"
RootCmdline boots the root disk read-only on the virtio console, whichever VMM boots the VM. The root stays read-only, as the VMM opened it: the init mounts an overlay for what it has to write.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Files ¶
type Files struct {
KVM int
Vhost int
Kernel string
Rootfs int
StateRead int
StateWrite int
Console int
}
Files are the numbers of the files QEMU was started with: the KVM and vhost-vsock devices, the root disk, the state disk opened read-only and once more read-write, the socket QEMU writes the console to, and one connection to virtiofsd per entry of Machine.Shares, in the same order. Kernel is a path, not a number, because the kernel loader of QEMU cannot take a descriptor. The state disk comes in both modes because QEMU opens a drive read-only first and asks the fdset for a read-write descriptor when the device attaches.
type Machine ¶
type Machine struct {
Kernel string
// KernelDigest is the SHA-256 the kernel must have, or empty
KernelDigest string
Rootfs string
State string
MemoryMiB int
CPUs int
Shell bool
Task bool
HyperV bool
ProxyPort uint32
TerminalPort uint32
Loopback []uint16
Owner *Owner
}
Machine is a VM that boots a kernel with a root disk and keeps its state on a second disk. Shell boots it into a shell instead of Claude Code, Task runs the task of the task share unattended. HyperV tells the guest it runs on Hyper-V, which shares the folders of the host over Plan 9 and has SCSI disks, instead of virtio-fs and virtio disks. ProxyPort and TerminalPort are the vsock ports of the proxy and the terminal session on the host, and 0 leaves the port off the kernel command line. Loopback are the ports on the loopback of the host the VM reaches through the proxy. Owner is the host user the VM user stands for in the shares, and nil leaves the ids as they are.
func (Machine) Cmdline ¶
Cmdline is the kernel command line that starts with what the VMM needs and goes on with the words of the guest.
func (Machine) GuestWords ¶
GuestWords are the words of the kernel command line that tell the guest its settings, the vsock ports of the host, the mounts of the host and the ports on the loopback of the host it may reach, whichever VMM boots it.
type Owner ¶
Owner is a user on the host. In the shares, the VM user sees this user's files as its own. Files of other host users appear as nobody.
type Share ¶
type Share struct {
}
Share is a host folder that virtiofsd serves to the VM. The guest mounts it by its tag. Guest is set for a share beyond the project and the home: the path the guest mounts it on, read-only. ReadOnly makes a share read-only that the guest knows where to mount by its tag.
func (Share) IsReadOnly ¶ added in v1.2.0
IsReadOnly tells whether the VM may only read the share.
func (Share) VirtiofsdArgs ¶
VirtiofsdArgs returns the arguments for virtiofsd that serve the share to the VM user standing for the owner.