virtcontainers/fc: Upgrade Firecracker to v0.23.1

This patch upgrades Firecracker version from v0.21.1 to v0.23.1

* Generate swagger models for v0.23.1 (from firecracker.yaml)
* Change uint64 types in TokenBucket object according to rate-limiter
implementation (introduced in commit #cfeb966)
* Update Firecracker Logger/Metrics to support the new API
* Update payload in fc.vmRunning to support the new API
* Add Metrics type to fcConfig

Fixes: #1518

Signed-off-by: Orestis Lagkas Nikolos <olagkasn@nubificus.co.uk>
This commit is contained in:
Orestis Lagkas Nikolos 2021-03-16 14:12:10 -05:00
parent 9c8e95c820
commit 6255cc1959
25 changed files with 2382 additions and 266 deletions

View File

@ -273,20 +273,8 @@ func (fc *firecracker) vmRunning(ctx context.Context) bool {
fc.Logger().WithError(err).Error("getting vm status failed") fc.Logger().WithError(err).Error("getting vm status failed")
return false return false
} }
// The current state of the Firecracker instance (swagger:model InstanceInfo)
// Be explicit return resp.Payload.Started
switch *resp.Payload.State {
case models.InstanceInfoStateStarting:
// Unsure what we should do here
fc.Logger().WithField("unexpected-state", models.InstanceInfoStateStarting).Debug("vmRunning")
return false
case models.InstanceInfoStateRunning:
return true
case models.InstanceInfoStateUninitialized:
return false
default:
return false
}
} }
func (fc *firecracker) getVersionNumber() (string, error) { func (fc *firecracker) getVersionNumber() (string, error) {
@ -302,7 +290,7 @@ func (fc *firecracker) getVersionNumber() (string, error) {
fields := strings.Split(string(data), " ") fields := strings.Split(string(data), " ")
if len(fields) > 1 { if len(fields) > 1 {
// The output format of `Firecracker --verion` is as follows // The output format of `Firecracker --verion` is as follows
// Firecracker v0.21.1 // Firecracker v0.23.1
version = strings.TrimPrefix(strings.TrimSpace(fields[1]), "v") version = strings.TrimPrefix(strings.TrimSpace(fields[1]), "v")
return version, nil return version, nil
} }
@ -612,16 +600,26 @@ func (fc *firecracker) fcSetLogger(ctx context.Context) error {
return fmt.Errorf("Failed setting log: %s", err) return fmt.Errorf("Failed setting log: %s", err)
} }
fc.fcConfig.Logger = &models.Logger{
Level: &fcLogLevel,
LogPath: &jailedLogFifo,
}
return err
}
func (fc *firecracker) fcSetMetrics(ctx context.Context) error {
span, _ := fc.trace(ctx, "fcSetMetrics")
defer span.End()
// listen to metrics file and transfer error info // listen to metrics file and transfer error info
jailedMetricsFifo, err := fc.fcListenToFifo(fcMetricsFifo, fc.updateMetrics) jailedMetricsFifo, err := fc.fcListenToFifo(fcMetricsFifo, fc.updateMetrics)
if err != nil { if err != nil {
return fmt.Errorf("Failed setting log: %s", err) return fmt.Errorf("Failed setting log: %s", err)
} }
fc.fcConfig.Logger = &models.Logger{ fc.fcConfig.Metrics = &models.Metrics{
Level: &fcLogLevel, MetricsPath: &jailedMetricsFifo,
LogFifo: &jailedLogFifo,
MetricsFifo: &jailedMetricsFifo,
} }
return err return err
@ -745,6 +743,10 @@ func (fc *firecracker) fcInitConfiguration(ctx context.Context) error {
return err return err
} }
if err := fc.fcSetMetrics(ctx); err != nil {
return err
}
fc.state.set(cfReady) fc.state.set(cfReady)
for _, d := range fc.pendingDevices { for _, d := range fc.pendingDevices {
if err := fc.addDevice(ctx, d.dev, d.devType); err != nil { if err := fc.addDevice(ctx, d.dev, d.devType); err != nil {

View File

@ -20,6 +20,9 @@ type BootSource struct {
// Kernel boot arguments // Kernel boot arguments
BootArgs string `json:"boot_args,omitempty"` BootArgs string `json:"boot_args,omitempty"`
// Host level path to the initrd image used to boot the guest
InitrdPath string `json:"initrd_path,omitempty"`
// Host level path to the kernel image used to boot the guest // Host level path to the kernel image used to boot the guest
// Required: true // Required: true
KernelImagePath *string `json:"kernel_image_path"` KernelImagePath *string `json:"kernel_image_path"`

View File

@ -6,8 +6,6 @@ package models
// Editing this file might prove futile when you re-run the swagger generate command // Editing this file might prove futile when you re-run the swagger generate command
import ( import (
"encoding/json"
strfmt "github.com/go-openapi/strfmt" strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors" "github.com/go-openapi/errors"
@ -19,14 +17,15 @@ import (
// swagger:model InstanceInfo // swagger:model InstanceInfo
type InstanceInfo struct { type InstanceInfo struct {
// Application name.
AppName string `json:"app_name,omitempty"`
// MicroVM / instance ID. // MicroVM / instance ID.
// Required: true // Required: true
ID *string `json:"id"` ID *string `json:"id"`
// The current detailed state of the Firecracker instance. This value is read-only for the control-plane. // The current detailed state of the Firecracker instance. This value is read-only for the control-plane.
// Required: true Started bool `json:"started,omitempty"`
// Enum: [Uninitialized Starting Running]
State *string `json:"state"`
// MicroVM hypervisor build version. // MicroVM hypervisor build version.
// Required: true // Required: true
@ -41,10 +40,6 @@ func (m *InstanceInfo) Validate(formats strfmt.Registry) error {
res = append(res, err) res = append(res, err)
} }
if err := m.validateState(formats); err != nil {
res = append(res, err)
}
if err := m.validateVmmVersion(formats); err != nil { if err := m.validateVmmVersion(formats); err != nil {
res = append(res, err) res = append(res, err)
} }
@ -64,52 +59,6 @@ func (m *InstanceInfo) validateID(formats strfmt.Registry) error {
return nil return nil
} }
var instanceInfoTypeStatePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["Uninitialized","Starting","Running"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
instanceInfoTypeStatePropEnum = append(instanceInfoTypeStatePropEnum, v)
}
}
const (
// InstanceInfoStateUninitialized captures enum value "Uninitialized"
InstanceInfoStateUninitialized string = "Uninitialized"
// InstanceInfoStateStarting captures enum value "Starting"
InstanceInfoStateStarting string = "Starting"
// InstanceInfoStateRunning captures enum value "Running"
InstanceInfoStateRunning string = "Running"
)
// prop value enum
func (m *InstanceInfo) validateStateEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, instanceInfoTypeStatePropEnum); err != nil {
return err
}
return nil
}
func (m *InstanceInfo) validateState(formats strfmt.Registry) error {
if err := validate.Required("state", "body", m.State); err != nil {
return err
}
// value enum
if err := m.validateStateEnum("state", "body", *m.State); err != nil {
return err
}
return nil
}
func (m *InstanceInfo) validateVmmVersion(formats strfmt.Registry) error { func (m *InstanceInfo) validateVmmVersion(formats strfmt.Registry) error {
if err := validate.Required("vmm_version", "body", m.VmmVersion); err != nil { if err := validate.Required("vmm_version", "body", m.VmmVersion); err != nil {

View File

@ -19,17 +19,13 @@ import (
// swagger:model Logger // swagger:model Logger
type Logger struct { type Logger struct {
// Set the level. // Set the level. The possible values are case-insensitive.
// Enum: [Error Warning Info Debug] // Enum: [Error Warning Info Debug]
Level *string `json:"level,omitempty"` Level *string `json:"level,omitempty"`
// The named pipe for the human readable log output. // Path to the named pipe or file for the human readable log output.
// Required: true // Required: true
LogFifo *string `json:"log_fifo"` LogPath *string `json:"log_path"`
// The named pipe where the JSON-formatted metrics will be flushed.
// Required: true
MetricsFifo *string `json:"metrics_fifo"`
// Whether or not to output the level in the logs. // Whether or not to output the level in the logs.
ShowLevel *bool `json:"show_level,omitempty"` ShowLevel *bool `json:"show_level,omitempty"`
@ -46,11 +42,7 @@ func (m *Logger) Validate(formats strfmt.Registry) error {
res = append(res, err) res = append(res, err)
} }
if err := m.validateLogFifo(formats); err != nil { if err := m.validateLogPath(formats); err != nil {
res = append(res, err)
}
if err := m.validateMetricsFifo(formats); err != nil {
res = append(res, err) res = append(res, err)
} }
@ -109,18 +101,9 @@ func (m *Logger) validateLevel(formats strfmt.Registry) error {
return nil return nil
} }
func (m *Logger) validateLogFifo(formats strfmt.Registry) error { func (m *Logger) validateLogPath(formats strfmt.Registry) error {
if err := validate.Required("log_fifo", "body", m.LogFifo); err != nil { if err := validate.Required("log_path", "body", m.LogPath); err != nil {
return err
}
return nil
}
func (m *Logger) validateMetricsFifo(formats strfmt.Registry) error {
if err := validate.Required("metrics_fifo", "body", m.MetricsFifo); err != nil {
return err return err
} }

View File

@ -28,6 +28,9 @@ type MachineConfiguration struct {
// Required: true // Required: true
MemSizeMib *int64 `json:"mem_size_mib"` MemSizeMib *int64 `json:"mem_size_mib"`
// Enable dirty page tracking. If this is enabled, then incremental guest memory snapshots can be created. These belong to diff snapshots, which contain, besides the microVM state, only the memory dirtied since a previous snapshot. Full snapshots each contain a full copy of the guest memory.
TrackDirtyPages bool `json:"track_dirty_pages,omitempty"`
// Number of vCPUs (either 1 or an even number) // Number of vCPUs (either 1 or an even number)
// Required: true // Required: true
// Maximum: 32 // Maximum: 32

View File

@ -0,0 +1,64 @@
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Metrics Describes the configuration option for the metrics capability.
// swagger:model Metrics
type Metrics struct {
// Path to the named pipe or file where the JSON-formatted metrics are flushed.
// Required: true
MetricsPath *string `json:"metrics_path"`
}
// Validate validates this metrics
func (m *Metrics) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateMetricsPath(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Metrics) validateMetricsPath(formats strfmt.Registry) error {
if err := validate.Required("metrics_path", "body", m.MetricsPath); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *Metrics) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Metrics) UnmarshalBinary(b []byte) error {
var res Metrics
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,43 @@
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// MmdsConfig Defines the MMDS configuration.
// swagger:model MmdsConfig
type MmdsConfig struct {
// A valid IPv4 link-local address.
IPV4Address *string `json:"ipv4_address,omitempty"`
}
// Validate validates this mmds config
func (m *MmdsConfig) Validate(formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *MmdsConfig) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *MmdsConfig) UnmarshalBinary(b []byte) error {
var res MmdsConfig
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,134 @@
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SnapshotCreateParams snapshot create params
// swagger:model SnapshotCreateParams
type SnapshotCreateParams struct {
// Path to the file that will contain the guest memory.
// Required: true
MemFilePath *string `json:"mem_file_path"`
// Path to the file that will contain the microVM state.
// Required: true
SnapshotPath *string `json:"snapshot_path"`
// Type of snapshot to create. It is optional and by default, a full snapshot is created.
// Enum: [Full]
SnapshotType string `json:"snapshot_type,omitempty"`
// The microVM version for which we want to create the snapshot. It is optional and it defaults to the current version.
Version string `json:"version,omitempty"`
}
// Validate validates this snapshot create params
func (m *SnapshotCreateParams) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateMemFilePath(formats); err != nil {
res = append(res, err)
}
if err := m.validateSnapshotPath(formats); err != nil {
res = append(res, err)
}
if err := m.validateSnapshotType(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *SnapshotCreateParams) validateMemFilePath(formats strfmt.Registry) error {
if err := validate.Required("mem_file_path", "body", m.MemFilePath); err != nil {
return err
}
return nil
}
func (m *SnapshotCreateParams) validateSnapshotPath(formats strfmt.Registry) error {
if err := validate.Required("snapshot_path", "body", m.SnapshotPath); err != nil {
return err
}
return nil
}
var snapshotCreateParamsTypeSnapshotTypePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["Full"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
snapshotCreateParamsTypeSnapshotTypePropEnum = append(snapshotCreateParamsTypeSnapshotTypePropEnum, v)
}
}
const (
// SnapshotCreateParamsSnapshotTypeFull captures enum value "Full"
SnapshotCreateParamsSnapshotTypeFull string = "Full"
)
// prop value enum
func (m *SnapshotCreateParams) validateSnapshotTypeEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, snapshotCreateParamsTypeSnapshotTypePropEnum); err != nil {
return err
}
return nil
}
func (m *SnapshotCreateParams) validateSnapshotType(formats strfmt.Registry) error {
if swag.IsZero(m.SnapshotType) { // not required
return nil
}
// value enum
if err := m.validateSnapshotTypeEnum("snapshot_type", "body", m.SnapshotType); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *SnapshotCreateParams) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *SnapshotCreateParams) UnmarshalBinary(b []byte) error {
var res SnapshotCreateParams
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,84 @@
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// SnapshotLoadParams snapshot load params
// swagger:model SnapshotLoadParams
type SnapshotLoadParams struct {
// Enable support for incremental (diff) snapshots by tracking dirty guest pages.
EnableDiffSnapshots bool `json:"enable_diff_snapshots,omitempty"`
// Path to the file that contains the guest memory to be loaded.
// Required: true
MemFilePath *string `json:"mem_file_path"`
// Path to the file that contains the microVM state to be loaded.
// Required: true
SnapshotPath *string `json:"snapshot_path"`
}
// Validate validates this snapshot load params
func (m *SnapshotLoadParams) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateMemFilePath(formats); err != nil {
res = append(res, err)
}
if err := m.validateSnapshotPath(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *SnapshotLoadParams) validateMemFilePath(formats strfmt.Registry) error {
if err := validate.Required("mem_file_path", "body", m.MemFilePath); err != nil {
return err
}
return nil
}
func (m *SnapshotLoadParams) validateSnapshotPath(formats strfmt.Registry) error {
if err := validate.Required("snapshot_path", "body", m.SnapshotPath); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *SnapshotLoadParams) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *SnapshotLoadParams) UnmarshalBinary(b []byte) error {
var res SnapshotLoadParams
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,101 @@
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// VM Defines the microVM running state. It is especially useful in the snapshotting context.
// swagger:model Vm
type VM struct {
// state
// Required: true
// Enum: [Paused Resumed]
State *string `json:"state"`
}
// Validate validates this Vm
func (m *VM) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateState(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var vmTypeStatePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["Paused","Resumed"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
vmTypeStatePropEnum = append(vmTypeStatePropEnum, v)
}
}
const (
// VMStatePaused captures enum value "Paused"
VMStatePaused string = "Paused"
// VMStateResumed captures enum value "Resumed"
VMStateResumed string = "Resumed"
)
// prop value enum
func (m *VM) validateStateEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, vmTypeStatePropEnum); err != nil {
return err
}
return nil
}
func (m *VM) validateState(formats strfmt.Registry) error {
if err := validate.Required("state", "body", m.State); err != nil {
return err
}
// value enum
if err := m.validateStateEnum("state", "body", *m.State); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *VM) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *VM) UnmarshalBinary(b []byte) error {
var res VM
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,139 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// NewCreateSnapshotParams creates a new CreateSnapshotParams object
// with the default values initialized.
func NewCreateSnapshotParams() *CreateSnapshotParams {
var ()
return &CreateSnapshotParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateSnapshotParamsWithTimeout creates a new CreateSnapshotParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewCreateSnapshotParamsWithTimeout(timeout time.Duration) *CreateSnapshotParams {
var ()
return &CreateSnapshotParams{
timeout: timeout,
}
}
// NewCreateSnapshotParamsWithContext creates a new CreateSnapshotParams object
// with the default values initialized, and the ability to set a context for a request
func NewCreateSnapshotParamsWithContext(ctx context.Context) *CreateSnapshotParams {
var ()
return &CreateSnapshotParams{
Context: ctx,
}
}
// NewCreateSnapshotParamsWithHTTPClient creates a new CreateSnapshotParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewCreateSnapshotParamsWithHTTPClient(client *http.Client) *CreateSnapshotParams {
var ()
return &CreateSnapshotParams{
HTTPClient: client,
}
}
/*CreateSnapshotParams contains all the parameters to send to the API endpoint
for the create snapshot operation typically these are written to a http.Request
*/
type CreateSnapshotParams struct {
/*Body
The configuration used for creating a snaphot.
*/
Body *models.SnapshotCreateParams
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the create snapshot params
func (o *CreateSnapshotParams) WithTimeout(timeout time.Duration) *CreateSnapshotParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create snapshot params
func (o *CreateSnapshotParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create snapshot params
func (o *CreateSnapshotParams) WithContext(ctx context.Context) *CreateSnapshotParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create snapshot params
func (o *CreateSnapshotParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create snapshot params
func (o *CreateSnapshotParams) WithHTTPClient(client *http.Client) *CreateSnapshotParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create snapshot params
func (o *CreateSnapshotParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create snapshot params
func (o *CreateSnapshotParams) WithBody(body *models.SnapshotCreateParams) *CreateSnapshotParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create snapshot params
func (o *CreateSnapshotParams) SetBody(body *models.SnapshotCreateParams) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *CreateSnapshotParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Body != nil {
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,140 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// CreateSnapshotReader is a Reader for the CreateSnapshot structure.
type CreateSnapshotReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateSnapshotReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 204:
result := NewCreateSnapshotNoContent()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewCreateSnapshotBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
result := NewCreateSnapshotDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewCreateSnapshotNoContent creates a CreateSnapshotNoContent with default headers values
func NewCreateSnapshotNoContent() *CreateSnapshotNoContent {
return &CreateSnapshotNoContent{}
}
/*CreateSnapshotNoContent handles this case with default header values.
Snapshot created
*/
type CreateSnapshotNoContent struct {
}
func (o *CreateSnapshotNoContent) Error() string {
return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshotNoContent ", 204)
}
func (o *CreateSnapshotNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewCreateSnapshotBadRequest creates a CreateSnapshotBadRequest with default headers values
func NewCreateSnapshotBadRequest() *CreateSnapshotBadRequest {
return &CreateSnapshotBadRequest{}
}
/*CreateSnapshotBadRequest handles this case with default header values.
Snapshot cannot be created due to bad input
*/
type CreateSnapshotBadRequest struct {
Payload *models.Error
}
func (o *CreateSnapshotBadRequest) Error() string {
return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshotBadRequest %+v", 400, o.Payload)
}
func (o *CreateSnapshotBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewCreateSnapshotDefault creates a CreateSnapshotDefault with default headers values
func NewCreateSnapshotDefault(code int) *CreateSnapshotDefault {
return &CreateSnapshotDefault{
_statusCode: code,
}
}
/*CreateSnapshotDefault handles this case with default header values.
Internal server error
*/
type CreateSnapshotDefault struct {
_statusCode int
Payload *models.Error
}
// Code gets the status code for the create snapshot default response
func (o *CreateSnapshotDefault) Code() int {
return o._statusCode
}
func (o *CreateSnapshotDefault) Error() string {
return fmt.Sprintf("[PUT /snapshot/create][%d] createSnapshot default %+v", o._statusCode, o.Payload)
}
func (o *CreateSnapshotDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -32,8 +32,8 @@ func (o *GetMmdsReader) ReadResponse(response runtime.ClientResponse, consumer r
} }
return result, nil return result, nil
case 400: case 404:
result := NewGetMmdsBadRequest() result := NewGetMmdsNotFound()
if err := result.readResponse(response, consumer, o.formats); err != nil { if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err return nil, err
} }
@ -78,24 +78,24 @@ func (o *GetMmdsOK) readResponse(response runtime.ClientResponse, consumer runti
return nil return nil
} }
// NewGetMmdsBadRequest creates a GetMmdsBadRequest with default headers values // NewGetMmdsNotFound creates a GetMmdsNotFound with default headers values
func NewGetMmdsBadRequest() *GetMmdsBadRequest { func NewGetMmdsNotFound() *GetMmdsNotFound {
return &GetMmdsBadRequest{} return &GetMmdsNotFound{}
} }
/*GetMmdsBadRequest handles this case with default header values. /*GetMmdsNotFound handles this case with default header values.
Cannot get the MMDS data store due to bad input. The MMDS data store content can not be found.
*/ */
type GetMmdsBadRequest struct { type GetMmdsNotFound struct {
Payload *models.Error Payload *models.Error
} }
func (o *GetMmdsBadRequest) Error() string { func (o *GetMmdsNotFound) Error() string {
return fmt.Sprintf("[GET /mmds][%d] getMmdsBadRequest %+v", 400, o.Payload) return fmt.Sprintf("[GET /mmds][%d] getMmdsNotFound %+v", 404, o.Payload)
} }
func (o *GetMmdsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { func (o *GetMmdsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error) o.Payload = new(models.Error)

View File

@ -0,0 +1,139 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// NewLoadSnapshotParams creates a new LoadSnapshotParams object
// with the default values initialized.
func NewLoadSnapshotParams() *LoadSnapshotParams {
var ()
return &LoadSnapshotParams{
timeout: cr.DefaultTimeout,
}
}
// NewLoadSnapshotParamsWithTimeout creates a new LoadSnapshotParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewLoadSnapshotParamsWithTimeout(timeout time.Duration) *LoadSnapshotParams {
var ()
return &LoadSnapshotParams{
timeout: timeout,
}
}
// NewLoadSnapshotParamsWithContext creates a new LoadSnapshotParams object
// with the default values initialized, and the ability to set a context for a request
func NewLoadSnapshotParamsWithContext(ctx context.Context) *LoadSnapshotParams {
var ()
return &LoadSnapshotParams{
Context: ctx,
}
}
// NewLoadSnapshotParamsWithHTTPClient creates a new LoadSnapshotParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewLoadSnapshotParamsWithHTTPClient(client *http.Client) *LoadSnapshotParams {
var ()
return &LoadSnapshotParams{
HTTPClient: client,
}
}
/*LoadSnapshotParams contains all the parameters to send to the API endpoint
for the load snapshot operation typically these are written to a http.Request
*/
type LoadSnapshotParams struct {
/*Body
The configuration used for loading a snaphot.
*/
Body *models.SnapshotLoadParams
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the load snapshot params
func (o *LoadSnapshotParams) WithTimeout(timeout time.Duration) *LoadSnapshotParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the load snapshot params
func (o *LoadSnapshotParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the load snapshot params
func (o *LoadSnapshotParams) WithContext(ctx context.Context) *LoadSnapshotParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the load snapshot params
func (o *LoadSnapshotParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the load snapshot params
func (o *LoadSnapshotParams) WithHTTPClient(client *http.Client) *LoadSnapshotParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the load snapshot params
func (o *LoadSnapshotParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the load snapshot params
func (o *LoadSnapshotParams) WithBody(body *models.SnapshotLoadParams) *LoadSnapshotParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the load snapshot params
func (o *LoadSnapshotParams) SetBody(body *models.SnapshotLoadParams) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *LoadSnapshotParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Body != nil {
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,140 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// LoadSnapshotReader is a Reader for the LoadSnapshot structure.
type LoadSnapshotReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *LoadSnapshotReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 204:
result := NewLoadSnapshotNoContent()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewLoadSnapshotBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
result := NewLoadSnapshotDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewLoadSnapshotNoContent creates a LoadSnapshotNoContent with default headers values
func NewLoadSnapshotNoContent() *LoadSnapshotNoContent {
return &LoadSnapshotNoContent{}
}
/*LoadSnapshotNoContent handles this case with default header values.
Snapshot loaded
*/
type LoadSnapshotNoContent struct {
}
func (o *LoadSnapshotNoContent) Error() string {
return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshotNoContent ", 204)
}
func (o *LoadSnapshotNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewLoadSnapshotBadRequest creates a LoadSnapshotBadRequest with default headers values
func NewLoadSnapshotBadRequest() *LoadSnapshotBadRequest {
return &LoadSnapshotBadRequest{}
}
/*LoadSnapshotBadRequest handles this case with default header values.
Snapshot cannot be loaded due to bad input
*/
type LoadSnapshotBadRequest struct {
Payload *models.Error
}
func (o *LoadSnapshotBadRequest) Error() string {
return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshotBadRequest %+v", 400, o.Payload)
}
func (o *LoadSnapshotBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewLoadSnapshotDefault creates a LoadSnapshotDefault with default headers values
func NewLoadSnapshotDefault(code int) *LoadSnapshotDefault {
return &LoadSnapshotDefault{
_statusCode: code,
}
}
/*LoadSnapshotDefault handles this case with default header values.
Internal server error
*/
type LoadSnapshotDefault struct {
_statusCode int
Payload *models.Error
}
// Code gets the status code for the load snapshot default response
func (o *LoadSnapshotDefault) Code() int {
return o._statusCode
}
func (o *LoadSnapshotDefault) Error() string {
return fmt.Sprintf("[PUT /snapshot/load][%d] loadSnapshot default %+v", o._statusCode, o.Payload)
}
func (o *LoadSnapshotDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -108,6 +108,66 @@ func (a *Client) PutMmds(params *PutMmdsParams) (*PutMmdsNoContent, error) {
} }
/*
PutMmdsConfig sets m m d s configuration pre boot only
Creates MMDS configuration to be used by the MMDS network stack.
*/
func (a *Client) PutMmdsConfig(params *PutMmdsConfigParams) (*PutMmdsConfigNoContent, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPutMmdsConfigParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "PutMmdsConfig",
Method: "PUT",
PathPattern: "/mmds/config",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &PutMmdsConfigReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*PutMmdsConfigNoContent), nil
}
/*
CreateSnapshot creates a full snapshot post boot only
Creates a snapshot of the microVM state. The microVM should be in the `Paused` state.
*/
func (a *Client) CreateSnapshot(params *CreateSnapshotParams) (*CreateSnapshotNoContent, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateSnapshotParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "createSnapshot",
Method: "PUT",
PathPattern: "/snapshot/create",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &CreateSnapshotReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*CreateSnapshotNoContent), nil
}
/* /*
CreateSyncAction creates a synchronous action CreateSyncAction creates a synchronous action
*/ */
@ -195,7 +255,37 @@ func (a *Client) GetMachineConfiguration(params *GetMachineConfigurationParams)
} }
/* /*
PatchGuestDriveByID updates the properties of a drive LoadSnapshot loads a snapshot pre boot only
Loads the microVM state from a snapshot. Only accepted on a fresh Firecracker process (before configuring any resource other than the Logger and Metrics).
*/
func (a *Client) LoadSnapshot(params *LoadSnapshotParams) (*LoadSnapshotNoContent, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewLoadSnapshotParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "loadSnapshot",
Method: "PUT",
PathPattern: "/snapshot/load",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &LoadSnapshotReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*LoadSnapshotNoContent), nil
}
/*
PatchGuestDriveByID updates the properties of a drive post boot only
Updates the properties of the drive with the ID specified by drive_id path parameter. Will fail if update is not possible. Updates the properties of the drive with the ID specified by drive_id path parameter. Will fail if update is not possible.
*/ */
@ -225,7 +315,7 @@ func (a *Client) PatchGuestDriveByID(params *PatchGuestDriveByIDParams) (*PatchG
} }
/* /*
PatchGuestNetworkInterfaceByID updates the rate limiters applied to a network interface PatchGuestNetworkInterfaceByID updates the rate limiters applied to a network interface post boot only
Updates the rate limiters applied to a network interface. Updates the rate limiters applied to a network interface.
*/ */
@ -255,7 +345,7 @@ func (a *Client) PatchGuestNetworkInterfaceByID(params *PatchGuestNetworkInterfa
} }
/* /*
PatchMachineConfiguration partiallies updates the machine configuration of the VM PatchMachineConfiguration partiallies updates the machine configuration of the VM pre boot only
Partially updates the Virtual Machine Configuration with the specified input. If any of the parameters has an incorrect value, the whole update fails. Partially updates the Virtual Machine Configuration with the specified input. If any of the parameters has an incorrect value, the whole update fails.
*/ */
@ -285,9 +375,39 @@ func (a *Client) PatchMachineConfiguration(params *PatchMachineConfigurationPara
} }
/* /*
PutGuestBootSource creates or updates the boot source PatchVM updates the micro VM state
Creates new boot source if one does not already exist, otherwise updates it. Will fail if update is not possible. Note that the only currently supported boot source is LocalImage. Sets the desired state (Paused or Resumed) for the microVM.
*/
func (a *Client) PatchVM(params *PatchVMParams) (*PatchVMNoContent, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPatchVMParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "patchVm",
Method: "PATCH",
PathPattern: "/vm",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &PatchVMReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*PatchVMNoContent), nil
}
/*
PutGuestBootSource creates or updates the boot source pre boot only
Creates new boot source if one does not already exist, otherwise updates it. Will fail if update is not possible.
*/ */
func (a *Client) PutGuestBootSource(params *PutGuestBootSourceParams) (*PutGuestBootSourceNoContent, error) { func (a *Client) PutGuestBootSource(params *PutGuestBootSourceParams) (*PutGuestBootSourceNoContent, error) {
// TODO: Validate the params before sending // TODO: Validate the params before sending
@ -315,7 +435,7 @@ func (a *Client) PutGuestBootSource(params *PutGuestBootSourceParams) (*PutGuest
} }
/* /*
PutGuestDriveByID creates or updates a drive PutGuestDriveByID creates or updates a drive pre boot only
Creates new drive with ID specified by drive_id path parameter. If a drive with the specified ID already exists, updates its state based on new input. Will fail if update is not possible. Creates new drive with ID specified by drive_id path parameter. If a drive with the specified ID already exists, updates its state based on new input. Will fail if update is not possible.
*/ */
@ -345,7 +465,7 @@ func (a *Client) PutGuestDriveByID(params *PutGuestDriveByIDParams) (*PutGuestDr
} }
/* /*
PutGuestNetworkInterfaceByID creates a network interface PutGuestNetworkInterfaceByID creates a network interface pre boot only
Creates new network interface with ID specified by iface_id path parameter. Creates new network interface with ID specified by iface_id path parameter.
*/ */
@ -375,7 +495,7 @@ func (a *Client) PutGuestNetworkInterfaceByID(params *PutGuestNetworkInterfaceBy
} }
/* /*
PutGuestVsock creates updates a vsock device PutGuestVsock creates updates a vsock device pre boot only
The first call creates the device with the configuration specified in body. Subsequent calls will update the device configuration. May fail if update is not possible. The first call creates the device with the configuration specified in body. Subsequent calls will update the device configuration. May fail if update is not possible.
*/ */
@ -405,7 +525,7 @@ func (a *Client) PutGuestVsock(params *PutGuestVsockParams) (*PutGuestVsockNoCon
} }
/* /*
PutLogger initializes the logger by specifying two named pipes i e for the logs and metrics output PutLogger initializes the logger by specifying a named pipe or a file for the logs output
*/ */
func (a *Client) PutLogger(params *PutLoggerParams) (*PutLoggerNoContent, error) { func (a *Client) PutLogger(params *PutLoggerParams) (*PutLoggerNoContent, error) {
// TODO: Validate the params before sending // TODO: Validate the params before sending
@ -433,7 +553,7 @@ func (a *Client) PutLogger(params *PutLoggerParams) (*PutLoggerNoContent, error)
} }
/* /*
PutMachineConfiguration updates the machine configuration of the VM PutMachineConfiguration updates the machine configuration of the VM pre boot only
Updates the Virtual Machine Configuration with the specified input. Firecracker starts with default values for vCPU count (=1) and memory size (=128 MiB). With Hyperthreading enabled, the vCPU count is restricted to be 1 or an even number, otherwise there are no restrictions regarding the vCPU count. If any of the parameters has an incorrect value, the whole update fails. Updates the Virtual Machine Configuration with the specified input. Firecracker starts with default values for vCPU count (=1) and memory size (=128 MiB). With Hyperthreading enabled, the vCPU count is restricted to be 1 or an even number, otherwise there are no restrictions regarding the vCPU count. If any of the parameters has an incorrect value, the whole update fails.
*/ */
@ -462,6 +582,34 @@ func (a *Client) PutMachineConfiguration(params *PutMachineConfigurationParams)
} }
/*
PutMetrics initializes the metrics system by specifying a named pipe or a file for the metrics output
*/
func (a *Client) PutMetrics(params *PutMetricsParams) (*PutMetricsNoContent, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewPutMetricsParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "putMetrics",
Method: "PUT",
PathPattern: "/metrics",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http"},
Params: params,
Reader: &PutMetricsReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*PutMetricsNoContent), nil
}
// SetTransport changes the transport on the client // SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) { func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport a.transport = transport

View File

@ -0,0 +1,139 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// NewPatchVMParams creates a new PatchVMParams object
// with the default values initialized.
func NewPatchVMParams() *PatchVMParams {
var ()
return &PatchVMParams{
timeout: cr.DefaultTimeout,
}
}
// NewPatchVMParamsWithTimeout creates a new PatchVMParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewPatchVMParamsWithTimeout(timeout time.Duration) *PatchVMParams {
var ()
return &PatchVMParams{
timeout: timeout,
}
}
// NewPatchVMParamsWithContext creates a new PatchVMParams object
// with the default values initialized, and the ability to set a context for a request
func NewPatchVMParamsWithContext(ctx context.Context) *PatchVMParams {
var ()
return &PatchVMParams{
Context: ctx,
}
}
// NewPatchVMParamsWithHTTPClient creates a new PatchVMParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewPatchVMParamsWithHTTPClient(client *http.Client) *PatchVMParams {
var ()
return &PatchVMParams{
HTTPClient: client,
}
}
/*PatchVMParams contains all the parameters to send to the API endpoint
for the patch Vm operation typically these are written to a http.Request
*/
type PatchVMParams struct {
/*Body
The microVM state
*/
Body *models.VM
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the patch Vm params
func (o *PatchVMParams) WithTimeout(timeout time.Duration) *PatchVMParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the patch Vm params
func (o *PatchVMParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the patch Vm params
func (o *PatchVMParams) WithContext(ctx context.Context) *PatchVMParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the patch Vm params
func (o *PatchVMParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the patch Vm params
func (o *PatchVMParams) WithHTTPClient(client *http.Client) *PatchVMParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the patch Vm params
func (o *PatchVMParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the patch Vm params
func (o *PatchVMParams) WithBody(body *models.VM) *PatchVMParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the patch Vm params
func (o *PatchVMParams) SetBody(body *models.VM) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *PatchVMParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Body != nil {
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,140 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// PatchVMReader is a Reader for the PatchVM structure.
type PatchVMReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *PatchVMReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 204:
result := NewPatchVMNoContent()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewPatchVMBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
result := NewPatchVMDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewPatchVMNoContent creates a PatchVMNoContent with default headers values
func NewPatchVMNoContent() *PatchVMNoContent {
return &PatchVMNoContent{}
}
/*PatchVMNoContent handles this case with default header values.
Vm state updated
*/
type PatchVMNoContent struct {
}
func (o *PatchVMNoContent) Error() string {
return fmt.Sprintf("[PATCH /vm][%d] patchVmNoContent ", 204)
}
func (o *PatchVMNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewPatchVMBadRequest creates a PatchVMBadRequest with default headers values
func NewPatchVMBadRequest() *PatchVMBadRequest {
return &PatchVMBadRequest{}
}
/*PatchVMBadRequest handles this case with default header values.
Vm state cannot be updated due to bad input
*/
type PatchVMBadRequest struct {
Payload *models.Error
}
func (o *PatchVMBadRequest) Error() string {
return fmt.Sprintf("[PATCH /vm][%d] patchVmBadRequest %+v", 400, o.Payload)
}
func (o *PatchVMBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewPatchVMDefault creates a PatchVMDefault with default headers values
func NewPatchVMDefault(code int) *PatchVMDefault {
return &PatchVMDefault{
_statusCode: code,
}
}
/*PatchVMDefault handles this case with default header values.
Internal server error
*/
type PatchVMDefault struct {
_statusCode int
Payload *models.Error
}
// Code gets the status code for the patch Vm default response
func (o *PatchVMDefault) Code() int {
return o._statusCode
}
func (o *PatchVMDefault) Error() string {
return fmt.Sprintf("[PATCH /vm][%d] patchVm default %+v", o._statusCode, o.Payload)
}
func (o *PatchVMDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,139 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// NewPutMetricsParams creates a new PutMetricsParams object
// with the default values initialized.
func NewPutMetricsParams() *PutMetricsParams {
var ()
return &PutMetricsParams{
timeout: cr.DefaultTimeout,
}
}
// NewPutMetricsParamsWithTimeout creates a new PutMetricsParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewPutMetricsParamsWithTimeout(timeout time.Duration) *PutMetricsParams {
var ()
return &PutMetricsParams{
timeout: timeout,
}
}
// NewPutMetricsParamsWithContext creates a new PutMetricsParams object
// with the default values initialized, and the ability to set a context for a request
func NewPutMetricsParamsWithContext(ctx context.Context) *PutMetricsParams {
var ()
return &PutMetricsParams{
Context: ctx,
}
}
// NewPutMetricsParamsWithHTTPClient creates a new PutMetricsParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewPutMetricsParamsWithHTTPClient(client *http.Client) *PutMetricsParams {
var ()
return &PutMetricsParams{
HTTPClient: client,
}
}
/*PutMetricsParams contains all the parameters to send to the API endpoint
for the put metrics operation typically these are written to a http.Request
*/
type PutMetricsParams struct {
/*Body
Metrics system description
*/
Body *models.Metrics
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the put metrics params
func (o *PutMetricsParams) WithTimeout(timeout time.Duration) *PutMetricsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the put metrics params
func (o *PutMetricsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the put metrics params
func (o *PutMetricsParams) WithContext(ctx context.Context) *PutMetricsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the put metrics params
func (o *PutMetricsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the put metrics params
func (o *PutMetricsParams) WithHTTPClient(client *http.Client) *PutMetricsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the put metrics params
func (o *PutMetricsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the put metrics params
func (o *PutMetricsParams) WithBody(body *models.Metrics) *PutMetricsParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the put metrics params
func (o *PutMetricsParams) SetBody(body *models.Metrics) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *PutMetricsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Body != nil {
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,140 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// PutMetricsReader is a Reader for the PutMetrics structure.
type PutMetricsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *PutMetricsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 204:
result := NewPutMetricsNoContent()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewPutMetricsBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
result := NewPutMetricsDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewPutMetricsNoContent creates a PutMetricsNoContent with default headers values
func NewPutMetricsNoContent() *PutMetricsNoContent {
return &PutMetricsNoContent{}
}
/*PutMetricsNoContent handles this case with default header values.
Metrics system created.
*/
type PutMetricsNoContent struct {
}
func (o *PutMetricsNoContent) Error() string {
return fmt.Sprintf("[PUT /metrics][%d] putMetricsNoContent ", 204)
}
func (o *PutMetricsNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewPutMetricsBadRequest creates a PutMetricsBadRequest with default headers values
func NewPutMetricsBadRequest() *PutMetricsBadRequest {
return &PutMetricsBadRequest{}
}
/*PutMetricsBadRequest handles this case with default header values.
Metrics system cannot be initialized due to bad input.
*/
type PutMetricsBadRequest struct {
Payload *models.Error
}
func (o *PutMetricsBadRequest) Error() string {
return fmt.Sprintf("[PUT /metrics][%d] putMetricsBadRequest %+v", 400, o.Payload)
}
func (o *PutMetricsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewPutMetricsDefault creates a PutMetricsDefault with default headers values
func NewPutMetricsDefault(code int) *PutMetricsDefault {
return &PutMetricsDefault{
_statusCode: code,
}
}
/*PutMetricsDefault handles this case with default header values.
Internal server error.
*/
type PutMetricsDefault struct {
_statusCode int
Payload *models.Error
}
// Code gets the status code for the put metrics default response
func (o *PutMetricsDefault) Code() int {
return o._statusCode
}
func (o *PutMetricsDefault) Error() string {
return fmt.Sprintf("[PUT /metrics][%d] putMetrics default %+v", o._statusCode, o.Payload)
}
func (o *PutMetricsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,139 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// NewPutMmdsConfigParams creates a new PutMmdsConfigParams object
// with the default values initialized.
func NewPutMmdsConfigParams() *PutMmdsConfigParams {
var ()
return &PutMmdsConfigParams{
timeout: cr.DefaultTimeout,
}
}
// NewPutMmdsConfigParamsWithTimeout creates a new PutMmdsConfigParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewPutMmdsConfigParamsWithTimeout(timeout time.Duration) *PutMmdsConfigParams {
var ()
return &PutMmdsConfigParams{
timeout: timeout,
}
}
// NewPutMmdsConfigParamsWithContext creates a new PutMmdsConfigParams object
// with the default values initialized, and the ability to set a context for a request
func NewPutMmdsConfigParamsWithContext(ctx context.Context) *PutMmdsConfigParams {
var ()
return &PutMmdsConfigParams{
Context: ctx,
}
}
// NewPutMmdsConfigParamsWithHTTPClient creates a new PutMmdsConfigParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewPutMmdsConfigParamsWithHTTPClient(client *http.Client) *PutMmdsConfigParams {
var ()
return &PutMmdsConfigParams{
HTTPClient: client,
}
}
/*PutMmdsConfigParams contains all the parameters to send to the API endpoint
for the put mmds config operation typically these are written to a http.Request
*/
type PutMmdsConfigParams struct {
/*Body
The MMDS configuration as JSON.
*/
Body *models.MmdsConfig
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the put mmds config params
func (o *PutMmdsConfigParams) WithTimeout(timeout time.Duration) *PutMmdsConfigParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the put mmds config params
func (o *PutMmdsConfigParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the put mmds config params
func (o *PutMmdsConfigParams) WithContext(ctx context.Context) *PutMmdsConfigParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the put mmds config params
func (o *PutMmdsConfigParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the put mmds config params
func (o *PutMmdsConfigParams) WithHTTPClient(client *http.Client) *PutMmdsConfigParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the put mmds config params
func (o *PutMmdsConfigParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the put mmds config params
func (o *PutMmdsConfigParams) WithBody(body *models.MmdsConfig) *PutMmdsConfigParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the put mmds config params
func (o *PutMmdsConfigParams) SetBody(body *models.MmdsConfig) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *PutMmdsConfigParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Body != nil {
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,140 @@
// Code generated by go-swagger; DO NOT EDIT.
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
models "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/firecracker/client/models"
)
// PutMmdsConfigReader is a Reader for the PutMmdsConfig structure.
type PutMmdsConfigReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *PutMmdsConfigReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 204:
result := NewPutMmdsConfigNoContent()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewPutMmdsConfigBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
result := NewPutMmdsConfigDefault(response.Code())
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
if response.Code()/100 == 2 {
return result, nil
}
return nil, result
}
}
// NewPutMmdsConfigNoContent creates a PutMmdsConfigNoContent with default headers values
func NewPutMmdsConfigNoContent() *PutMmdsConfigNoContent {
return &PutMmdsConfigNoContent{}
}
/*PutMmdsConfigNoContent handles this case with default header values.
MMDS configuration was created/updated.
*/
type PutMmdsConfigNoContent struct {
}
func (o *PutMmdsConfigNoContent) Error() string {
return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfigNoContent ", 204)
}
func (o *PutMmdsConfigNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewPutMmdsConfigBadRequest creates a PutMmdsConfigBadRequest with default headers values
func NewPutMmdsConfigBadRequest() *PutMmdsConfigBadRequest {
return &PutMmdsConfigBadRequest{}
}
/*PutMmdsConfigBadRequest handles this case with default header values.
MMDS configuration cannot be updated due to bad input.
*/
type PutMmdsConfigBadRequest struct {
Payload *models.Error
}
func (o *PutMmdsConfigBadRequest) Error() string {
return fmt.Sprintf("[PUT /mmds/config][%d] putMmdsConfigBadRequest %+v", 400, o.Payload)
}
func (o *PutMmdsConfigBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
// NewPutMmdsConfigDefault creates a PutMmdsConfigDefault with default headers values
func NewPutMmdsConfigDefault(code int) *PutMmdsConfigDefault {
return &PutMmdsConfigDefault{
_statusCode: code,
}
}
/*PutMmdsConfigDefault handles this case with default header values.
Internal server error
*/
type PutMmdsConfigDefault struct {
_statusCode int
Payload *models.Error
}
// Code gets the status code for the put mmds config default response
func (o *PutMmdsConfigDefault) Code() int {
return o._statusCode
}
func (o *PutMmdsConfigDefault) Error() string {
return fmt.Sprintf("[PUT /mmds/config][%d] PutMmdsConfig default %+v", o._statusCode, o.Payload)
}
func (o *PutMmdsConfigDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(models.Error)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -5,7 +5,7 @@ info:
The API is accessible through HTTP calls on specific URLs The API is accessible through HTTP calls on specific URLs
carrying JSON modeled data. carrying JSON modeled data.
The transport medium is a Unix Domain Socket. The transport medium is a Unix Domain Socket.
version: 0.21.1 version: 0.23.1
termsOfService: "" termsOfService: ""
contact: contact:
email: "compute-capsule@amazon.com" email: "compute-capsule@amazon.com"
@ -62,11 +62,10 @@ paths:
/boot-source: /boot-source:
put: put:
summary: Creates or updates the boot source. summary: Creates or updates the boot source. Pre-boot only.
description: description:
Creates new boot source if one does not already exist, otherwise updates it. Creates new boot source if one does not already exist, otherwise updates it.
Will fail if update is not possible. Will fail if update is not possible.
Note that the only currently supported boot source is LocalImage.
operationId: putGuestBootSource operationId: putGuestBootSource
parameters: parameters:
- name: body - name: body
@ -89,7 +88,7 @@ paths:
/drives/{drive_id}: /drives/{drive_id}:
put: put:
summary: Creates or updates a drive. summary: Creates or updates a drive. Pre-boot only.
description: description:
Creates new drive with ID specified by drive_id path parameter. Creates new drive with ID specified by drive_id path parameter.
If a drive with the specified ID already exists, updates its state based on new input. If a drive with the specified ID already exists, updates its state based on new input.
@ -119,7 +118,7 @@ paths:
schema: schema:
$ref: "#/definitions/Error" $ref: "#/definitions/Error"
patch: patch:
summary: Updates the properties of a drive. summary: Updates the properties of a drive. Post-boot only.
description: description:
Updates the properties of the drive with the ID specified by drive_id path parameter. Updates the properties of the drive with the ID specified by drive_id path parameter.
Will fail if update is not possible. Will fail if update is not possible.
@ -150,7 +149,7 @@ paths:
/logger: /logger:
put: put:
summary: Initializes the logger by specifying two named pipes (i.e. for the logs and metrics output). summary: Initializes the logger by specifying a named pipe or a file for the logs output.
operationId: putLogger operationId: putLogger
parameters: parameters:
- name: body - name: body
@ -190,7 +189,7 @@ paths:
$ref: "#/definitions/Error" $ref: "#/definitions/Error"
put: put:
summary: Updates the Machine Configuration of the VM. summary: Updates the Machine Configuration of the VM. Pre-boot only.
description: description:
Updates the Virtual Machine Configuration with the specified input. Updates the Virtual Machine Configuration with the specified input.
Firecracker starts with default values for vCPU count (=1) and memory size (=128 MiB). Firecracker starts with default values for vCPU count (=1) and memory size (=128 MiB).
@ -217,7 +216,7 @@ paths:
$ref: "#/definitions/Error" $ref: "#/definitions/Error"
patch: patch:
summary: Partially updates the Machine Configuration of the VM. summary: Partially updates the Machine Configuration of the VM. Pre-boot only.
description: description:
Partially updates the Virtual Machine Configuration with the specified input. Partially updates the Virtual Machine Configuration with the specified input.
If any of the parameters has an incorrect value, the whole update fails. If any of the parameters has an incorrect value, the whole update fails.
@ -240,6 +239,29 @@ paths:
schema: schema:
$ref: "#/definitions/Error" $ref: "#/definitions/Error"
/metrics:
put:
summary: Initializes the metrics system by specifying a named pipe or a file for the metrics output.
operationId: putMetrics
parameters:
- name: body
in: body
description: Metrics system description
required: true
schema:
$ref: "#/definitions/Metrics"
responses:
204:
description: Metrics system created.
400:
description: Metrics system cannot be initialized due to bad input.
schema:
$ref: "#/definitions/Error"
default:
description: Internal server error.
schema:
$ref: "#/definitions/Error"
/mmds: /mmds:
put: put:
summary: Creates a MMDS (Microvm Metadata Service) data store. summary: Creates a MMDS (Microvm Metadata Service) data store.
@ -286,8 +308,32 @@ paths:
description: The MMDS data store JSON. description: The MMDS data store JSON.
schema: schema:
type: object type: object
404:
description: The MMDS data store content can not be found.
schema:
$ref: "#/definitions/Error"
default:
description: Internal server error
schema:
$ref: "#/definitions/Error"
/mmds/config:
put:
summary: Set MMDS configuration. Pre-boot only.
description:
Creates MMDS configuration to be used by the MMDS network stack.
parameters:
- name: body
in: body
description: The MMDS configuration as JSON.
required: true
schema:
$ref: "#/definitions/MmdsConfig"
responses:
204:
description: MMDS configuration was created/updated.
400: 400:
description: Cannot get the MMDS data store due to bad input. description: MMDS configuration cannot be updated due to bad input.
schema: schema:
$ref: "#/definitions/Error" $ref: "#/definitions/Error"
default: default:
@ -297,7 +343,7 @@ paths:
/network-interfaces/{iface_id}: /network-interfaces/{iface_id}:
put: put:
summary: Creates a network interface. summary: Creates a network interface. Pre-boot only.
description: description:
Creates new network interface with ID specified by iface_id path parameter. Creates new network interface with ID specified by iface_id path parameter.
operationId: putGuestNetworkInterfaceByID operationId: putGuestNetworkInterfaceByID
@ -325,7 +371,7 @@ paths:
schema: schema:
$ref: "#/definitions/Error" $ref: "#/definitions/Error"
patch: patch:
summary: Updates the rate limiters applied to a network interface. summary: Updates the rate limiters applied to a network interface. Post-boot only.
description: description:
Updates the rate limiters applied to a network interface. Updates the rate limiters applied to a network interface.
operationId: patchGuestNetworkInterfaceByID operationId: patchGuestNetworkInterfaceByID
@ -353,9 +399,87 @@ paths:
schema: schema:
$ref: "#/definitions/Error" $ref: "#/definitions/Error"
/snapshot/create:
put:
summary: Creates a full snapshot. Post-boot only.
description:
Creates a snapshot of the microVM state. The microVM should be
in the `Paused` state.
operationId: createSnapshot
parameters:
- name: body
in: body
description: The configuration used for creating a snaphot.
required: true
schema:
$ref: "#/definitions/SnapshotCreateParams"
responses:
204:
description: Snapshot created
400:
description: Snapshot cannot be created due to bad input
schema:
$ref: "#/definitions/Error"
default:
description: Internal server error
schema:
$ref: "#/definitions/Error"
/snapshot/load:
put:
summary: Loads a snapshot. Pre-boot only.
description:
Loads the microVM state from a snapshot.
Only accepted on a fresh Firecracker process (before configuring
any resource other than the Logger and Metrics).
operationId: loadSnapshot
parameters:
- name: body
in: body
description: The configuration used for loading a snaphot.
required: true
schema:
$ref: "#/definitions/SnapshotLoadParams"
responses:
204:
description: Snapshot loaded
400:
description: Snapshot cannot be loaded due to bad input
schema:
$ref: "#/definitions/Error"
default:
description: Internal server error
schema:
$ref: "#/definitions/Error"
/vm:
patch:
summary: Updates the microVM state.
description:
Sets the desired state (Paused or Resumed) for the microVM.
operationId: patchVm
parameters:
- name: body
in: body
description: The microVM state
required: true
schema:
$ref: "#/definitions/Vm"
responses:
204:
description: Vm state updated
400:
description: Vm state cannot be updated due to bad input
schema:
$ref: "#/definitions/Error"
default:
description: Internal server error
schema:
$ref: "#/definitions/Error"
/vsock: /vsock:
put: put:
summary: Creates/updates a vsock device. summary: Creates/updates a vsock device. Pre-boot only.
description: description:
The first call creates the device with the configuration specified The first call creates the device with the configuration specified
in body. Subsequent calls will update the device configuration. in body. Subsequent calls will update the device configuration.
@ -388,12 +512,15 @@ definitions:
description: description:
Boot source descriptor. Boot source descriptor.
properties: properties:
kernel_image_path:
type: string
description: Host level path to the kernel image used to boot the guest
boot_args: boot_args:
type: string type: string
description: Kernel boot arguments description: Kernel boot arguments
initrd_path:
type: string
description: Host level path to the initrd image used to boot the guest
kernel_image_path:
type: string
description: Host level path to the kernel image used to boot the guest
CpuTemplate: CpuTemplate:
type: string type: string
@ -408,15 +535,14 @@ definitions:
type: object type: object
required: required:
- drive_id - drive_id
- path_on_host
- is_root_device
- is_read_only - is_read_only
- is_root_device
- path_on_host
properties: properties:
drive_id: drive_id:
type: string type: string
path_on_host: is_read_only:
type: string type: boolean
description: Host level path for the guest drive
is_root_device: is_root_device:
type: boolean type: boolean
partuuid: partuuid:
@ -425,8 +551,9 @@ definitions:
Represents the unique id of the boot partition of this device. It is Represents the unique id of the boot partition of this device. It is
optional and it will be taken into account only if the is_root_device optional and it will be taken into account only if the is_root_device
field is true. field is true.
is_read_only: path_on_host:
type: boolean type: string
description: Host level path for the guest drive
rate_limiter: rate_limiter:
$ref: "#/definitions/RateLimiter" $ref: "#/definitions/RateLimiter"
@ -459,21 +586,19 @@ definitions:
Describes MicroVM instance information. Describes MicroVM instance information.
required: required:
- id - id
- state
- vmm_version - vmm_version
properties: properties:
app_name:
description: Application name.
type: string
id: id:
description: MicroVM / instance ID. description: MicroVM / instance ID.
type: string type: string
state: started:
description: description:
The current detailed state of the Firecracker instance. The current detailed state of the Firecracker instance.
This value is read-only for the control-plane. This value is read-only for the control-plane.
type: string type: boolean
enum:
- Uninitialized
- Starting
- Running
vmm_version: vmm_version:
description: MicroVM hypervisor build version. description: MicroVM hypervisor build version.
type: string type: string
@ -483,20 +608,16 @@ definitions:
description: description:
Describes the configuration option for the logging capability. Describes the configuration option for the logging capability.
required: required:
- log_fifo - log_path
- metrics_fifo
properties: properties:
log_fifo:
type: string
description: The named pipe for the human readable log output.
metrics_fifo:
type: string
description: The named pipe where the JSON-formatted metrics will be flushed.
level: level:
type: string type: string
description: Set the level. description: Set the level. The possible values are case-insensitive.
enum: [Error, Warning, Info, Debug] enum: [Error, Warning, Info, Debug]
default: Warning default: Warning
log_path:
type: string
description: Path to the named pipe or file for the human readable log output.
show_level: show_level:
type: boolean type: boolean
description: Whether or not to output the level in the logs. description: Whether or not to output the level in the logs.
@ -512,39 +633,61 @@ definitions:
Describes the number of vCPUs, memory size, Hyperthreading capabilities and Describes the number of vCPUs, memory size, Hyperthreading capabilities and
the CPU template. the CPU template.
required: required:
- vcpu_count
- mem_size_mib
- ht_enabled - ht_enabled
- mem_size_mib
- vcpu_count
properties: properties:
cpu_template:
$ref: "#/definitions/CpuTemplate"
ht_enabled:
type: boolean
description: Flag for enabling/disabling Hyperthreading
mem_size_mib:
type: integer
description: Memory size of VM
track_dirty_pages:
type: boolean
description:
Enable dirty page tracking. If this is enabled, then incremental guest memory
snapshots can be created. These belong to diff snapshots, which contain, besides
the microVM state, only the memory dirtied since a previous snapshot. Full snapshots
each contain a full copy of the guest memory.
vcpu_count: vcpu_count:
type: integer type: integer
minimum: 1 minimum: 1
maximum: 32 maximum: 32
description: Number of vCPUs (either 1 or an even number) description: Number of vCPUs (either 1 or an even number)
mem_size_mib:
type: integer Metrics:
description: Memory size of VM type: object
ht_enabled: description:
type: boolean Describes the configuration option for the metrics capability.
description: Flag for enabling/disabling Hyperthreading required:
cpu_template: - metrics_path
$ref: "#/definitions/CpuTemplate" properties:
metrics_path:
type: string
description: Path to the named pipe or file where the JSON-formatted metrics are flushed.
MmdsConfig:
type: object
description:
Defines the MMDS configuration.
properties:
ipv4_address:
type: string
format: "169.254.([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-4]).([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
default: "169.254.169.254"
description: A valid IPv4 link-local address.
NetworkInterface: NetworkInterface:
type: object type: object
description: description:
Defines a network interface. Defines a network interface.
required: required:
- iface_id
- host_dev_name - host_dev_name
- iface_id
properties: properties:
iface_id:
type: string
guest_mac:
type: string
host_dev_name:
type: string
description: Host level path for the guest network interface
allow_mmds_requests: allow_mmds_requests:
type: boolean type: boolean
description: description:
@ -553,6 +696,13 @@ definitions:
both ARP requests for 169.254.169.254 and TCP segments heading to the both ARP requests for 169.254.169.254 and TCP segments heading to the
same address are intercepted by the device model, and do not reach same address are intercepted by the device model, and do not reach
the associated TAP device. the associated TAP device.
guest_mac:
type: string
host_dev_name:
type: string
description: Host level path for the guest network interface
iface_id:
type: string
rx_rate_limiter: rx_rate_limiter:
$ref: "#/definitions/RateLimiter" $ref: "#/definitions/RateLimiter"
tx_rate_limiter: tx_rate_limiter:
@ -598,6 +748,48 @@ definitions:
$ref: "#/definitions/TokenBucket" $ref: "#/definitions/TokenBucket"
description: Token bucket with operations as tokens description: Token bucket with operations as tokens
SnapshotCreateParams:
type: object
required:
- mem_file_path
- snapshot_path
properties:
mem_file_path:
type: string
description: Path to the file that will contain the guest memory.
snapshot_path:
type: string
description: Path to the file that will contain the microVM state.
snapshot_type:
type: string
enum:
- Full
description:
Type of snapshot to create. It is optional and by default, a full
snapshot is created.
version:
type: string
description:
The microVM version for which we want to create the snapshot.
It is optional and it defaults to the current version.
SnapshotLoadParams:
type: object
required:
- mem_file_path
- snapshot_path
properties:
enable_diff_snapshots:
type: boolean
description:
Enable support for incremental (diff) snapshots by tracking dirty guest pages.
mem_file_path:
type: string
description: Path to the file that contains the guest memory to be loaded.
snapshot_path:
type: string
description: Path to the file that contains the microVM state to be loaded.
TokenBucket: TokenBucket:
type: object type: object
description: description:
@ -610,14 +802,9 @@ definitions:
bound in size by the amount of tokens available. bound in size by the amount of tokens available.
Once the token bucket is empty, consumption speed is bound by the refill_rate. Once the token bucket is empty, consumption speed is bound by the refill_rate.
required: required:
- size
- refill_time - refill_time
- size
properties: properties:
size:
type: integer
format: uint64
description: The total number of tokens this bucket can hold.
minimum: 0
one_time_burst: one_time_burst:
type: integer type: integer
format: uint64 format: uint64
@ -628,6 +815,24 @@ definitions:
format: uint64 format: uint64
description: The amount of milliseconds it takes for the bucket to refill. description: The amount of milliseconds it takes for the bucket to refill.
minimum: 0 minimum: 0
size:
type: integer
format: uint64
description: The total number of tokens this bucket can hold.
minimum: 0
Vm:
type: object
description:
Defines the microVM running state. It is especially useful in the snapshotting context.
required:
- state
properties:
state:
type: string
enum:
- Paused
- Resumed
Vsock: Vsock:
type: object type: object
@ -642,12 +847,10 @@ definitions:
bound and listening on Unix sockets at `uds_path_<PORT>`. bound and listening on Unix sockets at `uds_path_<PORT>`.
E.g. "/path/to/host_vsock.sock_52" for port number 52. E.g. "/path/to/host_vsock.sock_52" for port number 52.
required: required:
- vsock_id
- guest_cid - guest_cid
- uds_path - uds_path
- vsock_id
properties: properties:
vsock_id:
type: string
guest_cid: guest_cid:
type: integer type: integer
minimum: 3 minimum: 3
@ -655,3 +858,5 @@ definitions:
uds_path: uds_path:
type: string type: string
description: Path to UNIX domain socket, used to proxy vsock connections. description: Path to UNIX domain socket, used to proxy vsock connections.
vsock_id:
type: string

View File

@ -21,4 +21,6 @@ type FcConfig struct {
NetworkInterfaces []*models.NetworkInterface `json:"network-interfaces,omitempty"` NetworkInterfaces []*models.NetworkInterface `json:"network-interfaces,omitempty"`
Logger *models.Logger `json:"logger,omitempty"` Logger *models.Logger `json:"logger,omitempty"`
Metrics *models.Metrics `json:"metrics,omitempty"`
} }

View File

@ -83,7 +83,7 @@ assets:
uscan-url: >- uscan-url: >-
https://github.com/firecracker-microvm/firecracker/tags https://github.com/firecracker-microvm/firecracker/tags
.*/v?(\d\S+)\.tar\.gz .*/v?(\d\S+)\.tar\.gz
version: "v0.21.1" version: "v0.23.1"
qemu: qemu:
description: "VMM that uses KVM" description: "VMM that uses KVM"