Documentation
¶
Index ¶
- func AddLocalMountIdentifier(mnt mount.Mount) mount.Mount
- func IsAgentOnlyIO(stdout string, logger *logrus.Entry) bool
- func IsLocalMount(mount *types.Mount) bool
- func StripLocalMountIdentifier(mnt *types.Mount) *types.Mount
- func UpdateUserInSpec(ctx context.Context, specData []byte, rootfsMount mount.Mount) ([]byte, error)
- type Dir
- func (d Dir) AddrFilePath() string
- func (d Dir) BundleLink(containerID string) (bundle.Dir, error)
- func (d Dir) CreateAddressLink(containerID string) error
- func (d Dir) CreateBundleLink(containerID string, bundleDir bundle.Dir) error
- func (d Dir) CreateShimLogFifoLink(containerID string) error
- func (d Dir) FirecrackerLogFifoPath() string
- func (d Dir) FirecrackerMetricsFifoPath() string
- func (d Dir) FirecrackerSockPath() string
- func (d Dir) FirecrackerSockRelPath() (string, error)
- func (d Dir) FirecrackerVSockPath() string
- func (d Dir) FirecrackerVSockRelPath() (string, error)
- func (d Dir) LogFifoPath() string
- func (d Dir) Mkdir() error
- func (d Dir) OpenLogFifo(requestCtx context.Context) (io.ReadWriteCloser, error)
- func (d Dir) RootPath() string
- func (d Dir) WriteAddress(shimSocketAddress string) error
- type IOConnector
- type IOConnectorPair
- type IOConnectorResult
- type IOProxy
- type TaskManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLocalMountIdentifier ¶
AddLocalMountIdentifier adds an identifier to a mount so that it can be detected by IsLocalMount. This is intended to be used by cooperating snapshotters to mark mounts as inside the VM so they can be plumbed at the proper points inside/outside the VM.
func IsAgentOnlyIO ¶
IsAgentOnlyIO checks whether Stdout target is agent only in order to allow log redirection entirely within the VM (currently cio.BinaryIO and cio.LogFile)
func IsLocalMount ¶
IsLocalMount returns true if the mount source is inside the VM as opposed to the default assumption that the mount source is a block device on the host.
func StripLocalMountIdentifier ¶
StripLocalMountIdentifier removes the identifier that signals that a mount is inside the VM. This is used before passing the mount information to runc
func UpdateUserInSpec ¶
func UpdateUserInSpec(ctx context.Context, specData []byte, rootfsMount mount.Mount) ([]byte, error)
UpdateUserInSpec modifies a serialized json spec object with user information from inside the container. If the client used firecrackeroci.WithVMLocalImageConfig or firecrackeroci.WithVMLocalUser, this method will do the mapping between username -> uid, group name -> gid, and lookup additional groups for the user. This is used to split where the user configures a spec via containerd's oci methods in the client from where the data is actually present (from the agent inside the VM)
Types ¶
type Dir ¶
type Dir string
Dir represents the root of a firecracker-containerd VM directory, which holds various files, sockets and FIFOs used during VM runtime.
func ShimDir ¶
ShimDir holds files, sockets and FIFOs scoped to a single shim managing the VM with the given VMID. It is unique per-VM and containerd namespace.
func (Dir) AddrFilePath ¶
AddrFilePath returns the path to the shim address file as found in the vmDir. The address file holds the abstract unix socket path at which the shim serves its API.
func (Dir) BundleLink ¶
BundleLink returns the path to the symlink to the bundle dir for a given container running inside the VM of this vm dir.
func (Dir) CreateAddressLink ¶
CreateAddressLink creates a symlink from the VM dir to the bundle dir for the shim address file. This symlink is read by containerd. CreateAddressLink assumes that CreateBundleLink has been called.
func (Dir) CreateBundleLink ¶
CreateBundleLink creates the BundleLink by symlinking to the provided bundle dir
func (Dir) CreateShimLogFifoLink ¶
CreateShimLogFifoLink creates a symlink from the bundleDir of the provided container. CreateAddressLink assumes that CreateBundleLink has been called.
func (Dir) FirecrackerLogFifoPath ¶
FirecrackerLogFifoPath returns the path to the FIFO at which the firecracker VMM writes its logs
func (Dir) FirecrackerMetricsFifoPath ¶
FirecrackerMetricsFifoPath returns the path to the FIFO at which the firecracker VMM writes metrics
func (Dir) FirecrackerSockPath ¶
FirecrackerSockPath returns the path to the unix socket at which the firecracker VMM services its API
func (Dir) FirecrackerSockRelPath ¶
FirecrackerSockRelPath returns the path to FirecrackerSockPath relative to the current working directory
func (Dir) FirecrackerVSockPath ¶
FirecrackerVSockPath returns the path to the vsock unix socket that the runtime uses to communicate with the VM agent.
func (Dir) FirecrackerVSockRelPath ¶
FirecrackerVSockRelPath returns the path to FirecrackerVSockPath relative to the current working directory
func (Dir) LogFifoPath ¶
LogFifoPath returns the path to the FIFO for writing shim logs
func (Dir) Mkdir ¶
Mkdir will mkdir the RootPath with correct permissions, or no-op if it already exists
func (Dir) OpenLogFifo ¶
OpenLogFifo opens the shim's log fifo as WriteOnly
func (Dir) WriteAddress ¶
WriteAddress will write the actual address file in the VM dir.
type IOConnector ¶
type IOConnector func(procCtx context.Context, logger *logrus.Entry) <-chan IOConnectorResult
IOConnector is function that begins initializing an IO connection (i.e. vsock, FIFO, etc.). It returns a channel that should be published to with an IOConnectorResult object once initialization is complete or an error occurs.
The return of a channel instead of plain values gives the implementation the freedom to do synchronous setup, asynchronous setup or a mix of both.
The provided context is canceled if the process fails to create/exec or when the process exits after a successful create/exec.
func ReadFIFOConnector ¶
func ReadFIFOConnector(path string) IOConnector
ReadFIFOConnector returns a FIFO which is open for reading
func VSockAcceptConnector ¶
func VSockAcceptConnector(port uint32) IOConnector
VSockAcceptConnector provides an IOConnector that establishes the connection by listening on the provided guest-side vsock port and accepting the first connection that comes in.
func VSockDialConnector ¶
func VSockDialConnector(timeout time.Duration, udsPath string, port uint32) IOConnector
VSockDialConnector returns an IOConnector for establishing vsock connections that are dialed from the host to a guest listener.
func WriteFIFOConnector ¶
func WriteFIFOConnector(path string) IOConnector
WriteFIFOConnector returns a FIFO which is open for writing
type IOConnectorPair ¶
type IOConnectorPair struct { ReadConnector IOConnector WriteConnector IOConnector }
IOConnectorPair holds the read and write side of IOConnectors whose IO should be proxied.
func InputPair ¶
func InputPair(src uint32, dest string) *IOConnectorPair
InputPair returns an IOConnectorPair from the given vsock port to the FIFO file.
func OutputPair ¶
func OutputPair(src string, dest uint32) *IOConnectorPair
OutputPair returns an IOConnectorPair from the given FIFO to the vsock port.
type IOConnectorResult ¶
type IOConnectorResult struct { io.ReadWriteCloser Err error }
IOConnectorResult represents the result of attempting to establish an IO connection. If successful, the ReadWriteCloser should be non-nil and Err should be nil. If unsuccessful, ReadWriteCloser should be nil and Err should be non-nil.
type IOProxy ¶
type IOProxy interface { // Close the proxy. Close() // IsOpen returns true if the proxy hasn't been closed. IsOpen() bool // contains filtered or unexported methods }
IOProxy is an interface to a particular implementation for initializing and copying the stdio of a process running in a VM. All its methods are unexported as they are used only internally. The interface exists just to give outside callers a choice of implementation when setting up a process.
func NewIOConnectorProxy ¶
func NewIOConnectorProxy(stdin, stdout, stderr *IOConnectorPair) IOProxy
NewIOConnectorProxy implements the IOProxy interface for a set of IOConnectorPairs, one each for stdin, stdout and stderr. If any one of those streams does not need to be proxied, the corresponding arg should be nil.
type TaskManager ¶
type TaskManager interface { // CreateTask adds a task to be managed. It creates the task using the // provided request/TaskService and sets up IO streams using the provided // IOConnectorSet. // If the TaskManager was shutdown by a previous call to ShutdownIfEmpty, an // error will be returned. CreateTask(context.Context, *taskAPI.CreateTaskRequest, taskAPI.TaskService, IOProxy) (*taskAPI.CreateTaskResponse, error) // DeleteProcess removes a task or exec being managed from the TaskManager. // It deletes the process from the provided TaskService using the provided // request. It also blocks until all IO for the task has been flushed or a // hardcoded timeout is hit. DeleteProcess(context.Context, *taskAPI.DeleteRequest, taskAPI.TaskService) (*taskAPI.DeleteResponse, error) // ExecProcess adds an exec process to be managed. It must be an exec for a // Task already managed by the TaskManager. // If the TaskManager was shutdown by a previous call to ShutdownIfEmpty, an // error will be returned. ExecProcess(context.Context, *taskAPI.ExecProcessRequest, taskAPI.TaskService, IOProxy) (*types.Empty, error) // ShutdownIfEmpty will atomically check if there are no tasks left being managed and, if so, // prevent any new tasks from being added going forward (future attempts will return an error). // If any tasks are still in the TaskManager's map, no change will be made. // It returns a bool indicating whether TaskManager shut down as a result of the call. ShutdownIfEmpty() bool // AttachIO attaches the given IO proxy to a task or exec. AttachIO(context.Context, string, string, IOProxy) error // IsProxyOpen returns true if the given task or exec has an IO proxy // which hasn't been closed. IsProxyOpen(string, string) (bool, error) }
TaskManager manages a set of tasks, ensuring that creation, deletion and io stream handling of the task happen in a synchronized manner. It's intended to contain logic common to both the host runtime shim and VM agent (which would otherwise be duped between the two).
func NewTaskManager ¶
func NewTaskManager(shimCtx context.Context, logger *logrus.Entry) TaskManager
NewTaskManager initializes a new TaskManager