The virtualisation server provides a single executable program which is used by the tester core to request virtualisation facilities.
The server has the following states:
Note that these are the states of the server, in the tester core to server protocol. The actual testbed will probably have more states, including for example Closed, Open (and therefore busy), Modified, Broken, etc. Ideally the virtualisation server will prevent multiple concurrent uses of the same testbed; the tester core is allowed to assume that either its caller or the virtualisation server will ensure that it has exclusive use of the testbed.
The server program speaks a protocol on its stdin/stdout. The protocol is line-based. In the future other ways of invoking the server may be defined; the current server should of course reject such invocations.
Initial response from virtualization server after starting is ok. This response is also the response from any of the commands listed below, unless otherwise specified.
Response, for example:
ok gnomovision-server revert ...
where the words after ok are features that not all servers support. Valid in all states.
Currently defined capabilities:
The revert command is supported. The base semantics are that the following aspects of the testbed are reverted:
The testbed will actually revert when it is closed. If this feature is not mentioned then changes to the testbed are persistent (so destructive tests should not be performed).
The caller is advised that username would be a good user to use for running tests (and doing other operations) when root is not required. The advertised account will exist on the testbed already. Several suggested-normal-user= capabilities (with distinct user names) may be advertised in which case more than one such user is available.
In testbeds without isolation-machine or isolation-container, the the testbed promises that this user does not run any untrusted code. So it is OK for the root user inside the testbed to complete trust this user (by, for example, running code in files owned by this user).
This is only meaningful if root-on-testbed is also advertised.
Response:
ok testbed-scratchspace
State: Closed to Open
Checks that the testbed is present and reserves it (waiting for other uses of the testbed to finish first, if necessary). testbed-scratchspace is a pathname on the testbed which can be used freely by the test scripts and which is valid until the next close, revert, or quit.
In testbeds with isolation-machine or isolation-container capability, the scratchspace directory is world-writeable. (This must be taken into account if the caller intends to impose security boundaries within the testbed; but, such a situation would be highly unusual for tests.)
In testbeds without such isolation, the directory is mode 755, and owned by the testbed user; therefore, with the root-on-testbed capability, it is not writeable by the suggested-normal-user. If desired, the caller should use chown to change the ownership, or create a suitable subdirectory.
(In autopkgtest 5.47 and earlier this directory was always mode 1777, like /tmp. This was a security vulnerability in non-isolating virt environments, and overly restrictive in isolating ones.)
Response:
ok testbed-scratchspace
State: Open, remains Open
Restores the testbed, undoing all of the changes made so far. Only available if the revert capability is advertised. If possible, the testbed's set of running processes will also be restored to the initial state.
Response:
ok testbed-scratchspace
State: Open, remains Open
Reboots the testbed, without reverting any changes to the files. Only available if the reboot capability is advertised.
Response:
ok
State: Open to Closed
Stops the testbed and undoes filesystem changes (if revert is advertised).
Response:
ok program,arg,arg... [keyword-info ...]
Prints a command that can be executed by the caller to run a command on the testbed.
The program has the following properties:
The response is only valid between open and the next subsequent close, revert or quit. Using it at other times has undefined behaviour.
To decode a print-execute-command response, and quote it for pasting into a shell (for manual testing), paste the response into this:
perl -MURI::Escape -ne '$|=1; s{^ok }{}; s/,/\0/g; print uri_unescape $_;' | jq -jrR '. / "\u0000" | @sh + "\n"'
Command:
copydown host-path testbed-path copyup testbed-path host-path
Response:
ok
Either
Both filenames are URL-encoded.
Response:
ok
The server exits with status 0, after closing the testbed if applicable.
Response: one of
ok not supported by virt server
Runs a shell in the testbed (as root, if available), while the testbed is open. This is intended for interactively debugging problems with tests. The virt server has to provide a hook_shell() function for this, otherwise this command is not supported.
On any error including signals to the server or EOF on stdin the testbed is unreserved and restored to its original state (ie, closed), and the server will print a message to stderr (unless it is dying with a signal).