POST /zstack /v1/pci-device/pci-devices/ {pciDeviceUuid} /attach Try it curl --request POST \
--url '/v1/pci-device/pci-devices/{pciDeviceUuid}/attach' \
--header 'Content-Type: application/json' \
--data '{}'{
"status": "ok",
"method": "POST",
"path": "/v1/pci-device/pci-devices/{pciDeviceUuid}/attach"
}Attach a PCI device to a Virtual Machine. Administrators can directly attach PCI devices in System or Active state to Virtual Machines in Active or Stopped state.
Headers
Authorization: OAuth the-session-uuid Body
{
"params": {
"vmInstanceUuid": "d3f41f8b996b390992cc4607e7bb10dc"
},
"systemTags": [],
"userTags": []
}
In the example above, the systemTags and userTags fields can be omitted. 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":{"vmInstanceUuid":"d3f41f8b996b390992cc4607e7bb10dc"}}' \
http://localhost:8080/zstack/v1/pci-device/pci-devices/201b541edbed3dccbebfaa57b3beb9bb/attach Parameter List
Name Type Location Description Allowed Values Starting Version pciDeviceUuid String url PCI device UUID 2.1 vmInstanceUuid String body (contained in the params structure) Virtual Machine UUID 2.1 systemTags (Optional) List body 2.1 userTags (Optional) List body 2.1
Response Example
{
"inventory": {
"uuid": "f89ad78682d73e08a2ed52bd4837aadf",
"hostUuid": "f2d1b937a92a3ac6a446feb1030f6315",
"vmInstanceUuid": "3daa5e997d023c508a4af3ddda65ddac",
"type": "GPU_Video_Controller",
"status": "Attached",
"vendorId": "10de",
"deviceId": "0e0f",
"subvendorId": "10de",
"subdeviceId": "118b",
"pciDeviceAddress": "0000:06:00.1"
}
} 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 2.1 inventory PciDeviceInventory See inventory 2.1
Name Type Description Starting Version code String Error code, a globally unique identifier of the error, e.g. SYS.1000, HOST.1001 2.1 description String Brief description of the error 2.1 details String Detailed error information 2.1 elaboration String Reserved field, defaults to null 2.1 opaque LinkedHashMap Reserved field, defaults to null 2.1 cause ErrorCode Root cause, the source error that caused the current error, null if no original error 2.1
Name Type Description Starting Version uuid String UUID of the resource, uniquely identifies the resource 2.1 name String Resource name 3.5.0 description String Resource description 2.1 hostUuid String Host UUID 2.1 parentUuid String Physical PCI device UUID 3.5.0 vmInstanceUuid String Virtual Machine UUID 2.1 pciSpecUuid String PCI device offering UUID 3.5.0 vendorId String Vendor ID 2.1 deviceId String Device ID 2.1 subvendorId String Sub-vendor ID 2.1 subdeviceId String Sub-device ID 2.1 pciDeviceAddress String PCI device address 2.1 createDate Timestamp Create date 2.1 lastOpDate Timestamp Last update date 2.1 type PciDeviceType See type 2.1 state PciDeviceState See state 2.1 status PciDeviceStatus See status 2.1 virtStatus PciDeviceVirtStatus See virtStatus 3.5.0 chooser PciDeviceChooser See chooser 4.1.0 metaData PciDeviceMetaData See metaData 2.1 matchedPciDeviceOfferingRef List See matchedPciDeviceOfferingRef 2.1 mdevSpecRefs List See mdevSpecRefs 3.5.0
Name Type Description Starting Version GPU_Video_Controller PciDeviceType GPU video controller 2.1 GPU_Audio_Controller PciDeviceType GPU audio controller 2.1 GPU_3D_Controller PciDeviceType GPU 3D controller 2.1 Moxa_Device PciDeviceType MOXA card 2.1 Generic PciDeviceType Generic device 2.1
Name Type Description Starting Version Enabled PciDeviceState Enabled 2.1 Disabled PciDeviceState Disabled 2.1
Name Type Description Starting Version Active PciDeviceStatus Ready 2.1 Attached PciDeviceStatus Attached 2.1 System PciDeviceStatus System 2.1
Name Type Description Starting Version UNVIRTUALIZABLE PciDeviceVirtStatus Unvirtualizable 3.5.0 SRIOV_VIRTUALIZABLE PciDeviceVirtStatus SRIOV virtualizable 3.5.0 VFIO_MDEV_VIRTUALIZABLE PciDeviceVirtStatus VFIO_MDEV virtualizable 3.5.0 SRIOV_VIRTUALIZED PciDeviceVirtStatus SRIOV virtualized 3.5.0 VFIO_MDEV_VIRTUALIZED PciDeviceVirtStatus VFIO_MDEV virtualized 3.5.0 SRIOV_VIRTUAL PciDeviceVirtStatus SRIOV virtual device 3.5.0 UNKNOWN PciDeviceVirtStatus Unknown 3.5.0
Name Type Description Starting Version None PciDeviceChooser 4.8.0 Device PciDeviceChooser 4.8.0 Spec PciDeviceChooser 4.8.0
Name Type Description Starting Version metaData String 2.1 metaDataEntries List See metaDataEntries 2.1
Name Type Description Starting Version key String Key 2.1 value String Value 2.1 op PciDeviceMetaDataOperator See op 2.1
Name Type Description Starting Version Equal PciDeviceMetaDataOperator Equal 2.1 Unequal PciDeviceMetaDataOperator Unequal 2.1
Name Type Description Starting Version pciDeviceUuid String 2.1 pciDeviceOfferingUuid String 2.1
Name Type Description Starting Version pciDeviceUuid String PCI device UUID 3.5.0 mdevSpecUuid String MDEV device offering UUID 3.5.0 effective Boolean Whether the current MDEV specification is used to partition this PCI device 3.5.0 createDate Timestamp Create date 3.5.0 lastOpDate Timestamp Last update date 3.5.0
Java SDK
AttachPciDeviceToVmAction action = new AttachPciDeviceToVmAction();
action.pciDeviceUuid = "201b541edbed3dccbebfaa57b3beb9bb";
action.vmInstanceUuid = "d3f41f8b996b390992cc4607e7bb10dc";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachPciDeviceToVmAction.Result res = action.call(); Python SDK
AttachPciDeviceToVmAction action = AttachPciDeviceToVmAction()
action.pciDeviceUuid = "201b541edbed3dccbebfaa57b3beb9bb"
action.vmInstanceUuid = "d3f41f8b996b390992cc4607e7bb10dc"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AttachPciDeviceToVmAction.Result res = action.call()