Skip to content

v1.2.0

Latest

Choose a tag to compare

@clemlesne clemlesne released this 16 Nov 17:00
· 33 commits to main since this release

Restore checks of the guest CPU and clock, write_file() space check, bounded guest output

Upgrade from 1.1.0

  • Images. Use the 1.2.0 VM images; the library downloads them. If images_dir, EXEC_SANDBOX_IMAGES_DIR or EXEC_SANDBOX_CACHE_DIR holds 1.1.0 files, replace them (for EXEC_SANDBOX_CACHE_DIR: delete them, then run sbx prefetch). If you build from source, build again. With 1.1.0 images, an exec whose output after the end of the code or after a timeout goes past the limits can fail with GUEST_PROTOCOL, and write_file() has no space check.
  • Saved instances. 1.2.0 cannot load the instances of earlier releases, and 1.1.0 cannot load those of 1.2.0. On 1.2.0, with its key, a 1.1.0 instance raises RouteError (INSTANCE_HOST_MISMATCH, empty required, context["writer_release"] "1.1.0"), and describe_instance(id) gives access="other_release". Keep 1.1.0 workers for these instances, or make them again.
  • Brokers. A broker that checks RouteError.required itself must handle the new rule equal_or_any (see Breaking changes > Routing).
  • ARM64 hosts with KVM or HVF. The Scheduler start must read the host CPU identity (Linux: /sys/devices/system/cpu/cpu*/regs/identification; in a container, mount the host's /sys), else it fails with ConfigError HOST_DEPENDENCY.
  • L1 cache. 1.2.0 does not use the 1.1.0 entries. Delete them (Clean up) or let eviction remove them when it needs the space.

Breaking changes

Saved instances

  • Format. The guest CPU models (x86, ARM64 TCG) and the stored facts changed (see Upgrade > Saved instances).
  • New load checks, before the download (RouteError INSTANCE_HOST_MISMATCH):
    • cpu_id (ARM64 with KVM or HVF): the same host CPU identity. 1.1.0 checked only the accelerator; QEMU decided at the restore. On macOS, an update across 15.2 changes the value.
    • counter_hz: the same guest clock rate, or x86 KVM with TSC scaling. No check when the host of the first boot had no exact rate.
  • State that cannot run here. When QEMU aborts while it loads the state, or exits with code 1 on a vCPU register that KVM refuses, or the guest panics just after the load, reuse() raises what a QEMU refusal raises: RouteError (qemu_version) if this QEMU is older than the saver's, else InternalError INTERNAL, with the cause in the message (1.1.0: TransientError MIGRATION_FAILED, QEMU_CRASHED or GUEST_SILENT_AFTER_RESTORE). The L1 cache removes such an entry. A kill, or an abort on a host limit, stays TransientError.

Routing

  • RouteKey. CPU_VENDOR is removed. New keys: CPU_ID (cpu_id, rule equal; absent on x86 and ARM64 TCG) and COUNTER_HZ (counter_hz, new rule RouteRule.EQUAL_OR_ANY: the same value, or the worker value ROUTE_ANY, "any", a new export). A release can now remove keys.
  • Facts. HostFacts.cpu_vendor is removed. New required fields: HostFacts.cpu_id (None on x86 and ARM64 TCG) and GuestFacts.counter_hz (None when the host of the first boot had no exact rate).
  • ARM64 TCG cpu_model is neoverse-v1,pauth=off,cntfrq=62500000 (1.1.0: neoverse-v1,pauth=off). The timer rate stays 62.5 MHz.
  • WorkerFacts.satisfies({}) returns False (1.1.0: True): an empty required names no worker. Use the release in describe_instance(id).writer_release or in the error's context["writer_release"].

Python API

  • exec() output limit. These cases now raise InvalidInputError OUTPUT_LIMIT (1.1.0: a result):

    • stdout just past 1 MB, when part of it came after the end of the code (a timing case);
    • output past the limit, then a REPL exit with a code other than 137. The message ends with "the REPL then exited with code n"; the next exec() runs in a new REPL.

    A timeout or exit code 137 still gives a result.

  • write_file() stream position. On any error or cancel, a seekable stream is back where the call found it (1.1.0: only after a failed read of the source).

  • Path errors. read_file() with an empty path, and read_file() or list_files() with a path over 4096 characters, raise InvalidInputError PATH_INVALID (1.1.0: a pydantic ValidationError).

Host

  • x86 guest CPU check. On x86, the Scheduler start checks that this host runs the guest CPU, and fails with ConfigError HOST_DEPENDENCY that names the missing features (1.1.0: each VM start failed). With KVM or HVF, the host needs x86-64-v3 (Intel Haswell, AMD Zen 1 or newer; 1.1.0: Broadwell on Intel); TCG runs on any x86 CPU. Another QEMU error of this check raises TransientError QEMU_CRASHED.
  • Host limits. When the read of the CPU identity, the clock rate or KVM TSC scaling hits a process, memory or file-handle limit, or the macOS clock rate read times out, the Scheduler start fails with TransientError LOCAL_DISK.
  • New QEMU binary. On x86 with KVM, describe_worker(), reuse() and check_reuse() run the guest CPU check again after a change of the QEMU binary: ConfigError HOST_DEPENDENCY or TransientError QEMU_CRASHED.

Guest

  • x86 guest CPU. No rdseed. GenuineIntel guests show family 6, model 60, stepping 4 (1.1.0: family 15, model 107); other vendors keep the qemu64 signature.
  • Space during write_file(). While a write_file() of a known size runs, code in the VM sees the full file size as used on the home disk (1.1.0: as the data came).

Build from source

  • The first make build rebuilds the kernel, the initramfs and each qcow2. The .qcow2.hash file holds one line.
  • scripts/build-initramfs.sh takes no output folder: it ignores a second argument and writes to images/dist.

Other changes

write_file()

  • A file that does not fit fails at once with GUEST_IO when its size is known (bytes, a Path, a stream that can seek to its end), before the guest writes any of it: 36 ms for 500 MiB into disk_mb=512 (1.1.0: 7.4 s; Apple silicon, HVF). The message gives the bytes needed and the bytes free. The guest makes no folder of the path (1.1.0: the folders stayed).
  • Reserved space. Code in the VM cannot take the reserved space during the call. The file needs its full size free, also when it replaces a file. At exactly the free space, the reservation can fail (ext4 needs one more block): GUEST_IO, and the folders stay. A stream of unknown size gets no check and no reservation.
  • First guest error. The call stops sending at the first guest error (1.1.0: it sent all the data first).
  • Bandwidth. During the call, the home disk has no bandwidth limit, also for code in the VM; the limits of I/O requests per second stay. When the call ends, the limits apply again, with full bursts. 400 MiB of random data: 1.1 s (1.1.0: 5.6 s; new VM, Apple silicon, HVF). Each call adds about 2 ms (at most 2 s).
  • Stream size. A stream with more than 500 MiB after its position still raises ARGUMENT_INVALID, now after the session lock wait. A seekable stream that cannot seek to its end (for example a procfs file) is sent with no size (1.1.0: a raw OSError).

Exec output

  • Caps. The guest applies the stdout cap (1 MB) and the stderr cap (100 KB) also to the output that it reads after the end of the code and after a timeout (1.1.0: no cap there). stderr keeps the lines of the read that crosses its cap.
  • Timeouts. An exec whose end marker came before the deadline no longer ends as a timeout. Output that the deadline cuts is no longer lost, and it ends on a whole character (1.1.0: U+FFFD). With a SIGTERM handler, a character or an end marker that the deadline split comes out whole: the exec gives its exit code, not a timeout.

Bounds on guest data

  • The host raises InternalError GUEST_PROTOCOL when a guest sends more characters than a stream cap and one 8 KiB read (1.1.0: no host bound), or answers a write_file() with anything but an error before the end of the data.
  • read_file() refuses a compressed stream with no frame end or with data after it, and more than 500 MiB, for example from a file that grows during the read (GUEST_UNAVAILABLE).

Errors

  • Other release. When this release cannot read the head of an instance, context["writer_release"] names the release that wrote it (when the head names it), and the message ends with "(exec-sandbox X wrote it)".
  • Refusal text. "refused" is now "cannot run": "QEMU X cannot run a state that QEMU Y saved", and the reason "the saved state cannot run on this worker's QEMU (...)".
  • Restore. A QEMU death in the migration step of a restore raises TransientError QEMU_CRASHED with the new context["loading"] (true once the load started; 1.1.0: at times MIGRATION_FAILED). GUEST_SILENT_AFTER_RESTORE has the new context["exit_code"], also in its message. Both errors can come up to 1 s later.
  • QEMU answers. A query-jobs answer of qemu-storage-daemon without the job, or not a list of objects, raises OVERLAY_FAILED (1.1.0: the job counted as done). A query-migrate answer that is not an object raises MIGRATION_FAILED.

Host

  • Zhaoxin hosts (vendor " Shanghai ") start VMs.
  • numpy matrix products in x86 guests on Intel hosts: 2.3 times faster under KVM, 2.9 times under TCG.
  • seccomp probe. A cancel, or a QEMU or wrapper that keeps the pipes open, no longer leaves a QEMU running or the probe waiting.
  • BLOCK_IO_ERROR. The cost of the event check no longer grows with the number of events (384.9 µs to 0.4 µs per event at 5,000 events).

Guest

  • nodev on the read-only mounts /bin, /sbin, /usr, /etc/hosts, /etc/resolv.conf and /proc/sys.

Logs

  • Free-threaded Python. With configure_logging(), another handler of the same record no longer raises RuntimeError ("dictionary changed size during iteration").
  • New WARNING "Home disk bandwidth limit not lifted" and ERROR "Home disk I/O limits not set back" (the next write_file() sets the limits back).
  • New WARNING "The clock counter rate of this host could not be read: none is used", and the same line for "CPU identity" and "KVM TSC scaling".
  • New WARNING "No exact clock counter rate: this host refuses executable memory (CNTFRQ_EL0 read)" (Linux ARM64 with KVM; for example SELinux execmem, PaX MPROTECT, systemd MemoryDenyWriteExecute=yes): the saves of this worker record no counter_hz.
  • The WARNING "Health check task timed out during shutdown, cancelling" is now "... during shutdown and was cancelled".

CLI

  • An error of --upload, --download, --env or --expose names its option.
  • For a RouteError with an empty required, sbx says to use the release that wrote the instance. The ROUTE advice names the CPU architecture, the guest CPU model, the host CPU and the guest clock rate.
  • sbx worker describe shows cpu_id and counter_hz when they have a value; sbx instance describe shows them (null when none). Neither shows cpu_vendor.

Full changelog: v1.1.0...v1.2.0