criu

package module
v6.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 8 Imported by: 6

README

test verify Go Reference

go-criu -- Go bindings for CRIU

This repository provides Go bindings for CRIU. The code is based on the Go-based PHaul implementation from the CRIU repository. For easier inclusion into other Go projects, the CRIU Go bindings have been moved to this repository.

CRIU

The Go bindings provide an easy way to use the CRIU RPC calls from Go without the need to set up all the infrastructure to make the actual RPC connection to CRIU.

The following example would print the version of CRIU:

import (
	"log"

	"github.com/checkpoint-restore/go-criu/v6"
)

func main() {
	c := criu.MakeCriu()
	version, err := c.GetCriuVersion()
	if err != nil {
		log.Fatalln(err)
	}
	log.Println(version)
}

or to just check if at least a certain CRIU version is installed:

	c := criu.MakeCriu()
	result, err := c.IsCriuAtLeast(31100)

CRIT

The crit package provides bindings to decode, encode, and manipulate CRIU image files natively within Go. It also provides a CLI tool similar to the original CRIT Python tool. To get started with this, see the docs at https://criu.org/CRIT_(Go_library).

Releases

The first go-criu release was 3.11 based on CRIU 3.11. The initial plan was to follow CRIU so that go-criu would carry the same version number as CRIU.

As go-criu is imported in other projects and as Go modules are expected to follow Semantic Versioning go-criu will also follow Semantic Versioning starting with the 4.0.0 release.

The following table shows the relation between go-criu and criu versions:

Major version Latest release CRIU version
v6             6.2.0         3.17        
v5             5.3.0         3.16        
v5             5.0.0         3.15        
v4             4.1.0         3.14        

How to contribute

While bug fixes can first be identified via an "issue", that is not required. It's ok to just open up a PR with the fix, but make sure you include the same information you would have included in an issue - like how to reproduce it.

PRs for new features should include some background on what use cases the new code is trying to address. When possible and when it makes sense, try to break-up larger PRs into smaller ones - it's easier to review smaller code changes. But only if those smaller ones make sense as stand-alone PRs.

Regardless of the type of PR, all PRs should include:

  • well documented code changes
  • additional testcases. Ideally, they should fail w/o your code change applied
  • documentation changes

Squash your commits into logical pieces of work that might want to be reviewed separate from the rest of the PRs. Ideally, each commit should implement a single idea, and the PR branch should pass the tests at every commit. GitHub makes it easy to review the cumulative effect of many commits; so, when in doubt, use smaller commits.

PRs that fix issues should include a reference like Closes #XXXX in the commit message so that github will automatically close the referenced issue when the PR is merged.

Contributors must assert that they are in compliance with the Developer Certificate of Origin 1.1. This is achieved by adding a "Signed-off-by" line containing the contributor's name and e-mail to every commit message. Your signature certifies that you wrote the patch or otherwise have the right to pass it on as an open-source patch.

Unless mentioned otherwise in a specific file's header, all code in this project is released under the Apache 2.0 license.

The author of a change remains the copyright holder of their code (no copyright assignment). The list of authors and contributors can be retrieved from the git commit history and in some cases, the file headers.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Criu

type Criu struct {
	// contains filtered or unexported fields
}

Criu struct

func MakeCriu

func MakeCriu() *Criu

MakeCriu returns the Criu object required for most operations

func (*Criu) Cleanup

func (c *Criu) Cleanup()

Cleanup cleans up

func (*Criu) Dump

func (c *Criu) Dump(opts *rpc.CriuOpts, nfy Notify) error

Dump dumps a process

func (*Criu) FeatureCheck

func (c *Criu) FeatureCheck(features *rpc.CriuFeatures) (*rpc.CriuFeatures, error)

func (*Criu) GetCriuVersion

func (c *Criu) GetCriuVersion() (int, error)

GetCriuVersion executes the VERSION RPC call and returns the version as an integer. Major * 10000 + Minor * 100 + SubLevel

func (*Criu) IsCriuAtLeast

func (c *Criu) IsCriuAtLeast(version int) (bool, error)

IsCriuAtLeast checks if the version is at least the same as the parameter version

func (*Criu) PreDump

func (c *Criu) PreDump(opts *rpc.CriuOpts, nfy Notify) error

PreDump does a pre-dump

func (*Criu) Prepare

func (c *Criu) Prepare() error

Prepare sets up everything for the RPC communication to CRIU

func (*Criu) Restore

func (c *Criu) Restore(opts *rpc.CriuOpts, nfy Notify) error

Restore restores a process

func (*Criu) SetCriuPath

func (c *Criu) SetCriuPath(path string)

SetCriuPath allows setting the path to the CRIU binary if it is in a non standard location

func (*Criu) StartPageServer

func (c *Criu) StartPageServer(opts *rpc.CriuOpts) error

StartPageServer starts the page server

func (*Criu) StartPageServerChld

func (c *Criu) StartPageServerChld(opts *rpc.CriuOpts) (int, int, error)

StartPageServerChld starts the page server and returns PID and port

type NoNotify

type NoNotify struct{}

NoNotify struct

func (NoNotify) NetworkLock

func (c NoNotify) NetworkLock() error

NetworkLock NoNotify

func (NoNotify) NetworkUnlock

func (c NoNotify) NetworkUnlock() error

NetworkUnlock NoNotify

func (NoNotify) PostDump

func (c NoNotify) PostDump() error

PostDump NoNotify

func (NoNotify) PostRestore

func (c NoNotify) PostRestore(pid int32) error

PostRestore NoNotify

func (NoNotify) PostResume

func (c NoNotify) PostResume() error

PostResume NoNotify

func (NoNotify) PostSetupNamespaces

func (c NoNotify) PostSetupNamespaces() error

PostSetupNamespaces NoNotify

func (NoNotify) PreDump

func (c NoNotify) PreDump() error

PreDump NoNotify

func (NoNotify) PreRestore

func (c NoNotify) PreRestore() error

PreRestore NoNotify

func (NoNotify) SetupNamespaces

func (c NoNotify) SetupNamespaces(pid int32) error

SetupNamespaces NoNotify

type Notify

type Notify interface {
	PreDump() error
	PostDump() error
	PreRestore() error
	PostRestore(pid int32) error
	NetworkLock() error
	NetworkUnlock() error
	SetupNamespaces(pid int32) error
	PostSetupNamespaces() error
	PostResume() error
}

Notify interface

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL