Example #1
0
// launchQemu run qemu and wait it's quit, includes
func launchQemu(qc *QemuContext, ctx *hypervisor.VmContext) {
	qemu := qc.driver.executable
	if qemu == "" {
		ctx.Hub <- &hypervisor.VmStartFailEvent{Message: "can not find qemu executable"}
		return
	}

	args := qc.arguments(ctx)

	if glog.V(1) {
		glog.Info("cmdline arguments: ", strings.Join(args, " "))
	}

	pid, err := utils.ExecInDaemon(qemu, append([]string{"qemu-system-x86_64"}, args...))
	if err != nil {
		//fail to daemonize
		glog.Errorf("%v", err)
		ctx.Hub <- &hypervisor.VmStartFailEvent{Message: "try to start qemu failed"}
		return
	}

	glog.V(1).Infof("starting daemon with pid: %d", pid)

	err = ctx.DCtx.(*QemuContext).watchPid(int(pid), ctx.Hub)
	if err != nil {
		glog.Error("watch qemu process failed")
		ctx.Hub <- &hypervisor.VmStartFailEvent{Message: "watch qemu process failed"}
		return
	}
}
Example #2
0
func main() {
	if reexec.Init() {
		return
	}

	fnd := flag.Bool("nondaemon", false, "Not daemonize")
	flDisableIptables := flag.Bool("noniptables", false, "Don't enable iptables rules")
	flConfig := flag.String("config", "", "Config file for hyperd")
	flHost := flag.String("host", "", "Host for hyperd")
	flMirrors := flag.String("registry_mirror", "", "Prefered docker registry mirror")
	flInsecureRegistries := flag.String("insecure_registry", "", "Enable insecure registry communication")
	flHelp := flag.Bool("help", false, "Print help message for Hyperd daemon")
	flag.Set("alsologtostderr", "true")
	flag.Set("log_dir", "/var/log/hyper/")
	os.MkdirAll("/var/log/hyper/", 0755)
	flag.Usage = func() { printHelp() }
	flag.Parse()
	if *flHelp == true {
		printHelp()
		return
	}

	if !*fnd {
		path, err := osext.Executable()
		if err != nil {
			fmt.Printf("cannot find self executable path for %s: %v\n", os.Args[0], err)
			os.Exit(-1)
		}

		_, err = runvutils.ExecInDaemon(path, append([]string{os.Args[0], "--nondaemon"}, os.Args[1:]...))
		if err != nil {
			fmt.Println("faile to daemonize hyperd")
			os.Exit(-1)
		}

		return
	}

	var opts = &Options{
		DisableIptables:    *flDisableIptables,
		Config:             *flConfig,
		Hosts:              *flHost,
		Mirrors:            *flMirrors,
		InsecureRegistries: *flInsecureRegistries,
	}

	mainDaemon(opts)
}
Example #3
0
func main() {
	if reexec.Init() {
		return
	}

	fnd := flag.Bool("nondaemon", false, "Not daemonize")
	flDisableIptables := flag.Bool("noniptables", false, "Don't enable iptables rules")
	flConfig := flag.String("config", "", "Config file for hyperd")
	flHost := flag.String("host", "", "Host for hyperd")
	flHelp := flag.Bool("help", false, "Print help message for Hyperd daemon")
	glog.Init()
	flag.Usage = func() { printHelp() }
	flag.Parse()
	if *flHelp == true {
		printHelp()
		return
	}

	if !*fnd {
		path, err := osext.Executable()
		if err != nil {
			fmt.Printf("cannot find self executable path for %s: %v\n", os.Args[0], err)
			os.Exit(-1)
		}

		_, err = runvutils.ExecInDaemon(path, append(os.Args, "--nondaemon"))
		if err != nil {
			fmt.Println("faile to daemonize hyperd")
			os.Exit(-1)
		}

		return
	}

	mainDaemon(*flConfig, *flHost, *flDisableIptables)
}
Example #4
0
				fmt.Printf("Failed to create runv namespace path: %v", err)
				os.Exit(-1)
			}

			args := []string{
				"runv-namespaced",
				"--namespace", namespace,
				"--state", root,
				"--driver", driver,
				"--kernel", kernel,
				"--initrd", initrd,
			}
			if context.GlobalBool("debug") {
				args = append(args, "-v", "3", "--log_dir", context.GlobalString("log_dir"))
			}
			pid, err = utils.ExecInDaemon(path, args)
			if err != nil {
				fmt.Printf("failed to launch runv daemon, error:%v\n", err)
				os.Exit(-1)
			}
			address = filepath.Join(namespace, "namespaced.sock")
		}

		status := startContainer(context, container, address, spec)
		if status < 0 && sharedContainer == "" {
			syscall.Kill(int(pid), syscall.SIGINT)
		}
		os.Exit(status)
	},
}