mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-09 11:58:16 +00:00
commit
2d89766d3a
@ -75,7 +75,7 @@ assets:
|
|||||||
url: "https://github.com/cloud-hypervisor/cloud-hypervisor"
|
url: "https://github.com/cloud-hypervisor/cloud-hypervisor"
|
||||||
uscan-url: >-
|
uscan-url: >-
|
||||||
https://github.com/cloud-hypervisor/cloud-hypervisor/tags.*/v?(\d\S+)\.tar\.gz
|
https://github.com/cloud-hypervisor/cloud-hypervisor/tags.*/v?(\d\S+)\.tar\.gz
|
||||||
version: "stable/v0.5.x"
|
version: "df794993f8abe20f829275c77fb2a52ed485f70a"
|
||||||
|
|
||||||
firecracker:
|
firecracker:
|
||||||
description: "Firecracker micro-VMM"
|
description: "Firecracker micro-VMM"
|
||||||
|
@ -50,8 +50,11 @@ const (
|
|||||||
const (
|
const (
|
||||||
// Values are mandatory by http API
|
// Values are mandatory by http API
|
||||||
// Values based on:
|
// Values based on:
|
||||||
clhTimeout = 10
|
clhTimeout = 10
|
||||||
clhAPITimeout = 1
|
clhAPITimeout = 1
|
||||||
|
// Timeout for hot-plug - hotplug devices can take more time, than usual API calls
|
||||||
|
// Use longer time timeout for it.
|
||||||
|
clhHotPlugAPITimeout = 5
|
||||||
clhStopSandboxTimeout = 3
|
clhStopSandboxTimeout = 3
|
||||||
clhSocket = "clh.sock"
|
clhSocket = "clh.sock"
|
||||||
clhAPISocket = "clh-api.sock"
|
clhAPISocket = "clh-api.sock"
|
||||||
@ -69,13 +72,21 @@ const (
|
|||||||
// The main purpose is to hide the client in an interface to allow mock testing.
|
// The main purpose is to hide the client in an interface to allow mock testing.
|
||||||
// This is an interface that has to match with OpenAPI CLH client
|
// This is an interface that has to match with OpenAPI CLH client
|
||||||
type clhClient interface {
|
type clhClient interface {
|
||||||
|
// Check for the REST API availability
|
||||||
VmmPingGet(ctx context.Context) (chclient.VmmPingResponse, *http.Response, error)
|
VmmPingGet(ctx context.Context) (chclient.VmmPingResponse, *http.Response, error)
|
||||||
|
// Shut the VMM down
|
||||||
ShutdownVMM(ctx context.Context) (*http.Response, error)
|
ShutdownVMM(ctx context.Context) (*http.Response, error)
|
||||||
|
// Create the VM
|
||||||
CreateVM(ctx context.Context, vmConfig chclient.VmConfig) (*http.Response, error)
|
CreateVM(ctx context.Context, vmConfig chclient.VmConfig) (*http.Response, error)
|
||||||
|
// Dump the VM information
|
||||||
// No lint: golint suggest to rename to VMInfoGet.
|
// No lint: golint suggest to rename to VMInfoGet.
|
||||||
VmInfoGet(ctx context.Context) (chclient.VmInfo, *http.Response, error) //nolint:golint
|
VmInfoGet(ctx context.Context) (chclient.VmInfo, *http.Response, error) //nolint:golint
|
||||||
|
// Boot the VM
|
||||||
BootVM(ctx context.Context) (*http.Response, error)
|
BootVM(ctx context.Context) (*http.Response, error)
|
||||||
|
// Add/remove CPUs to/from the VM
|
||||||
VmResizePut(ctx context.Context, vmResize chclient.VmResize) (*http.Response, error)
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
type CloudHypervisorVersion struct {
|
type CloudHypervisorVersion struct {
|
||||||
@ -372,9 +383,35 @@ func (clh *cloudHypervisor) getThreadIDs() (vcpuThreadIDs, error) {
|
|||||||
return vcpuInfo, nil
|
return vcpuInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (clh *cloudHypervisor) hotPlugVFIODevice(device config.VFIODev) error {
|
||||||
|
cl := clh.client()
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), clhHotPlugAPITimeout*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
_, _, err := cl.VmmPingGet(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return openAPIClientError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = cl.VmAddDevicePut(ctx, chclient.VmAddDevice{Path: device.SysfsDev})
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("Failed to hotplug device %+v %s", device, openAPIClientError(err))
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (clh *cloudHypervisor) hotplugAddDevice(devInfo interface{}, devType deviceType) (interface{}, error) {
|
func (clh *cloudHypervisor) hotplugAddDevice(devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||||
clh.Logger().WithField("function", "hotplugAddDevice").Warn("hotplug add device not supported")
|
span, _ := clh.trace("hotplugAddDevice")
|
||||||
return nil, nil
|
defer span.Finish()
|
||||||
|
|
||||||
|
switch devType {
|
||||||
|
case vfioDev:
|
||||||
|
device := devInfo.(*config.VFIODev)
|
||||||
|
return nil, clh.hotPlugVFIODevice(*device)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("cannot hotplug device: unsupported device type '%v'", devType)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (clh *cloudHypervisor) hotplugRemoveDevice(devInfo interface{}, devType deviceType) (interface{}, error) {
|
func (clh *cloudHypervisor) hotplugRemoveDevice(devInfo interface{}, devType deviceType) (interface{}, error) {
|
||||||
|
@ -86,6 +86,11 @@ func (c *clhClientMock) VmResizePut(ctx context.Context, vmResize chclient.VmRes
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:golint
|
||||||
|
func (c *clhClientMock) VmAddDevicePut(ctx context.Context, vmAddDevice chclient.VmAddDevice) (*http.Response, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func TestCloudHypervisorAddVSock(t *testing.T) {
|
func TestCloudHypervisorAddVSock(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
clh := cloudHypervisor{}
|
clh := cloudHypervisor{}
|
||||||
|
@ -194,6 +194,8 @@ func getVFIODetails(deviceFileName, iommuDevicesPath string) (deviceBDF, deviceS
|
|||||||
case config.VFIODeviceNormalType:
|
case config.VFIODeviceNormalType:
|
||||||
// Get bdf of device eg. 0000:00:1c.0
|
// Get bdf of device eg. 0000:00:1c.0
|
||||||
deviceBDF = getBDF(deviceFileName)
|
deviceBDF = getBDF(deviceFileName)
|
||||||
|
// Get sysfs path used by cloud-hypervisor
|
||||||
|
deviceSysfsDev = filepath.Join(config.SysBusPciDevicesPath, deviceFileName)
|
||||||
case config.VFIODeviceMediatedType:
|
case config.VFIODeviceMediatedType:
|
||||||
// Get sysfsdev of device eg. /sys/devices/pci0000:00/0000:00:02.0/f79944e4-5a3d-11e8-99ce-479cbab002e4
|
// Get sysfsdev of device eg. /sys/devices/pci0000:00/0000:00:02.0/f79944e4-5a3d-11e8-99ce-479cbab002e4
|
||||||
sysfsDevStr := filepath.Join(iommuDevicesPath, deviceFileName)
|
sysfsDevStr := filepath.Join(iommuDevicesPath, deviceFileName)
|
||||||
|
@ -40,6 +40,7 @@ Class | Method | HTTP request | Description
|
|||||||
*DefaultApi* | [**ResumeVM**](docs/DefaultApi.md#resumevm) | **Put** /vm.resume | Resume a previously paused VM instance.
|
*DefaultApi* | [**ResumeVM**](docs/DefaultApi.md#resumevm) | **Put** /vm.resume | Resume a previously paused VM instance.
|
||||||
*DefaultApi* | [**ShutdownVM**](docs/DefaultApi.md#shutdownvm) | **Put** /vm.shutdown | Shut the VM instance down.
|
*DefaultApi* | [**ShutdownVM**](docs/DefaultApi.md#shutdownvm) | **Put** /vm.shutdown | Shut the VM instance down.
|
||||||
*DefaultApi* | [**ShutdownVMM**](docs/DefaultApi.md#shutdownvmm) | **Put** /vmm.shutdown | Shuts the cloud-hypervisor VMM.
|
*DefaultApi* | [**ShutdownVMM**](docs/DefaultApi.md#shutdownvmm) | **Put** /vmm.shutdown | Shuts the cloud-hypervisor VMM.
|
||||||
|
*DefaultApi* | [**VmAddDevicePut**](docs/DefaultApi.md#vmadddeviceput) | **Put** /vm.add-device | Add a new device to the VM
|
||||||
*DefaultApi* | [**VmInfoGet**](docs/DefaultApi.md#vminfoget) | **Get** /vm.info | Returns general information about the cloud-hypervisor Virtual Machine (VM) instance.
|
*DefaultApi* | [**VmInfoGet**](docs/DefaultApi.md#vminfoget) | **Get** /vm.info | Returns general information about the cloud-hypervisor Virtual Machine (VM) instance.
|
||||||
*DefaultApi* | [**VmResizePut**](docs/DefaultApi.md#vmresizeput) | **Put** /vm.resize | Resize the VM
|
*DefaultApi* | [**VmResizePut**](docs/DefaultApi.md#vmresizeput) | **Put** /vm.resize | Resize the VM
|
||||||
*DefaultApi* | [**VmmPingGet**](docs/DefaultApi.md#vmmpingget) | **Get** /vmm.ping | Ping the VMM to check for API server availability
|
*DefaultApi* | [**VmmPingGet**](docs/DefaultApi.md#vmmpingget) | **Get** /vmm.ping | Ping the VMM to check for API server availability
|
||||||
@ -58,8 +59,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [NetConfig](docs/NetConfig.md)
|
- [NetConfig](docs/NetConfig.md)
|
||||||
- [PmemConfig](docs/PmemConfig.md)
|
- [PmemConfig](docs/PmemConfig.md)
|
||||||
- [RngConfig](docs/RngConfig.md)
|
- [RngConfig](docs/RngConfig.md)
|
||||||
- [VhostUserBlkConfig](docs/VhostUserBlkConfig.md)
|
- [VmAddDevice](docs/VmAddDevice.md)
|
||||||
- [VhostUserNetConfig](docs/VhostUserNetConfig.md)
|
|
||||||
- [VmConfig](docs/VmConfig.md)
|
- [VmConfig](docs/VmConfig.md)
|
||||||
- [VmInfo](docs/VmInfo.md)
|
- [VmInfo](docs/VmInfo.md)
|
||||||
- [VmResize](docs/VmResize.md)
|
- [VmResize](docs/VmResize.md)
|
||||||
|
@ -128,6 +128,21 @@ paths:
|
|||||||
"404":
|
"404":
|
||||||
description: The VM instance could not be resized because it is not created.
|
description: The VM instance could not be resized because it is not created.
|
||||||
summary: Resize the VM
|
summary: Resize the VM
|
||||||
|
/vm.add-device:
|
||||||
|
put:
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/VmAddDevice'
|
||||||
|
description: The path of the new device
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
"204":
|
||||||
|
description: The new device was successfully added to the VM instance.
|
||||||
|
"404":
|
||||||
|
description: The new device could not be added to the VM instance.
|
||||||
|
summary: Add a new device to the VM
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
VmmPingResponse:
|
VmmPingResponse:
|
||||||
@ -161,7 +176,9 @@ components:
|
|||||||
queue_size: 5
|
queue_size: 5
|
||||||
vhost_socket: vhost_socket
|
vhost_socket: vhost_socket
|
||||||
vhost_user: false
|
vhost_user: false
|
||||||
|
direct: false
|
||||||
wce: true
|
wce: true
|
||||||
|
poll_queue: true
|
||||||
- path: path
|
- path: path
|
||||||
num_queues: 5
|
num_queues: 5
|
||||||
readonly: false
|
readonly: false
|
||||||
@ -169,7 +186,9 @@ components:
|
|||||||
queue_size: 5
|
queue_size: 5
|
||||||
vhost_socket: vhost_socket
|
vhost_socket: vhost_socket
|
||||||
vhost_user: false
|
vhost_user: false
|
||||||
|
direct: false
|
||||||
wce: true
|
wce: true
|
||||||
|
poll_queue: true
|
||||||
cpus:
|
cpus:
|
||||||
boot_vcpus: 1
|
boot_vcpus: 1
|
||||||
max_vcpus: 1
|
max_vcpus: 1
|
||||||
@ -180,15 +199,6 @@ components:
|
|||||||
iommu: false
|
iommu: false
|
||||||
kernel:
|
kernel:
|
||||||
path: path
|
path: path
|
||||||
vhost_user_blk:
|
|
||||||
- sock: sock
|
|
||||||
num_queues: 1
|
|
||||||
queue_size: 1
|
|
||||||
wce: true
|
|
||||||
- sock: sock
|
|
||||||
num_queues: 1
|
|
||||||
queue_size: 1
|
|
||||||
wce: true
|
|
||||||
rng:
|
rng:
|
||||||
iommu: false
|
iommu: false
|
||||||
src: /dev/urandom
|
src: /dev/urandom
|
||||||
@ -205,15 +215,6 @@ components:
|
|||||||
cache_size: 2
|
cache_size: 2
|
||||||
dax: true
|
dax: true
|
||||||
tag: tag
|
tag: tag
|
||||||
vhost_user_net:
|
|
||||||
- sock: sock
|
|
||||||
num_queues: 7
|
|
||||||
queue_size: 1
|
|
||||||
mac: mac
|
|
||||||
- sock: sock
|
|
||||||
num_queues: 7
|
|
||||||
queue_size: 1
|
|
||||||
mac: mac
|
|
||||||
vsock:
|
vsock:
|
||||||
- sock: sock
|
- sock: sock
|
||||||
iommu: false
|
iommu: false
|
||||||
@ -262,8 +263,9 @@ components:
|
|||||||
state:
|
state:
|
||||||
enum:
|
enum:
|
||||||
- Created
|
- Created
|
||||||
- Booted
|
- Running
|
||||||
- Shutdown
|
- Shutdown
|
||||||
|
- Paused
|
||||||
type: string
|
type: string
|
||||||
required:
|
required:
|
||||||
- config
|
- config
|
||||||
@ -288,7 +290,9 @@ components:
|
|||||||
queue_size: 5
|
queue_size: 5
|
||||||
vhost_socket: vhost_socket
|
vhost_socket: vhost_socket
|
||||||
vhost_user: false
|
vhost_user: false
|
||||||
|
direct: false
|
||||||
wce: true
|
wce: true
|
||||||
|
poll_queue: true
|
||||||
- path: path
|
- path: path
|
||||||
num_queues: 5
|
num_queues: 5
|
||||||
readonly: false
|
readonly: false
|
||||||
@ -296,7 +300,9 @@ components:
|
|||||||
queue_size: 5
|
queue_size: 5
|
||||||
vhost_socket: vhost_socket
|
vhost_socket: vhost_socket
|
||||||
vhost_user: false
|
vhost_user: false
|
||||||
|
direct: false
|
||||||
wce: true
|
wce: true
|
||||||
|
poll_queue: true
|
||||||
cpus:
|
cpus:
|
||||||
boot_vcpus: 1
|
boot_vcpus: 1
|
||||||
max_vcpus: 1
|
max_vcpus: 1
|
||||||
@ -307,15 +313,6 @@ components:
|
|||||||
iommu: false
|
iommu: false
|
||||||
kernel:
|
kernel:
|
||||||
path: path
|
path: path
|
||||||
vhost_user_blk:
|
|
||||||
- sock: sock
|
|
||||||
num_queues: 1
|
|
||||||
queue_size: 1
|
|
||||||
wce: true
|
|
||||||
- sock: sock
|
|
||||||
num_queues: 1
|
|
||||||
queue_size: 1
|
|
||||||
wce: true
|
|
||||||
rng:
|
rng:
|
||||||
iommu: false
|
iommu: false
|
||||||
src: /dev/urandom
|
src: /dev/urandom
|
||||||
@ -332,15 +329,6 @@ components:
|
|||||||
cache_size: 2
|
cache_size: 2
|
||||||
dax: true
|
dax: true
|
||||||
tag: tag
|
tag: tag
|
||||||
vhost_user_net:
|
|
||||||
- sock: sock
|
|
||||||
num_queues: 7
|
|
||||||
queue_size: 1
|
|
||||||
mac: mac
|
|
||||||
- sock: sock
|
|
||||||
num_queues: 7
|
|
||||||
queue_size: 1
|
|
||||||
mac: mac
|
|
||||||
vsock:
|
vsock:
|
||||||
- sock: sock
|
- sock: sock
|
||||||
iommu: false
|
iommu: false
|
||||||
@ -418,14 +406,6 @@ components:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/DeviceConfig'
|
$ref: '#/components/schemas/DeviceConfig'
|
||||||
type: array
|
type: array
|
||||||
vhost_user_net:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/VhostUserNetConfig'
|
|
||||||
type: array
|
|
||||||
vhost_user_blk:
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/VhostUserBlkConfig'
|
|
||||||
type: array
|
|
||||||
vsock:
|
vsock:
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/VsockConfig'
|
$ref: '#/components/schemas/VsockConfig'
|
||||||
@ -498,13 +478,18 @@ components:
|
|||||||
queue_size: 5
|
queue_size: 5
|
||||||
vhost_socket: vhost_socket
|
vhost_socket: vhost_socket
|
||||||
vhost_user: false
|
vhost_user: false
|
||||||
|
direct: false
|
||||||
wce: true
|
wce: true
|
||||||
|
poll_queue: true
|
||||||
properties:
|
properties:
|
||||||
path:
|
path:
|
||||||
type: string
|
type: string
|
||||||
readonly:
|
readonly:
|
||||||
default: false
|
default: false
|
||||||
type: boolean
|
type: boolean
|
||||||
|
direct:
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
iommu:
|
iommu:
|
||||||
default: false
|
default: false
|
||||||
type: boolean
|
type: boolean
|
||||||
@ -522,6 +507,9 @@ components:
|
|||||||
wce:
|
wce:
|
||||||
default: true
|
default: true
|
||||||
type: boolean
|
type: boolean
|
||||||
|
poll_queue:
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
required:
|
required:
|
||||||
- path
|
- path
|
||||||
type: object
|
type: object
|
||||||
@ -641,7 +629,7 @@ components:
|
|||||||
- "false"
|
- "false"
|
||||||
- Tty
|
- Tty
|
||||||
- File
|
- File
|
||||||
- None
|
- null
|
||||||
type: string
|
type: string
|
||||||
iommu:
|
iommu:
|
||||||
default: false
|
default: false
|
||||||
@ -662,47 +650,6 @@ components:
|
|||||||
required:
|
required:
|
||||||
- path
|
- path
|
||||||
type: object
|
type: object
|
||||||
VhostUserNetConfig:
|
|
||||||
example:
|
|
||||||
sock: sock
|
|
||||||
num_queues: 7
|
|
||||||
queue_size: 1
|
|
||||||
mac: mac
|
|
||||||
properties:
|
|
||||||
sock:
|
|
||||||
type: string
|
|
||||||
num_queues:
|
|
||||||
default: 2
|
|
||||||
type: integer
|
|
||||||
queue_size:
|
|
||||||
default: 256
|
|
||||||
type: integer
|
|
||||||
mac:
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- sock
|
|
||||||
type: object
|
|
||||||
VhostUserBlkConfig:
|
|
||||||
example:
|
|
||||||
sock: sock
|
|
||||||
num_queues: 1
|
|
||||||
queue_size: 1
|
|
||||||
wce: true
|
|
||||||
properties:
|
|
||||||
sock:
|
|
||||||
type: string
|
|
||||||
num_queues:
|
|
||||||
default: 1
|
|
||||||
type: integer
|
|
||||||
queue_size:
|
|
||||||
default: 128
|
|
||||||
type: integer
|
|
||||||
wce:
|
|
||||||
default: true
|
|
||||||
type: boolean
|
|
||||||
required:
|
|
||||||
- sock
|
|
||||||
type: object
|
|
||||||
VsockConfig:
|
VsockConfig:
|
||||||
example:
|
example:
|
||||||
sock: sock
|
sock: sock
|
||||||
@ -735,3 +682,10 @@ components:
|
|||||||
desired_ram:
|
desired_ram:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
|
VmAddDevice:
|
||||||
|
example:
|
||||||
|
path: path
|
||||||
|
properties:
|
||||||
|
path:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
@ -531,6 +531,72 @@ func (a *DefaultApiService) ShutdownVMM(ctx _context.Context) (*_nethttp.Respons
|
|||||||
return localVarHTTPResponse, nil
|
return localVarHTTPResponse, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
func (a *DefaultApiService) VmAddDevicePut(ctx _context.Context, vmAddDevice VmAddDevice) (*_nethttp.Response, error) {
|
||||||
|
var (
|
||||||
|
localVarHTTPMethod = _nethttp.MethodPut
|
||||||
|
localVarPostBody interface{}
|
||||||
|
localVarFormFileName string
|
||||||
|
localVarFileName string
|
||||||
|
localVarFileBytes []byte
|
||||||
|
)
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
localVarPath := a.client.cfg.BasePath + "/vm.add-device"
|
||||||
|
localVarHeaderParams := make(map[string]string)
|
||||||
|
localVarQueryParams := _neturl.Values{}
|
||||||
|
localVarFormParams := _neturl.Values{}
|
||||||
|
|
||||||
|
// to determine the Content-Type header
|
||||||
|
localVarHTTPContentTypes := []string{"application/json"}
|
||||||
|
|
||||||
|
// set Content-Type header
|
||||||
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
||||||
|
if localVarHTTPContentType != "" {
|
||||||
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
||||||
|
}
|
||||||
|
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHTTPHeaderAccepts := []string{}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
||||||
|
if localVarHTTPHeaderAccept != "" {
|
||||||
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
||||||
|
}
|
||||||
|
// body params
|
||||||
|
localVarPostBody = &vmAddDevice
|
||||||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
localVarHTTPResponse, err := a.client.callAPI(r)
|
||||||
|
if err != nil || localVarHTTPResponse == nil {
|
||||||
|
return localVarHTTPResponse, err
|
||||||
|
}
|
||||||
|
|
||||||
|
localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body)
|
||||||
|
localVarHTTPResponse.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
return localVarHTTPResponse, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if localVarHTTPResponse.StatusCode >= 300 {
|
||||||
|
newErr := GenericOpenAPIError{
|
||||||
|
body: localVarBody,
|
||||||
|
error: localVarHTTPResponse.Status,
|
||||||
|
}
|
||||||
|
return localVarHTTPResponse, newErr
|
||||||
|
}
|
||||||
|
|
||||||
|
return localVarHTTPResponse, nil
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
VmInfoGet Returns general information about the cloud-hypervisor Virtual Machine (VM) instance.
|
VmInfoGet Returns general information about the cloud-hypervisor Virtual Machine (VM) instance.
|
||||||
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||||||
|
@ -12,6 +12,7 @@ Method | HTTP request | Description
|
|||||||
[**ResumeVM**](DefaultApi.md#ResumeVM) | **Put** /vm.resume | Resume a previously paused VM instance.
|
[**ResumeVM**](DefaultApi.md#ResumeVM) | **Put** /vm.resume | Resume a previously paused VM instance.
|
||||||
[**ShutdownVM**](DefaultApi.md#ShutdownVM) | **Put** /vm.shutdown | Shut the VM instance down.
|
[**ShutdownVM**](DefaultApi.md#ShutdownVM) | **Put** /vm.shutdown | Shut the VM instance down.
|
||||||
[**ShutdownVMM**](DefaultApi.md#ShutdownVMM) | **Put** /vmm.shutdown | Shuts the cloud-hypervisor VMM.
|
[**ShutdownVMM**](DefaultApi.md#ShutdownVMM) | **Put** /vmm.shutdown | Shuts the cloud-hypervisor VMM.
|
||||||
|
[**VmAddDevicePut**](DefaultApi.md#VmAddDevicePut) | **Put** /vm.add-device | Add a new device to the VM
|
||||||
[**VmInfoGet**](DefaultApi.md#VmInfoGet) | **Get** /vm.info | Returns general information about the cloud-hypervisor Virtual Machine (VM) instance.
|
[**VmInfoGet**](DefaultApi.md#VmInfoGet) | **Get** /vm.info | Returns general information about the cloud-hypervisor Virtual Machine (VM) instance.
|
||||||
[**VmResizePut**](DefaultApi.md#VmResizePut) | **Put** /vm.resize | Resize the VM
|
[**VmResizePut**](DefaultApi.md#VmResizePut) | **Put** /vm.resize | Resize the VM
|
||||||
[**VmmPingGet**](DefaultApi.md#VmmPingGet) | **Get** /vmm.ping | Ping the VMM to check for API server availability
|
[**VmmPingGet**](DefaultApi.md#VmmPingGet) | **Get** /vmm.ping | Ping the VMM to check for API server availability
|
||||||
@ -246,6 +247,38 @@ No authorization required
|
|||||||
[[Back to README]](../README.md)
|
[[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
|
## VmAddDevicePut
|
||||||
|
|
||||||
|
> VmAddDevicePut(ctx, vmAddDevice)
|
||||||
|
|
||||||
|
Add a new device to the VM
|
||||||
|
|
||||||
|
### Required Parameters
|
||||||
|
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
|
||||||
|
**vmAddDevice** | [**VmAddDevice**](VmAddDevice.md)| The path of the new device |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
(empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models)
|
||||||
|
[[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
## VmInfoGet
|
## VmInfoGet
|
||||||
|
|
||||||
> VmInfo VmInfoGet(ctx, )
|
> VmInfo VmInfoGet(ctx, )
|
||||||
|
@ -6,12 +6,14 @@ Name | Type | Description | Notes
|
|||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Path** | **string** | |
|
**Path** | **string** | |
|
||||||
**Readonly** | **bool** | | [optional] [default to false]
|
**Readonly** | **bool** | | [optional] [default to false]
|
||||||
|
**Direct** | **bool** | | [optional] [default to false]
|
||||||
**Iommu** | **bool** | | [optional] [default to false]
|
**Iommu** | **bool** | | [optional] [default to false]
|
||||||
**NumQueues** | **int32** | | [optional] [default to 1]
|
**NumQueues** | **int32** | | [optional] [default to 1]
|
||||||
**QueueSize** | **int32** | | [optional] [default to 128]
|
**QueueSize** | **int32** | | [optional] [default to 128]
|
||||||
**VhostUser** | **bool** | | [optional] [default to false]
|
**VhostUser** | **bool** | | [optional] [default to false]
|
||||||
**VhostSocket** | **string** | | [optional]
|
**VhostSocket** | **string** | | [optional]
|
||||||
**Wce** | **bool** | | [optional] [default to true]
|
**Wce** | **bool** | | [optional] [default to true]
|
||||||
|
**PollQueue** | **bool** | | [optional] [default to true]
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
# VhostUserBlkConfig
|
|
||||||
|
|
||||||
## Properties
|
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
|
||||||
------------ | ------------- | ------------- | -------------
|
|
||||||
**Sock** | **string** | |
|
|
||||||
**NumQueues** | **int32** | | [optional] [default to 1]
|
|
||||||
**QueueSize** | **int32** | | [optional] [default to 128]
|
|
||||||
**Wce** | **bool** | | [optional] [default to true]
|
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
|
||||||
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
|||||||
# VhostUserNetConfig
|
# VmAddDevice
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**Sock** | **string** | |
|
**Path** | **string** | | [optional]
|
||||||
**NumQueues** | **int32** | | [optional] [default to 2]
|
|
||||||
**QueueSize** | **int32** | | [optional] [default to 256]
|
|
||||||
**Mac** | **string** | | [optional]
|
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
@ -16,8 +16,6 @@ Name | Type | Description | Notes
|
|||||||
**Serial** | [**ConsoleConfig**](ConsoleConfig.md) | | [optional]
|
**Serial** | [**ConsoleConfig**](ConsoleConfig.md) | | [optional]
|
||||||
**Console** | [**ConsoleConfig**](ConsoleConfig.md) | | [optional]
|
**Console** | [**ConsoleConfig**](ConsoleConfig.md) | | [optional]
|
||||||
**Devices** | [**[]DeviceConfig**](DeviceConfig.md) | | [optional]
|
**Devices** | [**[]DeviceConfig**](DeviceConfig.md) | | [optional]
|
||||||
**VhostUserNet** | [**[]VhostUserNetConfig**](VhostUserNetConfig.md) | | [optional]
|
|
||||||
**VhostUserBlk** | [**[]VhostUserBlkConfig**](VhostUserBlkConfig.md) | | [optional]
|
|
||||||
**Vsock** | [**[]VsockConfig**](VsockConfig.md) | | [optional]
|
**Vsock** | [**[]VsockConfig**](VsockConfig.md) | | [optional]
|
||||||
**Iommu** | **bool** | | [optional] [default to false]
|
**Iommu** | **bool** | | [optional] [default to false]
|
||||||
|
|
||||||
|
@ -12,10 +12,12 @@ package openapi
|
|||||||
type DiskConfig struct {
|
type DiskConfig struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Readonly bool `json:"readonly,omitempty"`
|
Readonly bool `json:"readonly,omitempty"`
|
||||||
|
Direct bool `json:"direct,omitempty"`
|
||||||
Iommu bool `json:"iommu,omitempty"`
|
Iommu bool `json:"iommu,omitempty"`
|
||||||
NumQueues int32 `json:"num_queues,omitempty"`
|
NumQueues int32 `json:"num_queues,omitempty"`
|
||||||
QueueSize int32 `json:"queue_size,omitempty"`
|
QueueSize int32 `json:"queue_size,omitempty"`
|
||||||
VhostUser bool `json:"vhost_user,omitempty"`
|
VhostUser bool `json:"vhost_user,omitempty"`
|
||||||
VhostSocket string `json:"vhost_socket,omitempty"`
|
VhostSocket string `json:"vhost_socket,omitempty"`
|
||||||
Wce bool `json:"wce,omitempty"`
|
Wce bool `json:"wce,omitempty"`
|
||||||
|
PollQueue bool `json:"poll_queue,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
// VhostUserBlkConfig struct for VhostUserBlkConfig
|
|
||||||
type VhostUserBlkConfig struct {
|
|
||||||
Sock string `json:"sock"`
|
|
||||||
NumQueues int32 `json:"num_queues,omitempty"`
|
|
||||||
QueueSize int32 `json:"queue_size,omitempty"`
|
|
||||||
Wce bool `json:"wce,omitempty"`
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
// VhostUserNetConfig struct for VhostUserNetConfig
|
|
||||||
type VhostUserNetConfig struct {
|
|
||||||
Sock string `json:"sock"`
|
|
||||||
NumQueues int32 `json:"num_queues,omitempty"`
|
|
||||||
QueueSize int32 `json:"queue_size,omitempty"`
|
|
||||||
Mac string `json:"mac,omitempty"`
|
|
||||||
}
|
|
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
// VmAddDevice struct for VmAddDevice
|
||||||
|
type VmAddDevice struct {
|
||||||
|
Path string `json:"path,omitempty"`
|
||||||
|
}
|
@ -22,8 +22,6 @@ type VmConfig struct {
|
|||||||
Serial ConsoleConfig `json:"serial,omitempty"`
|
Serial ConsoleConfig `json:"serial,omitempty"`
|
||||||
Console ConsoleConfig `json:"console,omitempty"`
|
Console ConsoleConfig `json:"console,omitempty"`
|
||||||
Devices []DeviceConfig `json:"devices,omitempty"`
|
Devices []DeviceConfig `json:"devices,omitempty"`
|
||||||
VhostUserNet []VhostUserNetConfig `json:"vhost_user_net,omitempty"`
|
|
||||||
VhostUserBlk []VhostUserBlkConfig `json:"vhost_user_blk,omitempty"`
|
|
||||||
Vsock []VsockConfig `json:"vsock,omitempty"`
|
Vsock []VsockConfig `json:"vsock,omitempty"`
|
||||||
Iommu bool `json:"iommu,omitempty"`
|
Iommu bool `json:"iommu,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,22 @@ paths:
|
|||||||
404:
|
404:
|
||||||
description: The VM instance could not be resized because it is not created.
|
description: The VM instance could not be resized because it is not created.
|
||||||
|
|
||||||
|
/vm.add-device:
|
||||||
|
put:
|
||||||
|
summary: Add a new device to the VM
|
||||||
|
requestBody:
|
||||||
|
description: The path of the new device
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/VmAddDevice'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
204:
|
||||||
|
description: The new device was successfully added to the VM instance.
|
||||||
|
404:
|
||||||
|
description: The new device could not be added to the VM instance.
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
||||||
@ -161,7 +177,7 @@ components:
|
|||||||
$ref: '#/components/schemas/VmConfig'
|
$ref: '#/components/schemas/VmConfig'
|
||||||
state:
|
state:
|
||||||
type: string
|
type: string
|
||||||
enum: [Created, Booted, Shutdown]
|
enum: [Created, Running, Shutdown, Paused]
|
||||||
description: Virtual Machine information
|
description: Virtual Machine information
|
||||||
|
|
||||||
VmConfig:
|
VmConfig:
|
||||||
@ -204,14 +220,6 @@ components:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/DeviceConfig'
|
$ref: '#/components/schemas/DeviceConfig'
|
||||||
vhost_user_net:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/VhostUserNetConfig'
|
|
||||||
vhost_user_blk:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/VhostUserBlkConfig'
|
|
||||||
vsock:
|
vsock:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
@ -277,6 +285,9 @@ components:
|
|||||||
readonly:
|
readonly:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
|
direct:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
iommu:
|
iommu:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
@ -294,6 +305,9 @@ components:
|
|||||||
wce:
|
wce:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
|
poll_queue:
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
|
||||||
NetConfig:
|
NetConfig:
|
||||||
type: object
|
type: object
|
||||||
@ -387,7 +401,7 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
mode:
|
mode:
|
||||||
type: string
|
type: string
|
||||||
enum: [Off, Tty, File, None]
|
enum: [Off, Tty, File, Null]
|
||||||
iommu:
|
iommu:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
@ -403,39 +417,6 @@ components:
|
|||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
VhostUserNetConfig:
|
|
||||||
required:
|
|
||||||
- sock
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
sock:
|
|
||||||
type: string
|
|
||||||
num_queues:
|
|
||||||
type: integer
|
|
||||||
default: 2
|
|
||||||
queue_size:
|
|
||||||
type: integer
|
|
||||||
default: 256
|
|
||||||
mac:
|
|
||||||
type: string
|
|
||||||
|
|
||||||
VhostUserBlkConfig:
|
|
||||||
required:
|
|
||||||
- sock
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
sock:
|
|
||||||
type: string
|
|
||||||
num_queues:
|
|
||||||
type: integer
|
|
||||||
default: 1
|
|
||||||
queue_size:
|
|
||||||
type: integer
|
|
||||||
default: 128
|
|
||||||
wce:
|
|
||||||
type: boolean
|
|
||||||
default: true
|
|
||||||
|
|
||||||
VsockConfig:
|
VsockConfig:
|
||||||
required:
|
required:
|
||||||
- cid
|
- cid
|
||||||
@ -462,3 +443,9 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
desired_ram:
|
desired_ram:
|
||||||
type: integer
|
type: integer
|
||||||
|
|
||||||
|
VmAddDevice:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
path:
|
||||||
|
type: string
|
||||||
|
@ -217,6 +217,10 @@ func (v *virtiofsd) kill() (err error) {
|
|||||||
span, _ := v.trace("kill")
|
span, _ := v.trace("kill")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
|
if v.PID == 0 {
|
||||||
|
return errors.New("invalid virtiofsd PID(0)")
|
||||||
|
}
|
||||||
|
|
||||||
err = syscall.Kill(v.PID, syscall.SIGKILL)
|
err = syscall.Kill(v.PID, syscall.SIGKILL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.PID = 0
|
v.PID = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user