Repository navigation
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_DIRorEXEC_SANDBOX_CACHE_DIRholds 1.1.0 files, replace them (forEXEC_SANDBOX_CACHE_DIR: delete them, then runsbx 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 withGUEST_PROTOCOL, andwrite_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, emptyrequired,context["writer_release"]"1.1.0"), anddescribe_instance(id)givesaccess="other_release". Keep 1.1.0 workers for these instances, or make them again. - Brokers. A broker that checks
RouteError.requireditself must handle the new ruleequal_or_any(see Breaking changes > Routing). - ARM64 hosts with KVM or HVF. The
Schedulerstart 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 withConfigErrorHOST_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 (
RouteErrorINSTANCE_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, elseInternalErrorINTERNAL, with the cause in the message (1.1.0:TransientErrorMIGRATION_FAILED,QEMU_CRASHEDorGUEST_SILENT_AFTER_RESTORE). The L1 cache removes such an entry. A kill, or an abort on a host limit, staysTransientError.
Routing
RouteKey.CPU_VENDORis removed. New keys:CPU_ID(cpu_id, ruleequal; absent on x86 and ARM64 TCG) andCOUNTER_HZ(counter_hz, new ruleRouteRule.EQUAL_OR_ANY: the same value, or the worker valueROUTE_ANY,"any", a new export). A release can now remove keys.- Facts.
HostFacts.cpu_vendoris removed. New required fields:HostFacts.cpu_id(None on x86 and ARM64 TCG) andGuestFacts.counter_hz(None when the host of the first boot had no exact rate). - ARM64 TCG
cpu_modelisneoverse-v1,pauth=off,cntfrq=62500000(1.1.0:neoverse-v1,pauth=off). The timer rate stays 62.5 MHz. WorkerFacts.satisfies({})returnsFalse(1.1.0:True): an emptyrequirednames no worker. Use the release indescribe_instance(id).writer_releaseor in the error'scontext["writer_release"].
Python API
-
exec()output limit. These cases now raiseInvalidInputErrorOUTPUT_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, andread_file()orlist_files()with a path over 4096 characters, raiseInvalidInputErrorPATH_INVALID(1.1.0: a pydanticValidationError).
Host
- x86 guest CPU check. On x86, the
Schedulerstart checks that this host runs the guest CPU, and fails withConfigErrorHOST_DEPENDENCYthat 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 raisesTransientErrorQEMU_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
Schedulerstart fails withTransientErrorLOCAL_DISK. - New QEMU binary. On x86 with KVM,
describe_worker(),reuse()andcheck_reuse()run the guest CPU check again after a change of the QEMU binary:ConfigErrorHOST_DEPENDENCYorTransientErrorQEMU_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 awrite_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 buildrebuilds the kernel, the initramfs and each qcow2. The.qcow2.hashfile holds one line. scripts/build-initramfs.shtakes no output folder: it ignores a second argument and writes toimages/dist.
Other changes
write_file()
- A file that does not fit fails at once with
GUEST_IOwhen its size is known (bytes, aPath, a stream that can seek to its end), before the guest writes any of it: 36 ms for 500 MiB intodisk_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 rawOSError).
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
InternalErrorGUEST_PROTOCOLwhen a guest sends more characters than a stream cap and one 8 KiB read (1.1.0: no host bound), or answers awrite_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
TransientErrorQEMU_CRASHEDwith the newcontext["loading"](trueonce the load started; 1.1.0: at timesMIGRATION_FAILED).GUEST_SILENT_AFTER_RESTOREhas the newcontext["exit_code"], also in its message. Both errors can come up to 1 s later. - QEMU answers. A
query-jobsanswer of qemu-storage-daemon without the job, or not a list of objects, raisesOVERLAY_FAILED(1.1.0: the job counted as done). Aquery-migrateanswer that is not an object raisesMIGRATION_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
nodevon the read-only mounts/bin,/sbin,/usr,/etc/hosts,/etc/resolv.confand/proc/sys.
Logs
- Free-threaded Python. With
configure_logging(), another handler of the same record no longer raisesRuntimeError("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 nocounter_hz. - The WARNING "Health check task timed out during shutdown, cancelling" is now "... during shutdown and was cancelled".
CLI
- An error of
--upload,--download,--envor--exposenames its option. - For a
RouteErrorwith an emptyrequired,sbxsays 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 describeshowscpu_idandcounter_hzwhen they have a value;sbx instance describeshows them (nullwhen none). Neither showscpu_vendor.
Full changelog: v1.1.0...v1.2.0