pci.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package monitor
  15. // PciBridgeInfo -> PCIBridgeInfo (struct)
  16. // PCIBridgeInfo implements the "PciBridgeInfo" QMP API type.
  17. type PCIBridgeInfo struct {
  18. Bus PCIBusInfo `json:"bus"`
  19. Devices []PCIDeviceInfo `json:"devices,omitempty"`
  20. }
  21. // PciBusInfo -> PCIBusInfo (struct)
  22. // PCIBusInfo implements the "PciBusInfo" QMP API type.
  23. type PCIBusInfo struct {
  24. Number int64 `json:"number"`
  25. Secondary int64 `json:"secondary"`
  26. Subordinate int64 `json:"subordinate"`
  27. IORange PCIMemoryRange `json:"io_range"`
  28. MemoryRange PCIMemoryRange `json:"memory_range"`
  29. PrefetchableRange PCIMemoryRange `json:"prefetchable_range"`
  30. }
  31. // PciDeviceClass -> PCIDeviceClass (struct)
  32. // PCIDeviceClass implements the "PciDeviceClass" QMP API type.
  33. type PCIDeviceClass struct {
  34. Desc *string `json:"desc,omitempty"`
  35. Class int64 `json:"class"`
  36. }
  37. // PciDeviceId -> PCIDeviceID (struct)
  38. // PCIDeviceID implements the "PciDeviceId" QMP API type.
  39. type PCIDeviceID struct {
  40. Device int64 `json:"device"`
  41. Vendor int64 `json:"vendor"`
  42. }
  43. // PciDeviceInfo -> PCIDeviceInfo (struct)
  44. // PCIDeviceInfo implements the "PciDeviceInfo" QMP API type.
  45. type PCIDeviceInfo struct {
  46. Bus int64 `json:"bus"`
  47. Slot int64 `json:"slot"`
  48. Function int64 `json:"function"`
  49. ClassInfo PCIDeviceClass `json:"class_info"`
  50. ID PCIDeviceID `json:"id"`
  51. Irq *int64 `json:"irq,omitempty"`
  52. QdevID string `json:"qdev_id"`
  53. PCIBridge *PCIBridgeInfo `json:"pci_bridge,omitempty"`
  54. Regions []PCIMemoryRegion `json:"regions"`
  55. }
  56. // PciInfo -> PCIInfo (struct)
  57. // PCIInfo implements the "PciInfo" QMP API type.
  58. type PCIInfo struct {
  59. Bus int64 `json:"bus"`
  60. Devices []PCIDeviceInfo `json:"devices"`
  61. }
  62. // PciMemoryRange -> PCIMemoryRange (struct)
  63. // PCIMemoryRange implements the "PciMemoryRange" QMP API type.
  64. type PCIMemoryRange struct {
  65. Base int64 `json:"base"`
  66. Limit int64 `json:"limit"`
  67. }
  68. // PciMemoryRegion -> PCIMemoryRegion (struct)
  69. // PCIMemoryRegion implements the "PciMemoryRegion" QMP API type.
  70. type PCIMemoryRegion struct {
  71. Bar int64 `json:"bar"`
  72. Type string `json:"type"`
  73. Address int64 `json:"address"`
  74. Size int64 `json:"size"`
  75. Prefetch *bool `json:"prefetch,omitempty"`
  76. MemType64 *bool `json:"mem_type_64,omitempty"`
  77. }
  78. type QueryPciCallback func(pciInfoList []PCIInfo, err string)
  79. type MemoryDeviceInfo struct {
  80. Type string
  81. Data PcdimmDeviceInfo
  82. }
  83. type PcdimmDeviceInfo struct {
  84. ID *string `json:"id,omitempty"`
  85. Addr int64 `json:"addr"`
  86. Size int64 `json:"size"`
  87. Slot int64 `json:"slot"`
  88. Node int64 `json:"node"`
  89. Memdev string `json:"memdev"`
  90. Hotplugged bool `json:"hotplugged"`
  91. Hotpluggable bool `json:"hotpluggable"`
  92. }
  93. type QueryMemoryDevicesCallback func(memoryDevicesInfoList []MemoryDeviceInfo, err string)
  94. // MachineInfo implements the "MachineInfo" QMP API type.
  95. type MachineInfo struct {
  96. Name string `json:"name"`
  97. Alias *string `json:"alias,omitempty"`
  98. IsDefault *bool `json:"is-default,omitempty"`
  99. CPUMax int64 `json:"cpu-max"`
  100. HotpluggableCpus bool `json:"hotpluggable-cpus"`
  101. }
  102. type QueryMachinesCallback func(machineInfoList []MachineInfo, err string)
  103. // Memdev -> Memdev (struct)
  104. // Memdev implements the "Memdev" QMP API type.
  105. type Memdev struct {
  106. ID *string `json:"id,omitempty"`
  107. Size uint64 `json:"size"`
  108. Merge bool `json:"merge"`
  109. Dump bool `json:"dump"`
  110. Prealloc bool `json:"prealloc"`
  111. HostNodes []uint16 `json:"host-nodes"`
  112. Policy string `json:"policy"`
  113. }
  114. type MemdevListCallback func(res []Memdev, err string)
  115. // CpuInstanceProperties -> CPUInstanceProperties (struct)
  116. // CPUInstanceProperties implements the "CpuInstanceProperties" QMP API type.
  117. type CPUInstanceProperties struct {
  118. NodeID *int64 `json:"node-id,omitempty"`
  119. SocketID *int64 `json:"socket-id,omitempty"`
  120. CoreID *int64 `json:"core-id,omitempty"`
  121. ThreadID *int64 `json:"thread-id,omitempty"`
  122. }
  123. // HotpluggableCPU -> HotpluggableCPU (struct)
  124. // HotpluggableCPU implements the "HotpluggableCPU" QMP API type.
  125. type HotpluggableCPU struct {
  126. Type string `json:"type"`
  127. VcpusCount int64 `json:"vcpus-count"`
  128. Props CPUInstanceProperties `json:"props"`
  129. QomPath *string `json:"qom-path,omitempty"`
  130. }
  131. type HotpluggableCPUListCallback func(res []HotpluggableCPU, err string)