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

Commit

Permalink
virtcontainers: check minimum supported version of firecracker
Browse files Browse the repository at this point in the history
Check minimum supported version of firecracker to make sure it's compatible
with kata containers

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed Sep 20, 2019
1 parent 8680db6 commit 3d0949d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion virtcontainers/fc.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/blang/semver"
"github.com/kata-containers/runtime/virtcontainers/device/config"
fcmodels "github.com/kata-containers/runtime/virtcontainers/pkg/firecracker/client/models"
"github.com/kata-containers/runtime/virtcontainers/store"
"github.com/kata-containers/runtime/virtcontainers/types"
"github.com/kata-containers/runtime/virtcontainers/utils"
Expand Down Expand Up @@ -66,6 +68,9 @@ const (
defaultGuestVSockCID = int64(0x3)
)

// Specify the minimum version of firecracker supported
var fcMinSupportedVersion = semver.MustParse("0.18.0")

var fcKernelParams = append(commonVirtioblkKernelRootParams, []Param{
// The boot source is the first partition of the first block device added
{"pci", "off"},
Expand Down Expand Up @@ -296,6 +301,23 @@ func (fc *firecracker) vmRunning() bool {
}
}

func (fc *firecracker) checkVersion(vmmInfo *fcmodels.InstanceInfo) error {
if vmmInfo == nil || vmmInfo.VmmVersion == nil {
return fmt.Errorf("Unknown firecracker version")
}

v, err := semver.Make(*vmmInfo.VmmVersion)
if err != nil {
return fmt.Errorf("Malformed firecracker version: %v", err)
}

if v.LT(fcMinSupportedVersion) {
return fmt.Errorf("version %v is not supported. Minimum supported version of firecracker is %v", v.String(), fcMinSupportedVersion.String())
}

return nil
}

// waitVMM will wait for timeout seconds for the VMM to be up and running.
// This does not mean that the VM is up and running. It only indicates that the VMM is up and
// running and able to handle commands to setup and launch a VM
Expand All @@ -309,8 +331,11 @@ func (fc *firecracker) waitVMM(timeout int) error {

timeStart := time.Now()
for {
_, err := fc.client().Operations.DescribeInstance(nil)
vmmInfo, err := fc.client().Operations.DescribeInstance(nil)
if err == nil {
if err := fc.checkVersion(vmmInfo.Payload); err != nil {
return err
}
return nil
}

Expand Down

0 comments on commit 3d0949d

Please sign in to comment.