Skip to content

Commit

Permalink
configuration: add nemu support
Browse files Browse the repository at this point in the history
NEMU requires a unique runtime configuration.  Add support for utilizing
a configuration-nemu.toml

Fixes: kata-containers#1647

Signed-off-by: Eric Ernst <[email protected]>
  • Loading branch information
Eric Ernst committed May 9, 2019
1 parent a7935d4 commit 47c5f91
Show file tree
Hide file tree
Showing 4 changed files with 389 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.git-commit
.git-commit.tmp
/cli/config/configuration-fc.toml
/cli/config/configuration-nemu.toml
/cli/config/configuration-qemu.toml
/cli/config-generated.go
/cli/coverage.html
Expand Down
59 changes: 54 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ endif
# Prefix where depedencies are installed
PREFIXDEPS := $(PREFIX)
BINDIR := $(EXEC_PREFIX)/bin
NEMUBINDIR := $(PREFIXDEPS)/bin
QEMUBINDIR := $(PREFIXDEPS)/bin
FCBINDIR := $(PREFIXDEPS)/bin
SYSCONFDIR := /etc
Expand Down Expand Up @@ -106,22 +107,24 @@ KERNELDIR := $(PKGDATADIR)

INITRDPATH := $(PKGDATADIR)/$(INITRDNAME)
IMAGEPATH := $(PKGDATADIR)/$(IMAGENAME)
FIRMWAREPATH :=

# Name of default configuration file the runtime will use.
CONFIG_FILE = configuration.toml

HYPERVISOR_FC = firecracker
HYPERVISOR_NEMU = nemu
HYPERVISOR_QEMU = qemu

# Determines which hypervisor is specified in $(CONFIG_FILE).
DEFAULT_HYPERVISOR = $(HYPERVISOR_QEMU)

# List of hypervisors this build system can generate configuration for.
HYPERVISORS := $(HYPERVISOR_FC) $(HYPERVISOR_QEMU)
HYPERVISORS := $(HYPERVISOR_FC) $(HYPERVISOR_QEMU) $(HYPERVISOR_NEMU)

QEMUPATH := $(QEMUBINDIR)/$(QEMUCMD)

NEMUPATH := $(NEMUBINDIR)/$(NEMUCMD)

FCPATH = $(FCBINDIR)/$(FCCMD)

SHIMCMD := $(BIN_PREFIX)-shim
Expand Down Expand Up @@ -216,10 +219,37 @@ ifneq (,$(QEMUCMD))
# qemu-specific options (all should be suffixed by "_QEMU")
DEFBLOCKSTORAGEDRIVER_QEMU := virtio-scsi
DEFNETWORKMODEL_QEMU := tcfilter
KERNELNAME_QEMU = $(call MAKE_KERNEL_NAME,$(KERNELTYPE))
KERNELPATH_QEMU = $(KERNELDIR)/$(KERNELNAME_QEMU)
KERNELNAME = $(call MAKE_KERNEL_NAME,$(KERNELTYPE))
KERNELPATH = $(KERNELDIR)/$(KERNELNAME)
endif


ifneq (,$(NEMUCMD))
KNOWN_HYPERVISORS += $(HYPERVISOR_NEMU)

CONFIG_FILE_NEMU = configuration-nemu.toml
CONFIG_NEMU = $(CLI_DIR)/config/$(CONFIG_FILE_NEMU)
CONFIG_NEMU_IN = $(CONFIG_NEMU).in

CONFIG_PATH_NEMU = $(abspath $(CONFDIR)/$(CONFIG_FILE_NEMU))
CONFIG_PATHS += $(CONFIG_PATH_NEMU)

SYSCONFIG_NEMU = $(abspath $(SYSCONFDIR)/$(CONFIG_FILE_NEMU))
SYSCONFIG_PATHS += $(SYSCONFIG_NEMU)

CONFIGS += $(CONFIG_NEMU)

