diff options
Diffstat (limited to 'vendor')
5 files changed, 11 insertions, 390 deletions
diff --git a/vendor/github.com/checkpoint-restore/go-criu/test/main.go b/vendor/github.com/checkpoint-restore/go-criu/test/main.go deleted file mode 100644 index 418ebb843..000000000 --- a/vendor/github.com/checkpoint-restore/go-criu/test/main.go +++ /dev/null @@ -1,133 +0,0 @@ -package main - -import ( - "fmt" - "github.com/checkpoint-restore/go-criu" - "github.com/checkpoint-restore/go-criu/rpc" - "github.com/golang/protobuf/proto" - "os" - "strconv" -) - -// TestNfy struct -type TestNfy struct { - criu.NoNotify -} - -// PreDump test function -func (c TestNfy) PreDump() error { - fmt.Printf("TEST PRE DUMP\n") - return nil -} - -func doDump(c *criu.Criu, pidS string, imgDir string, pre bool, prevImg string) error { - fmt.Printf("Dumping\n") - pid, _ := strconv.Atoi(pidS) - img, err := os.Open(imgDir) - if err != nil { - return fmt.Errorf("can't open image dir (%s)", err) - } - defer img.Close() - - opts := rpc.CriuOpts{ - Pid: proto.Int32(int32(pid)), - ImagesDirFd: proto.Int32(int32(img.Fd())), - LogLevel: proto.Int32(4), - LogFile: proto.String("dump.log"), - } - - if prevImg != "" { - opts.ParentImg = proto.String(prevImg) - opts.TrackMem = proto.Bool(true) - } - - if pre { - err = c.PreDump(opts, TestNfy{}) - } else { - err = c.Dump(opts, TestNfy{}) - } - if err != nil { - return fmt.Errorf("dump fail (%s)", err) - } - - return nil -} - -// Usage: test $act $pid $images_dir -func main() { - c := criu.MakeCriu() - // Read out CRIU version - version, err := c.GetCriuVersion() - if err != nil { - fmt.Println(err) - os.Exit(1) - } - fmt.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) - } - if !result { - fmt.Println("CRIU too old") - os.Exit(1) - } - 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) - } - case "dump2": - err := c.Prepare() - if err != nil { - fmt.Print(err) - os.Exit(1) - } - - 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) - } - err = doDump(c, os.Args[2], os.Args[3], false, "./pre") - if err != nil { - fmt.Printf("dump failed") - fmt.Print(err) - os.Exit(1) - } - - c.Cleanup() - case "restore": - fmt.Printf("Restoring\n") - img, err := os.Open(os.Args[2]) - if err != nil { - fmt.Printf("can't open image dir") - os.Exit(1) - } - defer img.Close() - - opts := rpc.CriuOpts{ - ImagesDirFd: proto.Int32(int32(img.Fd())), - LogLevel: proto.Int32(4), - LogFile: proto.String("restore.log"), - } - - err = c.Restore(opts, nil) - if err != nil { - fmt.Printf("Error:") - fmt.Print(err) - fmt.Printf("\n") - os.Exit(1) - } - default: - fmt.Printf("unknown action\n") - os.Exit(1) - } - - fmt.Printf("Success\n") -} diff --git a/vendor/github.com/checkpoint-restore/go-criu/test/phaul-main.go b/vendor/github.com/checkpoint-restore/go-criu/test/phaul-main.go deleted file mode 100644 index f1bec2c55..000000000 --- a/vendor/github.com/checkpoint-restore/go-criu/test/phaul-main.go +++ /dev/null @@ -1,192 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strconv" - "strings" - "syscall" - - "github.com/checkpoint-restore/go-criu" - "github.com/checkpoint-restore/go-criu/phaul" - "github.com/checkpoint-restore/go-criu/rpc" - "github.com/golang/protobuf/proto" -) - -type testLocal struct { - criu.NoNotify - r *testRemote -} - -type testRemote struct { - srv *phaul.Server -} - -/* Dir where test will put dump images */ -const imagesDir = "image" - -func prepareImages() error { - err := os.Mkdir(imagesDir, 0700) - if err != nil { - return err - } - - /* Work dir for PhaulClient */ - err = os.Mkdir(imagesDir+"/local", 0700) - if err != nil { - return err - } - - /* Work dir for PhaulServer */ - err = os.Mkdir(imagesDir+"/remote", 0700) - if err != nil { - return err - } - - /* Work dir for DumpCopyRestore */ - err = os.Mkdir(imagesDir+"/test", 0700) - if err != nil { - return err - } - - return nil -} - -func mergeImages(dumpDir, lastPreDumpDir string) error { - idir, err := os.Open(dumpDir) - if err != nil { - return err - } - - defer idir.Close() - - imgs, err := idir.Readdirnames(0) - if err != nil { - return err - } - - for _, fname := range imgs { - if !strings.HasSuffix(fname, ".img") { - continue - } - - fmt.Printf("\t%s -> %s/\n", fname, lastPreDumpDir) - err = syscall.Link(dumpDir+"/"+fname, lastPreDumpDir+"/"+fname) - if err != nil { - return err - } - } - - return nil -} - -func (r *testRemote) doRestore() error { - lastSrvImagesDir := r.srv.LastImagesDir() - /* - * In imagesDir we have images from dump, in the - * lastSrvImagesDir -- where server-side images - * (from page server, with pages and pagemaps) are. - * Need to put former into latter and restore from - * them. - */ - err := mergeImages(imagesDir+"/test", lastSrvImagesDir) - if err != nil { - return err - } - - imgDir, err := os.Open(lastSrvImagesDir) - if err != nil { - return err - } - defer imgDir.Close() - - opts := rpc.CriuOpts{ - LogLevel: proto.Int32(4), - LogFile: proto.String("restore.log"), - ImagesDirFd: proto.Int32(int32(imgDir.Fd())), - } - - cr := r.srv.GetCriu() - fmt.Printf("Do restore\n") - return cr.Restore(opts, nil) -} - -func (l *testLocal) PostDump() error { - return l.r.doRestore() -} - -func (l *testLocal) DumpCopyRestore(cr *criu.Criu, cfg phaul.Config, lastClnImagesDir string) error { - fmt.Printf("Final stage\n") - - imgDir, err := os.Open(imagesDir + "/test") - if err != nil { - return err - } - defer imgDir.Close() - - psi := rpc.CriuPageServerInfo{ - Fd: proto.Int32(int32(cfg.Memfd)), - } - - opts := rpc.CriuOpts{ - Pid: proto.Int32(int32(cfg.Pid)), - LogLevel: proto.Int32(4), - LogFile: proto.String("dump.log"), - ImagesDirFd: proto.Int32(int32(imgDir.Fd())), - TrackMem: proto.Bool(true), - ParentImg: proto.String(lastClnImagesDir), - Ps: &psi, - } - - fmt.Printf("Do dump\n") - return cr.Dump(opts, l) -} - -func main() { - pid, _ := strconv.Atoi(os.Args[1]) - fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM, 0) - if err != nil { - fmt.Printf("Can't make socketpair: %v\n", err) - os.Exit(1) - } - - err = prepareImages() - if err != nil { - fmt.Printf("Can't prepare dirs for images: %v\n", err) - os.Exit(1) - return - } - - fmt.Printf("Make server part (socket %d)\n", fds[1]) - srv, err := phaul.MakePhaulServer(phaul.Config{ - Pid: pid, - Memfd: fds[1], - Wdir: imagesDir + "/remote"}) - if err != nil { - fmt.Printf("Unable to run a server: %v", err) - os.Exit(1) - return - } - - r := &testRemote{srv} - - fmt.Printf("Make client part (socket %d)\n", fds[0]) - cln, err := phaul.MakePhaulClient(&testLocal{r: r}, srv, - phaul.Config{ - Pid: pid, - Memfd: fds[0], - Wdir: imagesDir + "/local"}) - if err != nil { - fmt.Printf("Unable to run a client: %v\n", err) - os.Exit(1) - } - - fmt.Printf("Migrate\n") - err = cln.Migrate() - if err != nil { - fmt.Printf("Failed: %v\n", err) - os.Exit(1) - } - - fmt.Printf("SUCCESS!\n") -} diff --git a/vendor/github.com/checkpoint-restore/go-criu/test/piggie.c b/vendor/github.com/checkpoint-restore/go-criu/test/piggie.c deleted file mode 100644 index 1dc0801c0..000000000 --- a/vendor/github.com/checkpoint-restore/go-criu/test/piggie.c +++ /dev/null @@ -1,57 +0,0 @@ -#define _GNU_SOURCE -#include <stdio.h> -#include <signal.h> -#include <unistd.h> -#include <sys/mman.h> -#include <fcntl.h> -#include <sched.h> - -#define STKS (4*4096) - -#ifndef CLONE_NEWPID -#define CLONE_NEWPID 0x20000000 -#endif - -static int do_test(void *logf) -{ - int fd, i = 0; - - setsid(); - - close(0); - close(1); - close(2); - - fd = open("/dev/null", O_RDONLY); - if (fd != 0) { - dup2(fd, 0); - close(fd); - } - - fd = open(logf, O_WRONLY | O_TRUNC | O_CREAT, 0600); - dup2(fd, 1); - dup2(fd, 2); - if (fd != 1 && fd != 2) - close(fd); - - while (1) { - sleep(1); - printf("%d\n", i++); - fflush(stdout); - } - - return 0; -} - -int main(int argc, char **argv) -{ - int pid; - void *stk; - - stk = mmap(NULL, STKS, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN, 0, 0); - pid = clone(do_test, stk + STKS, SIGCHLD | CLONE_NEWPID, argv[1]); - printf("Child forked, pid %d\n", pid); - - return 0; -} diff --git a/vendor/github.com/containers/storage/drivers/overlay/check.go b/vendor/github.com/containers/storage/drivers/overlay/check.go index 2a096edf6..590d517fa 100644 --- a/vendor/github.com/containers/storage/drivers/overlay/check.go +++ b/vendor/github.com/containers/storage/drivers/overlay/check.go @@ -20,7 +20,7 @@ import ( // which copies up the opaque flag when copying up an opaque // directory or the kernel enable CONFIG_OVERLAY_FS_REDIRECT_DIR. // When these exist naive diff should be used. -func doesSupportNativeDiff(d string) error { +func doesSupportNativeDiff(d, mountOpts string) error { td, err := ioutil.TempDir(d, "opaque-bug-check") if err != nil { return err @@ -57,6 +57,9 @@ func doesSupportNativeDiff(d string) error { } opts := fmt.Sprintf("lowerdir=%s:%s,upperdir=%s,workdir=%s", path.Join(td, "l2"), path.Join(td, "l1"), path.Join(td, "l3"), path.Join(td, "work")) + if mountOpts != "" { + opts = fmt.Sprintf("%s,%s", opts, mountOpts) + } if err := unix.Mount("overlay", filepath.Join(td, "merged"), "overlay", 0, opts); err != nil { return errors.Wrap(err, "failed to mount overlay") } diff --git a/vendor/github.com/containers/storage/drivers/overlay/overlay.go b/vendor/github.com/containers/storage/drivers/overlay/overlay.go index 2e0498f51..d2cc65bca 100644 --- a/vendor/github.com/containers/storage/drivers/overlay/overlay.go +++ b/vendor/github.com/containers/storage/drivers/overlay/overlay.go @@ -206,7 +206,7 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap return nil, fmt.Errorf("Storage option overlay.size only supported for backingFS XFS. Found %v", backingFs) } - logrus.Debugf("backingFs=%s, projectQuotaSupported=%v, useNativeDiff=%v", backingFs, projectQuotaSupported, !useNaiveDiff(home)) + logrus.Debugf("backingFs=%s, projectQuotaSupported=%v, useNativeDiff=%v", backingFs, projectQuotaSupported, !d.useNaiveDiff()) return d, nil } @@ -338,9 +338,9 @@ func supportsOverlay(home string, homeMagic graphdriver.FsMagic, rootUID, rootGI return supportsDType, errors.Wrap(graphdriver.ErrNotSupported, "'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.") } -func useNaiveDiff(home string) bool { +func (d *Driver) useNaiveDiff() bool { useNaiveDiffLock.Do(func() { - if err := doesSupportNativeDiff(home); err != nil { + if err := doesSupportNativeDiff(d.home, d.options.mountOptions); err != nil { logrus.Warnf("Not using native diff for overlay, this may cause degraded performance for building images: %v", err) useNaiveDiffOnly = true } @@ -358,7 +358,7 @@ func (d *Driver) Status() [][2]string { return [][2]string{ {"Backing Filesystem", backingFs}, {"Supports d_type", strconv.FormatBool(d.supportsDType)}, - {"Native Overlay Diff", strconv.FormatBool(!useNaiveDiff(d.home))}, + {"Native Overlay Diff", strconv.FormatBool(!d.useNaiveDiff())}, } } @@ -883,7 +883,7 @@ func (d *Driver) getDiffPath(id string) string { // and its parent and returns the size in bytes of the changes // relative to its base filesystem directory. func (d *Driver) DiffSize(id string, idMappings *idtools.IDMappings, parent string, parentMappings *idtools.IDMappings, mountLabel string) (size int64, err error) { - if useNaiveDiff(d.home) || !d.isParent(id, parent) { + if d.useNaiveDiff() || !d.isParent(id, parent) { return d.naiveDiff.DiffSize(id, idMappings, parent, parentMappings, mountLabel) } return directory.Size(d.getDiffPath(id)) @@ -892,7 +892,7 @@ func (d *Driver) DiffSize(id string, idMappings *idtools.IDMappings, parent stri // Diff produces an archive of the changes between the specified // layer and its parent layer which may be "". func (d *Driver) Diff(id string, idMappings *idtools.IDMappings, parent string, parentMappings *idtools.IDMappings, mountLabel string) (io.ReadCloser, error) { - if useNaiveDiff(d.home) || !d.isParent(id, parent) { + if d.useNaiveDiff() || !d.isParent(id, parent) { return d.naiveDiff.Diff(id, idMappings, parent, parentMappings, mountLabel) } @@ -919,7 +919,7 @@ func (d *Driver) Diff(id string, idMappings *idtools.IDMappings, parent string, // Changes produces a list of changes between the specified layer // and its parent layer. If parent is "", then all changes will be ADD changes. func (d *Driver) Changes(id string, idMappings *idtools.IDMappings, parent string, parentMappings *idtools.IDMappings, mountLabel string) ([]archive.Change, error) { - if useNaiveDiff(d.home) || !d.isParent(id, parent) { + if d.useNaiveDiff() || !d.isParent(id, parent) { return d.naiveDiff.Changes(id, idMappings, parent, parentMappings, mountLabel) } // Overlay doesn't have snapshots, so we need to get changes from all parent |