From 40f49312a4881c904a1cbdace04c4c697bd2d429 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 10 Aug 2020 22:07:47 +0000 Subject: [PATCH] clh: opeanapi: update api for cloud hypervisor Update api geneated by openapi. Signed-off-by: Jose Carlos Venegas Munoz --- virtcontainers/clh.go | 8 +- virtcontainers/clh_test.go | 8 +- .../client/.openapi-generator/FILES | 61 +++++ .../client/.openapi-generator/VERSION | 2 +- .../pkg/cloud-hypervisor/client/README.md | 4 + .../cloud-hypervisor/client/api/openapi.yaml | 221 ++++++++++++---- .../cloud-hypervisor/client/api_default.go | 246 +++++++++++++++--- .../pkg/cloud-hypervisor/client/client.go | 12 +- .../client/docs/CpuTopology.md | 14 + .../client/docs/CpusConfig.md | 1 + .../client/docs/DefaultApi.md | 65 +++-- .../client/docs/MemoryConfig.md | 1 + .../client/docs/PciDeviceInfo.md | 12 + .../client/docs/SgxEpcConfig.md | 12 + .../cloud-hypervisor/client/docs/VmConfig.md | 1 + .../cloud-hypervisor/client/docs/VmResize.md | 1 + .../pkg/cloud-hypervisor/client/go.mod | 4 +- .../client/model_cpu_topology.go | 17 ++ .../client/model_cpus_config.go | 1 + .../client/model_memory_config.go | 1 + .../client/model_pci_device_info.go | 15 ++ .../client/model_sgx_epc_config.go | 15 ++ .../client/model_vm_config.go | 1 + .../client/model_vm_resize.go | 2 + .../cloud-hypervisor/cloud-hypervisor.yaml | 104 +++++++- 25 files changed, 705 insertions(+), 124 deletions(-) create mode 100644 virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/FILES create mode 100644 virtcontainers/pkg/cloud-hypervisor/client/docs/CpuTopology.md create mode 100644 virtcontainers/pkg/cloud-hypervisor/client/docs/PciDeviceInfo.md create mode 100644 virtcontainers/pkg/cloud-hypervisor/client/docs/SgxEpcConfig.md create mode 100644 virtcontainers/pkg/cloud-hypervisor/client/model_cpu_topology.go create mode 100644 virtcontainers/pkg/cloud-hypervisor/client/model_pci_device_info.go create mode 100644 virtcontainers/pkg/cloud-hypervisor/client/model_sgx_epc_config.go diff --git a/virtcontainers/clh.go b/virtcontainers/clh.go index f4afb0440d..87543deaa6 100644 --- a/virtcontainers/clh.go +++ b/virtcontainers/clh.go @@ -86,9 +86,9 @@ type clhClient interface { // Add/remove CPUs to/from the VM VmResizePut(ctx context.Context, vmResize chclient.VmResize) (*http.Response, error) // Add VFIO PCI device to the VM - VmAddDevicePut(ctx context.Context, vmAddDevice chclient.VmAddDevice) (*http.Response, error) + VmAddDevicePut(ctx context.Context, vmAddDevice chclient.VmAddDevice) (chclient.PciDeviceInfo, *http.Response, error) // Add a new disk device to the VM - VmAddDiskPut(ctx context.Context, diskConfig chclient.DiskConfig) (*http.Response, error) + VmAddDiskPut(ctx context.Context, diskConfig chclient.DiskConfig) (chclient.PciDeviceInfo, *http.Response, error) } type CloudHypervisorVersion struct { @@ -422,7 +422,7 @@ func (clh *cloudHypervisor) hotplugBlockDevice(drive *config.BlockDrive) error { Readonly: drive.ReadOnly, VhostUser: false, } - _, err = cl.VmAddDiskPut(ctx, blkDevice) + _, _, err = cl.VmAddDiskPut(ctx, blkDevice) } if err != nil { @@ -441,7 +441,7 @@ func (clh *cloudHypervisor) hotPlugVFIODevice(device config.VFIODev) error { return openAPIClientError(err) } - _, err = cl.VmAddDevicePut(ctx, chclient.VmAddDevice{Path: device.SysfsDev}) + _, _, err = cl.VmAddDevicePut(ctx, chclient.VmAddDevice{Path: device.SysfsDev}) if err != nil { err = fmt.Errorf("Failed to hotplug device %+v %s", device, openAPIClientError(err)) } diff --git a/virtcontainers/clh_test.go b/virtcontainers/clh_test.go index 4690de524e..9b76884fb5 100644 --- a/virtcontainers/clh_test.go +++ b/virtcontainers/clh_test.go @@ -95,13 +95,13 @@ func (c *clhClientMock) VmResizePut(ctx context.Context, vmResize chclient.VmRes } //nolint:golint -func (c *clhClientMock) VmAddDevicePut(ctx context.Context, vmAddDevice chclient.VmAddDevice) (*http.Response, error) { - return nil, nil +func (c *clhClientMock) VmAddDevicePut(ctx context.Context, vmAddDevice chclient.VmAddDevice) (chclient.PciDeviceInfo, *http.Response, error) { + return chclient.PciDeviceInfo{}, nil, nil } //nolint:golint -func (c *clhClientMock) VmAddDiskPut(ctx context.Context, diskConfig chclient.DiskConfig) (*http.Response, error) { - return nil, nil +func (c *clhClientMock) VmAddDiskPut(ctx context.Context, diskConfig chclient.DiskConfig) (chclient.PciDeviceInfo, *http.Response, error) { + return chclient.PciDeviceInfo{}, nil, nil } func TestCloudHypervisorAddVSock(t *testing.T) { diff --git a/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/FILES b/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/FILES new file mode 100644 index 0000000000..7914a2aa65 --- /dev/null +++ b/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/FILES @@ -0,0 +1,61 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +api_default.go +client.go +configuration.go +docs/CmdLineConfig.md +docs/ConsoleConfig.md +docs/CpuTopology.md +docs/CpusConfig.md +docs/DefaultApi.md +docs/DeviceConfig.md +docs/DiskConfig.md +docs/FsConfig.md +docs/InitramfsConfig.md +docs/KernelConfig.md +docs/MemoryConfig.md +docs/NetConfig.md +docs/PciDeviceInfo.md +docs/PmemConfig.md +docs/RestoreConfig.md +docs/RngConfig.md +docs/SgxEpcConfig.md +docs/VmAddDevice.md +docs/VmConfig.md +docs/VmInfo.md +docs/VmRemoveDevice.md +docs/VmResize.md +docs/VmSnapshotConfig.md +docs/VmmPingResponse.md +docs/VsockConfig.md +git_push.sh +go.mod +go.sum +model_cmd_line_config.go +model_console_config.go +model_cpu_topology.go +model_cpus_config.go +model_device_config.go +model_disk_config.go +model_fs_config.go +model_initramfs_config.go +model_kernel_config.go +model_memory_config.go +model_net_config.go +model_pci_device_info.go +model_pmem_config.go +model_restore_config.go +model_rng_config.go +model_sgx_epc_config.go +model_vm_add_device.go +model_vm_config.go +model_vm_info.go +model_vm_remove_device.go +model_vm_resize.go +model_vm_snapshot_config.go +model_vmm_ping_response.go +model_vsock_config.go +response.go diff --git a/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION b/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION index b5d898602c..d99e7162d0 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION +++ b/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION @@ -1 +1 @@ -4.3.1-SNAPSHOT \ No newline at end of file +5.0.0-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 cdc7621b86..fe7b0209a5 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/README.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/README.md @@ -46,6 +46,7 @@ Class | Method | HTTP request | Description *DefaultApi* | [**VmAddNetPut**](docs/DefaultApi.md#vmaddnetput) | **Put** /vm.add-net | Add a new network device to the VM *DefaultApi* | [**VmAddPmemPut**](docs/DefaultApi.md#vmaddpmemput) | **Put** /vm.add-pmem | Add a new pmem device to the VM *DefaultApi* | [**VmAddVsockPut**](docs/DefaultApi.md#vmaddvsockput) | **Put** /vm.add-vsock | Add a new vsock device to the VM +*DefaultApi* | [**VmCountersGet**](docs/DefaultApi.md#vmcountersget) | **Get** /vm.counters | Get counters from the VM *DefaultApi* | [**VmInfoGet**](docs/DefaultApi.md#vminfoget) | **Get** /vm.info | Returns general information about the cloud-hypervisor Virtual Machine (VM) instance. *DefaultApi* | [**VmRemoveDevicePut**](docs/DefaultApi.md#vmremovedeviceput) | **Put** /vm.remove-device | Remove a device from the VM *DefaultApi* | [**VmResizePut**](docs/DefaultApi.md#vmresizeput) | **Put** /vm.resize | Resize the VM @@ -58,6 +59,7 @@ Class | Method | HTTP request | Description - [CmdLineConfig](docs/CmdLineConfig.md) - [ConsoleConfig](docs/ConsoleConfig.md) + - [CpuTopology](docs/CpuTopology.md) - [CpusConfig](docs/CpusConfig.md) - [DeviceConfig](docs/DeviceConfig.md) - [DiskConfig](docs/DiskConfig.md) @@ -66,9 +68,11 @@ Class | Method | HTTP request | Description - [KernelConfig](docs/KernelConfig.md) - [MemoryConfig](docs/MemoryConfig.md) - [NetConfig](docs/NetConfig.md) + - [PciDeviceInfo](docs/PciDeviceInfo.md) - [PmemConfig](docs/PmemConfig.md) - [RestoreConfig](docs/RestoreConfig.md) - [RngConfig](docs/RngConfig.md) + - [SgxEpcConfig](docs/SgxEpcConfig.md) - [VmAddDevice](docs/VmAddDevice.md) - [VmConfig](docs/VmConfig.md) - [VmInfo](docs/VmInfo.md) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml b/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml index ef2cfcc496..97a47b8e9d 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml +++ b/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml @@ -38,6 +38,16 @@ paths: description: The VM information summary: Returns general information about the cloud-hypervisor Virtual Machine (VM) instance. + /vm.counters: + get: + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/VmCounters' + description: The VM counters + summary: Get counters from the VM /vm.create: put: operationId: createVM @@ -138,7 +148,11 @@ paths: description: The path of the new device required: true responses: - "204": + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' description: The new device was successfully added to the VM instance. "404": description: The new device could not be added to the VM instance. @@ -168,7 +182,11 @@ paths: description: The details of the new disk required: true responses: - "204": + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' description: The new disk was successfully added to the VM instance. "500": description: The new disk could not be added to the VM instance. @@ -183,7 +201,11 @@ paths: description: The details of the new virtio-fs required: true responses: - "204": + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' description: The new device was successfully added to the VM instance. "500": description: The new device could not be added to the VM instance. @@ -198,7 +220,11 @@ paths: description: The details of the new pmem device required: true responses: - "204": + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' description: The new device was successfully added to the VM instance. "500": description: The new device could not be added to the VM instance. @@ -213,7 +239,11 @@ paths: description: The details of the new network device required: true responses: - "204": + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' description: The new device was successfully added to the VM instance. "500": description: The new device could not be added to the VM instance. @@ -228,7 +258,11 @@ paths: description: The details of the new vsock device required: true responses: - "204": + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' description: The new device was successfully added to the VM instance. "500": description: The new device could not be added to the VM instance. @@ -293,13 +327,14 @@ components: hugepages: false shared: false mergeable: false + balloon: false file: file - size: 1 - hotplug_size: 5 + size: 7 + hotplug_size: 9 hotplug_method: acpi disks: - path: path - num_queues: 5 + num_queues: 3 readonly: false iommu: false queue_size: 2 @@ -309,7 +344,7 @@ components: poll_queue: true id: id - path: path - num_queues: 5 + num_queues: 3 readonly: false iommu: false queue_size: 2 @@ -319,6 +354,11 @@ components: poll_queue: true id: id cpus: + topology: + dies_per_package: 5 + threads_per_core: 1 + cores_per_die: 5 + packages: 2 boot_vcpus: 1 max_vcpus: 1 devices: @@ -333,17 +373,22 @@ components: rng: iommu: false src: /dev/urandom + sgx_epc: + - prefault: false + size: 1 + - prefault: false + size: 1 fs: - - num_queues: 3 - queue_size: 2 - cache_size: 4 + - num_queues: 1 + queue_size: 1 + cache_size: 1 dax: true tag: tag socket: socket id: id - - num_queues: 3 - queue_size: 2 - cache_size: 4 + - num_queues: 1 + queue_size: 1 + cache_size: 1 dax: true tag: tag socket: socket @@ -356,13 +401,13 @@ components: pmem: - mergeable: false file: file - size: 7 + size: 6 iommu: false id: id discard_writes: false - mergeable: false file: file - size: 7 + size: 6 iommu: false id: id discard_writes: false @@ -377,9 +422,9 @@ components: path: path net: - tap: tap - num_queues: 7 + num_queues: 4 iommu: false - queue_size: 9 + queue_size: 7 vhost_socket: vhost_socket vhost_user: false ip: 192.168.249.1 @@ -387,9 +432,9 @@ components: mac: mac mask: 255.255.255.0 - tap: tap - num_queues: 7 + num_queues: 4 iommu: false - queue_size: 9 + queue_size: 7 vhost_socket: vhost_socket vhost_user: false ip: 192.168.249.1 @@ -410,6 +455,27 @@ components: - config - state type: object + VmCounters: + additionalProperties: + additionalProperties: + format: uint64 + type: integer + type: object + type: object + PciDeviceInfo: + description: Information about a PCI device + example: + bdf: bdf + id: id + properties: + id: + type: string + bdf: + type: string + required: + - bdf + - id + type: object VmConfig: description: Virtual machine configuration example: @@ -421,13 +487,14 @@ components: hugepages: false shared: false mergeable: false + balloon: false file: file - size: 1 - hotplug_size: 5 + size: 7 + hotplug_size: 9 hotplug_method: acpi disks: - path: path - num_queues: 5 + num_queues: 3 readonly: false iommu: false queue_size: 2 @@ -437,7 +504,7 @@ components: poll_queue: true id: id - path: path - num_queues: 5 + num_queues: 3 readonly: false iommu: false queue_size: 2 @@ -447,6 +514,11 @@ components: poll_queue: true id: id cpus: + topology: + dies_per_package: 5 + threads_per_core: 1 + cores_per_die: 5 + packages: 2 boot_vcpus: 1 max_vcpus: 1 devices: @@ -461,17 +533,22 @@ components: rng: iommu: false src: /dev/urandom + sgx_epc: + - prefault: false + size: 1 + - prefault: false + size: 1 fs: - - num_queues: 3 - queue_size: 2 - cache_size: 4 + - num_queues: 1 + queue_size: 1 + cache_size: 1 dax: true tag: tag socket: socket id: id - - num_queues: 3 - queue_size: 2 - cache_size: 4 + - num_queues: 1 + queue_size: 1 + cache_size: 1 dax: true tag: tag socket: socket @@ -484,13 +561,13 @@ components: pmem: - mergeable: false file: file - size: 7 + size: 6 iommu: false id: id discard_writes: false - mergeable: false file: file - size: 7 + size: 6 iommu: false id: id discard_writes: false @@ -505,9 +582,9 @@ components: path: path net: - tap: tap - num_queues: 7 + num_queues: 4 iommu: false - queue_size: 9 + queue_size: 7 vhost_socket: vhost_socket vhost_user: false ip: 192.168.249.1 @@ -515,9 +592,9 @@ components: mac: mac mask: 255.255.255.0 - tap: tap - num_queues: 7 + num_queues: 4 iommu: false - queue_size: 9 + queue_size: 7 vhost_socket: vhost_socket vhost_user: false ip: 192.168.249.1 @@ -563,6 +640,10 @@ components: type: array vsock: $ref: '#/components/schemas/VsockConfig' + sgx_epc: + items: + $ref: '#/components/schemas/SgxEpcConfig' + type: array iommu: default: false type: boolean @@ -570,8 +651,29 @@ components: - cmdline - kernel type: object + CpuTopology: + example: + dies_per_package: 5 + threads_per_core: 1 + cores_per_die: 5 + packages: 2 + properties: + threads_per_core: + type: integer + cores_per_die: + type: integer + dies_per_package: + type: integer + packages: + type: integer + type: object CpusConfig: example: + topology: + dies_per_package: 5 + threads_per_core: 1 + cores_per_die: 5 + packages: 2 boot_vcpus: 1 max_vcpus: 1 properties: @@ -583,6 +685,8 @@ components: default: 1 minimum: 1 type: integer + topology: + $ref: '#/components/schemas/CpuTopology' required: - boot_vcpus - max_vcpus @@ -592,9 +696,10 @@ components: hugepages: false shared: false mergeable: false + balloon: false file: file - size: 1 - hotplug_size: 5 + size: 7 + hotplug_size: 9 hotplug_method: acpi properties: size: @@ -617,6 +722,9 @@ components: hugepages: default: false type: boolean + balloon: + default: false + type: boolean required: - size type: object @@ -651,7 +759,7 @@ components: DiskConfig: example: path: path - num_queues: 5 + num_queues: 3 readonly: false iommu: false queue_size: 2 @@ -694,9 +802,9 @@ components: NetConfig: example: tap: tap - num_queues: 7 + num_queues: 4 iommu: false - queue_size: 9 + queue_size: 7 vhost_socket: vhost_socket vhost_user: false ip: 192.168.249.1 @@ -748,9 +856,9 @@ components: type: object FsConfig: example: - num_queues: 3 - queue_size: 2 - cache_size: 4 + num_queues: 1 + queue_size: 1 + cache_size: 1 dax: true tag: tag socket: socket @@ -782,7 +890,7 @@ components: example: mergeable: false file: file - size: 7 + size: 6 iommu: false id: id discard_writes: false @@ -867,9 +975,24 @@ components: - cid - socket type: object + SgxEpcConfig: + example: + prefault: false + size: 1 + properties: + size: + format: uint64 + type: integer + prefault: + default: false + type: boolean + required: + - size + type: object VmResize: example: desired_vcpus: 1 + desired_ram_w_balloon: 1 desired_ram: 6 properties: desired_vcpus: @@ -879,6 +1002,10 @@ components: description: desired memory ram in bytes format: int64 type: integer + desired_ram_w_balloon: + description: desired ballon size in bytes + format: int64 + type: integer type: object VmAddDevice: example: diff --git a/virtcontainers/pkg/cloud-hypervisor/client/api_default.go b/virtcontainers/pkg/cloud-hypervisor/client/api_default.go index 0f58bec5fb..c6bcc555e6 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/api_default.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/api_default.go @@ -14,6 +14,7 @@ import ( _ioutil "io/ioutil" _nethttp "net/http" _neturl "net/url" + _bytes "bytes" ) // Linger please @@ -72,6 +73,7 @@ func (a *DefaultApiService) BootVM(ctx _context.Context) (*_nethttp.Response, er localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -138,6 +140,7 @@ func (a *DefaultApiService) CreateVM(ctx _context.Context, vmConfig VmConfig) (* localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -201,6 +204,7 @@ func (a *DefaultApiService) DeleteVM(ctx _context.Context) (*_nethttp.Response, localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -264,6 +268,7 @@ func (a *DefaultApiService) PauseVM(ctx _context.Context) (*_nethttp.Response, e localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -327,6 +332,7 @@ func (a *DefaultApiService) RebootVM(ctx _context.Context) (*_nethttp.Response, localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -390,6 +396,7 @@ func (a *DefaultApiService) ResumeVM(ctx _context.Context) (*_nethttp.Response, localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -453,6 +460,7 @@ func (a *DefaultApiService) ShutdownVM(ctx _context.Context) (*_nethttp.Response localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -516,6 +524,7 @@ func (a *DefaultApiService) ShutdownVMM(ctx _context.Context) (*_nethttp.Respons localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -535,14 +544,16 @@ func (a *DefaultApiService) ShutdownVMM(ctx _context.Context) (*_nethttp.Respons VmAddDevicePut Add a new device to the VM * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param vmAddDevice The path of the new device +@return PciDeviceInfo */ -func (a *DefaultApiService) VmAddDevicePut(ctx _context.Context, vmAddDevice VmAddDevice) (*_nethttp.Response, error) { +func (a *DefaultApiService) VmAddDevicePut(ctx _context.Context, vmAddDevice VmAddDevice) (PciDeviceInfo, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPut localVarPostBody interface{} localVarFormFileName string localVarFileName string localVarFileBytes []byte + localVarReturnValue PciDeviceInfo ) // create path and map variables @@ -561,7 +572,7 @@ func (a *DefaultApiService) VmAddDevicePut(ctx _context.Context, vmAddDevice VmA } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} + localVarHTTPHeaderAccepts := []string{"application/json"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -572,18 +583,19 @@ func (a *DefaultApiService) VmAddDevicePut(ctx _context.Context, vmAddDevice VmA localVarPostBody = &vmAddDevice r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return localVarReturnValue, nil, err } localVarHTTPResponse, err := a.client.callAPI(r) if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { @@ -591,24 +603,35 @@ func (a *DefaultApiService) VmAddDevicePut(ctx _context.Context, vmAddDevice VmA body: localVarBody, error: localVarHTTPResponse.Status, } - return localVarHTTPResponse, newErr + return localVarReturnValue, localVarHTTPResponse, newErr } - return localVarHTTPResponse, nil + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil } /* VmAddDiskPut Add a new disk to the VM * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param diskConfig The details of the new disk +@return PciDeviceInfo */ -func (a *DefaultApiService) VmAddDiskPut(ctx _context.Context, diskConfig DiskConfig) (*_nethttp.Response, error) { +func (a *DefaultApiService) VmAddDiskPut(ctx _context.Context, diskConfig DiskConfig) (PciDeviceInfo, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPut localVarPostBody interface{} localVarFormFileName string localVarFileName string localVarFileBytes []byte + localVarReturnValue PciDeviceInfo ) // create path and map variables @@ -627,7 +650,7 @@ func (a *DefaultApiService) VmAddDiskPut(ctx _context.Context, diskConfig DiskCo } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} + localVarHTTPHeaderAccepts := []string{"application/json"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -638,18 +661,19 @@ func (a *DefaultApiService) VmAddDiskPut(ctx _context.Context, diskConfig DiskCo localVarPostBody = &diskConfig r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return localVarReturnValue, nil, err } localVarHTTPResponse, err := a.client.callAPI(r) if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { @@ -657,24 +681,35 @@ func (a *DefaultApiService) VmAddDiskPut(ctx _context.Context, diskConfig DiskCo body: localVarBody, error: localVarHTTPResponse.Status, } - return localVarHTTPResponse, newErr + return localVarReturnValue, localVarHTTPResponse, newErr } - return localVarHTTPResponse, nil + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil } /* VmAddFsPut Add a new virtio-fs device to the VM * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param fsConfig The details of the new virtio-fs +@return PciDeviceInfo */ -func (a *DefaultApiService) VmAddFsPut(ctx _context.Context, fsConfig FsConfig) (*_nethttp.Response, error) { +func (a *DefaultApiService) VmAddFsPut(ctx _context.Context, fsConfig FsConfig) (PciDeviceInfo, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPut localVarPostBody interface{} localVarFormFileName string localVarFileName string localVarFileBytes []byte + localVarReturnValue PciDeviceInfo ) // create path and map variables @@ -693,7 +728,7 @@ func (a *DefaultApiService) VmAddFsPut(ctx _context.Context, fsConfig FsConfig) } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} + localVarHTTPHeaderAccepts := []string{"application/json"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -704,18 +739,19 @@ func (a *DefaultApiService) VmAddFsPut(ctx _context.Context, fsConfig FsConfig) localVarPostBody = &fsConfig r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return localVarReturnValue, nil, err } localVarHTTPResponse, err := a.client.callAPI(r) if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { @@ -723,24 +759,35 @@ func (a *DefaultApiService) VmAddFsPut(ctx _context.Context, fsConfig FsConfig) body: localVarBody, error: localVarHTTPResponse.Status, } - return localVarHTTPResponse, newErr + return localVarReturnValue, localVarHTTPResponse, newErr } - return localVarHTTPResponse, nil + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil } /* VmAddNetPut Add a new network device to the VM * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param netConfig The details of the new network device +@return PciDeviceInfo */ -func (a *DefaultApiService) VmAddNetPut(ctx _context.Context, netConfig NetConfig) (*_nethttp.Response, error) { +func (a *DefaultApiService) VmAddNetPut(ctx _context.Context, netConfig NetConfig) (PciDeviceInfo, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPut localVarPostBody interface{} localVarFormFileName string localVarFileName string localVarFileBytes []byte + localVarReturnValue PciDeviceInfo ) // create path and map variables @@ -759,7 +806,7 @@ func (a *DefaultApiService) VmAddNetPut(ctx _context.Context, netConfig NetConfi } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} + localVarHTTPHeaderAccepts := []string{"application/json"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -770,18 +817,19 @@ func (a *DefaultApiService) VmAddNetPut(ctx _context.Context, netConfig NetConfi localVarPostBody = &netConfig r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return localVarReturnValue, nil, err } localVarHTTPResponse, err := a.client.callAPI(r) if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { @@ -789,24 +837,35 @@ func (a *DefaultApiService) VmAddNetPut(ctx _context.Context, netConfig NetConfi body: localVarBody, error: localVarHTTPResponse.Status, } - return localVarHTTPResponse, newErr + return localVarReturnValue, localVarHTTPResponse, newErr } - return localVarHTTPResponse, nil + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil } /* VmAddPmemPut Add a new pmem device to the VM * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param pmemConfig The details of the new pmem device +@return PciDeviceInfo */ -func (a *DefaultApiService) VmAddPmemPut(ctx _context.Context, pmemConfig PmemConfig) (*_nethttp.Response, error) { +func (a *DefaultApiService) VmAddPmemPut(ctx _context.Context, pmemConfig PmemConfig) (PciDeviceInfo, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPut localVarPostBody interface{} localVarFormFileName string localVarFileName string localVarFileBytes []byte + localVarReturnValue PciDeviceInfo ) // create path and map variables @@ -825,7 +884,7 @@ func (a *DefaultApiService) VmAddPmemPut(ctx _context.Context, pmemConfig PmemCo } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} + localVarHTTPHeaderAccepts := []string{"application/json"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -836,18 +895,19 @@ func (a *DefaultApiService) VmAddPmemPut(ctx _context.Context, pmemConfig PmemCo localVarPostBody = &pmemConfig r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return localVarReturnValue, nil, err } localVarHTTPResponse, err := a.client.callAPI(r) if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { @@ -855,24 +915,35 @@ func (a *DefaultApiService) VmAddPmemPut(ctx _context.Context, pmemConfig PmemCo body: localVarBody, error: localVarHTTPResponse.Status, } - return localVarHTTPResponse, newErr + return localVarReturnValue, localVarHTTPResponse, newErr } - return localVarHTTPResponse, nil + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil } /* VmAddVsockPut Add a new vsock device to the VM * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param vsockConfig The details of the new vsock device +@return PciDeviceInfo */ -func (a *DefaultApiService) VmAddVsockPut(ctx _context.Context, vsockConfig VsockConfig) (*_nethttp.Response, error) { +func (a *DefaultApiService) VmAddVsockPut(ctx _context.Context, vsockConfig VsockConfig) (PciDeviceInfo, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPut localVarPostBody interface{} localVarFormFileName string localVarFileName string localVarFileBytes []byte + localVarReturnValue PciDeviceInfo ) // create path and map variables @@ -891,7 +962,7 @@ func (a *DefaultApiService) VmAddVsockPut(ctx _context.Context, vsockConfig Vsoc } // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} + localVarHTTPHeaderAccepts := []string{"application/json"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) @@ -902,18 +973,19 @@ func (a *DefaultApiService) VmAddVsockPut(ctx _context.Context, vsockConfig Vsoc localVarPostBody = &vsockConfig r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { - return nil, err + return localVarReturnValue, nil, err } localVarHTTPResponse, err := a.client.callAPI(r) if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { @@ -921,10 +993,94 @@ func (a *DefaultApiService) VmAddVsockPut(ctx _context.Context, vsockConfig Vsoc body: localVarBody, error: localVarHTTPResponse.Status, } - return localVarHTTPResponse, newErr + return localVarReturnValue, localVarHTTPResponse, newErr } - return localVarHTTPResponse, nil + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +/* +VmCountersGet Get counters from the VM + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). +@return map[string]map[string]int32 +*/ +func (a *DefaultApiService) VmCountersGet(ctx _context.Context) (map[string]map[string]int32, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue map[string]map[string]int32 + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/vm.counters" + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil } /* @@ -977,6 +1133,7 @@ func (a *DefaultApiService) VmInfoGet(ctx _context.Context) (VmInfo, *_nethttp.R localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } @@ -1052,6 +1209,7 @@ func (a *DefaultApiService) VmRemoveDevicePut(ctx _context.Context, vmRemoveDevi localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -1118,6 +1276,7 @@ func (a *DefaultApiService) VmResizePut(ctx _context.Context, vmResize VmResize) localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -1184,6 +1343,7 @@ func (a *DefaultApiService) VmRestorePut(ctx _context.Context, restoreConfig Res localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -1250,6 +1410,7 @@ func (a *DefaultApiService) VmSnapshotPut(ctx _context.Context, vmSnapshotConfig localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarHTTPResponse, err } @@ -1315,6 +1476,7 @@ func (a *DefaultApiService) VmmPingGet(ctx _context.Context) (VmmPingResponse, * localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(_bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/client.go b/virtcontainers/pkg/cloud-hypervisor/client/client.go index d59e15f8d6..40d3ec919e 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/client.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/client.go @@ -17,6 +17,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "log" "mime/multipart" "net/http" @@ -35,7 +36,7 @@ import ( ) var ( - jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) + jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?(?:problem\+)?json)`) xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) ) @@ -366,6 +367,15 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err *s = string(b) return nil } + if f, ok := v.(**os.File); ok { + *f, err = ioutil.TempFile("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + _, err = (*f).Seek(0, io.SeekStart) + return + } if xmlCheck.MatchString(contentType) { if err = xml.Unmarshal(b, v); err != nil { return err diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/CpuTopology.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/CpuTopology.md new file mode 100644 index 0000000000..870faae76c --- /dev/null +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/CpuTopology.md @@ -0,0 +1,14 @@ +# CpuTopology + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ThreadsPerCore** | **int32** | | [optional] +**CoresPerDie** | **int32** | | [optional] +**DiesPerPackage** | **int32** | | [optional] +**Packages** | **int32** | | [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/CpusConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md index fc0755f404..840673d55d 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **BootVcpus** | **int32** | | [default to 1] **MaxVcpus** | **int32** | | [default to 1] +**Topology** | [**CpuTopology**](CpuTopology.md) | | [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/DefaultApi.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md index 0f0624a580..d29a8a868d 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md @@ -18,6 +18,7 @@ Method | HTTP request | Description [**VmAddNetPut**](DefaultApi.md#VmAddNetPut) | **Put** /vm.add-net | Add a new network device to the VM [**VmAddPmemPut**](DefaultApi.md#VmAddPmemPut) | **Put** /vm.add-pmem | Add a new pmem device to the VM [**VmAddVsockPut**](DefaultApi.md#VmAddVsockPut) | **Put** /vm.add-vsock | Add a new vsock device to the VM +[**VmCountersGet**](DefaultApi.md#VmCountersGet) | **Get** /vm.counters | Get counters from the VM [**VmInfoGet**](DefaultApi.md#VmInfoGet) | **Get** /vm.info | Returns general information about the cloud-hypervisor Virtual Machine (VM) instance. [**VmRemoveDevicePut**](DefaultApi.md#VmRemoveDevicePut) | **Put** /vm.remove-device | Remove a device from the VM [**VmResizePut**](DefaultApi.md#VmResizePut) | **Put** /vm.resize | Resize the VM @@ -257,7 +258,7 @@ No authorization required ## VmAddDevicePut -> VmAddDevicePut(ctx, vmAddDevice) +> PciDeviceInfo VmAddDevicePut(ctx, vmAddDevice) Add a new device to the VM @@ -271,7 +272,7 @@ Name | Type | Description | Notes ### Return type - (empty response body) +[**PciDeviceInfo**](PciDeviceInfo.md) ### Authorization @@ -280,7 +281,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) @@ -289,7 +290,7 @@ No authorization required ## VmAddDiskPut -> VmAddDiskPut(ctx, diskConfig) +> PciDeviceInfo VmAddDiskPut(ctx, diskConfig) Add a new disk to the VM @@ -303,7 +304,7 @@ Name | Type | Description | Notes ### Return type - (empty response body) +[**PciDeviceInfo**](PciDeviceInfo.md) ### Authorization @@ -312,7 +313,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) @@ -321,7 +322,7 @@ No authorization required ## VmAddFsPut -> VmAddFsPut(ctx, fsConfig) +> PciDeviceInfo VmAddFsPut(ctx, fsConfig) Add a new virtio-fs device to the VM @@ -335,7 +336,7 @@ Name | Type | Description | Notes ### Return type - (empty response body) +[**PciDeviceInfo**](PciDeviceInfo.md) ### Authorization @@ -344,7 +345,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) @@ -353,7 +354,7 @@ No authorization required ## VmAddNetPut -> VmAddNetPut(ctx, netConfig) +> PciDeviceInfo VmAddNetPut(ctx, netConfig) Add a new network device to the VM @@ -367,7 +368,7 @@ Name | Type | Description | Notes ### Return type - (empty response body) +[**PciDeviceInfo**](PciDeviceInfo.md) ### Authorization @@ -376,7 +377,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) @@ -385,7 +386,7 @@ No authorization required ## VmAddPmemPut -> VmAddPmemPut(ctx, pmemConfig) +> PciDeviceInfo VmAddPmemPut(ctx, pmemConfig) Add a new pmem device to the VM @@ -399,7 +400,7 @@ Name | Type | Description | Notes ### Return type - (empty response body) +[**PciDeviceInfo**](PciDeviceInfo.md) ### Authorization @@ -408,7 +409,7 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) @@ -417,7 +418,7 @@ No authorization required ## VmAddVsockPut -> VmAddVsockPut(ctx, vsockConfig) +> PciDeviceInfo VmAddVsockPut(ctx, vsockConfig) Add a new vsock device to the VM @@ -431,7 +432,7 @@ Name | Type | Description | Notes ### Return type - (empty response body) +[**PciDeviceInfo**](PciDeviceInfo.md) ### Authorization @@ -440,7 +441,35 @@ No authorization required ### HTTP request headers - **Content-Type**: application/json -- **Accept**: Not defined +- **Accept**: application/json + +[[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) + + +## VmCountersGet + +> map[string]map[string]int32 VmCountersGet(ctx, ) + +Get counters from the VM + +### Required Parameters + +This endpoint does not need any parameter. + +### Return type + +[**map[string]map[string]int32**](map.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) diff --git a/virtcontainers/pkg/cloud-hypervisor/client/docs/MemoryConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/MemoryConfig.md index 03dd5b31ec..f7b3f7acd0 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/MemoryConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/MemoryConfig.md @@ -11,6 +11,7 @@ Name | Type | Description | Notes **HotplugMethod** | **string** | | [optional] [default to acpi] **Shared** | **bool** | | [optional] [default to false] **Hugepages** | **bool** | | [optional] [default to false] +**Balloon** | **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/PciDeviceInfo.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/PciDeviceInfo.md new file mode 100644 index 0000000000..e5b956d351 --- /dev/null +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/PciDeviceInfo.md @@ -0,0 +1,12 @@ +# PciDeviceInfo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | +**Bdf** | **string** | | + +[[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/SgxEpcConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/SgxEpcConfig.md new file mode 100644 index 0000000000..929c278c8f --- /dev/null +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/SgxEpcConfig.md @@ -0,0 +1,12 @@ +# SgxEpcConfig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Size** | **int32** | | +**Prefault** | **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/VmConfig.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md index 302008926d..fa2a8d21c0 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md @@ -18,6 +18,7 @@ Name | Type | Description | Notes **Console** | [**ConsoleConfig**](ConsoleConfig.md) | | [optional] **Devices** | [**[]DeviceConfig**](DeviceConfig.md) | | [optional] **Vsock** | [**VsockConfig**](VsockConfig.md) | | [optional] +**SgxEpc** | [**[]SgxEpcConfig**](SgxEpcConfig.md) | | [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/VmResize.md b/virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md index 0adf6f7167..4df9497a65 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md +++ b/virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **DesiredVcpus** | **int32** | | [optional] **DesiredRam** | **int64** | desired memory ram in bytes | [optional] +**DesiredRamWBalloon** | **int64** | desired ballon size in bytes | [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/go.mod b/virtcontainers/pkg/cloud-hypervisor/client/go.mod index f55c1461f8..7406f2bda1 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/go.mod +++ b/virtcontainers/pkg/cloud-hypervisor/client/go.mod @@ -3,5 +3,7 @@ module github.com/GIT_USER_ID/GIT_REPO_ID require ( github.com/antihax/optional v1.0.0 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 - + ) + +go 1.13 diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_cpu_topology.go b/virtcontainers/pkg/cloud-hypervisor/client/model_cpu_topology.go new file mode 100644 index 0000000000..3c8bf4b0d3 --- /dev/null +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_cpu_topology.go @@ -0,0 +1,17 @@ +/* + * Cloud Hypervisor API + * + * Local HTTP based API for managing and inspecting a cloud-hypervisor virtual machine. + * + * API version: 0.3.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi +// CpuTopology struct for CpuTopology +type CpuTopology struct { + ThreadsPerCore int32 `json:"threads_per_core,omitempty"` + CoresPerDie int32 `json:"cores_per_die,omitempty"` + DiesPerPackage int32 `json:"dies_per_package,omitempty"` + Packages int32 `json:"packages,omitempty"` +} diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go index e7ffb4bf01..37ce5e8e5f 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go @@ -12,4 +12,5 @@ package openapi type CpusConfig struct { BootVcpus int32 `json:"boot_vcpus"` MaxVcpus int32 `json:"max_vcpus"` + Topology CpuTopology `json:"topology,omitempty"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_memory_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_memory_config.go index 5601f46d31..4b05540dad 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_memory_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_memory_config.go @@ -17,4 +17,5 @@ type MemoryConfig struct { HotplugMethod string `json:"hotplug_method,omitempty"` Shared bool `json:"shared,omitempty"` Hugepages bool `json:"hugepages,omitempty"` + Balloon bool `json:"balloon,omitempty"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_pci_device_info.go b/virtcontainers/pkg/cloud-hypervisor/client/model_pci_device_info.go new file mode 100644 index 0000000000..308386207d --- /dev/null +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_pci_device_info.go @@ -0,0 +1,15 @@ +/* + * Cloud Hypervisor API + * + * Local HTTP based API for managing and inspecting a cloud-hypervisor virtual machine. + * + * API version: 0.3.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi +// PciDeviceInfo Information about a PCI device +type PciDeviceInfo struct { + Id string `json:"id"` + Bdf string `json:"bdf"` +} diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_sgx_epc_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_sgx_epc_config.go new file mode 100644 index 0000000000..9af3428094 --- /dev/null +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_sgx_epc_config.go @@ -0,0 +1,15 @@ +/* + * Cloud Hypervisor API + * + * Local HTTP based API for managing and inspecting a cloud-hypervisor virtual machine. + * + * API version: 0.3.0 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi +// SgxEpcConfig struct for SgxEpcConfig +type SgxEpcConfig struct { + Size int32 `json:"size"` + Prefault bool `json:"prefault,omitempty"` +} diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go b/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go index d75e03b85f..528406f2cd 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go @@ -24,5 +24,6 @@ type VmConfig struct { Console ConsoleConfig `json:"console,omitempty"` Devices []DeviceConfig `json:"devices,omitempty"` Vsock VsockConfig `json:"vsock,omitempty"` + SgxEpc []SgxEpcConfig `json:"sgx_epc,omitempty"` Iommu bool `json:"iommu,omitempty"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go b/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go index ec0e4e9db0..5f79ff93f4 100644 --- a/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go +++ b/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go @@ -13,4 +13,6 @@ type VmResize struct { DesiredVcpus int32 `json:"desired_vcpus,omitempty"` // desired memory ram in bytes DesiredRam int64 `json:"desired_ram,omitempty"` + // desired ballon size in bytes + DesiredRamWBalloon int64 `json:"desired_ram_w_balloon,omitempty"` } diff --git a/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml b/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml index 5c5edb2837..8b9f26e494 100644 --- a/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml +++ b/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml @@ -42,6 +42,17 @@ paths: schema: $ref: '#/components/schemas/VmInfo' + /vm.counters: + get: + summary: Get counters from the VM + responses: + 200: + description: The VM counters + content: + application/json: + schema: + $ref: '#/components/schemas/VmCounters' + /vm.create: put: summary: Create the cloud-hypervisor Virtual Machine (VM) instance. The instance is not booted, only created. @@ -150,8 +161,12 @@ paths: $ref: '#/components/schemas/VmAddDevice' required: true responses: - 204: + 200: description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' 404: description: The new device could not be added to the VM instance. @@ -182,8 +197,12 @@ paths: $ref: '#/components/schemas/DiskConfig' required: true responses: - 204: + 200: description: The new disk was successfully added to the VM instance. + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' 500: description: The new disk could not be added to the VM instance. @@ -198,8 +217,12 @@ paths: $ref: '#/components/schemas/FsConfig' required: true responses: - 204: + 200: description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' 500: description: The new device could not be added to the VM instance. @@ -214,8 +237,12 @@ paths: $ref: '#/components/schemas/PmemConfig' required: true responses: - 204: + 200: description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' 500: description: The new device could not be added to the VM instance. @@ -230,8 +257,12 @@ paths: $ref: '#/components/schemas/NetConfig' required: true responses: - 204: + 200: description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' 500: description: The new device could not be added to the VM instance. @@ -246,8 +277,12 @@ paths: $ref: '#/components/schemas/VsockConfig' required: true responses: - 204: + 200: description: The new device was successfully added to the VM instance. + content: + application/json: + schema: + $ref: '#/components/schemas/PciDeviceInfo' 500: description: The new device could not be added to the VM instance. @@ -311,6 +346,26 @@ components: enum: [Created, Running, Shutdown, Paused] description: Virtual Machine information + VmCounters: + type: object + additionalProperties: + type: object + additionalProperties: + type: integer + format: uint64 + + PciDeviceInfo: + required: + - id + - bdf + type: object + properties: + id: + type: string + bdf: + type: string + description: Information about a PCI device + VmConfig: required: - kernel @@ -355,11 +410,27 @@ components: $ref: '#/components/schemas/DeviceConfig' vsock: $ref: '#/components/schemas/VsockConfig' + sgx_epc: + type: array + items: + $ref: '#/components/schemas/SgxEpcConfig' iommu: type: boolean default: false description: Virtual machine configuration + CpuTopology: + type: object + properties: + threads_per_core: + type: integer + cores_per_die: + type: integer + dies_per_package: + type: integer + packages: + type: integer + CpusConfig: required: - boot_vcpus @@ -374,6 +445,8 @@ components: minimum: 1 default: 1 type: integer + topology: + $ref: '#/components/schemas/CpuTopology' MemoryConfig: required: @@ -401,6 +474,9 @@ components: hugepages: type: boolean default: false + balloon: + type: boolean + default: false KernelConfig: required: @@ -598,6 +674,18 @@ components: id: type: string + SgxEpcConfig: + required: + - size + type: object + properties: + size: + type: integer + format: uint64 + prefault: + type: boolean + default: false + VmResize: type: object properties: @@ -608,6 +696,10 @@ components: description: desired memory ram in bytes type: integer format: int64 + desired_ram_w_balloon: + description: desired ballon size in bytes + type: integer + format: int64 VmAddDevice: type: object