# nemu-specific options (all should be suffixed by "_NEMU")
DEFMACHINEACCELERATOR_NEMU := virt
DEFBLOCKSTORAGEDRIVER_NEMU := virtio-scsi
DEFNETWORKMODEL_NEMU := tcfilter
KERNELNAME = $(call MAKE_KERNEL_NAME,$(KERNELTYPE))
KERNELPATH = $(KERNELDIR)/$(KERNELNAME)
FIRMWAREPATH_NEMU := $(SHAREDIR)/kata-nemu/OVMF.fd
endif



ifneq (,$(FCCMD))
KNOWN_HYPERVISORS += $(HYPERVISOR_FC)

Expand Down Expand Up @@ -263,6 +293,10 @@ ifeq ($(DEFAULT_HYPERVISOR),$(HYPERVISOR_FC))
DEFAULT_HYPERVISOR_CONFIG = $(CONFIG_FILE_FC)
endif

ifeq ($(DEFAULT_HYPERVISOR),$(HYPERVISOR_NEMU))
DEFAULT_HYPERVISOR_CONFIG = $(CONFIG_FILE_NEMU)
endif

CONFDIR := $(DEFAULTSDIR)/$(PROJECT_DIR)
SYSCONFDIR := $(SYSCONFDIR)/$(PROJECT_DIR)

