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

Commit

Permalink
firecracker: Update virtcontainer to use latest swagger definition
Browse files Browse the repository at this point in the history
Update virtcontainer to use latest swagger definition.
Most changes are around mandatory parameters which need to be
passed in via pointers so that the absence of the same can be
detected (vs using default values).

Signed-off-by: Manohar Castelino <[email protected]>
  • Loading branch information
mcastelino committed Jun 20, 2019
1 parent 1e9e00a commit 4d526db
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions virtcontainers/fc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"syscall"
"time"

"github.com/firecracker-microvm/firecracker-go-sdk/client"
models "github.com/firecracker-microvm/firecracker-go-sdk/client/models"
ops "github.com/firecracker-microvm/firecracker-go-sdk/client/operations"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/kata-containers/runtime/virtcontainers/pkg/firecracker/client"
models "github.com/kata-containers/runtime/virtcontainers/pkg/firecracker/client/models"
ops "github.com/kata-containers/runtime/virtcontainers/pkg/firecracker/client/operations"
opentracing "github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -195,7 +195,7 @@ func (fc *firecracker) vmRunning() bool {
}

// Be explicit
switch resp.Payload.State {
switch *resp.Payload.State {
case models.InstanceInfoStateStarting:
// Unsure what we should do here
fc.Logger().WithField("unexpected-state", models.InstanceInfoStateStarting).Debug("vmRunning")
Expand Down Expand Up @@ -370,9 +370,9 @@ func (fc *firecracker) fcSetVMBaseConfig(mem int64, vcpus int64, htEnabled bool)

param := ops.NewPutMachineConfigurationParams()
cfg := &models.MachineConfiguration{
HtEnabled: htEnabled,
MemSizeMib: mem,
VcpuCount: vcpus,
HtEnabled: &htEnabled,
MemSizeMib: &mem,
VcpuCount: &vcpus,
}
param.SetBody(cfg)
_, err := fc.client().Operations.PutMachineConfiguration(param)
Expand All @@ -389,8 +389,9 @@ func (fc *firecracker) fcStartVM() error {
fc.fcClient = fc.newFireClient()

actionParams := ops.NewCreateSyncActionParams()
actionType := "InstanceStart"
actionInfo := &models.InstanceActionInfo{
ActionType: "InstanceStart",
ActionType: &actionType,
}
actionParams.SetInfo(actionInfo)
_, err := fc.client().Operations.CreateSyncAction(actionParams)
Expand Down Expand Up @@ -535,8 +536,9 @@ func (fc *firecracker) fcAddVsock(vs kataVSOCK) error {

vsockParams := ops.NewPutGuestVsockByIDParams()
vsockID := "root"
ctxID := int64(vs.contextID)
vsock := &models.Vsock{
GuestCid: int64(vs.contextID),
GuestCid: &ctxID,
ID: &vsockID,
}
vsockParams.SetID(vsockID)
Expand All @@ -562,7 +564,7 @@ func (fc *firecracker) fcAddNetDevice(endpoint Endpoint) error {
AllowMmdsRequests: false,
GuestMac: endpoint.HardwareAddr(),
IfaceID: &ifaceID,
HostDevName: endpoint.NetworkPair().TapInterface.TAPIface.Name,
HostDevName: &endpoint.NetworkPair().TapInterface.TAPIface.Name,
}
cfg.SetBody(ifaceCfg)
cfg.SetIfaceID(ifaceID)
Expand Down Expand Up @@ -614,8 +616,9 @@ func (fc *firecracker) fcUpdateBlockDrive(drive config.BlockDrive) error {
// Rescan needs to used only if the VM is running
if fc.vmRunning() {
actionParams := ops.NewCreateSyncActionParams()
actionType := "BlockDeviceRescan"
actionInfo := &models.InstanceActionInfo{
ActionType: "BlockDeviceRescan",
ActionType: &actionType,
Payload: driveID,
}
actionParams.SetInfo(actionInfo)
Expand Down

0 comments on commit 4d526db

Please sign in to comment.