mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-15 06:34:03 +00:00
pkg/katautils: Add support for ACRN hypervisor config
This patch adds support for, 1. Extracting and configuring ACRN hypervisor from toml. 2. Add ACRN hypervisor ctl for controlling ACRN hypervisor. This will be used for updating virtio-blk based container rootfs using blk rescan feature. v2->v3: Fixed acrnctl path. v1->v2: Trimmed hypervisor config options as needed by ACRN. Fixes: #1778 Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
This commit is contained in:
parent
adcac9368f
commit
828e0a2205
@ -9,6 +9,7 @@
|
|||||||
package katautils
|
package katautils
|
||||||
|
|
||||||
var defaultHypervisorPath = "/usr/bin/qemu-lite-system-x86_64"
|
var defaultHypervisorPath = "/usr/bin/qemu-lite-system-x86_64"
|
||||||
|
var defaultHypervisorCtlPath = "/usr/bin/acrnctl"
|
||||||
var defaultImagePath = "/usr/share/kata-containers/kata-containers.img"
|
var defaultImagePath = "/usr/share/kata-containers/kata-containers.img"
|
||||||
var defaultKernelPath = "/usr/share/kata-containers/vmlinuz.container"
|
var defaultKernelPath = "/usr/share/kata-containers/vmlinuz.container"
|
||||||
var defaultInitrdPath = "/usr/share/kata-containers/kata-containers-initrd.img"
|
var defaultInitrdPath = "/usr/share/kata-containers/kata-containers-initrd.img"
|
||||||
|
@ -50,6 +50,7 @@ const (
|
|||||||
// supported hypervisor component types
|
// supported hypervisor component types
|
||||||
firecrackerHypervisorTableType = "firecracker"
|
firecrackerHypervisorTableType = "firecracker"
|
||||||
qemuHypervisorTableType = "qemu"
|
qemuHypervisorTableType = "qemu"
|
||||||
|
acrnHypervisorTableType = "acrn"
|
||||||
|
|
||||||
// supported proxy component types
|
// supported proxy component types
|
||||||
kataProxyTableType = "kata"
|
kataProxyTableType = "kata"
|
||||||
@ -84,6 +85,7 @@ type factory struct {
|
|||||||
type hypervisor struct {
|
type hypervisor struct {
|
||||||
Path string `toml:"path"`
|
Path string `toml:"path"`
|
||||||
Kernel string `toml:"kernel"`
|
Kernel string `toml:"kernel"`
|
||||||
|
CtlPath string `toml:"ctlpath"`
|
||||||
Initrd string `toml:"initrd"`
|
Initrd string `toml:"initrd"`
|
||||||
Image string `toml:"image"`
|
Image string `toml:"image"`
|
||||||
Firmware string `toml:"firmware"`
|
Firmware string `toml:"firmware"`
|
||||||
@ -163,6 +165,16 @@ func (h hypervisor) path() (string, error) {
|
|||||||
return ResolvePath(p)
|
return ResolvePath(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h hypervisor) ctlpath() (string, error) {
|
||||||
|
p := h.CtlPath
|
||||||
|
|
||||||
|
if h.CtlPath == "" {
|
||||||
|
p = defaultHypervisorCtlPath
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResolvePath(p)
|
||||||
|
}
|
||||||
|
|
||||||
func (h hypervisor) kernel() (string, error) {
|
func (h hypervisor) kernel() (string, error) {
|
||||||
p := h.Kernel
|
p := h.Kernel
|
||||||
|
|
||||||
@ -602,6 +614,67 @@ func newQemuHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newAcrnHypervisorConfig(h hypervisor) (vc.HypervisorConfig, error) {
|
||||||
|
hypervisor, err := h.path()
|
||||||
|
if err != nil {
|
||||||
|
return vc.HypervisorConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
hypervisorctl, err := h.ctlpath()
|
||||||
|
if err != nil {
|
||||||
|
return vc.HypervisorConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel, err := h.kernel()
|
||||||
|
if err != nil {
|
||||||
|
return vc.HypervisorConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
image, err := h.image()
|
||||||
|
if err != nil {
|
||||||
|
return vc.HypervisorConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if image == "" {
|
||||||
|
return vc.HypervisorConfig{},
|
||||||
|
errors.New("image must be defined in the configuration file")
|
||||||
|
}
|
||||||
|
|
||||||
|
firmware, err := h.firmware()
|
||||||
|
if err != nil {
|
||||||
|
return vc.HypervisorConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
kernelParams := h.kernelParams()
|
||||||
|
|
||||||
|
blockDriver, err := h.blockDeviceDriver()
|
||||||
|
if err != nil {
|
||||||
|
return vc.HypervisorConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return vc.HypervisorConfig{
|
||||||
|
HypervisorPath: hypervisor,
|
||||||
|
KernelPath: kernel,
|
||||||
|
ImagePath: image,
|
||||||
|
HypervisorCtlPath: hypervisorctl,
|
||||||
|
FirmwarePath: firmware,
|
||||||
|
KernelParams: vc.DeserializeParams(strings.Fields(kernelParams)),
|
||||||
|
NumVCPUs: h.defaultVCPUs(),
|
||||||
|
DefaultMaxVCPUs: h.defaultMaxVCPUs(),
|
||||||
|
MemorySize: h.defaultMemSz(),
|
||||||
|
MemSlots: h.defaultMemSlots(),
|
||||||
|
EntropySource: h.GetEntropySource(),
|
||||||
|
DefaultBridges: h.defaultBridges(),
|
||||||
|
HugePages: h.HugePages,
|
||||||
|
Mlock: !h.Swap,
|
||||||
|
Debug: h.Debug,
|
||||||
|
DisableNestingChecks: h.DisableNestingChecks,
|
||||||
|
BlockDeviceDriver: blockDriver,
|
||||||
|
DisableVhostNet: h.DisableVhostNet,
|
||||||
|
GuestHookPath: h.guestHookPath(),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func newFactoryConfig(f factory) (oci.FactoryConfig, error) {
|
func newFactoryConfig(f factory) (oci.FactoryConfig, error) {
|
||||||
if f.TemplatePath == "" {
|
if f.TemplatePath == "" {
|
||||||
f.TemplatePath = defaultTemplatePath
|
f.TemplatePath = defaultTemplatePath
|
||||||
@ -642,11 +715,15 @@ func updateRuntimeConfigHypervisor(configPath string, tomlConf tomlConfig, confi
|
|||||||
case qemuHypervisorTableType:
|
case qemuHypervisorTableType:
|
||||||
config.HypervisorType = vc.QemuHypervisor
|
config.HypervisorType = vc.QemuHypervisor
|
||||||
hConfig, err = newQemuHypervisorConfig(hypervisor)
|
hConfig, err = newQemuHypervisorConfig(hypervisor)
|
||||||
|
case acrnHypervisorTableType:
|
||||||
|
config.HypervisorType = vc.AcrnHypervisor
|
||||||
|
hConfig, err = newAcrnHypervisorConfig(hypervisor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%v: %v", configPath, err)
|
return fmt.Errorf("%v: %v", configPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.HypervisorConfig = hConfig
|
config.HypervisorConfig = hConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@ const (
|
|||||||
// QemuHypervisor is the QEMU hypervisor.
|
// QemuHypervisor is the QEMU hypervisor.
|
||||||
QemuHypervisor HypervisorType = "qemu"
|
QemuHypervisor HypervisorType = "qemu"
|
||||||
|
|
||||||
|
// AcrnHypervisor is the ACRN hypervisor.
|
||||||
|
AcrnHypervisor HypervisorType = "acrn"
|
||||||
|
|
||||||
// MockHypervisor is a mock hypervisor for testing purposes
|
// MockHypervisor is a mock hypervisor for testing purposes
|
||||||
MockHypervisor HypervisorType = "mock"
|
MockHypervisor HypervisorType = "mock"
|
||||||
)
|
)
|
||||||
@ -212,6 +215,9 @@ type HypervisorConfig struct {
|
|||||||
// HypervisorPath is the hypervisor executable host path.
|
// HypervisorPath is the hypervisor executable host path.
|
||||||
HypervisorPath string
|
HypervisorPath string
|
||||||
|
|
||||||
|
// HypervisorCtlPath is the hypervisor ctl executable host path.
|
||||||
|
HypervisorCtlPath string
|
||||||
|
|
||||||
// BlockDeviceDriver specifies the driver to be used for block device
|
// BlockDeviceDriver specifies the driver to be used for block device
|
||||||
// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
|
// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
|
||||||
BlockDeviceDriver string
|
BlockDeviceDriver string
|
||||||
|
Loading…
Reference in New Issue
Block a user