From 1a7539c1f5aac905e6e6b5c552d580f2264ec387 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 9 Dec 2019 21:43:48 +0000 Subject: [PATCH] clh: update client update api based latest master. Signed-off-by: Jose Carlos Venegas Munoz --- .../client/.openapi-generator/VERSION | 2 +- .../pkg/cloud-hypervisor/client/README.md | 5 +- .../cloud-hypervisor/client/api/openapi.yaml | 237 ++++++++++-------- .../cloud-hypervisor/client/api_default.go | 67 +++++ .../pkg/cloud-hypervisor/client/client.go | 25 +- .../cloud-hypervisor/client/configuration.go | 52 ++++ .../{VhostUserConfig.md => CpusConfig.md} | 7 +- .../client/docs/DefaultApi.md | 33 +++ .../cloud-hypervisor/client/docs/FsConfig.md | 5 +- .../cloud-hypervisor/client/docs/NetConfig.md | 8 +- .../client/docs/VhostUserBlkConfig.md | 6 +- .../client/docs/VhostUserNetConfig.md | 6 +- .../cloud-hypervisor/client/docs/VmConfig.md | 2 +- .../client/docs/{CpuConfig.md => VmResize.md} | 4 +- ...st_user_config.go => model_cpus_config.go} | 9 +- .../client/model_fs_config.go | 5 +- .../client/model_net_config.go | 6 +- .../client/model_vhost_user_blk_config.go | 6 +- .../client/model_vhost_user_net_config.go | 6 +- .../client/model_vm_config.go | 2 +- ...model_cpu_config.go => model_vm_resize.go} | 6 +- .../cloud-hypervisor/cloud-hypervisor.yaml | 85 +++++-- 22 files changed, 412 insertions(+), 172 deletions(-) rename virtcontainers/pkg/cloud-hypervisor/client/docs/{VhostUserConfig.md => CpusConfig.md} (69%) rename virtcontainers/pkg/cloud-hypervisor/client/docs/{CpuConfig.md => VmResize.md} (82%) rename virtcontainers/pkg/cloud-hypervisor/client/{model_vhost_user_config.go => model_cpus_config.go} (55%) rename virtcontainers/pkg/cloud-hypervisor/client/{model_cpu_config.go => model_vm_resize.go} (70%) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION b/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION index e4955748d3..58592f031f 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION +++ b/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.2-SNAPSHOT \ No newline at end of file +4.2.3-SNAPSHOT \ No newline at end of file diff --git a/virtcontainers/pkg/cloud-hypervisor/client/README.md b/virtcontainers/pkg/cloud-hypervisor/client/README.md index aca4bb6e12..57e775f839 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/README.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/README.md @@ -41,6 +41,7 @@ Class | Method | HTTP request | Description *DefaultApi* | [**ShutdownVM**](docs/DefaultApi.md#shutdownvm) | **Put** /vm.shutdown | Shut the VM instance down. *DefaultApi* | [**ShutdownVMM**](docs/DefaultApi.md#shutdownvmm) | **Put** /vmm.shutdown | Shuts the cloud-hypervisor VMM. *DefaultApi* | [**VmInfoGet**](docs/DefaultApi.md#vminfoget) | **Get** /vm.info | Returns general information about the cloud-hypervisor Virtual Machine (VM) instance. +*DefaultApi* | [**VmResizePut**](docs/DefaultApi.md#vmresizeput) | **Put** /vm.resize | Resize the VM *DefaultApi* | [**VmmPingGet**](docs/DefaultApi.md#vmmpingget) | **Get** /vmm.ping | Ping the VMM to check for API server availability @@ -48,7 +49,7 @@ Class | Method | HTTP request | Description - [CmdLineConfig](docs/CmdLineConfig.md) - [ConsoleConfig](docs/ConsoleConfig.md) - - [CpuConfig](docs/CpuConfig.md) + - [CpusConfig](docs/CpusConfig.md) - [DeviceConfig](docs/DeviceConfig.md) - [DiskConfig](docs/DiskConfig.md) - [FsConfig](docs/FsConfig.md) @@ -58,10 +59,10 @@ Class | Method | HTTP request | Description - [PmemConfig](docs/PmemConfig.md) - [RngConfig](docs/RngConfig.md) - [VhostUserBlkConfig](docs/VhostUserBlkConfig.md) - - [VhostUserConfig](docs/VhostUserConfig.md) - [VhostUserNetConfig](docs/VhostUserNetConfig.md) - [VmConfig](docs/VmConfig.md) - [VmInfo](docs/VmInfo.md) + - [VmResize](docs/VmResize.md) - [VmmPingResponse](docs/VmmPingResponse.md) - [VsockConfig](docs/VsockConfig.md) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml b/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml index 4811402e3f..2c734abd89 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml +++ b/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml @@ -113,6 +113,21 @@ paths: 405: description: The VM instance could not reboot because it is not booted. summary: Reboot the VM instance. + /vm.resize: + put: + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VmResize' + description: The target size for the VM + required: true + responses: + 204: + description: The VM instance was successfully resized. + 404: + description: The VM instance could not be resized because it is not created. + summary: Resize the VM components: schemas: VmmPingResponse: @@ -137,14 +152,15 @@ components: memory: mergeable: false file: file - size: 6 + size: 1 disks: - path: path iommu: false - path: path iommu: false cpus: - cpu_count: 1 + boot_vcpus: 1 + max_vcpus: 1 devices: - path: path iommu: false @@ -153,40 +169,38 @@ components: kernel: path: path vhost_user_blk: - - wce: true - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 - - wce: true - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 + - sock: sock + num_queues: 2 + queue_size: 4 + wce: true + - sock: sock + num_queues: 2 + queue_size: 4 + wce: true rng: iommu: false src: /dev/urandom fs: - sock: sock - num_queues: 1 + num_queues: 5 queue_size: 5 - cache_size: 5 + cache_size: 2 + dax: true tag: tag - sock: sock - num_queues: 1 + num_queues: 5 queue_size: 5 - cache_size: 5 + cache_size: 2 + dax: true tag: tag vhost_user_net: - - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 + - sock: sock + num_queues: 9 + queue_size: 3 mac: mac - - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 + - sock: sock + num_queues: 9 + queue_size: 3 mac: mac vsock: - sock: sock @@ -198,11 +212,11 @@ components: pmem: - mergeable: false file: file - size: 2 + size: 7 iommu: false - mergeable: false file: file - size: 2 + size: 7 iommu: false cmdline: args: args @@ -214,14 +228,14 @@ components: net: - tap: tap iommu: false - ip: ip + ip: 192.168.249.1 mac: mac - mask: mask + mask: 255.255.255.0 - tap: tap iommu: false - ip: ip + ip: 192.168.249.1 mac: mac - mask: mask + mask: 255.255.255.0 properties: config: $ref: '#/components/schemas/VmConfig' @@ -245,14 +259,15 @@ components: memory: mergeable: false file: file - size: 6 + size: 1 disks: - path: path iommu: false - path: path iommu: false cpus: - cpu_count: 1 + boot_vcpus: 1 + max_vcpus: 1 devices: - path: path iommu: false @@ -261,40 +276,38 @@ components: kernel: path: path vhost_user_blk: - - wce: true - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 - - wce: true - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 + - sock: sock + num_queues: 2 + queue_size: 4 + wce: true + - sock: sock + num_queues: 2 + queue_size: 4 + wce: true rng: iommu: false src: /dev/urandom fs: - sock: sock - num_queues: 1 + num_queues: 5 queue_size: 5 - cache_size: 5 + cache_size: 2 + dax: true tag: tag - sock: sock - num_queues: 1 + num_queues: 5 queue_size: 5 - cache_size: 5 + cache_size: 2 + dax: true tag: tag vhost_user_net: - - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 + - sock: sock + num_queues: 9 + queue_size: 3 mac: mac - - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 + - sock: sock + num_queues: 9 + queue_size: 3 mac: mac vsock: - sock: sock @@ -306,11 +319,11 @@ components: pmem: - mergeable: false file: file - size: 2 + size: 7 iommu: false - mergeable: false file: file - size: 2 + size: 7 iommu: false cmdline: args: args @@ -322,17 +335,17 @@ components: net: - tap: tap iommu: false - ip: ip + ip: 192.168.249.1 mac: mac - mask: mask + mask: 255.255.255.0 - tap: tap iommu: false - ip: ip + ip: 192.168.249.1 mac: mac - mask: mask + mask: 255.255.255.0 properties: cpus: - $ref: '#/components/schemas/CpuConfig' + $ref: '#/components/schemas/CpusConfig' memory: $ref: '#/components/schemas/MemoryConfig' kernel: @@ -384,22 +397,28 @@ components: - cmdline - kernel type: object - CpuConfig: + CpusConfig: example: - cpu_count: 1 + boot_vcpus: 1 + max_vcpus: 1 properties: - cpu_count: + boot_vcpus: + default: 1 + minimum: 1 + type: integer + max_vcpus: default: 1 minimum: 1 type: integer required: - - cpu_count + - boot_vcpus + - max_vcpus type: object MemoryConfig: example: mergeable: false file: file - size: 6 + size: 1 properties: size: format: int64 @@ -447,25 +466,24 @@ components: example: tap: tap iommu: false - ip: ip + ip: 192.168.249.1 mac: mac - mask: mask + mask: 255.255.255.0 properties: tap: + default: "" type: string ip: + default: 192.168.249.1 type: string mask: + default: 255.255.255.0 type: string mac: type: string iommu: default: false type: boolean - required: - - ip - - mac - - mask type: object RngConfig: example: @@ -484,9 +502,10 @@ components: FsConfig: example: sock: sock - num_queues: 1 + num_queues: 5 queue_size: 5 - cache_size: 5 + cache_size: 2 + dax: true tag: tag properties: tag: @@ -494,15 +513,18 @@ components: sock: type: string num_queues: + default: 1 type: integer queue_size: + default: 1024 type: integer + dax: + default: true + type: boolean cache_size: format: int64 type: integer required: - - num_queues - - queue_size - sock - tag type: object @@ -510,7 +532,7 @@ components: example: mergeable: false file: file - size: 2 + size: 7 iommu: false properties: file: @@ -562,54 +584,46 @@ components: required: - path type: object - VhostUserConfig: + VhostUserNetConfig: example: sock: sock - num_queues: 7 - queue:size: 9 + num_queues: 9 + queue_size: 3 + mac: mac properties: sock: type: string num_queues: + default: 2 type: integer - queue:size: + queue_size: + default: 256 type: integer - required: - - num_queues - - queue_size - - sock - type: object - VhostUserNetConfig: - example: - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 - mac: mac - properties: mac: type: string - vu_cfg: - $ref: '#/components/schemas/VhostUserConfig' required: - - mac - - vu_cfg + - sock type: object VhostUserBlkConfig: example: + sock: sock + num_queues: 2 + queue_size: 4 wce: true - vu_cfg: - sock: sock - num_queues: 7 - queue:size: 9 properties: + sock: + type: string + num_queues: + default: 1 + type: integer + queue_size: + default: 128 + type: integer wce: + default: true type: boolean - vu_cfg: - $ref: '#/components/schemas/VhostUserConfig' required: - - vu_cfg - - wce + - sock type: object VsockConfig: example: @@ -632,3 +646,14 @@ components: - cid - sock type: object + VmResize: + example: + desired_vcpus: 1 + properties: + desired_vcpus: + default: 1 + minimum: 1 + type: integer + required: + - desired_vcpus + type: object diff --git a/virtcontainers/pkg/cloud-hypervisor/client/api_default.go b/virtcontainers/pkg/cloud-hypervisor/client/api_default.go index 7b52819ae4..853dde5320 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/api_default.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/api_default.go @@ -623,6 +623,73 @@ func (a *DefaultApiService) VmInfoGet(ctx _context.Context) (VmInfo, *_nethttp.R return localVarReturnValue, localVarHTTPResponse, nil } +/* +VmResizePut Resize the VM + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param vmResize The target size for the VM +*/ +func (a *DefaultApiService) VmResizePut(ctx _context.Context, vmResize VmResize) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/vm.resize" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = &vmResize + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + /* VmmPingGet Ping the VMM to check for API server availability * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). diff --git a/virtcontainers/pkg/cloud-hypervisor/client/client.go b/virtcontainers/pkg/cloud-hypervisor/client/client.go index a3acec293b..96f94180d3 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/client.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/client.go @@ -17,8 +17,10 @@ import ( "errors" "fmt" "io" + "log" "mime/multipart" "net/http" + "net/http/httputil" "net/url" "os" "path/filepath" @@ -157,7 +159,28 @@ func parameterToJson(obj interface{}) (string, error) { // callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { - return c.cfg.HTTPClient.Do(request) + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(request, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + resp, err := c.cfg.HTTPClient.Do(request) + if err != nil { + return resp, err + } + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + return resp, err + } + log.Printf("\n%s\n", string(dump)) + } + + return resp, err } // ChangeBasePath changes base path to allow switching to mocks diff --git a/virtcontainers/pkg/cloud-hypervisor/client/configuration.go b/virtcontainers/pkg/cloud-hypervisor/client/configuration.go index 82b3e352bf..3b215aff70 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/configuration.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/configuration.go @@ -10,7 +10,9 @@ package openapi import ( + "fmt" "net/http" + "strings" ) // contextKeys are used to identify the type of value in the context. @@ -49,6 +51,20 @@ type APIKey struct { Prefix string } +// ServerVariable stores the information about a server variable +type ServerVariable struct { + Description string + DefaultValue string + EnumValues []string +} + +// ServerConfiguration stores the information about a server +type ServerConfiguration struct { + Url string + Description string + Variables map[string]ServerVariable +} + // Configuration stores the configuration of the API client type Configuration struct { BasePath string `json:"basePath,omitempty"` @@ -56,6 +72,8 @@ type Configuration struct { Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` + Debug bool `json:"debug,omitempty"` + Servers []ServerConfiguration HTTPClient *http.Client } @@ -65,6 +83,12 @@ func NewConfiguration() *Configuration { BasePath: "http://localhost/api/v1", DefaultHeader: make(map[string]string), UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Servers: []ServerConfiguration{{ + Url: "http://localhost/api/v1", + Description: "No description provided", + }, + }, } return cfg } @@ -73,3 +97,31 @@ func NewConfiguration() *Configuration { func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } + +// ServerUrl returns URL based on server settings +func (c *Configuration) ServerUrl(index int, variables map[string]string) (string, error) { + if index < 0 || len(c.Servers) <= index { + return "", fmt.Errorf("Index %v out of range %v", index, len(c.Servers) - 1) + } + server := c.Servers[index] + url := server.Url + + // go through variables and replace placeholders + for name, variable := range server.Variables { + if value, ok := variables[name]; ok { + found := bool(len(variable.EnumValues) == 0) + for _, enumValue := range variable.EnumValues { + if value == enumValue { + found = true + } + } + if !found { + return "", fmt.Errorf("The variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) + } + url = strings.Replace(url, "{"+name+"}", value, -1) + } else { + url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + } + } + return url, nil +} diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md similarity index 69% rename from virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserConfig.md rename to virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md index 82f73d2c8e..fc0755f404 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md @@ -1,12 +1,11 @@ -# VhostUserConfig +# CpusConfig ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Sock** | **string** | | -**NumQueues** | **int32** | | -**Queuesize** | **int32** | | [optional] +**BootVcpus** | **int32** | | [default to 1] +**MaxVcpus** | **int32** | | [default to 1] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md index c847e32522..535d9c69d2 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md @@ -13,6 +13,7 @@ Method | HTTP request | Description [**ShutdownVM**](DefaultApi.md#ShutdownVM) | **Put** /vm.shutdown | Shut the VM instance down. [**ShutdownVMM**](DefaultApi.md#ShutdownVMM) | **Put** /vmm.shutdown | Shuts the cloud-hypervisor VMM. [**VmInfoGet**](DefaultApi.md#VmInfoGet) | **Get** /vm.info | Returns general information about the cloud-hypervisor Virtual Machine (VM) instance. +[**VmResizePut**](DefaultApi.md#VmResizePut) | **Put** /vm.resize | Resize the VM [**VmmPingGet**](DefaultApi.md#VmmPingGet) | **Get** /vmm.ping | Ping the VMM to check for API server availability @@ -273,6 +274,38 @@ No authorization required [[Back to README]](../README.md) +## VmResizePut + +> VmResizePut(ctx, vmResize) + +Resize the VM + +### Required Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**vmResize** | [**VmResize**](VmResize.md)| The target size for the VM | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## VmmPingGet > VmmPingResponse VmmPingGet(ctx, ) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/FsConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/FsConfig.md index abb082533f..62e73497e9 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/FsConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/FsConfig.md @@ -6,8 +6,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Tag** | **string** | | **Sock** | **string** | | -**NumQueues** | **int32** | | -**QueueSize** | **int32** | | +**NumQueues** | **int32** | | [optional] [default to 1] +**QueueSize** | **int32** | | [optional] [default to 1024] +**Dax** | **bool** | | [optional] [default to true] **CacheSize** | **int64** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/NetConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/NetConfig.md index 3df9f86a51..7198667688 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/NetConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/NetConfig.md @@ -4,10 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Tap** | **string** | | [optional] -**Ip** | **string** | | -**Mask** | **string** | | -**Mac** | **string** | | +**Tap** | **string** | | [optional] [default to ] +**Ip** | **string** | | [optional] [default to 192.168.249.1] +**Mask** | **string** | | [optional] [default to 255.255.255.0] +**Mac** | **string** | | [optional] **Iommu** | **bool** | | [optional] [default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserBlkConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserBlkConfig.md index 07301ee3f5..6b36c78b90 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserBlkConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserBlkConfig.md @@ -4,8 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Wce** | **bool** | | -**VuCfg** | [**VhostUserConfig**](VhostUserConfig.md) | | +**Sock** | **string** | | +**NumQueues** | **int32** | | [optional] [default to 1] +**QueueSize** | **int32** | | [optional] [default to 128] +**Wce** | **bool** | | [optional] [default to true] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserNetConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserNetConfig.md index a876fb006b..0a11429d80 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserNetConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/VhostUserNetConfig.md @@ -4,8 +4,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Mac** | **string** | | -**VuCfg** | [**VhostUserConfig**](VhostUserConfig.md) | | +**Sock** | **string** | | +**NumQueues** | **int32** | | [optional] [default to 2] +**QueueSize** | **int32** | | [optional] [default to 256] +**Mac** | **string** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md index 6d493639cb..1c5eb6672d 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Cpus** | [**CpuConfig**](CpuConfig.md) | | [optional] +**Cpus** | [**CpusConfig**](CpusConfig.md) | | [optional] **Memory** | [**MemoryConfig**](MemoryConfig.md) | | [optional] **Kernel** | [**KernelConfig**](KernelConfig.md) | | **Cmdline** | [**CmdLineConfig**](CmdLineConfig.md) | | diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/CpuConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md similarity index 82% rename from virtcontainers/pkg/cloud-hypervisor/client/docs/CpuConfig.md rename to virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md index ad660c9d13..240d8fe81e 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/CpuConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md @@ -1,10 +1,10 @@ -# CpuConfig +# VmResize ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**CpuCount** | **int32** | | [default to 1] +**DesiredVcpus** | **int32** | | [default to 1] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go similarity index 55% rename from virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_config.go rename to virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go index 66b7336277..e7ffb4bf01 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go @@ -8,9 +8,8 @@ */ package openapi -// VhostUserConfig struct for VhostUserConfig -type VhostUserConfig struct { - Sock string `json:"sock"` - NumQueues int32 `json:"num_queues"` - Queuesize int32 `json:"queue:size,omitempty"` +// CpusConfig struct for CpusConfig +type CpusConfig struct { + BootVcpus int32 `json:"boot_vcpus"` + MaxVcpus int32 `json:"max_vcpus"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_fs_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_fs_config.go index 9c9e46d76c..2a47604019 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_fs_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_fs_config.go @@ -12,7 +12,8 @@ package openapi type FsConfig struct { Tag string `json:"tag"` Sock string `json:"sock"` - NumQueues int32 `json:"num_queues"` - QueueSize int32 `json:"queue_size"` + NumQueues int32 `json:"num_queues,omitempty"` + QueueSize int32 `json:"queue_size,omitempty"` + Dax bool `json:"dax,omitempty"` CacheSize int64 `json:"cache_size,omitempty"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_net_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_net_config.go index 29dcbd9749..e4c0c08b08 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_net_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_net_config.go @@ -11,8 +11,8 @@ package openapi // NetConfig struct for NetConfig type NetConfig struct { Tap string `json:"tap,omitempty"` - Ip string `json:"ip"` - Mask string `json:"mask"` - Mac string `json:"mac"` + Ip string `json:"ip,omitempty"` + Mask string `json:"mask,omitempty"` + Mac string `json:"mac,omitempty"` Iommu bool `json:"iommu,omitempty"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_blk_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_blk_config.go index d3fd7e5d58..62e3b309cf 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_blk_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_blk_config.go @@ -10,6 +10,8 @@ package openapi // VhostUserBlkConfig struct for VhostUserBlkConfig type VhostUserBlkConfig struct { - Wce bool `json:"wce"` - VuCfg VhostUserConfig `json:"vu_cfg"` + Sock string `json:"sock"` + NumQueues int32 `json:"num_queues,omitempty"` + QueueSize int32 `json:"queue_size,omitempty"` + Wce bool `json:"wce,omitempty"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_net_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_net_config.go index af204be08e..3f1979c6fe 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_net_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_vhost_user_net_config.go @@ -10,6 +10,8 @@ package openapi // VhostUserNetConfig struct for VhostUserNetConfig type VhostUserNetConfig struct { - Mac string `json:"mac"` - VuCfg VhostUserConfig `json:"vu_cfg"` + Sock string `json:"sock"` + NumQueues int32 `json:"num_queues,omitempty"` + QueueSize int32 `json:"queue_size,omitempty"` + Mac string `json:"mac,omitempty"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go index e867820121..985ff73666 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go @@ -10,7 +10,7 @@ package openapi // VmConfig Virtual machine configuration type VmConfig struct { - Cpus CpuConfig `json:"cpus,omitempty"` + Cpus CpusConfig `json:"cpus,omitempty"` Memory MemoryConfig `json:"memory,omitempty"` Kernel KernelConfig `json:"kernel"` Cmdline CmdLineConfig `json:"cmdline"` diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_cpu_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go similarity index 70% rename from virtcontainers/pkg/cloud-hypervisor/client/model_cpu_config.go rename to virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go index 43ef352077..3139da6405 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_cpu_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go @@ -8,7 +8,7 @@ */ package openapi -// CpuConfig struct for CpuConfig -type CpuConfig struct { - CpuCount int32 `json:"cpu_count"` +// VmResize struct for VmResize +type VmResize struct { + DesiredVcpus int32 `json:"desired_vcpus"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml b/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml index 93473cbcc5..b23bfff630 100644 --- a/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml +++ b/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml @@ -123,6 +123,22 @@ paths: 405: description: The VM instance could not reboot because it is not booted. + /vm.resize: + put: + summary: Resize the VM + requestBody: + description: The target size for the VM + content: + application/json: + schema: + $ref: '#/components/schemas/VmResize' + required: true + responses: + 204: + description: The VM instance was successfully resized. + 404: + description: The VM instance could not be resized because it is not created. + components: schemas: @@ -155,7 +171,7 @@ components: type: object properties: cpus: - $ref: '#/components/schemas/CpuConfig' + $ref: '#/components/schemas/CpusConfig' memory: $ref: '#/components/schemas/MemoryConfig' kernel: @@ -205,12 +221,17 @@ components: default: false description: Virtual machine configuration - CpuConfig: + CpusConfig: required: - - cpu_count + - boot_vcpus + - max_vcpus type: object properties: - cpu_count: + boot_vcpus: + minimum: 1 + default: 1 + type: integer + max_vcpus: minimum: 1 default: 1 type: integer @@ -258,18 +279,17 @@ components: default: false NetConfig: - required: - - ip - - mask - - mac type: object properties: tap: type: string + default: "" ip: type: string + default: "192.168.249.1" mask: type: string + default: "255.255.255.0" mac: type: string iommu: @@ -292,8 +312,6 @@ components: required: - tag - sock - - num_queues - - queue_size type: object properties: tag: @@ -302,11 +320,17 @@ components: type: string num_queues: type: integer + default: 1 queue_size: type: integer + default: 1024 + dax: + type: boolean + default: true cache_size: type: integer format: int64 + default: 8589934592 PmemConfig: required: @@ -351,41 +375,38 @@ components: type: boolean default: false - VhostUserConfig: + VhostUserNetConfig: required: - sock - - num_queues - - queue_size type: object properties: sock: type: string num_queues: type: integer - queue:size: + default: 2 + queue_size: type: integer - - VhostUserNetConfig: - required: - - mac - - vu_cfg - type: object - properties: + default: 256 mac: type: string - vu_cfg: - $ref: '#/components/schemas/VhostUserConfig' VhostUserBlkConfig: required: - - wce - - vu_cfg + - sock type: object properties: + sock: + type: string + num_queues: + type: integer + default: 1 + queue_size: + type: integer + default: 128 wce: type: boolean - vu_cfg: - $ref: '#/components/schemas/VhostUserConfig' + default: true VsockConfig: required: @@ -404,3 +425,13 @@ components: iommu: type: boolean default: false + + VmResize: + required: + - desired_vcpus + type: object + properties: + desired_vcpus: + minimum: 1 + default: 1 + type: integer