Design
Scope
@skiffyard/virtualboxws drives Oracle™ VirtualBox™ 7 through its SOAP web service, vboxwebsrv, for a host that can be reached over the network but where running programs is not wanted: logon and logoff, machines, power, snapshots, clones, OVA import and export, and guest properties. call reaches any other method of the Main API.
Not in scope:
- Running
VBoxManage. That is the separate@deckyard/virtualboxdeck, which also covers remote hosts overssh. Capabilities are per deck, so the two stay apart; they share function names and shapes by convention (state names as VBoxManage™ prints them), not by code. - Guest control. Running programs in the guest and copying files are not offered here.
- VirtualBox before 7. Older majors are refused.
jennifer-tiny. It has no network driver.
Decisions
- SOAP built by hand over
httpandxml. The service is SOAP 1.1, document/literal, withSOAPAction: "". The request element isIface_methodin VirtualBox's namespace, parameters are unqualified children named as in VirtualBox's interface definition (_thisis the object), an array is repeated elements. The wire format follows the 7.0.6 and 7.1.4 sources (the WSDL generator and the web service itself). - References are released.
logonreturns a managed-object reference forIVirtualBox; every reference a function obtains is released when it is done, also on error, and lock sessions are taken per operation and unlocked afterwards.releaseRefandlogoffare exported for callers usingcall. - Long operations. A method that returns
IProgressis polled one second at a time until it completes or its deadline passes, then cancelled; a failed operation reports its own error text and result code. - One version difference. Only
IVirtualBox_createMachinediffers between 7.0 and 7.1 (7.1 adds a platform architecture);clonereads the platform from the source machine to fill it in. importAsmirrorsVBoxManage import --vmname. It reads the appliance description, enables every entry, replaces the name and sets the final values.- Deadlines around the whole exchange. Each request runs in a task bounded by
task.waitTimeout; ordinary calls getDEFAULT_TIMEOUT_MS(60 s), long operationsDEFAULT_LONG_TIMEOUT_MS(1 hour). - Topics layout.
src/virtualboxws.jincludes core, machines, snapshots and guest, each with its overlay.
Errors
- Every error of kind
"virtualboxws"is aVirtualboxwsError:reasonis"fault"(a SOAP fault),"http"(an HTTP error without a fault),"timeout"(no answer within the deadline, or a long operation not done by it),"unreachable"(no connection or no complete reply),"reply"(not the expected SOAP),"operation"(a long operation failed) or""(a check before the call);codeis the fault'sVBOX_E_*or COME_*name, a0xcode, orINVALID_OBJECTfor a reference the service no longer knows;statusis the HTTP status. errorCodereturns thecodefield. Logon refusal, existence checks and the guest-property wait read fields, never the deck's own messages.- A reply over
maxBytesis kind"limit"; a cancelled task stays"cancelled". - A service that cannot be reached (refused, reset, unreachable, DNS, TLS, a close before any reply) is the
httpmodule'snet.NetError, kind"net", passed on unchanged so itsreason,sentandrepliedstay readable. Other transport failures, such as a reply cut short, are aVirtualboxwsErrorwith reason"unreachable".
Security and limits
- Plain
httpis accepted for this machine only (127.0.0.1,localhost,[::1];DEFAULT_URLishttp://localhost:18083/). Another host needshttps(withTls) or an explicitwithPlainHttp, since the logon password would otherwise cross the network in clear. - Replies are capped at
DEFAULT_MAX_BYTES(1 MiB,withMaxBytes). - Parameters are encoded with
xml; a control character XML cannot carry is refused before sending. References must have the service's%016x-%016xshape; arguments are limited in length. - Text from the service in an error message is cut and cleaned of control and bidirectional characters.
- The service ends a session after its idle timeout (300 s by default on the server side).
Testing and validation
src/virtualboxws_test.jincludes the four topic overlays (36 tests). A loopback fake built onhttpdanswers by method and object reference from short specs (values, faults, invalid-object faults, raw HTTP replies, delays) and records every request, so tests assert both what was sent and that every reference was released.- No live VirtualBox was used; the wire format comes from the 7.0.6 and 7.1.4 sources.
Known limitations and open questions
- Check against a real
vboxwebsrvbefore 1.0. - The service is off by default and rarely deployed; most remote setups are served by
@deckyard/virtualboxoverssh. - Telling the task deadline from an
httpread timeout still relies on the runtime's message text, since only the former leaves the task running.
Dependencies on the interpreter
- Floor
jennifer >=0.28.0(the calls 0.29.0 removes are replaced by their 0.28.0 forms); the default binary (capabilitynet). The tests use the UTF-8 codec ofencoding.decodeandstrings.replicate, new in 0.27.0. - The bundled
httpandurimodules, thexmllibrary, tasks withtask.waitTimeout,task.cancelandtask.discard. - Kind
"limit"for reached caps (M28.54) and"cancelled"for a cancelled task; thrown structs classified by kind (the error-struct work of M28.51 to M28.57); transport failures asnet.NetError(M28.65).