Beispiel #1
0
func checkCPUCompat(srcCmd, dstCmd cmd.Cmd) error {
	// Dump
	_, _, err := srcCmd.Run("sudo", "criu", "cpuinfo", "dump")
	if _, ok := err.(*ssh.ExitError); ok {
		return fmt.Errorf("Error dumping CPU info")
	} else if _, ok := err.(*exec.ExitError); ok {
		return fmt.Errorf("Error dumping CPU info")
	} else if err != nil {
		return fmt.Errorf("Connection error: %s ", err)
	}

	// Copy

	err = cmd.Scp(srcCmd.URL("./cpuinfo.img"), dstCmd.URL("."))
	if _, ok := err.(*ssh.ExitError); ok {
		return fmt.Errorf("Error copying dump image")
	} else if _, ok := err.(*exec.ExitError); ok {
		return fmt.Errorf("Error copying dump image")
	} else if err != nil {
		return fmt.Errorf("Connection error: %s ", err)
	}

	// Check
	_, _, err = srcCmd.Run("sudo", "criu", "cpuinfo", "check")
	if _, ok := err.(*ssh.ExitError); ok {
		return fmt.Errorf("Error checking CPU info")
	} else if _, ok := err.(*exec.ExitError); ok {
		return fmt.Errorf("Error checking CPU info")
	} else if err != nil {
		return fmt.Errorf("Connection error: %s ", err)
	}
	return nil
}
		var downtime time.Duration

		if c.Bool("pre-dump") {
			// Process pre-dump
			predumpPath := fmt.Sprintf("%s/images/0", srcUrl.Path)
			prepareDir(src, predumpPath)

			checkpoint(src, containerId, predumpPath, true)

			srcTarFile := fmt.Sprintf("%s/predump.tar.gz", srcUrl.Path)
			prepareTar(src, srcTarFile, predumpPath)

			prepareDir(dst, fmt.Sprintf("%s/images/0", dstUrl.Path))

			log.Println("Copying predump image to dst")
			err := cmd.Scp(src.URL(srcTarFile), dst.URL(fmt.Sprintf("%s/images/0", dstUrl.Path)))
			if err != nil {
				log.Fatal("Error copying predump image files to dst", err)
			}

			dstTarFile := fmt.Sprintf("%s/images/0/predump.tar.gz", dstUrl.Path)
			unpackTar(dst, dstTarFile, fmt.Sprintf("%s/images/0", dstUrl.Path))

			// Process final image
			migrateStart = time.Now()

			imagesPath = fmt.Sprintf("%s/images/1", srcUrl.Path)
			log.Println("Performing the checkpoint")
			_, _, err = src.Run("sudo", "runc", "--id", containerId, "checkpoint", "--image-path", imagesPath, "--prev-images-dir", "../0", "--track-mem")
			if err != nil {
				log.Fatal("Error performing checkpoint:", err)