Attach Mdev Device Sliced from PCI Device to VM

POST/zstack/v1/mdev-devices/{mdevDeviceUuid}/vm-instances/{vmInstanceUuid}

Headers

Authorization: OAuth the-session-uuid

Body

{
  "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/e4108c6e45303e3bbd9743093127b894

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
mdevDeviceUuidStringurlMDEV device UUID 3.5.0
vmInstanceUuidStringurlVirtual Machine UUID 3.5.0
systemTags (Optional)ListbodySystem tags 3.5.0
userTags (Optional)ListbodyUser 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"
  }
}
NameTypeDescriptionStarting Version
successboolean 0.6
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation succeeds. See error3.5.0
inventoryMdevDeviceInventorySee inventory3.5.0

error

NameTypeDescriptionStarting Version
codeStringError code, a globally unique identifier of the error, e.g. SYS.1000, HOST.10013.5.0
descriptionStringBrief description of the error3.5.0
detailsStringDetailed error information3.5.0
elaborationStringReserved field, defaults to null3.5.0
opaqueLinkedHashMapReserved field, defaults to null3.5.0
causeErrorCodeRoot cause, the source error that caused the current error, null if no original error3.5.0

inventory

NameTypeDescriptionStarting Version
uuidStringUUID of the resource, uniquely identifies the resource3.5.0
nameStringResource name3.5.0
descriptionStringResource description3.5.0
parentUuidStringPhysical PCI device UUID3.5.0
hostUuidStringHost UUID3.5.0
vmInstanceUuidStringVirtual Machine UUID3.5.0
mdevSpecUuidStringMDEV device spec UUID3.5.0
createDateTimestampCreate date3.5.0
lastOpDateTimestampLast update date3.5.0
typeMdevDeviceTypeSee type3.5.0
stateMdevDeviceStateSee state3.5.0
statusMdevDeviceStatusSee status3.5.0
chooserMdevDeviceChooserSee chooser4.1.0

type

NameTypeDescriptionStarting Version
GPU_Video_ControllerMdevDeviceTypeGPU video controller3.5.0

state

NameTypeDescriptionStarting Version
EnabledMdevDeviceStateEnabled3.5.0
DisabledMdevDeviceStateDisabled3.5.0

status

NameTypeDescriptionStarting Version
ActiveMdevDeviceStatusReady3.5.0
AttachedMdevDeviceStatusAttached3.5.0

chooser

NameTypeDescriptionStarting Version
NonePciDeviceChooser 4.2.0
DevicePciDeviceChooser 4.2.0
SpecPciDeviceChooser 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()