From 76a64667d50df273acb88456be4abab52d13a191 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Fri, 26 Jun 2020 17:29:54 -0700 Subject: [PATCH 1/9] clh: Remove the use of deprecated '--memory file=' parameter [ Port from runtime commit 30b40f5505fd46d23b89eb5fb38301d2f7454f35 ] Along with the release of cloud-hypervisor v0.8.0, this option has been deprecated. clh now enforces to use the alternative controls, e.g. "shared" and "hugepages", which can infer the backing file paths. Also, we don't use "hugepages" in kata, so we are fine now as the "shared" control is already enabled. Fixes: #461 Signed-off-by: Bo Chen --- src/runtime/virtcontainers/clh.go | 1 - 1 file changed, 1 deletion(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 5d794893f..92ae5fd23 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -221,7 +221,6 @@ func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networ // Set initial memomory size of the virtual machine // Convert to int64 openApiClient only support int64 clh.vmconfig.Memory.Size = int64((utils.MemUnit(clh.config.MemorySize) * utils.MiB).ToBytes()) - clh.vmconfig.Memory.File = "/dev/shm" // shared memory should be enabled if using vhost-user(kata uses virtiofsd) clh.vmconfig.Memory.Shared = true hostMemKb, err := getHostMemorySizeKb(procMemInfo) From 8d5a60ac0ad802f7869f43c0109df93d3f500428 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 20 Jul 2020 22:54:22 +0000 Subject: [PATCH 2/9] versions: Update qemu-virtiofs to 5.0 [ Port from runtime commit d803f077c6fd26e4d020643eda415ea315f47e0c ] Update to qemu 5.0.x with support for virtiofs + dax. Fixes: #461 Signed-off-by: Jose Carlos Venegas Munoz Signed-off-by: Bo Chen --- versions.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/versions.yaml b/versions.yaml index 0b9d5f684..96e097011 100644 --- a/versions.yaml +++ b/versions.yaml @@ -106,9 +106,9 @@ assets: commit: "47c1cc30e440860aa695358f7c2dd0b9d7b53d16" qemu-experimental: - description: "QEMU with virtiofs 3.0" + description: "QEMU with virtiofs support" url: "https://gitlab.com/virtio-fs/qemu.git" - tag: "virtio-fs-v0.3" + tag: "qemu5.0-virtiofs-with51bits-dax" image: description: | From 89836cd31a9fb872e91a8d0e226f427341f77af3 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Thu, 6 Aug 2020 19:36:57 +0000 Subject: [PATCH 3/9] versions: cloud-hypervisor 0.9.0 [ Port from runtime commit 0dcbbd8dc113878c2aa8c78b5300e4853a7e64be ] Highlights for cloud-hypervisor version 0.9.0 include: virtiofs updates to new dax implementation based in qemu 5.0 Fixed random issues caused due to seccomp filters io_uring Based Block Device Support If the io_uring feature is enabled and the host kernel supports it then io_uring will be used for block devices. This results a very significant performance improvement. Block and Network Device Statistics Statistics for activity of the virtio network and block devices is now exposed through a new vm.counters HTTP API entry point. These take the form of simple counters which can be used to observe the activity of the VM. HTTP API Responses The HTTP API for adding devices now responds with the name that was assigned to the device as well the PCI BDF. CPU Topology A topology parameter has been added to --cpus which allows the configuration of the guest CPU topology allowing the user to specify the numbers of sockets, packages per socket, cores per package and threads per core. Release Build Optimization Our release build is now built with LTO (Link Time Optimization) which results in a ~20% reduction in the binary size. Hypervisor Abstraction A new abstraction has been introduced, in the form of a hypervisor crate so as to enable the support of additional hypervisors beyond KVM. Snapshot/Restore Improvements Multiple improvements have been made to the VM snapshot/restore support that was added in the last release. This includes persisting more vCPU state and in particular preserving the guest paravirtualized clock in order to avoid vCPU hangs inside the guest when running with multiple vCPUs. Virtio Memory Ballooning Support A virtio-balloon device has been added, controlled through the resize control, which allows the reclamation of host memory by resizing a memory balloon inside the guest. Enhancements to ARM64 Support The ARM64 support introduced in the last release has been further enhanced with support for using PCI for exposing devices into the guest as well as multiple bug fixes. It also now supports using an initramfs when booting. Intel SGX Support The guest can now use Intel SGX if the host supports it. Details can be found in the dedicated SGX documentation. Seccomp Sandbox Improvements The most frequently used virtio devices are now isolated with their own seccomp filters. It is also now possible to pass --seccomp=log which result in the logging of requests that would have otherwise been denied to further aid development. Notable Bug Fixes Our virtio-vsock implementation has been resynced with the implementation from Firecracker and includes multiple bug fixes. CPU hotplug has been fixed so that it is now possible to add, remove, and re-add vCPUs (#1338) A workaround is now in place for when KVM reports MSRs available MSRs that are in fact unreadable preventing snapshot/restore from working correctly (#1543). virtio-mmio based devices are now more widely tested (#275). Multiple issues have been fixed with virtio device configuration (#1217) Console input was wrongly consumed by both virtio-console and the serial. (#1521) Fixes: #461 Signed-off-by: Jose Carlos Venegas Munoz Signed-off-by: Bo Chen --- versions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.yaml b/versions.yaml index 96e097011..518f43900 100644 --- a/versions.yaml +++ b/versions.yaml @@ -75,7 +75,7 @@ assets: url: "https://github.com/cloud-hypervisor/cloud-hypervisor" uscan-url: >- https://github.com/cloud-hypervisor/cloud-hypervisor/tags.*/v?(\d\S+)\.tar\.gz - version: "v0.8.0" + version: "v0.9.0" firecracker: description: "Firecracker micro-VMM" From 3159438701ac42220023cfaac502cc775f81956b Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 10 Aug 2020 22:07:47 +0000 Subject: [PATCH 4/9] clh: opeanapi: update api for cloud hypervisor [ Port from runtime commit 40f49312a4881c904a1cbdace04c4c697bd2d429 ] Update api geneated by openapi. Fixes: #461 Signed-off-by: Jose Carlos Venegas Munoz Signed-off-by: Bo Chen --- src/runtime/virtcontainers/clh.go | 8 +- src/runtime/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 | 69 +++-- .../client/docs/DiskConfig.md | 2 +- .../cloud-hypervisor/client/docs/FsConfig.md | 4 +- .../client/docs/MemoryConfig.md | 1 + .../cloud-hypervisor/client/docs/NetConfig.md | 2 +- .../client/docs/PciDeviceInfo.md | 12 + .../client/docs/PmemConfig.md | 4 +- .../client/docs/SgxEpcConfig.md | 12 + .../cloud-hypervisor/client/docs/VmConfig.md | 3 +- .../cloud-hypervisor/client/docs/VmResize.md | 1 + .../client/docs/VsockConfig.md | 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 +++++++- 29 files changed, 713 insertions(+), 134 deletions(-) create mode 100644 src/runtime/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/FILES create mode 100644 src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/CpuTopology.md create mode 100644 src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/PciDeviceInfo.md create mode 100644 src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/SgxEpcConfig.md create mode 100644 src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_cpu_topology.go create mode 100644 src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_pci_device_info.go create mode 100644 src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_sgx_epc_config.go diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 92ae5fd23..4e4b105d4 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -85,9 +85,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 { @@ -428,7 +428,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 { @@ -447,7 +447,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/src/runtime/virtcontainers/clh_test.go b/src/runtime/virtcontainers/clh_test.go index 4368d502a..c4713b1e5 100644 --- a/src/runtime/virtcontainers/clh_test.go +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/FILES b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/FILES new file mode 100644 index 000000000..7914a2aa6 --- /dev/null +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION index b5d898602..d99e7162d 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/.openapi-generator/VERSION +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/README.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/README.md index cdc7621b8..fe7b0209a 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/README.md +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml index ef2cfcc49..97a47b8e9 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/api/openapi.yaml +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/api_default.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/api_default.go index 0f58bec5f..c6bcc555e 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/api_default.go +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go index d59e15f8d..40d3ec919 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/client.go +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/CpuTopology.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/CpuTopology.md new file mode 100644 index 000000000..870faae76 --- /dev/null +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md index fc0755f40..840673d55 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/CpusConfig.md +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md index 46059118d..d29a8a868 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/DefaultApi.md +++ b/src/runtime/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 @@ -331,11 +332,11 @@ Add a new virtio-fs device to the VM Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**fsConfig** | [**FsConfig**](FsConfig.md)| The details of the new virtio-fs | +**fsConfig** | [**FsConfig**](FsConfig.md)| The details of the new virtio-fs | ### 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 @@ -427,11 +428,11 @@ Add a new vsock device to the VM Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. -**vsockConfig** | [**VsockConfig**](VsockConfig.md)| The details of the new vsock device | +**vsockConfig** | [**VsockConfig**](VsockConfig.md)| The details of the new vsock device | ### 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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/DiskConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/DiskConfig.md index 09f8e7b5c..db7a7441a 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/DiskConfig.md +++ b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/DiskConfig.md @@ -13,7 +13,7 @@ Name | Type | Description | Notes **VhostUser** | **bool** | | [optional] [default to false] **VhostSocket** | **string** | | [optional] **PollQueue** | **bool** | | [optional] [default to true] -**Id** | **string** | | [optional] +**Id** | **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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/FsConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/FsConfig.md index cc1ad674b..d9bb88b95 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/FsConfig.md +++ b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/FsConfig.md @@ -5,12 +5,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Tag** | **string** | | -**Socket** | **string** | | +**Socket** | **string** | | **NumQueues** | **int32** | | [optional] [default to 1] **QueueSize** | **int32** | | [optional] [default to 1024] **Dax** | **bool** | | [optional] [default to true] **CacheSize** | **int64** | | [optional] -**Id** | **string** | | [optional] +**Id** | **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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/MemoryConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/MemoryConfig.md index 03dd5b31e..f7b3f7acd 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/MemoryConfig.md +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/NetConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/NetConfig.md index 7feb392a0..ef0fc9df9 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/NetConfig.md +++ b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/NetConfig.md @@ -13,7 +13,7 @@ Name | Type | Description | Notes **QueueSize** | **int32** | | [optional] [default to 256] **VhostUser** | **bool** | | [optional] [default to false] **VhostSocket** | **string** | | [optional] -**Id** | **string** | | [optional] +**Id** | **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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/PciDeviceInfo.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/PciDeviceInfo.md new file mode 100644 index 000000000..e5b956d35 --- /dev/null +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/PmemConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/PmemConfig.md index 2fdf74419..7435cb711 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/PmemConfig.md +++ b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/PmemConfig.md @@ -5,11 +5,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **File** | **string** | | -**Size** | **int64** | | [optional] +**Size** | **int64** | | [optional] **Iommu** | **bool** | | [optional] [default to false] **Mergeable** | **bool** | | [optional] [default to false] **DiscardWrites** | **bool** | | [optional] [default to false] -**Id** | **string** | | [optional] +**Id** | **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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/SgxEpcConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/SgxEpcConfig.md new file mode 100644 index 000000000..929c278c8 --- /dev/null +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md index 65fe91120..fa2a8d21c 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md +++ b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VmConfig.md @@ -17,7 +17,8 @@ Name | Type | Description | Notes **Serial** | [**ConsoleConfig**](ConsoleConfig.md) | | [optional] **Console** | [**ConsoleConfig**](ConsoleConfig.md) | | [optional] **Devices** | [**[]DeviceConfig**](DeviceConfig.md) | | [optional] -**Vsock** | [**VsockConfig**](VsockConfig.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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md index 0adf6f716..4df9497a6 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VmResize.md +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VsockConfig.md b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VsockConfig.md index c8715276d..9ce2f7d77 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VsockConfig.md +++ b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/docs/VsockConfig.md @@ -5,9 +5,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Cid** | **int64** | Guest Vsock CID | -**Socket** | **string** | Path to UNIX domain socket, used to proxy vsock connections. | +**Socket** | **string** | Path to UNIX domain socket, used to proxy vsock connections. | **Iommu** | **bool** | | [optional] [default to false] -**Id** | **string** | | [optional] +**Id** | **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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_cpu_topology.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_cpu_topology.go new file mode 100644 index 000000000..3c8bf4b0d --- /dev/null +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go index e7ffb4bf0..37ce5e8e5 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_cpus_config.go +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_memory_config.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_memory_config.go index 5601f46d3..4b05540da 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_memory_config.go +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_pci_device_info.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_pci_device_info.go new file mode 100644 index 000000000..308386207 --- /dev/null +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_sgx_epc_config.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_sgx_epc_config.go new file mode 100644 index 000000000..9af342809 --- /dev/null +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go index d75e03b85..528406f2c 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_vm_config.go +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go b/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go index ec0e4e9db..5f79ff93f 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_vm_resize.go +++ b/src/runtime/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/src/runtime/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml b/src/runtime/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml index 5c5edb283..8b9f26e49 100644 --- a/src/runtime/virtcontainers/pkg/cloud-hypervisor/cloud-hypervisor.yaml +++ b/src/runtime/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 From 895959d007422b50e53d25297814942c6c551c31 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Tue, 11 Aug 2020 16:34:19 +0000 Subject: [PATCH 5/9] clh: Provide cpu topology to API [ Port from runtime commit 39897867bc89667daaafdd141367ec4a5fdc9247 ] API now requires cpu topology. Fixes: #461 Signed-off-by: Jose Carlos Venegas Munoz Signed-off-by: Bo Chen --- src/runtime/virtcontainers/clh.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 4e4b105d4..4e8ae627b 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -296,6 +296,12 @@ func (clh *cloudHypervisor) createSandbox(ctx context.Context, id string, networ Mode: cctOFF, } + clh.vmconfig.Cpus.Topology = chclient.CpuTopology{ + ThreadsPerCore: 1, + CoresPerDie: int32(clh.config.DefaultMaxVCPUs), + DiesPerPackage: 1, + Packages: 1, + } // Overwrite the default value of HTTP API socket path for cloud hypervisor apiSocketPath, err := clh.apiSocketPath(id) if err != nil { From 45e32e1b776ef3bcabe26683e7bc28916424e539 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Wed, 15 Jul 2020 19:03:36 -0700 Subject: [PATCH 6/9] clh: Set 'Id' explicitly while hotplugging block device [ Port from runtime commit 03fb9c50c180d3359178c30e06f1122df312ae76 ] To support unplug block device, we need to set the 'Id' explicitly while hotplugging devices with cloud-hypervisor HTTP API. Fixes: #461 Signed-off-by: Bo Chen --- src/runtime/virtcontainers/clh.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 4e8ae627b..bdf0809fd 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -408,7 +408,11 @@ func (clh *cloudHypervisor) getThreadIDs() (vcpuThreadIDs, error) { return vcpuInfo, nil } -func (clh *cloudHypervisor) hotplugBlockDevice(drive *config.BlockDrive) error { +func clhDriveIndexToID(i int) string { + return "clh_drive_" + strconv.Itoa(i) +} + +func (clh *cloudHypervisor) hotplugAddBlockDevice(drive *config.BlockDrive) error { if clh.config.BlockDeviceDriver != config.VirtioBlock { return fmt.Errorf("incorrect hypervisor configuration on 'block_device_driver':"+ " using '%v' but only support '%v'", clh.config.BlockDeviceDriver, config.VirtioBlock) @@ -423,6 +427,8 @@ func (clh *cloudHypervisor) hotplugBlockDevice(drive *config.BlockDrive) error { return openAPIClientError(err) } + driveID := clhDriveIndexToID(drive.Index) + //Explicitly set PCIAddr to NULL, so that VirtPath can be used drive.PCIAddr = "" @@ -433,6 +439,7 @@ func (clh *cloudHypervisor) hotplugBlockDevice(drive *config.BlockDrive) error { Path: drive.File, Readonly: drive.ReadOnly, VhostUser: false, + Id: driveID, } _, _, err = cl.VmAddDiskPut(ctx, blkDevice) } @@ -467,7 +474,7 @@ func (clh *cloudHypervisor) hotplugAddDevice(devInfo interface{}, devType device switch devType { case blockDev: drive := devInfo.(*config.BlockDrive) - return nil, clh.hotplugBlockDevice(drive) + return nil, clh.hotplugAddBlockDevice(drive) case vfioDev: device := devInfo.(*config.VFIODev) return nil, clh.hotPlugVFIODevice(*device) From 3ec05a9f958103b53b641f6fe0cdcc585d6e2222 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Thu, 13 Aug 2020 16:46:27 -0700 Subject: [PATCH 7/9] clh: Add support to unplug block devices [ Port from runtime commit 44b58e4151d1fc7debed41274b65c37233a437e3 ] This patch enables kata+clh to unplug block devices, which is required to pass cri-o integration tests. Fixes: #461 Signed-off-by: Bo Chen --- src/runtime/virtcontainers/clh.go | 36 ++++++++++++++++++++++++-- src/runtime/virtcontainers/clh_test.go | 31 +++++++++++++++++++--- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index bdf0809fd..e417de55a 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -88,6 +88,8 @@ type clhClient interface { 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) (chclient.PciDeviceInfo, *http.Response, error) + // Remove a device from the VM + VmRemoveDevicePut(ctx context.Context, vmRemoveDevice chclient.VmRemoveDevice) (*http.Response, error) } type CloudHypervisorVersion struct { @@ -484,9 +486,39 @@ func (clh *cloudHypervisor) hotplugAddDevice(devInfo interface{}, devType device } +func (clh *cloudHypervisor) hotplugRemoveBlockDevice(drive *config.BlockDrive) error { + cl := clh.client() + ctx, cancel := context.WithTimeout(context.Background(), clhHotPlugAPITimeout*time.Second) + defer cancel() + + driveID := clhDriveIndexToID(drive.Index) + + if drive.Pmem { + return fmt.Errorf("pmem device hotplug remove not supported") + } + + _, err := cl.VmRemoveDevicePut(ctx, chclient.VmRemoveDevice{Id: driveID}) + + if err != nil { + err = fmt.Errorf("failed to hotplug remove block device %+v %s", drive, openAPIClientError(err)) + } + + return err +} + func (clh *cloudHypervisor) hotplugRemoveDevice(devInfo interface{}, devType deviceType) (interface{}, error) { - clh.Logger().WithField("function", "hotplugRemoveDevice").Warn("hotplug remove device not supported") - return nil, nil + span, _ := clh.trace("hotplugRemoveDevice") + defer span.Finish() + + switch devType { + case blockDev: + return nil, clh.hotplugRemoveBlockDevice(devInfo.(*config.BlockDrive)) + default: + clh.Logger().WithFields(log.Fields{"devInfo": devInfo, + "deviceType": devType}).Error("hotplugRemoveDevice: unsupported device") + return nil, fmt.Errorf("Could not hot remove device: unsupported device: %v, type: %v", + devInfo, devType) + } } func (clh *cloudHypervisor) hypervisorConfig() HypervisorConfig { diff --git a/src/runtime/virtcontainers/clh_test.go b/src/runtime/virtcontainers/clh_test.go index c4713b1e5..3dcc90737 100644 --- a/src/runtime/virtcontainers/clh_test.go +++ b/src/runtime/virtcontainers/clh_test.go @@ -104,6 +104,11 @@ func (c *clhClientMock) VmAddDiskPut(ctx context.Context, diskConfig chclient.Di return chclient.PciDeviceInfo{}, nil, nil } +//nolint:golint +func (c *clhClientMock) VmRemoveDevicePut(ctx context.Context, vmRemoveDevice chclient.VmRemoveDevice) (*http.Response, error) { + return nil, nil +} + func TestCloudHypervisorAddVSock(t *testing.T) { assert := assert.New(t) clh := cloudHypervisor{} @@ -363,7 +368,7 @@ func TestCheckVersion(t *testing.T) { } } -func TestCloudHypervisorHotplugBlockDevice(t *testing.T) { +func TestCloudHypervisorHotplugAddBlockDevice(t *testing.T) { assert := assert.New(t) clhConfig, err := newClhConfig() @@ -374,13 +379,31 @@ func TestCloudHypervisorHotplugBlockDevice(t *testing.T) { clh.APIClient = &clhClientMock{} clh.config.BlockDeviceDriver = config.VirtioBlock - err = clh.hotplugBlockDevice(&config.BlockDrive{Pmem: false}) + err = clh.hotplugAddBlockDevice(&config.BlockDrive{Pmem: false}) assert.NoError(err, "Hotplug disk block device expected no error") - err = clh.hotplugBlockDevice(&config.BlockDrive{Pmem: true}) + err = clh.hotplugAddBlockDevice(&config.BlockDrive{Pmem: true}) assert.Error(err, "Hotplug pmem block device expected error") clh.config.BlockDeviceDriver = config.VirtioSCSI - err = clh.hotplugBlockDevice(&config.BlockDrive{Pmem: false}) + err = clh.hotplugAddBlockDevice(&config.BlockDrive{Pmem: false}) assert.Error(err, "Hotplug block device not using 'virtio-blk' expected error") } + +func TestCloudHypervisorHotplugRemoveBlockDevice(t *testing.T) { + assert := assert.New(t) + + clhConfig, err := newClhConfig() + assert.NoError(err) + + clh := &cloudHypervisor{} + clh.config = clhConfig + clh.APIClient = &clhClientMock{} + + clh.config.BlockDeviceDriver = config.VirtioBlock + err = clh.hotplugRemoveBlockDevice(&config.BlockDrive{Pmem: false}) + assert.NoError(err, "Hotplug remove disk block device expected no error") + + err = clh.hotplugRemoveBlockDevice(&config.BlockDrive{Pmem: true}) + assert.Error(err, "Hotplug remove pmem block device expected error") +} From 04b156f604943b3d8708f39ab55fc00d9f71d8c5 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 20 Jul 2020 22:57:30 +0000 Subject: [PATCH 8/9] qemu-virtiofs: Update to qemu 5.0 + virtiofs + dax [ Port from packaging commit cbe53bdb14e303830fa9f2d5a7f3c9161a32f033 ] Update build scripts for qemu-virtiofs. - virtiofs-0.3 patches are not needed - Sync build on how vanilla qemu is built - Apply patches for virtiofsd if any (none today) - Apply patches that are used for the qemu vanilla - Apply patches in order Fixes: #461 Signed-off-by: Jose Carlos Venegas Munoz Signed-off-by: Bo Chen --- .../virtiofsd/0001-add-time-to-seccomp.patch | 26 ---------- ...x-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch | 50 ------------------- .../static-build/qemu-virtiofs/Dockerfile | 36 ++++++++++--- 3 files changed, 28 insertions(+), 84 deletions(-) delete mode 100644 tools/packaging/qemu/patches/virtiofsd/0001-add-time-to-seccomp.patch delete mode 100644 tools/packaging/qemu/patches/virtiofsd/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch diff --git a/tools/packaging/qemu/patches/virtiofsd/0001-add-time-to-seccomp.patch b/tools/packaging/qemu/patches/virtiofsd/0001-add-time-to-seccomp.patch deleted file mode 100644 index deadcb5b0..000000000 --- a/tools/packaging/qemu/patches/virtiofsd/0001-add-time-to-seccomp.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 2317a63d2acab16be4655ec87542a2bf3d75551b Mon Sep 17 00:00:00 2001 -From: "Dr. David Alan Gilbert" -Date: Thu, 26 Sep 2019 18:41:34 +0100 -Subject: [PATCH] virtiofsd: Add time to seccomp - -Needed by static builds - -Signed-off-by: Dr. David Alan Gilbert ---- - contrib/virtiofsd/seccomp.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/contrib/virtiofsd/seccomp.c b/contrib/virtiofsd/seccomp.c -index 3b92c6ee13..374bab2bef 100644 ---- a/contrib/virtiofsd/seccomp.c -+++ b/contrib/virtiofsd/seccomp.c -@@ -75,6 +75,7 @@ static const int syscall_whitelist[] = { - SCMP_SYS(setresuid), - SCMP_SYS(set_robust_list), - SCMP_SYS(symlinkat), -+ SCMP_SYS(time), /* Rarely needed, except on static builds */ - SCMP_SYS(tgkill), - SCMP_SYS(unlinkat), - SCMP_SYS(utimensat), --- -2.21.0 diff --git a/tools/packaging/qemu/patches/virtiofsd/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch b/tools/packaging/qemu/patches/virtiofsd/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch deleted file mode 100644 index 03f8f5c1b..000000000 --- a/tools/packaging/qemu/patches/virtiofsd/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 47adda63e398a179b6211763377c8f61c5d62f5a Mon Sep 17 00:00:00 2001 -From: Sebastien Boeuf -Date: Wed, 7 Aug 2019 07:15:32 -0700 -Subject: [PATCH] libvhost-user: Fix the VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD - check - -Vhost user protocol features are set as a bitmask. And the following -constant VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD value is 10 because the bit -10 indicates if the features is set or not. - -The proper way to check for the presence or absence of this feature is -to shift 1 by the value of this constant and then mask it with the -actual bitmask representing the supported protocol features. - -This patch aims to fix the current code as it was not doing the -shifting, but instead it was masking directly with the value of the -constant itself. - -Signed-off-by: Sebastien Boeuf ---- - contrib/libvhost-user/libvhost-user.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c -index 215ce22b79..626e2a035f 100644 ---- a/contrib/libvhost-user/libvhost-user.c -+++ b/contrib/libvhost-user/libvhost-user.c -@@ -1129,7 +1129,8 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq *vq, int fd, - - vmsg.fd_num = fd_num; - -- if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) == 0) { -+ if ((dev->protocol_features & -+ (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) == 0) { - return false; - } - -@@ -2554,7 +2555,8 @@ int64_t vu_fs_cache_request(VuDev *dev, VhostUserSlaveRequest req, int fd, - - vmsg.fd_num = fd_num; - -- if ((dev->protocol_features & VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) == 0) { -+ if ((dev->protocol_features & -+ (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) == 0) { - return -EINVAL; - } - --- -2.20.1 - diff --git a/tools/packaging/static-build/qemu-virtiofs/Dockerfile b/tools/packaging/static-build/qemu-virtiofs/Dockerfile index 9f68ce8d9..2a906d694 100644 --- a/tools/packaging/static-build/qemu-virtiofs/Dockerfile +++ b/tools/packaging/static-build/qemu-virtiofs/Dockerfile @@ -1,4 +1,4 @@ -from ubuntu:18.04 +from ubuntu:20.04 ARG QEMU_VIRTIOFS_REPO # commit/tag/branch @@ -19,37 +19,57 @@ RUN apt-get --no-install-recommends install -y \ flex \ gawk \ libaudit-dev \ + libblkid-dev \ libcap-dev \ libcap-ng-dev \ libdw-dev \ libelf-dev \ + libffi-dev \ libglib2.0-0 \ libglib2.0-dev \ libglib2.0-dev git \ libltdl-dev \ + libmount-dev \ libpixman-1-dev \ libpmem-dev \ libseccomp-dev \ + libseccomp2 \ + libselinux1-dev \ libtool \ - patch \ + make \ pkg-config \ pkg-config \ python \ python-dev \ rsync \ seccomp \ - libseccomp2 \ zlib1g-dev RUN cd .. && git clone "${QEMU_VIRTIOFS_REPO}" qemu-virtiofs RUN git checkout "${QEMU_VIRTIOFS_TAG}" -ADD qemu/patches/virtiofsd/0001-add-time-to-seccomp.patch /root/0001-add-time-to-seccomp.patch -ADD qemu/patches/virtiofsd/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch /root/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch -RUN patch -p1 < /root/0001-add-time-to-seccomp.patch -RUN patch -p1 < /root/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch + ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh -RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | sed -e 's|--enable-rbd||g' -e 's|--disable-seccomp||g' | xargs ./configure \ +ADD qemu/patches/ /root/kata_qemu_patches + +# Apply experimental specific patches +# Patches to quick fix virtiofs fork +ENV VIRTIOFS_PATCHES_DIR=/root/kata_qemu_patches/${QEMU_VIRTIOFS_TAG}/ +RUN find "${VIRTIOFS_PATCHES_DIR}" -name '*.patch' -type f |sort -t- -k1,1n > patches_virtiofs +RUN echo "Patches to apply for virtiofs fixes:" +RUN cat patches_virtiofs +RUN [ ! -s patches_virtiofs ] || git apply $(cat patches_virtiofs) + +RUN cat VERSION | awk 'BEGIN{FS=OFS="."}{print $1 "." $2 ".x"}' > stable_branch +RUN echo "root/kata_qemu_patches/$(cat stable_branch)/" > patches_qemu_dir +RUN echo "patches dir $(cat patches_qemu_dir)" +RUN find "$(cat patches_qemu_dir)" -name '*.patch' -type f |sort -t- -k1,1n > patches_qemu +RUN echo "Patches to apply for qemu:" +RUN cat patches_qemu +RUN [ ! -s patches_qemu ] || git apply $(cat patches_qemu ) + +RUN PREFIX="${PREFIX}" /root/configure-hypervisor.sh -s kata-qemu | sed -e 's|--disable-seccomp||g' | xargs ./configure \ --with-pkgversion=kata-static + RUN make -j$(nproc) RUN make -j$(nproc) virtiofsd RUN make install DESTDIR=/tmp/qemu-virtiofs-static From 39b53f446735b23c883a13dead82c26d0ce33059 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Thu, 6 Aug 2020 15:37:32 +0000 Subject: [PATCH 9/9] clh: enable build using Podman [ Port from packaging commit 4e1b5729f47d5f67902e1344521bc5b121673046 ] Build clh with Podman, allow build the vmm in the Podman CI Virtiofs qemu has to be build as this is requried by clh. Fixes: #461 Signed-off-by: Jose Carlos Venegas Munoz Signed-off-by: Bo Chen --- .../cloud-hypervisor/docker-build/build.sh | 10 ++++++++-- .../qemu-virtiofs/build-static-qemu-virtiofs.sh | 12 +++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/packaging/static-build/cloud-hypervisor/docker-build/build.sh b/tools/packaging/static-build/cloud-hypervisor/docker-build/build.sh index d29c933dd..f7e3e988a 100755 --- a/tools/packaging/static-build/cloud-hypervisor/docker-build/build.sh +++ b/tools/packaging/static-build/cloud-hypervisor/docker-build/build.sh @@ -11,7 +11,13 @@ set -o pipefail script_dir=$(dirname $(readlink -f "$0")) docker_image="cloud-hypervisor-builder" -sudo docker build -t "${docker_image}" "${script_dir}" +DOCKER_CLI="docker" + +if ! command -v docker && command -v podman; then + DOCKER_CLI="podman" +fi + +sudo "${DOCKER_CLI}" build -t "${docker_image}" "${script_dir}" if test -t 1; then USE_TTY="-ti" @@ -20,7 +26,7 @@ else echo "INFO: not tty build" fi -sudo docker run \ +sudo "${DOCKER_CLI}" run \ --rm \ -v "$(pwd):/$(pwd)" \ -w "$(pwd)" \ diff --git a/tools/packaging/static-build/qemu-virtiofs/build-static-qemu-virtiofs.sh b/tools/packaging/static-build/qemu-virtiofs/build-static-qemu-virtiofs.sh index dd89c32f2..482339317 100755 --- a/tools/packaging/static-build/qemu-virtiofs/build-static-qemu-virtiofs.sh +++ b/tools/packaging/static-build/qemu-virtiofs/build-static-qemu-virtiofs.sh @@ -13,11 +13,17 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${script_dir}/../../scripts/lib.sh" source "${script_dir}/../qemu.blacklist" +DOCKER_CLI="docker" + +if ! command -v docker &>/dev/null && command -v podman &>/dev/null; then + DOCKER_CLI="podman" +fi + kata_version="${kata_version:-}" packaging_dir="${script_dir}/../.." qemu_virtiofs_repo=$(get_from_kata_deps "assets.hypervisor.qemu-experimental.url" "${kata_version}") # This tag will be supported on the runtime versions.yaml -qemu_virtiofs_tag=$(get_from_kata_deps "assets.hypervisor.qemu-experimental.tag" "${kata_version}") +qemu_virtiofs_tag=$(get_from_kata_deps "assets.hypervisor.qemu-experimental.tag" "${kata_version}") qemu_virtiofs_tar="kata-static-qemu-virtiofsd.tar.gz" qemu_tmp_tar="kata-static-qemu-virtiofsd-tmp.tar.gz" @@ -27,7 +33,7 @@ http_proxy="${http_proxy:-}" https_proxy="${https_proxy:-}" prefix="${prefix:-"/opt/kata"}" -sudo docker build \ +sudo "${DOCKER_CLI}" build \ --no-cache \ --build-arg http_proxy="${http_proxy}" \ --build-arg https_proxy="${https_proxy}" \ @@ -39,7 +45,7 @@ sudo docker build \ -f "${script_dir}/Dockerfile" \ -t qemu-virtiofs-static -sudo docker run \ +sudo "${DOCKER_CLI}" run \ -i \ -v "${PWD}":/share qemu-virtiofs-static \ mv "/tmp/qemu-virtiofs-static/${qemu_virtiofs_tar}" /share/