diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c48d235fd..1fe0cb36b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,10 +16,9 @@ jobs: - name: checkout uses: actions/checkout@v2 - - name: install deps + - name: install criu run: | - sudo apt-get install -y golint libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python-protobuf libnl-3-dev libnet-dev libcap-dev - sudo make install.tools + sudo apt-get install -y libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python-protobuf libnl-3-dev libnet-dev libcap-dev git clone --single-branch -b ${{ matrix.criu_branch }} https://github.com/checkpoint-restore/criu.git make -C criu sudo make -C criu install-criu PREFIX=/usr @@ -32,8 +31,7 @@ jobs: - name: Run tests run: | - sudo make lint build phaul test/test test/phaul test/piggie # Run actual test as root as it uses CRIU. sudo make test phaul-test # This builds crit-go - sudo make -C crit-go/magic-gen lint build magicgen test + sudo make -C crit-go/magic-gen build magicgen test diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 000000000..e9001fbe5 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,24 @@ +name: verify +on: [ push, pull_request ] + +jobs: + lint: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: golangci/golangci-lint-action@v2 + with: + # must be specified without patch version + version: v1.36 + # Only show new issues for a pull request. + only-new-issues: true + + gomod: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: verify go.mod/go.sum + run: | + go mod tidy + (cd crit-go/magic-gen && go mod tidy) + git diff --exit-code diff --git a/.gitignore b/.gitignore index ad240f3c7..d99bf92cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ test/test -test/piggie +test/piggie/piggie test/phaul image rpc/rpc.proto diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..fbbac4b41 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,12 @@ +run: + skip_dirs: + - rpc + - stats + +linters: + disable-all: false + presets: + - bugs + - performance + - unused + - format diff --git a/Makefile b/Makefile index 45113546a..2c303a3c9 100644 --- a/Makefile +++ b/Makefile @@ -1,55 +1,46 @@ GO ?= go CC ?= gcc -ifeq ($(GOPATH),) -export GOPATH := $(shell $(GO) env GOPATH) -endif -FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH))) -GOBIN := $(shell $(GO) env GOBIN) -ifeq ($(GOBIN),) - GOBIN := $(FIRST_GOPATH)/bin -endif -all: build test phaul phaul-test +all: build test phaul-test lint: - @golint -set_exit_status . test phaul + golangci-lint run ./... + build: - @$(GO) build -v + $(GO) build -v ./... -test/piggie: test/piggie.c - @$(CC) $^ -o $@ +TEST_BINARIES := test/test test/piggie/piggie test/phaul/phaul +test-bin: $(TEST_BINARIES) -test/test: test/main.go - @$(GO) build -v -o test/test test/main.go +test/piggie/piggie: test/piggie/piggie.c + $(CC) $^ -o $@ -test: test/test test/piggie - mkdir -p image - test/piggie - test/test dump `pidof piggie` image - test/test restore image - pkill -9 piggie || : +test/test: test/*.go + $(GO) build -v -o $@ $^ -phaul: - @cd phaul; go build -v +test: $(TEST_BINARIES) + mkdir -p image + PID=$$(test/piggie/piggie) && { \ + test/test dump $$PID image && \ + test/test restore image; \ + pkill -9 piggie; \ + } + rm -rf image -test/phaul: test/phaul-main.go - @$(GO) build -v -o test/phaul test/phaul-main.go +test/phaul/phaul: test/phaul/*.go + $(GO) build -v -o $@ $^ -phaul-test: test/phaul test/piggie +phaul-test: $(TEST_BINARIES) rm -rf image - test/piggie - test/phaul `pidof piggie` - pkill -9 piggie || : + PID=$$(test/piggie/piggie) && { \ + test/phaul/phaul $$PID; \ + pkill -9 piggie; \ + } clean: - @rm -f test/test test/piggie test/phaul + @rm -f $(TEST_BINARIES) @rm -rf image - @rm -f rpc/rpc.proto - -install.tools: - if [ ! -x "$(GOBIN)/golint" ]; then \ - $(GO) get -u golang.org/x/lint/golint; \ - fi + @rm -f rpc/rpc.proto stats/stats.proto rpc/rpc.proto: curl -sSL https://raw.githubusercontent.com/checkpoint-restore/criu/master/images/rpc.proto -o $@ @@ -63,4 +54,4 @@ rpc/rpc.pb.go: rpc/rpc.proto stats/stats.pb.go: stats/stats.proto protoc --go_out=. $^ -.PHONY: build test clean lint phaul +.PHONY: build test phaul-test test-bin clean lint diff --git a/README.md b/README.md index ac66cf931..94e0d96cc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![master](https://github.com/checkpoint-restore/go-criu/workflows/ci/badge.svg?branch=master)](https://github.com/checkpoint-restore/go-criu/actions) +[![test](https://github.com/checkpoint-restore/go-criu/workflows/ci/badge.svg?branch=master)](https://github.com/checkpoint-restore/go-criu/actions?query=workflow%3Aci) +[![verify](https://github.com/checkpoint-restore/go-criu/workflows/verify/badge.svg?branch=master)](https://github.com/checkpoint-restore/go-criu/actions?query=workflow%3Averify) ## go-criu -- Go bindings for [CRIU](https://criu.org/) diff --git a/crit-go/magic-gen/Makefile b/crit-go/magic-gen/Makefile index 87f494ed4..0de28bf47 100644 --- a/crit-go/magic-gen/Makefile +++ b/crit-go/magic-gen/Makefile @@ -1,25 +1,14 @@ GO ?= go CC ?= gcc -ifeq ($(GOPATH),) -export GOPATH := $(shell $(GO) env GOPATH) -endif -FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH))) -GOBIN := $(shell $(GO) env GOBIN) -ifeq ($(GOBIN),) - GOBIN := $(FIRST_GOPATH)/bin -endif all: build test magicgen -lint: - @golint magic-gen.go - build: @$(GO) build -v test/magicgen: build echo "#define TEST_MAGIC 0x12345678" > test_input - @rm -f test_output + @rm -f test_output ./magic-gen test_input test_output cmp samplemagic test_output if [ $$? -eq 0 ]; then \ @@ -29,8 +18,7 @@ test/magicgen: build echo FAIL; \ exit 1; \ fi - @rm -f test_input - @rm -f test_output + @rm -f test_input test_output test: test/magicgen @@ -41,13 +29,8 @@ magicgen: build magic.h ./magic-gen magic.h magic.json @rm -f magic.h -install.tools: - if [ ! -x "$(GOBIN)/golint" ]; then \ - $(GO) get -u golang.org/x/lint/golint; \ - fi - clean: @rm -f testmagic.json @rm -f test_output -.PHONY: build test clean lint magicgen +.PHONY: build test clean magicgen diff --git a/crit-go/magic-gen/go.sum b/crit-go/magic-gen/go.sum index 91fe3fada..afe976cf5 100644 --- a/crit-go/magic-gen/go.sum +++ b/crit-go/magic-gen/go.sum @@ -1,8 +1,13 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/thoas/go-funk v0.7.0 h1:GmirKrs6j6zJbhJIficOsz2aAI7700KsU/5YrdHRM1Y= github.com/thoas/go-funk v0.7.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/crit-go/magic-gen/magic-gen.go b/crit-go/magic-gen/magic-gen.go index 48b91ef9e..64816ef44 100644 --- a/crit-go/magic-gen/magic-gen.go +++ b/crit-go/magic-gen/magic-gen.go @@ -4,11 +4,12 @@ import ( "bufio" "encoding/json" "fmt" - "github.com/thoas/go-funk" "os" "reflect" "strconv" "strings" + + "github.com/thoas/go-funk" ) func main() { @@ -23,7 +24,7 @@ func main() { infile, err := os.Open(magiccheader) check(err) defer infile.Close() - outfile, err := os.OpenFile(magicjson, os.O_CREATE|os.O_WRONLY, 0644) + outfile, err := os.OpenFile(magicjson, os.O_CREATE|os.O_WRONLY, 0o644) check(err) defer outfile.Close() enc := json.NewEncoder(outfile) diff --git a/go.mod b/go.mod index b32a07bfb..58931e5f9 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/checkpoint-restore/go-criu/v4 +module github.com/checkpoint-restore/go-criu/v5 go 1.13 diff --git a/main.go b/main.go index d0a6da478..78811c309 100644 --- a/main.go +++ b/main.go @@ -8,8 +8,8 @@ import ( "strconv" "syscall" - "github.com/checkpoint-restore/go-criu/v4/rpc" - "github.com/golang/protobuf/proto" + "github.com/checkpoint-restore/go-criu/v5/rpc" + "google.golang.org/protobuf/proto" ) // Criu struct @@ -45,6 +45,7 @@ func (c *Criu) Prepare() error { defer srv.Close() args := []string{"swrk", strconv.Itoa(fds[1])} + // #nosec G204 cmd := exec.Command(c.swrkPath, args...) err = cmd.Start() @@ -64,7 +65,7 @@ func (c *Criu) Cleanup() { if c.swrkCmd != nil { c.swrkSk.Close() c.swrkSk = nil - c.swrkCmd.Wait() + _ = c.swrkCmd.Wait() c.swrkCmd = nil } } @@ -187,28 +188,28 @@ func (c *Criu) doSwrkWithResp(reqType rpc.CriuReqType, opts *rpc.CriuOpts, nfy N } // Dump dumps a process -func (c *Criu) Dump(opts rpc.CriuOpts, nfy Notify) error { - return c.doSwrk(rpc.CriuReqType_DUMP, &opts, nfy) +func (c *Criu) Dump(opts *rpc.CriuOpts, nfy Notify) error { + return c.doSwrk(rpc.CriuReqType_DUMP, opts, nfy) } // Restore restores a process -func (c *Criu) Restore(opts rpc.CriuOpts, nfy Notify) error { - return c.doSwrk(rpc.CriuReqType_RESTORE, &opts, nfy) +func (c *Criu) Restore(opts *rpc.CriuOpts, nfy Notify) error { + return c.doSwrk(rpc.CriuReqType_RESTORE, opts, nfy) } // PreDump does a pre-dump -func (c *Criu) PreDump(opts rpc.CriuOpts, nfy Notify) error { - return c.doSwrk(rpc.CriuReqType_PRE_DUMP, &opts, nfy) +func (c *Criu) PreDump(opts *rpc.CriuOpts, nfy Notify) error { + return c.doSwrk(rpc.CriuReqType_PRE_DUMP, opts, nfy) } // StartPageServer starts the page server -func (c *Criu) StartPageServer(opts rpc.CriuOpts) error { - return c.doSwrk(rpc.CriuReqType_PAGE_SERVER, &opts, nil) +func (c *Criu) StartPageServer(opts *rpc.CriuOpts) error { + return c.doSwrk(rpc.CriuReqType_PAGE_SERVER, opts, nil) } // StartPageServerChld starts the page server and returns PID and port -func (c *Criu) StartPageServerChld(opts rpc.CriuOpts) (int, int, error) { - resp, err := c.doSwrkWithResp(rpc.CriuReqType_PAGE_SERVER_CHLD, &opts, nil) +func (c *Criu) StartPageServerChld(opts *rpc.CriuOpts) (int, int, error) { + resp, err := c.doSwrkWithResp(rpc.CriuReqType_PAGE_SERVER_CHLD, opts, nil) if err != nil { return 0, 0, err } diff --git a/notify.go b/notify.go index 1c8547b43..a177f2bb5 100644 --- a/notify.go +++ b/notify.go @@ -1,6 +1,6 @@ package criu -//Notify interface +// Notify interface type Notify interface { PreDump() error PostDump() error @@ -14,8 +14,7 @@ type Notify interface { } // NoNotify struct -type NoNotify struct { -} +type NoNotify struct{} // PreDump NoNotify func (c NoNotify) PreDump() error { diff --git a/phaul/api.go b/phaul/api.go index 9519b568f..286a04dca 100644 --- a/phaul/api.go +++ b/phaul/api.go @@ -1,7 +1,7 @@ package phaul import ( - "github.com/checkpoint-restore/go-criu/v4" + "github.com/checkpoint-restore/go-criu/v5" ) // Config is the configuration which is passed around diff --git a/phaul/client.go b/phaul/client.go index 36d6f5db3..71a67cd69 100644 --- a/phaul/client.go +++ b/phaul/client.go @@ -3,15 +3,17 @@ package phaul import ( "fmt" - "github.com/checkpoint-restore/go-criu/v4" - "github.com/checkpoint-restore/go-criu/v4/rpc" - "github.com/checkpoint-restore/go-criu/v4/stats" - "github.com/golang/protobuf/proto" + "github.com/checkpoint-restore/go-criu/v5" + "github.com/checkpoint-restore/go-criu/v5/rpc" + "github.com/checkpoint-restore/go-criu/v5/stats" + "google.golang.org/protobuf/proto" ) -const minPagesWritten uint64 = 64 -const maxIters int = 8 -const maxGrowDelta int64 = 32 +const ( + minPagesWritten uint64 = 64 + maxIters int = 8 + maxGrowDelta int64 = 32 +) // Client struct type Client struct { @@ -57,7 +59,7 @@ func (pc *Client) Migrate() error { psi := rpc.CriuPageServerInfo{ Fd: proto.Int32(int32(pc.cfg.Memfd)), } - opts := rpc.CriuOpts{ + opts := &rpc.CriuOpts{ Pid: proto.Int32(int32(pc.cfg.Pid)), LogLevel: proto.Int32(4), LogFile: proto.String("pre-dump.log"), diff --git a/phaul/images.go b/phaul/images.go index 5a433cace..41925f8cf 100644 --- a/phaul/images.go +++ b/phaul/images.go @@ -11,6 +11,7 @@ type images struct { dir string } +//nolint:unparam // suppress "error is always nil" warning func preparePhaulImages(wdir string) (*images, error) { return &images{dir: wdir}, nil } @@ -21,7 +22,7 @@ func (i *images) getPath(idx int) string { func (i *images) openNextDir() (*os.File, error) { ipath := i.getPath(i.cursor) - err := os.Mkdir(ipath, 0700) + err := os.Mkdir(ipath, 0o700) if err != nil { return nil, err } diff --git a/phaul/server.go b/phaul/server.go index d24f3f2b4..b13816f35 100644 --- a/phaul/server.go +++ b/phaul/server.go @@ -4,13 +4,12 @@ import ( "errors" "fmt" "os" - "path/filepath" - "github.com/checkpoint-restore/go-criu/v4" - "github.com/checkpoint-restore/go-criu/v4/rpc" - "github.com/golang/protobuf/proto" + "github.com/checkpoint-restore/go-criu/v5" + "github.com/checkpoint-restore/go-criu/v5/rpc" "golang.org/x/sys/unix" + "google.golang.org/protobuf/proto" ) // Server struct @@ -42,7 +41,7 @@ func (s *Server) StartIter() error { psi := rpc.CriuPageServerInfo{ Fd: proto.Int32(int32(s.cfg.Memfd)), } - opts := rpc.CriuOpts{ + opts := &rpc.CriuOpts{ LogLevel: proto.Int32(4), LogFile: proto.String("ps.log"), Ps: &psi, diff --git a/phaul/stats.go b/phaul/stats.go index 2e34a9d68..d3821d314 100644 --- a/phaul/stats.go +++ b/phaul/stats.go @@ -3,8 +3,8 @@ package phaul import ( "os" - "github.com/checkpoint-restore/go-criu/v4/stats" - "github.com/golang/protobuf/proto" + "github.com/checkpoint-restore/go-criu/v5/stats" + "google.golang.org/protobuf/proto" ) /* FIXME: report stats from CriuResp */ diff --git a/test/main.go b/test/main.go index 5fcb55729..6ef8901b8 100644 --- a/test/main.go +++ b/test/main.go @@ -2,11 +2,13 @@ package main import ( "fmt" - "github.com/checkpoint-restore/go-criu/v4" - "github.com/checkpoint-restore/go-criu/v4/rpc" - "github.com/golang/protobuf/proto" + "log" "os" "strconv" + + "github.com/checkpoint-restore/go-criu/v5" + "github.com/checkpoint-restore/go-criu/v5/rpc" + "google.golang.org/protobuf/proto" ) // TestNfy struct @@ -16,20 +18,23 @@ type TestNfy struct { // PreDump test function func (c TestNfy) PreDump() error { - fmt.Printf("TEST PRE DUMP\n") + log.Println("TEST PRE DUMP") return nil } func doDump(c *criu.Criu, pidS string, imgDir string, pre bool, prevImg string) error { - fmt.Printf("Dumping\n") - pid, _ := strconv.Atoi(pidS) + log.Println("Dumping") + pid, err := strconv.ParseInt(pidS, 10, 0) + if err != nil { + return fmt.Errorf("can't parse pid: %w", err) + } img, err := os.Open(imgDir) if err != nil { - return fmt.Errorf("can't open image dir (%s)", err) + return fmt.Errorf("can't open image dir: %w", err) } defer img.Close() - opts := rpc.CriuOpts{ + opts := &rpc.CriuOpts{ Pid: proto.Int32(int32(pid)), ImagesDirFd: proto.Int32(int32(img.Fd())), LogLevel: proto.Int32(4), @@ -47,7 +52,7 @@ func doDump(c *criu.Criu, pidS string, imgDir string, pre bool, prevImg string) err = c.Dump(opts, TestNfy{}) } if err != nil { - return fmt.Errorf("dump fail (%s)", err) + return fmt.Errorf("dump fail: %w", err) } return nil @@ -62,24 +67,21 @@ func main() { fmt.Println(err) os.Exit(1) } - fmt.Println("CRIU version", version) + log.Println("CRIU version", version) // Check if version at least 3.2 result, err := c.IsCriuAtLeast(30200) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatalln(err) } if !result { - fmt.Println("CRIU too old") - os.Exit(1) + log.Fatalln("CRIU version to old") } act := os.Args[1] switch act { case "dump": err := doDump(c, os.Args[2], os.Args[3], false, "") if err != nil { - fmt.Print(err) - os.Exit(1) + log.Fatalln("dump failed:", err) } case "dump2": err := c.Prepare() @@ -90,28 +92,23 @@ func main() { err = doDump(c, os.Args[2], os.Args[3]+"/pre", true, "") if err != nil { - fmt.Printf("pre-dump failed") - fmt.Print(err) - os.Exit(1) + log.Fatalln("pre-dump failed:", err) } err = doDump(c, os.Args[2], os.Args[3], false, "./pre") if err != nil { - fmt.Printf("dump failed") - fmt.Print(err) - os.Exit(1) + log.Fatalln("dump failed: ", err) } c.Cleanup() case "restore": - fmt.Printf("Restoring\n") + log.Println("Restoring") img, err := os.Open(os.Args[2]) if err != nil { - fmt.Printf("can't open image dir") - os.Exit(1) + log.Fatalln("can't open image dir:", err) } defer img.Close() - opts := rpc.CriuOpts{ + opts := &rpc.CriuOpts{ ImagesDirFd: proto.Int32(int32(img.Fd())), LogLevel: proto.Int32(4), LogFile: proto.String("restore.log"), @@ -119,15 +116,11 @@ func main() { err = c.Restore(opts, nil) if err != nil { - fmt.Printf("Error:") - fmt.Print(err) - fmt.Printf("\n") - os.Exit(1) + log.Fatalln("restore failed:", err) } default: - fmt.Printf("unknown action\n") - os.Exit(1) + log.Fatalln("unknown action") } - fmt.Printf("Success\n") + log.Println("Success") } diff --git a/test/phaul-main.go b/test/phaul/main.go similarity index 87% rename from test/phaul-main.go rename to test/phaul/main.go index e28e290d9..58583ec96 100644 --- a/test/phaul-main.go +++ b/test/phaul/main.go @@ -7,10 +7,10 @@ import ( "strings" "syscall" - "github.com/checkpoint-restore/go-criu/v4" - "github.com/checkpoint-restore/go-criu/v4/phaul" - "github.com/checkpoint-restore/go-criu/v4/rpc" - "github.com/golang/protobuf/proto" + "github.com/checkpoint-restore/go-criu/v5" + "github.com/checkpoint-restore/go-criu/v5/phaul" + "github.com/checkpoint-restore/go-criu/v5/rpc" + "google.golang.org/protobuf/proto" ) type testLocal struct { @@ -26,25 +26,25 @@ type testRemote struct { const imagesDir = "image" func prepareImages() error { - err := os.Mkdir(imagesDir, 0700) + err := os.Mkdir(imagesDir, 0o700) if err != nil { return err } /* Work dir for PhaulClient */ - err = os.Mkdir(imagesDir+"/local", 0700) + err = os.Mkdir(imagesDir+"/local", 0o700) if err != nil { return err } /* Work dir for PhaulServer */ - err = os.Mkdir(imagesDir+"/remote", 0700) + err = os.Mkdir(imagesDir+"/remote", 0o700) if err != nil { return err } /* Work dir for DumpCopyRestore */ - err = os.Mkdir(imagesDir+"/test", 0700) + err = os.Mkdir(imagesDir+"/test", 0o700) if err != nil { return err } @@ -100,7 +100,7 @@ func (r *testRemote) doRestore() error { } defer imgDir.Close() - opts := rpc.CriuOpts{ + opts := &rpc.CriuOpts{ LogLevel: proto.Int32(4), LogFile: proto.String("restore.log"), ImagesDirFd: proto.Int32(int32(imgDir.Fd())), @@ -128,7 +128,7 @@ func (l *testLocal) DumpCopyRestore(cr *criu.Criu, cfg phaul.Config, lastClnImag Fd: proto.Int32(int32(cfg.Memfd)), } - opts := rpc.CriuOpts{ + opts := &rpc.CriuOpts{ Pid: proto.Int32(int32(cfg.Pid)), LogLevel: proto.Int32(4), LogFile: proto.String("dump.log"), @@ -161,7 +161,8 @@ func main() { srv, err := phaul.MakePhaulServer(phaul.Config{ Pid: pid, Memfd: fds[1], - Wdir: imagesDir + "/remote"}) + Wdir: imagesDir + "/remote", + }) if err != nil { fmt.Printf("Unable to run a server: %v", err) os.Exit(1) @@ -175,7 +176,8 @@ func main() { phaul.Config{ Pid: pid, Memfd: fds[0], - Wdir: imagesDir + "/local"}) + Wdir: imagesDir + "/local", + }) if err != nil { fmt.Printf("Unable to run a client: %v\n", err) os.Exit(1) diff --git a/test/piggie.c b/test/piggie/piggie.c similarity index 95% rename from test/piggie.c rename to test/piggie/piggie.c index dcc36acce..bcab21383 100644 --- a/test/piggie.c +++ b/test/piggie/piggie.c @@ -55,7 +55,7 @@ int main(int argc, char **argv) fprintf(stderr, "clone() failed: %m\n"); return 1; } - printf("Child forked, pid %d\n", pid); + printf("%d\n", pid); return 0; }