Expand All @@ -283,6 +317,8 @@ USER_VARS += DESTDIR
USER_VARS += DEFAULT_HYPERVISOR
USER_VARS += FCCMD
USER_VARS += FCPATH
USER_VARS += NEMUCMD
USER_VARS += NEMUPATH
USER_VARS += SYSCONFIG
USER_VARS += IMAGENAME
USER_VARS += IMAGEPATH
Expand All @@ -293,7 +329,9 @@ USER_VARS += KERNELDIR
USER_VARS += KERNELTYPE
USER_VARS += KERNELTYPE_FC
USER_VARS += FIRMWAREPATH
USER_VARS += FIRMWAREPATH_NEMU
USER_VARS += MACHINEACCELERATORS
USER_VARS += DEFMACHINEACCELERATOR_NEMU
USER_VARS += KERNELPARAMS
USER_VARS += LIBEXECDIR
USER_VARS += LOCALSTATEDIR
Expand All @@ -320,11 +358,13 @@ USER_VARS += DEFMEMSLOTS
USER_VARS += DEFBRIDGES
USER_VARS += DEFNETWORKMODEL_FC
USER_VARS += DEFNETWORKMODEL_QEMU
USER_VARS += DEFNETWORKMODEL_NEMU
USER_VARS += DEFDISABLEGUESTSECCOMP
USER_VARS += DEFAULTEXPFEATURES
USER_VARS += DEFDISABLEBLOCK
USER_VARS += DEFBLOCKSTORAGEDRIVER_FC
USER_VARS += DEFBLOCKSTORAGEDRIVER_QEMU
USER_VARS += DEFBLOCKSTORAGEDRIVER_NEMU
USER_VARS += DEFSHAREDFS
USER_VARS += DEFVIRTIOFSDAEMON
USER_VARS += DEFVIRTIOFSCACHESIZE
Expand Down Expand Up @@ -428,16 +468,20 @@ $(GENERATED_FILES): %: %.in $(MAKEFILE_LIST) VERSION .git-commit
-e "s|@COMMIT@|$(shell cat .git-commit)|g" \
-e "s|@VERSION@|$(VERSION)|g" \
-e "s|@CONFIG_QEMU_IN@|$(CONFIG_QEMU_IN)|g" \
-e "s|@CONFIG_NEMU_IN@|$(CONFIG_NEMU_IN)|g" \
-e "s|@CONFIG_FC_IN@|$(CONFIG_FC_IN)|g" \
-e "s|@CONFIG_PATH@|$(CONFIG_PATH)|g" \
-e "s|@FCPATH@|$(FCPATH)|g" \
-e "s|@NEMUPATH@|$(NEMUPATH)|g" \
-e "s|@SYSCONFIG@|$(SYSCONFIG)|g" \
-e "s|@IMAGEPATH@|$(IMAGEPATH)|g" \
-e "s|@KERNELPATH_FC@|$(KERNELPATH_FC)|g" \
-e "s|@KERNELPATH_QEMU@|$(KERNELPATH_QEMU)|g" \
-e "s|@KERNELPATH@|$(KERNELPATH)|g" \
-e "s|@INITRDPATH@|$(INITRDPATH)|g" \
-e "s|@FIRMWAREPATH@|$(FIRMWAREPATH)|g" \
-e "s|@FIRMWAREPATH_NEMU@|$(FIRMWAREPATH_NEMU)|g" \
-e "s|@MACHINEACCELERATORS@|$(MACHINEACCELERATORS)|g" \
-e "s|@DEFMACHINEACCELERATOR_NEMU@|$(DEFMACHINEACCELERATOR_NEMU)|g" \
-e "s|@KERNELPARAMS@|$(KERNELPARAMS)|g" \
-e "s|@LOCALSTATEDIR@|$(LOCALSTATEDIR)|g" \
-e "s|@PKGLIBEXECDIR@|$(PKGLIBEXECDIR)|g" \
Expand All @@ -460,11 +504,13 @@ $(GENERATED_FILES): %: %.in $(MAKEFILE_LIST) VERSION .git-commit
-e "s|@DEFBRIDGES@|$(DEFBRIDGES)|g" \
-e "s|@DEFNETWORKMODEL_FC@|$(DEFNETWORKMODEL_FC)|g" \
-e "s|@DEFNETWORKMODEL_QEMU@|$(DEFNETWORKMODEL_QEMU)|g" \
-e "s|@DEFNETWORKMODEL_NEMU@|$(DEFNETWORKMODEL_NEMU)|g" \
-e "s|@DEFDISABLEGUESTSECCOMP@|$(DEFDISABLEGUESTSECCOMP)|g" \
-e "s|@DEFAULTEXPFEATURES@|$(DEFAULTEXPFEATURES)|g" \
-e "s|@DEFDISABLEBLOCK@|$(DEFDISABLEBLOCK)|g" \
-e "s|@DEFBLOCKSTORAGEDRIVER_FC@|$(DEFBLOCKSTORAGEDRIVER_FC)|g" \
-e "s|@DEFBLOCKSTORAGEDRIVER_QEMU@|$(DEFBLOCKSTORAGEDRIVER_QEMU)|g" \
-e "s|@DEFBLOCKSTORAGEDRIVER_NEMU@|$(DEFBLOCKSTORAGEDRIVER_NEMU)|g" \
-e "s|@DEFSHAREDFS@|$(DEFSHAREDFS)|g" \
-e "s|@DEFVIRTIOFSDAEMON@|$(DEFVIRTIOFSDAEMON)|g" \
-e "s|@DEFVIRTIOFSCACHESIZE@|$(DEFVIRTIOFSCACHESIZE)|g" \
Expand Down Expand Up @@ -622,6 +668,9 @@ endif
ifneq (,$(findstring $(HYPERVISOR_QEMU),$(KNOWN_HYPERVISORS)))
@printf "\t$(HYPERVISOR_QEMU) hypervisor path (QEMUPATH) : %s\n" $(abspath $(QEMUPATH))
endif
ifneq (,$(findstring $(HYPERVISOR_NEMU),$(KNOWN_HYPERVISORS)))
@printf "\t$(HYPERVISOR_NEMU) hypervisor path (NEMUPATH) : %s\n" $(abspath $(NEMUPATH))
endif
ifneq (,$(findstring $(HYPERVISOR_FC),$(KNOWN_HYPERVISORS)))
@printf "\t$(HYPERVISOR_FC) hypervisor path (FCPATH) : %s\n" $(abspath $(FCPATH))
endif
Expand Down
3 changes: 3 additions & 0 deletions arch/amd64-options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ QEMUCMD := qemu-lite-system-x86_64

# Firecracker binary name
FCCMD := firecracker

# NEMU binary name
NEMUCMD := nemu-system-x86_64
Loading

0 comments on commit 47c5f91

Please sign in to comment.