Attach Mdev Device Sliced from PCI Device to VM
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {},
"systemTags": [],
"userTags": []
}systemTags and userTags fields can be omitted in the above example. They are listed to indicate that the body can contain these two fields.
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{}}' http://localhost:8080/zstack/v1/mdev-devices/2a23f189ed803f869deab2b22ef83b4d/vm-instances/e4108c6e45303e3bbd9743093127b894Parameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| mdevDeviceUuid | String | url | MDEV device UUID | 3.5.0 | |
| vmInstanceUuid | String | url | Virtual Machine UUID | 3.5.0 | |
| systemTags (Optional) | List | body | System tags | 3.5.0 | |
| userTags (Optional) | List | body | User tags | 3.5.0 |
API Response
Response Example
{
"inventory": {
"uuid": "0eae7167f0db486aace15529dbc38be9",
"name": "GRID M60-2A",
"parentUuid": "9ab8975b943f4b8f82450629386ddf74",
"hostUuid": "f6db3ae1ef974f539b340851b11bb750",
"mdevSpecUuid": "c4ee001ad1924cc398f3d17c89a12bfb",
"type": "GPU_Video_Controller",
"state": "Enabled",
"status": "Active",
"chooser": "None",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | Error code. If not null, the operation failed. This field is null when the operation succeeds. See error | 3.5.0 |
| inventory | MdevDeviceInventory | See inventory | 3.5.0 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code, a globally unique identifier of the error, e.g. SYS.1000, HOST.1001 | 3.5.0 |
| description | String | Brief description of the error | 3.5.0 |
| details | String | Detailed error information | 3.5.0 |
| elaboration | String | Reserved field, defaults to null | 3.5.0 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 3.5.0 |
| cause | ErrorCode | Root cause, the source error that caused the current error, null if no original error | 3.5.0 |
inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource, uniquely identifies the resource | 3.5.0 |
| name | String | Resource name | 3.5.0 |
| description | String | Resource description | 3.5.0 |
| parentUuid | String | Physical PCI device UUID | 3.5.0 |
| hostUuid | String | Host UUID | 3.5.0 |
| vmInstanceUuid | String | Virtual Machine UUID | 3.5.0 |
| mdevSpecUuid | String | MDEV device spec UUID | 3.5.0 |
| createDate | Timestamp | Create date | 3.5.0 |
| lastOpDate | Timestamp | Last update date | 3.5.0 |
| type | MdevDeviceType | See type | 3.5.0 |
| state | MdevDeviceState | See state | 3.5.0 |
| status | MdevDeviceStatus | See status | 3.5.0 |
| chooser | MdevDeviceChooser | See chooser | 4.1.0 |
type
| Name | Type | Description | Starting Version |
|---|---|---|---|
| GPU_Video_Controller | MdevDeviceType | GPU video controller | 3.5.0 |
state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Enabled | MdevDeviceState | Enabled | 3.5.0 |
| Disabled | MdevDeviceState | Disabled | 3.5.0 |
status
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Active | MdevDeviceStatus | Ready | 3.5.0 |
| Attached | MdevDeviceStatus | Attached | 3.5.0 |
chooser
| Name | Type | Description | Starting Version |
|---|---|---|---|
| None | PciDeviceChooser | 4.2.0 | |
| Device | PciDeviceChooser | 4.2.0 | |
| Spec | PciDeviceChooser | 4.2.0 |
SDK Examples
Java SDK
AttachMdevDeviceToVmAction action = new AttachMdevDeviceToVmAction();
action.mdevDeviceUuid = "2a23f189ed803f869deab2b22ef83b4d";
action.vmInstanceUuid = "e4108c6e45303e3bbd9743093127b894";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachMdevDeviceToVmAction.Result res = action.call();Python SDK
AttachMdevDeviceToVmAction action = AttachMdevDeviceToVmAction()
action.mdevDeviceUuid = "2a23f189ed803f869deab2b22ef83b4d"
action.vmInstanceUuid = "e4108c6e45303e3bbd9743093127b894"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachMdevDeviceToVmAction.Result res = action.call()