diff --git a/Makefile b/Makefile index 4bfb34a2..daf7e63a 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,8 @@ JAILER_BIN=$(FC_TEST_DATA_PATH)/jailer-main UID = $(shell id -u) GID = $(shell id -g) -firecracker_version=v1.4.0 +# Version has to be in format of vx.x.x +firecracker_version=v1.4.1 # The below files are needed and can be downloaded from the internet release_url=https://github.com/firecracker-microvm/firecracker/releases/download/$(firecracker_version)/firecracker-$(firecracker_version)-$(arch).tgz diff --git a/client/models/cpu_config.go b/client/models/cpu_config.go new file mode 100644 index 00000000..73a3c60d --- /dev/null +++ b/client/models/cpu_config.go @@ -0,0 +1,39 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +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" +) + +// CPUConfig The CPU configuration template defines a set of bit maps as modifiers of flags accessed by register to be disabled/enabled for the microvm. +// swagger:model CpuConfig +type CPUConfig string + +// Validate validates this Cpu config +func (m CPUConfig) Validate(formats strfmt.Registry) error { + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/models/cpu_template.go b/client/models/cpu_template.go index f00f36b6..42d4c796 100644 --- a/client/models/cpu_template.go +++ b/client/models/cpu_template.go @@ -27,7 +27,7 @@ import ( "github.com/go-openapi/validate" ) -// CPUTemplate The CPU Template defines a set of flags to be disabled from the microvm so that the features exposed to the guest are the same as in the selected instance type. Works only on Intel. +// CPUTemplate The CPU Template defines a set of flags to be disabled from the microvm so that the features exposed to the guest are the same as in the selected instance type. // swagger:model CpuTemplate type CPUTemplate string @@ -38,6 +38,21 @@ const ( // CPUTemplateT2 captures enum value "T2" CPUTemplateT2 CPUTemplate = "T2" + + // CPUTemplateT2S captures enum value "T2S" + CPUTemplateT2S CPUTemplate = "T2S" + + // CPUTemplateT2CL captures enum value "T2CL" + CPUTemplateT2CL CPUTemplate = "T2CL" + + // CPUTemplateT2A captures enum value "T2A" + CPUTemplateT2A CPUTemplate = "T2A" + + // CPUTemplateV1N1 captures enum value "V1N1" + CPUTemplateV1N1 CPUTemplate = "V1N1" + + // CPUTemplateNone captures enum value "None" + CPUTemplateNone CPUTemplate = "None" ) // for schema @@ -45,7 +60,7 @@ var cpuTemplateEnum []interface{} func init() { var res []CPUTemplate - if err := json.Unmarshal([]byte(`["C3","T2"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["C3","T2","T2S","T2CL","T2A","V1N1","None"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/client/models/entropy_device.go b/client/models/entropy_device.go new file mode 100644 index 00000000..28d2fd70 --- /dev/null +++ b/client/models/entropy_device.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +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" +) + +// EntropyDevice Defines an entropy device. +// swagger:model EntropyDevice +type EntropyDevice struct { + + // rate limiter + RateLimiter *RateLimiter `json:"rate_limiter,omitempty"` +} + +// Validate validates this entropy device +func (m *EntropyDevice) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRateLimiter(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EntropyDevice) validateRateLimiter(formats strfmt.Registry) error { + + if swag.IsZero(m.RateLimiter) { // not required + return nil + } + + if m.RateLimiter != nil { + if err := m.RateLimiter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rate_limiter") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *EntropyDevice) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EntropyDevice) UnmarshalBinary(b []byte) error { + var res EntropyDevice + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/client/models/machine_configuration.go b/client/models/machine_configuration.go index 31279cbb..8cde7bf0 100644 --- a/client/models/machine_configuration.go +++ b/client/models/machine_configuration.go @@ -41,7 +41,7 @@ type MachineConfiguration struct { Smt *bool `json:"smt,omitempty"` // 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"` + TrackDirtyPages *bool `json:"track_dirty_pages,omitempty"` // Number of vCPUs (either 1 or an even number) // Required: true diff --git a/client/operations/operations_client.go b/client/operations/operations_client.go index ed4dd348..15638389 100644 --- a/client/operations/operations_client.go +++ b/client/operations/operations_client.go @@ -190,7 +190,7 @@ func (a *Client) DescribeInstance(params *DescribeInstanceParams) (*DescribeInst /* GetExportVMConfig gets the full VM configuration -Gets configuration for all VM resources. +Gets configuration for all VM resources. If the VM is restored from a snapshot, the boot-source, machine-config.smt and machine-config.cpu_template will be empty. */ func (a *Client) GetExportVMConfig(params *GetExportVMConfigParams) (*GetExportVMConfigOK, error) { // TODO: Validate the params before sending @@ -571,6 +571,66 @@ func (a *Client) PutBalloon(params *PutBalloonParams) (*PutBalloonNoContent, err } +/* +PutCPUConfiguration configures CPU features flags for the v c p us of the guest VM pre boot only + +Provides configuration to the Firecracker process to specify vCPU resource configuration prior to launching the guest machine. +*/ +func (a *Client) PutCPUConfiguration(params *PutCPUConfigurationParams) (*PutCPUConfigurationNoContent, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPutCPUConfigurationParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "putCpuConfiguration", + Method: "PUT", + PathPattern: "/cpu-config", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PutCPUConfigurationReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*PutCPUConfigurationNoContent), nil + +} + +/* +PutEntropyDevice creates an entropy device pre boot only + +Enables an entropy device that provides high-quality random data to the guest. +*/ +func (a *Client) PutEntropyDevice(params *PutEntropyDeviceParams) (*PutEntropyDeviceNoContent, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPutEntropyDeviceParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "putEntropyDevice", + Method: "PUT", + PathPattern: "/entropy", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PutEntropyDeviceReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*PutEntropyDeviceNoContent), nil + +} + /* PutGuestBootSource creates or updates the boot source pre boot only @@ -722,7 +782,7 @@ func (a *Client) PutLogger(params *PutLoggerParams) (*PutLoggerNoContent, error) /* 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 SMT 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). The vCPU count is restricted to the [1, 32] range. With SMT enabled, the vCPU count is required to be either 1 or an even number in the range. otherwise there are no restrictions regarding the vCPU count. If any of the parameters has an incorrect value, the whole update fails. All parameters that are optional and are not specified are set to their default values (smt = false, track_dirty_pages = false, cpu_template = None). */ func (a *Client) PutMachineConfiguration(params *PutMachineConfigurationParams) (*PutMachineConfigurationNoContent, error) { // TODO: Validate the params before sending @@ -861,6 +921,8 @@ type ClientIface interface { PatchMmds(params *PatchMmdsParams) (*PatchMmdsNoContent, error) PatchVM(params *PatchVMParams) (*PatchVMNoContent, error) PutBalloon(params *PutBalloonParams) (*PutBalloonNoContent, error) + PutCPUConfiguration(params *PutCPUConfigurationParams) (*PutCPUConfigurationNoContent, error) + PutEntropyDevice(params *PutEntropyDeviceParams) (*PutEntropyDeviceNoContent, error) PutGuestBootSource(params *PutGuestBootSourceParams) (*PutGuestBootSourceNoContent, error) PutGuestDriveByID(params *PutGuestDriveByIDParams) (*PutGuestDriveByIDNoContent, error) PutGuestNetworkInterfaceByID(params *PutGuestNetworkInterfaceByIDParams) (*PutGuestNetworkInterfaceByIDNoContent, error) diff --git a/client/operations/put_cpu_configuration_parameters.go b/client/operations/put_cpu_configuration_parameters.go new file mode 100644 index 00000000..6c30b446 --- /dev/null +++ b/client/operations/put_cpu_configuration_parameters.go @@ -0,0 +1,152 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +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/firecracker-microvm/firecracker-go-sdk/client/models" +) + +// NewPutCPUConfigurationParams creates a new PutCPUConfigurationParams object +// with the default values initialized. +func NewPutCPUConfigurationParams() *PutCPUConfigurationParams { + var () + return &PutCPUConfigurationParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewPutCPUConfigurationParamsWithTimeout creates a new PutCPUConfigurationParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewPutCPUConfigurationParamsWithTimeout(timeout time.Duration) *PutCPUConfigurationParams { + var () + return &PutCPUConfigurationParams{ + + timeout: timeout, + } +} + +// NewPutCPUConfigurationParamsWithContext creates a new PutCPUConfigurationParams object +// with the default values initialized, and the ability to set a context for a request +func NewPutCPUConfigurationParamsWithContext(ctx context.Context) *PutCPUConfigurationParams { + var () + return &PutCPUConfigurationParams{ + + Context: ctx, + } +} + +// NewPutCPUConfigurationParamsWithHTTPClient creates a new PutCPUConfigurationParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewPutCPUConfigurationParamsWithHTTPClient(client *http.Client) *PutCPUConfigurationParams { + var () + return &PutCPUConfigurationParams{ + HTTPClient: client, + } +} + +/*PutCPUConfigurationParams contains all the parameters to send to the API endpoint +for the put Cpu configuration operation typically these are written to a http.Request +*/ +type PutCPUConfigurationParams struct { + + /*Body + CPU configuration request + + */ + Body *models.CPUConfig + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the put Cpu configuration params +func (o *PutCPUConfigurationParams) WithTimeout(timeout time.Duration) *PutCPUConfigurationParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the put Cpu configuration params +func (o *PutCPUConfigurationParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the put Cpu configuration params +func (o *PutCPUConfigurationParams) WithContext(ctx context.Context) *PutCPUConfigurationParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the put Cpu configuration params +func (o *PutCPUConfigurationParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the put Cpu configuration params +func (o *PutCPUConfigurationParams) WithHTTPClient(client *http.Client) *PutCPUConfigurationParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the put Cpu configuration params +func (o *PutCPUConfigurationParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the put Cpu configuration params +func (o *PutCPUConfigurationParams) WithBody(body *models.CPUConfig) *PutCPUConfigurationParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the put Cpu configuration params +func (o *PutCPUConfigurationParams) SetBody(body *models.CPUConfig) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *PutCPUConfigurationParams) 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 +} diff --git a/client/operations/put_cpu_configuration_responses.go b/client/operations/put_cpu_configuration_responses.go new file mode 100644 index 00000000..fd9e9ed8 --- /dev/null +++ b/client/operations/put_cpu_configuration_responses.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +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/firecracker-microvm/firecracker-go-sdk/client/models" +) + +// PutCPUConfigurationReader is a Reader for the PutCPUConfiguration structure. +type PutCPUConfigurationReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PutCPUConfigurationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 204: + result := NewPutCPUConfigurationNoContent() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPutCPUConfigurationBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + result := NewPutCPUConfigurationDefault(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 + } +} + +// NewPutCPUConfigurationNoContent creates a PutCPUConfigurationNoContent with default headers values +func NewPutCPUConfigurationNoContent() *PutCPUConfigurationNoContent { + return &PutCPUConfigurationNoContent{} +} + +/*PutCPUConfigurationNoContent handles this case with default header values. + +CPU configuration set successfully +*/ +type PutCPUConfigurationNoContent struct { +} + +func (o *PutCPUConfigurationNoContent) Error() string { + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfigurationNoContent ", 204) +} + +func (o *PutCPUConfigurationNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewPutCPUConfigurationBadRequest creates a PutCPUConfigurationBadRequest with default headers values +func NewPutCPUConfigurationBadRequest() *PutCPUConfigurationBadRequest { + return &PutCPUConfigurationBadRequest{} +} + +/*PutCPUConfigurationBadRequest handles this case with default header values. + +CPU configuration cannot be updated due to invalid input format +*/ +type PutCPUConfigurationBadRequest struct { + Payload *models.Error +} + +func (o *PutCPUConfigurationBadRequest) Error() string { + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfigurationBadRequest %+v", 400, o.Payload) +} + +func (o *PutCPUConfigurationBadRequest) GetPayload() *models.Error { + return o.Payload +} + +func (o *PutCPUConfigurationBadRequest) 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 +} + +// NewPutCPUConfigurationDefault creates a PutCPUConfigurationDefault with default headers values +func NewPutCPUConfigurationDefault(code int) *PutCPUConfigurationDefault { + return &PutCPUConfigurationDefault{ + _statusCode: code, + } +} + +/*PutCPUConfigurationDefault handles this case with default header values. + +Internal server error +*/ +type PutCPUConfigurationDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the put Cpu configuration default response +func (o *PutCPUConfigurationDefault) Code() int { + return o._statusCode +} + +func (o *PutCPUConfigurationDefault) Error() string { + return fmt.Sprintf("[PUT /cpu-config][%d] putCpuConfiguration default %+v", o._statusCode, o.Payload) +} + +func (o *PutCPUConfigurationDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *PutCPUConfigurationDefault) 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 +} diff --git a/client/operations/put_entropy_device_parameters.go b/client/operations/put_entropy_device_parameters.go new file mode 100644 index 00000000..ffe36898 --- /dev/null +++ b/client/operations/put_entropy_device_parameters.go @@ -0,0 +1,152 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +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/firecracker-microvm/firecracker-go-sdk/client/models" +) + +// NewPutEntropyDeviceParams creates a new PutEntropyDeviceParams object +// with the default values initialized. +func NewPutEntropyDeviceParams() *PutEntropyDeviceParams { + var () + return &PutEntropyDeviceParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewPutEntropyDeviceParamsWithTimeout creates a new PutEntropyDeviceParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewPutEntropyDeviceParamsWithTimeout(timeout time.Duration) *PutEntropyDeviceParams { + var () + return &PutEntropyDeviceParams{ + + timeout: timeout, + } +} + +// NewPutEntropyDeviceParamsWithContext creates a new PutEntropyDeviceParams object +// with the default values initialized, and the ability to set a context for a request +func NewPutEntropyDeviceParamsWithContext(ctx context.Context) *PutEntropyDeviceParams { + var () + return &PutEntropyDeviceParams{ + + Context: ctx, + } +} + +// NewPutEntropyDeviceParamsWithHTTPClient creates a new PutEntropyDeviceParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewPutEntropyDeviceParamsWithHTTPClient(client *http.Client) *PutEntropyDeviceParams { + var () + return &PutEntropyDeviceParams{ + HTTPClient: client, + } +} + +/*PutEntropyDeviceParams contains all the parameters to send to the API endpoint +for the put entropy device operation typically these are written to a http.Request +*/ +type PutEntropyDeviceParams struct { + + /*Body + Guest entropy device properties + + */ + Body *models.EntropyDevice + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the put entropy device params +func (o *PutEntropyDeviceParams) WithTimeout(timeout time.Duration) *PutEntropyDeviceParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the put entropy device params +func (o *PutEntropyDeviceParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the put entropy device params +func (o *PutEntropyDeviceParams) WithContext(ctx context.Context) *PutEntropyDeviceParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the put entropy device params +func (o *PutEntropyDeviceParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the put entropy device params +func (o *PutEntropyDeviceParams) WithHTTPClient(client *http.Client) *PutEntropyDeviceParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the put entropy device params +func (o *PutEntropyDeviceParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the put entropy device params +func (o *PutEntropyDeviceParams) WithBody(body *models.EntropyDevice) *PutEntropyDeviceParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the put entropy device params +func (o *PutEntropyDeviceParams) SetBody(body *models.EntropyDevice) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *PutEntropyDeviceParams) 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 +} diff --git a/client/operations/put_entropy_device_responses.go b/client/operations/put_entropy_device_responses.go new file mode 100644 index 00000000..de171755 --- /dev/null +++ b/client/operations/put_entropy_device_responses.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"). You may +// not use this file except in compliance with the License. A copy of the +// License is located at +// +// http://aws.amazon.com/apache2.0/ +// +// or in the "license" file accompanying this file. This file is distributed +// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +// express or implied. See the License for the specific language governing +// permissions and limitations under the License. + +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/firecracker-microvm/firecracker-go-sdk/client/models" +) + +// PutEntropyDeviceReader is a Reader for the PutEntropyDevice structure. +type PutEntropyDeviceReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PutEntropyDeviceReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 204: + result := NewPutEntropyDeviceNoContent() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewPutEntropyDeviceDefault(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 + } +} + +// NewPutEntropyDeviceNoContent creates a PutEntropyDeviceNoContent with default headers values +func NewPutEntropyDeviceNoContent() *PutEntropyDeviceNoContent { + return &PutEntropyDeviceNoContent{} +} + +/*PutEntropyDeviceNoContent handles this case with default header values. + +Entropy device created +*/ +type PutEntropyDeviceNoContent struct { +} + +func (o *PutEntropyDeviceNoContent) Error() string { + return fmt.Sprintf("[PUT /entropy][%d] putEntropyDeviceNoContent ", 204) +} + +func (o *PutEntropyDeviceNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewPutEntropyDeviceDefault creates a PutEntropyDeviceDefault with default headers values +func NewPutEntropyDeviceDefault(code int) *PutEntropyDeviceDefault { + return &PutEntropyDeviceDefault{ + _statusCode: code, + } +} + +/*PutEntropyDeviceDefault handles this case with default header values. + +Internal server error +*/ +type PutEntropyDeviceDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the put entropy device default response +func (o *PutEntropyDeviceDefault) Code() int { + return o._statusCode +} + +func (o *PutEntropyDeviceDefault) Error() string { + return fmt.Sprintf("[PUT /entropy][%d] putEntropyDevice default %+v", o._statusCode, o.Payload) +} + +func (o *PutEntropyDeviceDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *PutEntropyDeviceDefault) 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 +} diff --git a/client/operations/put_metrics_responses.go b/client/operations/put_metrics_responses.go index 9d2f6e72..8d1c92d8 100644 --- a/client/operations/put_metrics_responses.go +++ b/client/operations/put_metrics_responses.go @@ -89,7 +89,7 @@ func NewPutMetricsBadRequest() *PutMetricsBadRequest { /*PutMetricsBadRequest handles this case with default header values. -Metrics system cannot be initialized due to bad input. +Metrics system cannot be initialized due to bad input request or metrics system already initialized. */ type PutMetricsBadRequest struct { Payload *models.Error diff --git a/client/swagger.yaml b/client/swagger.yaml index cf621895..df3d1d6b 100644 --- a/client/swagger.yaml +++ b/client/swagger.yaml @@ -5,7 +5,7 @@ info: The API is accessible through HTTP calls on specific URLs carrying JSON modeled data. The transport medium is a Unix Domain Socket. - version: 1.0.0 + version: 1.4.1 termsOfService: "" contact: email: "compute-capsule@amazon.com" @@ -195,6 +195,32 @@ paths: schema: $ref: "#/definitions/Error" + /cpu-config: + put: + summary: Configures CPU features flags for the vCPUs of the guest VM. Pre-boot only. + description: + Provides configuration to the Firecracker process to specify vCPU resource configuration prior to + launching the guest machine. + operationId: putCpuConfiguration + parameters: + - name: body + in: body + description: CPU configuration request + schema: + $ref: "#/definitions/CpuConfig" + responses: + 204: + description: CPU configuration set successfully + 400: + description: CPU configuration cannot be updated due to invalid input format + schema: + $ref: "#/definitions/Error" + default: + description: Internal server error + schema: + $ref: "#/definitions/Error" + + /drives/{drive_id}: put: summary: Creates or updates a drive. Pre-boot only. @@ -302,9 +328,12 @@ paths: description: Updates the Virtual Machine Configuration with the specified input. Firecracker starts with default values for vCPU count (=1) and memory size (=128 MiB). - With SMT enabled, the vCPU count is restricted to be 1 or an even number, + The vCPU count is restricted to the [1, 32] range. + With SMT enabled, the vCPU count is required to be either 1 or an even number in the range. otherwise there are no restrictions regarding the vCPU count. If any of the parameters has an incorrect value, the whole update fails. + All parameters that are optional and are not specified are set to their default values + (smt = false, track_dirty_pages = false, cpu_template = None). operationId: putMachineConfiguration parameters: - name: body @@ -363,7 +392,7 @@ paths: 204: description: Metrics system created. 400: - description: Metrics system cannot be initialized due to bad input. + description: Metrics system cannot be initialized due to bad input request or metrics system already initialized. schema: $ref: "#/definitions/Error" default: @@ -455,6 +484,28 @@ paths: schema: $ref: "#/definitions/Error" + /entropy: + put: + summary: Creates an entropy device. Pre-boot only. + description: + Enables an entropy device that provides high-quality random data to the guest. + operationId: putEntropyDevice + parameters: + - name: body + in: body + description: Guest entropy device properties + required: true + schema: + $ref: "#/definitions/EntropyDevice" + responses: + 204: + description: Entropy device created + default: + description: Internal server error + schema: + $ref: "#/definitions/Error" + + /network-interfaces/{iface_id}: put: summary: Creates a network interface. Pre-boot only. @@ -609,7 +660,8 @@ paths: get: summary: Gets the full VM configuration. description: - Gets configuration for all VM resources. + Gets configuration for all VM resources. If the VM is restored from a snapshot, the boot-source, + machine-config.smt and machine-config.cpu_template will be empty. operationId: getExportVmConfig responses: 200: @@ -774,10 +826,31 @@ definitions: description: The CPU Template defines a set of flags to be disabled from the microvm so that the features exposed to the guest are the same as in the selected instance type. - Works only on Intel. enum: - C3 - T2 + - T2S + - T2CL + - T2A + - V1N1 + - None + default: "None" + + CpuConfig: + type: string + description: + The CPU configuration template defines a set of bit maps as modifiers of flags accessed by register + to be disabled/enabled for the microvm. + properties: + cpuid_modifiers: + type: object + description: A collection of CPUIDs to be modified. (x86_64) + msr_modifiers: + type: object + description: A collection of model specific registers to be modified. (x86_64) + reg_modifiers: + type: object + description: A collection of registers to be modified. (aarch64) Drive: type: object @@ -947,6 +1020,7 @@ definitions: 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. + default: false vcpu_count: type: integer minimum: 1 @@ -1183,6 +1257,14 @@ definitions: - Paused - Resumed + EntropyDevice: + type: object + description: + Defines an entropy device. + properties: + rate_limiter: + $ref: "#/definitions/RateLimiter" + FirecrackerVersion: type: object description: @@ -1219,4 +1301,4 @@ definitions: description: Path to UNIX domain socket, used to proxy vsock connections. vsock_id: type: string - description: This parameter has been deprecated since v1.0.0. + description: This parameter has been deprecated since v1.0.0. \ No newline at end of file diff --git a/examples/cmd/snapshotting/Makefile b/examples/cmd/snapshotting/Makefile index fbed4315..203e8650 100644 --- a/examples/cmd/snapshotting/Makefile +++ b/examples/cmd/snapshotting/Makefile @@ -12,7 +12,7 @@ # permissions and limitations under the License. RELEASE_URL=https://github.com/firecracker-microvm/firecracker/releases -VER=v1.0.0 +VER=v1.4.1 ARCH=$(shell uname -m) GID = $(shell id -g) diff --git a/fctesting/firecracker_mock_client.go b/fctesting/firecracker_mock_client.go index 868a3858..688cecfc 100644 --- a/fctesting/firecracker_mock_client.go +++ b/fctesting/firecracker_mock_client.go @@ -38,6 +38,8 @@ type MockClient struct { PatchMmdsFn func(params *ops.PatchMmdsParams) (*ops.PatchMmdsNoContent, error) PatchVMFn func(params *ops.PatchVMParams) (*ops.PatchVMNoContent, error) PutBalloonFn func(params *ops.PutBalloonParams) (*ops.PutBalloonNoContent, error) + PutCPUConfigurationFn func(params *ops.PutCPUConfigurationParams) (*ops.PutCPUConfigurationNoContent, error) + PutEntropyDeviceFn func(params *ops.PutEntropyDeviceParams) (*ops.PutEntropyDeviceNoContent, error) PutGuestBootSourceFn func(params *ops.PutGuestBootSourceParams) (*ops.PutGuestBootSourceNoContent, error) PutGuestDriveByIDFn func(params *ops.PutGuestDriveByIDParams) (*ops.PutGuestDriveByIDNoContent, error) PutGuestNetworkInterfaceByIDFn func(params *ops.PutGuestNetworkInterfaceByIDParams) (*ops.PutGuestNetworkInterfaceByIDNoContent, error) @@ -193,6 +195,22 @@ func (c *MockClient) PutBalloon(params *ops.PutBalloonParams) (*ops.PutBalloonNo return nil, nil } +func (c *MockClient) PutCPUConfiguration(params *ops.PutCPUConfigurationParams) (*ops.PutCPUConfigurationNoContent, error) { + if c.PutCPUConfigurationFn != nil { + return c.PutCPUConfigurationFn(params) + } + + return nil, nil +} + +func (c *MockClient) PutEntropyDevice(params *ops.PutEntropyDeviceParams) (*ops.PutEntropyDeviceNoContent, error) { + if c.PutEntropyDeviceFn != nil { + return c.PutEntropyDeviceFn(params) + } + + return nil, nil +} + func (c *MockClient) PutGuestBootSource(params *ops.PutGuestBootSourceParams) (*ops.PutGuestBootSourceNoContent, error) { if c.PutGuestBootSourceFn != nil { return c.PutGuestBootSourceFn(params)