build: Makefile for StratoVirt hypervisor

Add support for building StratoVirt hypervisor, including x86_64 and
arm64.

Fixes: #7794

Signed-off-by: Liu Wenyuan <liuwenyuan9@huawei.com>
This commit is contained in:
Liu Wenyuan
2023-08-23 17:27:01 +08:00
parent 26966c8469
commit 561c85be54
3 changed files with 56 additions and 1 deletions

View File

@@ -80,6 +80,7 @@ QEMUBINDIR := $(PREFIXDEPS)/bin
CLHBINDIR := $(PREFIXDEPS)/bin CLHBINDIR := $(PREFIXDEPS)/bin
FCBINDIR := $(PREFIXDEPS)/bin FCBINDIR := $(PREFIXDEPS)/bin
ACRNBINDIR := $(PREFIXDEPS)/bin ACRNBINDIR := $(PREFIXDEPS)/bin
STRATOVIRTBINDIR := $(PREFIXDEPS)/bin
SYSCONFDIR := /etc SYSCONFDIR := /etc
LOCALSTATEDIR := /var LOCALSTATEDIR := /var
@@ -103,6 +104,7 @@ GENERATED_VARS = \
CONFIG_QEMU_SNP_IN \ CONFIG_QEMU_SNP_IN \
CONFIG_CLH_IN \ CONFIG_CLH_IN \
CONFIG_FC_IN \ CONFIG_FC_IN \
CONFIG_STRATOVIRT_IN \
$(USER_VARS) $(USER_VARS)
SCRIPTS += $(COLLECT_SCRIPT) SCRIPTS += $(COLLECT_SCRIPT)
SCRIPTS_DIR := $(BINDIR) SCRIPTS_DIR := $(BINDIR)
@@ -146,12 +148,13 @@ HYPERVISOR_ACRN = acrn
HYPERVISOR_FC = firecracker HYPERVISOR_FC = firecracker
HYPERVISOR_QEMU = qemu HYPERVISOR_QEMU = qemu
HYPERVISOR_CLH = cloud-hypervisor HYPERVISOR_CLH = cloud-hypervisor
HYPERVISOR_STRATOVIRT = stratovirt
# Determines which hypervisor is specified in $(CONFIG_FILE). # Determines which hypervisor is specified in $(CONFIG_FILE).
DEFAULT_HYPERVISOR ?= $(HYPERVISOR_QEMU) DEFAULT_HYPERVISOR ?= $(HYPERVISOR_QEMU)
# List of hypervisors this build system can generate configuration for. # List of hypervisors this build system can generate configuration for.
HYPERVISORS := $(HYPERVISOR_ACRN) $(HYPERVISOR_FC) $(HYPERVISOR_QEMU) $(HYPERVISOR_CLH) HYPERVISORS := $(HYPERVISOR_ACRN) $(HYPERVISOR_FC) $(HYPERVISOR_QEMU) $(HYPERVISOR_CLH) $(HYPERVISOR_STRATOVIRT)
QEMUPATH := $(QEMUBINDIR)/$(QEMUCMD) QEMUPATH := $(QEMUBINDIR)/$(QEMUCMD)
QEMUVALIDHYPERVISORPATHS := [\"$(QEMUPATH)\"] QEMUVALIDHYPERVISORPATHS := [\"$(QEMUPATH)\"]
@@ -177,6 +180,9 @@ ACRNVALIDHYPERVISORPATHS := [\"$(ACRNPATH)\"]
ACRNCTLPATH := $(ACRNBINDIR)/$(ACRNCTLCMD) ACRNCTLPATH := $(ACRNBINDIR)/$(ACRNCTLCMD)
ACRNVALIDCTLPATHS := [\"$(ACRNCTLPATH)\"] ACRNVALIDCTLPATHS := [\"$(ACRNCTLPATH)\"]
STRATOVIRTPATH = $(STRATOVIRTBINDIR)/$(STRATOVIRTCMD)
STRATOVIRTVALIDHYPERVISORPATHS := [\"$(STRATOVIRTPATH)\"]
# Default number of vCPUs # Default number of vCPUs
DEFVCPUS := 1 DEFVCPUS := 1
# Default maximum number of vCPUs # Default maximum number of vCPUs
@@ -219,6 +225,7 @@ DEFVALIDENTROPYSOURCES := [\"/dev/urandom\",\"/dev/random\",\"\"]
DEFDISABLEBLOCK := false DEFDISABLEBLOCK := false
DEFSHAREDFS_CLH_VIRTIOFS := virtio-fs DEFSHAREDFS_CLH_VIRTIOFS := virtio-fs
DEFSHAREDFS_QEMU_VIRTIOFS := virtio-fs DEFSHAREDFS_QEMU_VIRTIOFS := virtio-fs
DEFSHAREDFS_STRATOVIRT_VIRTIOFS := virtio-fs
DEFSHAREDFS_QEMU_TDX_VIRTIOFS := virtio-9p DEFSHAREDFS_QEMU_TDX_VIRTIOFS := virtio-9p
DEFSHAREDFS_QEMU_SEV_VIRTIOFS := virtio-9p DEFSHAREDFS_QEMU_SEV_VIRTIOFS := virtio-9p
DEFSHAREDFS_QEMU_SNP_VIRTIOFS := virtio-9p DEFSHAREDFS_QEMU_SNP_VIRTIOFS := virtio-9p
@@ -381,6 +388,36 @@ ifneq (,$(CLHCMD))
KERNELPATH_CLH = $(KERNELDIR)/$(KERNEL_NAME_CLH) KERNELPATH_CLH = $(KERNELDIR)/$(KERNEL_NAME_CLH)
endif endif
ifneq (,$(STRATOVIRTCMD))
KNOWN_HYPERVISORS += $(HYPERVISOR_STRATOVIRT)
CONFIG_FILE_STRATOVIRT = configuration-stratovirt.toml
CONFIG_STRATOVIRT = config/$(CONFIG_FILE_STRATOVIRT)
CONFIG_STRATOVIRT_IN = $(CONFIG_STRATOVIRT).in
CONFIG_PATH_STRATOVIRT = $(abspath $(CONFDIR)/$(CONFIG_FILE_STRATOVIRT))
CONFIG_PATHS += $(CONFIG_PATH_STRATOVIRT)
SYSCONFIG_STRATOVIRT = $(abspath $(SYSCONFDIR)/$(CONFIG_FILE_STRATOVIRT))
SYSCONFIG_PATHS += $(SYSCONFIG_STRATOVIRT)
CONFIGS += $(CONFIG_STRATOVIRT)
# stratovirt-specific options (all should be suffixed by "_STRATOVIRT")
DEFMACHINETYPE_STRATOVIRT := microvm
DEFBLOCKSTORAGEDRIVER_STRATOVIRT := virtio-mmio
DEFNETWORKMODEL_STRATOVIRT := tcfilter
DEFSTATICRESOURCEMGMT_STRATOVIRT = true
ifeq ($(ARCH),amd64)
KERNELTYPE_STRATOVIRT = compressed
endif
ifeq ($(ARCH),arm64)
KERNELTYPE_STRATOVIRT = uncompressed
endif
KERNEL_NAME_STRATOVIRT = $(call MAKE_KERNEL_NAME,$(KERNELTYPE_STRATOVIRT))
KERNELPATH_STRATOVIRT = $(KERNELDIR)/$(KERNEL_NAME_STRATOVIRT)
endif
ifneq (,$(FCCMD)) ifneq (,$(FCCMD))
KNOWN_HYPERVISORS += $(HYPERVISOR_FC) KNOWN_HYPERVISORS += $(HYPERVISOR_FC)
@@ -479,6 +516,7 @@ USER_VARS += BINDIR
USER_VARS += CONFIG_ACRN_IN USER_VARS += CONFIG_ACRN_IN
USER_VARS += CONFIG_CLH_IN USER_VARS += CONFIG_CLH_IN
USER_VARS += CONFIG_FC_IN USER_VARS += CONFIG_FC_IN
USER_VARS += CONFIG_STRATOVIRT_IN
USER_VARS += CONFIG_PATH USER_VARS += CONFIG_PATH
USER_VARS += CONFIG_QEMU_IN USER_VARS += CONFIG_QEMU_IN
USER_VARS += DESTDIR USER_VARS += DESTDIR
@@ -497,6 +535,8 @@ USER_VARS += FCPATH
USER_VARS += FCVALIDHYPERVISORPATHS USER_VARS += FCVALIDHYPERVISORPATHS
USER_VARS += FCJAILERPATH USER_VARS += FCJAILERPATH
USER_VARS += FCVALIDJAILERPATHS USER_VARS += FCVALIDJAILERPATHS
USER_VARS += STRATOVIRTPATH
USER_VARS += STRATOVIRTVALIDHYPERVISORPATHS
USER_VARS += SYSCONFIG USER_VARS += SYSCONFIG
USER_VARS += IMAGENAME USER_VARS += IMAGENAME
USER_VARS += IMAGETDXNAME USER_VARS += IMAGETDXNAME
@@ -520,6 +560,7 @@ USER_VARS += KERNELTDXPATH
USER_VARS += KERNELSNPPATH USER_VARS += KERNELSNPPATH
USER_VARS += KERNELPATH_CLH USER_VARS += KERNELPATH_CLH
USER_VARS += KERNELPATH_FC USER_VARS += KERNELPATH_FC
USER_VARS += KERNELPATH_STRATOVIRT
USER_VARS += KERNELVIRTIOFSPATH USER_VARS += KERNELVIRTIOFSPATH
USER_VARS += FIRMWAREPATH USER_VARS += FIRMWAREPATH
USER_VARS += FIRMWARESEVPATH USER_VARS += FIRMWARESEVPATH
@@ -531,6 +572,7 @@ USER_VARS += MACHINEACCELERATORS
USER_VARS += CPUFEATURES USER_VARS += CPUFEATURES
USER_VARS += TDXCPUFEATURES USER_VARS += TDXCPUFEATURES
USER_VARS += DEFMACHINETYPE_CLH USER_VARS += DEFMACHINETYPE_CLH
USER_VARS += DEFMACHINETYPE_STRATOVIRT
USER_VARS += KERNELPARAMS USER_VARS += KERNELPARAMS
USER_VARS += KERNELTDXPARAMS USER_VARS += KERNELTDXPARAMS
USER_VARS += LIBEXECDIR USER_VARS += LIBEXECDIR
@@ -572,6 +614,7 @@ USER_VARS += DEFNETWORKMODEL_ACRN
USER_VARS += DEFNETWORKMODEL_CLH USER_VARS += DEFNETWORKMODEL_CLH
USER_VARS += DEFNETWORKMODEL_FC USER_VARS += DEFNETWORKMODEL_FC
USER_VARS += DEFNETWORKMODEL_QEMU USER_VARS += DEFNETWORKMODEL_QEMU
USER_VARS += DEFNETWORKMODEL_STRATOVIRT
USER_VARS += DEFDISABLEGUESTEMPTYDIR USER_VARS += DEFDISABLEGUESTEMPTYDIR
USER_VARS += DEFDISABLEGUESTSECCOMP USER_VARS += DEFDISABLEGUESTSECCOMP
USER_VARS += DEFDISABLESELINUX USER_VARS += DEFDISABLESELINUX
@@ -582,9 +625,11 @@ USER_VARS += DEFDISABLEBLOCK
USER_VARS += DEFBLOCKSTORAGEDRIVER_ACRN USER_VARS += DEFBLOCKSTORAGEDRIVER_ACRN
USER_VARS += DEFBLOCKSTORAGEDRIVER_FC USER_VARS += DEFBLOCKSTORAGEDRIVER_FC
USER_VARS += DEFBLOCKSTORAGEDRIVER_QEMU USER_VARS += DEFBLOCKSTORAGEDRIVER_QEMU
USER_VARS += DEFBLOCKSTORAGEDRIVER_STRATOVIRT
USER_VARS += DEFBLOCKDEVICEAIO_QEMU USER_VARS += DEFBLOCKDEVICEAIO_QEMU
USER_VARS += DEFSHAREDFS_CLH_VIRTIOFS USER_VARS += DEFSHAREDFS_CLH_VIRTIOFS
USER_VARS += DEFSHAREDFS_QEMU_VIRTIOFS USER_VARS += DEFSHAREDFS_QEMU_VIRTIOFS
USER_VARS += DEFSHAREDFS_STRATOVIRT_VIRTIOFS
USER_VARS += DEFSHAREDFS_QEMU_TDX_VIRTIOFS USER_VARS += DEFSHAREDFS_QEMU_TDX_VIRTIOFS
USER_VARS += DEFSHAREDFS_QEMU_SEV_VIRTIOFS USER_VARS += DEFSHAREDFS_QEMU_SEV_VIRTIOFS
USER_VARS += DEFSHAREDFS_QEMU_SNP_VIRTIOFS USER_VARS += DEFSHAREDFS_QEMU_SNP_VIRTIOFS
@@ -609,6 +654,7 @@ USER_VARS += DEFSANDBOXCGROUPONLY
USER_VARS += DEFSTATICRESOURCEMGMT USER_VARS += DEFSTATICRESOURCEMGMT
USER_VARS += DEFSTATICRESOURCEMGMT_CLH USER_VARS += DEFSTATICRESOURCEMGMT_CLH
USER_VARS += DEFSTATICRESOURCEMGMT_FC USER_VARS += DEFSTATICRESOURCEMGMT_FC
USER_VARS += DEFSTATICRESOURCEMGMT_STRATOVIRT
USER_VARS += DEFSTATICRESOURCEMGMT_TEE USER_VARS += DEFSTATICRESOURCEMGMT_TEE
USER_VARS += DEFBINDMOUNTS USER_VARS += DEFBINDMOUNTS
USER_VARS += DEFSERVICEOFFLOAD USER_VARS += DEFSERVICEOFFLOAD
@@ -940,6 +986,9 @@ ifneq (,$(findstring $(HYPERVISOR_FC),$(KNOWN_HYPERVISORS)))
endif endif
ifneq (,$(findstring $(HYPERVISOR_ACRN),$(KNOWN_HYPERVISORS))) ifneq (,$(findstring $(HYPERVISOR_ACRN),$(KNOWN_HYPERVISORS)))
@printf "\t$(HYPERVISOR_ACRN) hypervisor path (ACRNPATH) : %s\n" $(abspath $(ACRNPATH)) @printf "\t$(HYPERVISOR_ACRN) hypervisor path (ACRNPATH) : %s\n" $(abspath $(ACRNPATH))
endif
ifneq (,$(findstring $(HYPERVISOR_STRATOVIRT),$(KNOWN_HYPERVISORS)))
@printf "\t$(HYPERVISOR_STRATOVIRT) hypervisor path (STRATOVIRTPATH) : %s\n" $(abspath $(STRATOVIRTPATH))
endif endif
@printf "\tassets path (PKGDATADIR) : %s\n" $(abspath $(PKGDATADIR)) @printf "\tassets path (PKGDATADIR) : %s\n" $(abspath $(PKGDATADIR))
@printf "\tshim path (PKGLIBEXECDIR) : %s\n" $(abspath $(PKGLIBEXECDIR)) @printf "\tshim path (PKGLIBEXECDIR) : %s\n" $(abspath $(PKGLIBEXECDIR))

View File

@@ -28,3 +28,6 @@ ACRNCTLCMD := acrnctl
CLHCMD := cloud-hypervisor CLHCMD := cloud-hypervisor
DEFSTATICRESOURCEMGMT_CLH := false DEFSTATICRESOURCEMGMT_CLH := false
# stratovirt binary name
STRATOVIRTCMD := stratovirt

View File

@@ -21,3 +21,6 @@ FCJAILERCMD := jailer
CLHCMD := cloud-hypervisor CLHCMD := cloud-hypervisor
DEFSTATICRESOURCEMGMT_CLH := true DEFSTATICRESOURCEMGMT_CLH := true
# stratovirt binary name
STRATOVIRTCMD := stratovirt