Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
cli: Leverage the new support for ppc64le
Browse files Browse the repository at this point in the history
Fixes #302

Signed-off-by: Nitesh Konkar niteshkonkar@in.ibm.com
  • Loading branch information
nitkon committed May 31, 2018
1 parent baa553d commit 12e4dbe
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Makefile
Expand Up @@ -61,6 +61,12 @@ ifeq (,$(installing))
EXTRA_DEPS = clean
endif

ifeq (uncompressed,$(KERNELTYPE))
KERNEL_NAME = vmlinux.container
else
KERNEL_NAME = vmlinuz.container
endif

LIBEXECDIR := $(PREFIX)/libexec
SHAREDIR := $(PREFIX)/share
DEFAULTSDIR := $(SHAREDIR)/defaults
Expand All @@ -77,7 +83,7 @@ PKGLIBDIR := $(LOCALSTATEDIR)/lib/$(PROJECT_DIR)
PKGRUNDIR := $(LOCALSTATEDIR)/run/$(PROJECT_DIR)
PKGLIBEXECDIR := $(LIBEXECDIR)/$(PROJECT_DIR)

KERNELPATH := $(PKGDATADIR)/vmlinuz.container
KERNELPATH := $(PKGDATADIR)/$(KERNEL_NAME)
INITRDPATH := $(PKGDATADIR)/$(INITRDNAME)
IMAGEPATH := $(PKGDATADIR)/$(IMAGENAME)
FIRMWAREPATH :=
Expand Down Expand Up @@ -150,6 +156,7 @@ USER_VARS += INITRDNAME
USER_VARS += INITRDPATH
USER_VARS += MACHINETYPE
USER_VARS += KERNELPATH
USER_VARS += KERNELTYPE
USER_VARS += FIRMWAREPATH
USER_VARS += MACHINEACCELERATORS
USER_VARS += KERNELPARAMS
Expand Down
12 changes: 12 additions & 0 deletions arch/ppc64le-options.mk
@@ -0,0 +1,12 @@
# Copyright (c) 2018 IBM
#
# SPDX-License-Identifier: Apache-2.0
#

# Power ppc64le settings

MACHINETYPE := pseries
KERNELPARAMS :=
MACHINEACCELERATORS :=
KERNELTYPE := uncompressed #This architecture must use an uncompressed kernel.
QEMUCMD := qemu-system-ppc64le
65 changes: 65 additions & 0 deletions cli/kata-check_ppc64le.go
@@ -0,0 +1,65 @@
// Copyright (c) 2018 IBM
//
// SPDX-License-Identifier: Apache-2.0
//

package main

import (
"fmt"
"github.com/sirupsen/logrus"
)

// archRequiredCPUFlags maps a CPU flag value to search for and a
// human-readable description of that value.
var archRequiredCPUFlags = map[string]string{}

// archRequiredCPUAttribs maps a CPU (non-CPU flag) attribute value to search for
// and a human-readable description of that value.
var archRequiredCPUAttribs = map[string]string{}

// archRequiredKernelModules maps a required module name to a human-readable
// description of the modules functionality and an optional list of
// required module parameters.
var archRequiredKernelModules = map[string]kernelModule{
"kvm": {
desc: "Kernel-based Virtual Machine",
},
"kvm_hv": {
desc: "Kernel-based Virtual Machine hardware virtualization",
},
}

func archHostCanCreateVMContainer() error {
return kvmIsUsable()
}

// hostIsVMContainerCapable checks to see if the host is theoretically capable
// of creating a VM container.
func hostIsVMContainerCapable(details vmContainerCapableDetails) error {
_, err := getCPUInfo(details.cpuInfoFile)
if err != nil {
return err
}

count, err := checkKernelModules(details.requiredKernelModules, archKernelParamHandler)
if err != nil {
return err
}

if count == 0 {
return nil
}

return fmt.Errorf("ERROR: %s", failMessage)
}

// kvmIsUsable determines if it will be possible to create a full virtual machine
// by creating a minimal VM and then deleting it.
func kvmIsUsable() error {
return genericKvmIsUsable()
}

func archKernelParamHandler(onVMM bool, fields logrus.Fields, msg string) bool {
return genericArchKernelParamHandler(onVMM, fields, msg)
}
4 changes: 4 additions & 0 deletions cli/kata-env.go
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/urfave/cli"
runtim "runtime"
)

// Semantic version for the output of the command.
Expand Down Expand Up @@ -173,6 +174,9 @@ func getHostInfo() (HostInfo, error) {
}

hostVMContainerCapable := true
if runtim.GOARCH == "ppc64le" {
hostVMContainerCapable = false
}

details := vmContainerCapableDetails{
cpuInfoFile: procCPUInfo,
Expand Down

0 comments on commit 12e4dbe

Please sign in to comment.