mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-24 11:25:40 +00:00
Merge pull request #2197 from ijc/qemu-envvar-overrides
qemu: allow kvm and containerized options to be overridden by the env…
This commit is contained in:
commit
944793312a
@ -42,6 +42,19 @@ func haveKVM() bool {
|
||||
return !os.IsNotExist(err)
|
||||
}
|
||||
|
||||
func envOverrideBool(env string, b *bool) {
|
||||
val := os.Getenv(env)
|
||||
if val == "" {
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
*b, err = strconv.ParseBool(val)
|
||||
if err != nil {
|
||||
log.Fatal("Unable to parse %q=%q as a boolean", env, val)
|
||||
}
|
||||
}
|
||||
|
||||
func runQemu(args []string) {
|
||||
invoked := filepath.Base(os.Args[0])
|
||||
flags := flag.NewFlagSet("qemu", flag.ExitOnError)
|
||||
@ -89,6 +102,11 @@ func runQemu(args []string) {
|
||||
}
|
||||
remArgs := flags.Args()
|
||||
|
||||
// These envvars override the corresponding command line
|
||||
// options. So this must remain after the `flags.Parse` above.
|
||||
envOverrideBool("LINUXKIT_QEMU_KVM", enableKVM)
|
||||
envOverrideBool("LINUXKIT_QEMU_CONTAINERIZED", qemuContainerized)
|
||||
|
||||
if len(remArgs) == 0 {
|
||||
fmt.Println("Please specify the path to the image to boot")
|
||||
flags.Usage()
|
||||
|
Loading…
Reference in New Issue
Block a user