capabilities.go 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /*
  2. * This file is part of the libvirt-go-xml project
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. *
  22. * Copyright (C) 2016 Red Hat, Inc.
  23. *
  24. */
  25. package libvirtxml
  26. import (
  27. "encoding/xml"
  28. )
  29. type CapsHostCPUTopology struct {
  30. Sockets int `xml:"sockets,attr"`
  31. Cores int `xml:"cores,attr"`
  32. Threads int `xml:"threads,attr"`
  33. }
  34. type CapsHostCPUFeatureFlag struct {
  35. Name string `xml:"name,attr"`
  36. }
  37. type CapsHostCPUPageSize struct {
  38. Size int `xml:"size,attr"`
  39. Unit string `xml:"unit,attr"`
  40. }
  41. type CapsHostCPUMicrocode struct {
  42. Version int `xml:"version,attr"`
  43. }
  44. type CapsHostCPU struct {
  45. XMLName xml.Name `xml:"cpu"`
  46. Arch string `xml:"arch,omitempty"`
  47. Model string `xml:"model,omitempty"`
  48. Vendor string `xml:"vendor,omitempty"`
  49. Topology *CapsHostCPUTopology `xml:"topology"`
  50. FeatureFlags []CapsHostCPUFeatureFlag `xml:"feature"`
  51. Features *CapsHostCPUFeatures `xml:"features"`
  52. PageSizes []CapsHostCPUPageSize `xml:"pages"`
  53. Microcode *CapsHostCPUMicrocode `xml:"microcode"`
  54. }
  55. type CapsHostCPUFeature struct {
  56. }
  57. type CapsHostCPUFeatures struct {
  58. PAE *CapsHostCPUFeature `xml:"pae"`
  59. NonPAE *CapsHostCPUFeature `xml:"nonpae"`
  60. SVM *CapsHostCPUFeature `xml:"svm"`
  61. VMX *CapsHostCPUFeature `xml:"vmx"`
  62. }
  63. type CapsHostNUMAMemory struct {
  64. Size uint64 `xml:",chardata"`
  65. Unit string `xml:"unit,attr"`
  66. }
  67. type CapsHostNUMAPageInfo struct {
  68. Size int `xml:"size,attr"`
  69. Unit string `xml:"unit,attr"`
  70. Count uint64 `xml:",chardata"`
  71. }
  72. type CapsHostNUMACPU struct {
  73. ID int `xml:"id,attr"`
  74. SocketID *int `xml:"socket_id,attr"`
  75. CoreID *int `xml:"core_id,attr"`
  76. Siblings string `xml:"siblings,attr,omitempty"`
  77. }
  78. type CapsHostNUMASibling struct {
  79. ID int `xml:"id,attr"`
  80. Value int `xml:"value,attr"`
  81. }
  82. type CapsHostNUMACell struct {
  83. ID int `xml:"id,attr"`
  84. Memory *CapsHostNUMAMemory `xml:"memory"`
  85. PageInfo []CapsHostNUMAPageInfo `xml:"pages"`
  86. Distances *CapsHostNUMADistances `xml:"distances"`
  87. CPUS *CapsHostNUMACPUs `xml:"cpus"`
  88. }
  89. type CapsHostNUMADistances struct {
  90. Siblings []CapsHostNUMASibling `xml:"sibling"`
  91. }
  92. type CapsHostNUMACPUs struct {
  93. Num uint `xml:"num,attr,omitempty"`
  94. CPUs []CapsHostNUMACPU `xml:"cpu"`
  95. }
  96. type CapsHostNUMATopology struct {
  97. Cells *CapsHostNUMACells `xml:"cells"`
  98. }
  99. type CapsHostNUMACells struct {
  100. Num uint `xml:"num,attr,omitempty"`
  101. Cells []CapsHostNUMACell `xml:"cell"`
  102. }
  103. type CapsHostSecModelLabel struct {
  104. Type string `xml:"type,attr"`
  105. Value string `xml:",chardata"`
  106. }
  107. type CapsHostSecModel struct {
  108. Name string `xml:"model"`
  109. DOI string `xml:"doi"`
  110. Labels []CapsHostSecModelLabel `xml:"baselabel"`
  111. }
  112. type CapsHostMigrationFeatures struct {
  113. Live *CapsHostMigrationLive `xml:"live"`
  114. URITransports *CapsHostMigrationURITransports `xml:"uri_transports"`
  115. }
  116. type CapsHostMigrationLive struct {
  117. }
  118. type CapsHostMigrationURITransports struct {
  119. URI []string `xml:"uri_transport"`
  120. }
  121. type CapsHost struct {
  122. UUID string `xml:"uuid,omitempty"`
  123. CPU *CapsHostCPU `xml:"cpu"`
  124. PowerManagement *CapsHostPowerManagement `xml:"power_management"`
  125. IOMMU *CapsHostIOMMU `xml:"iommu"`
  126. MigrationFeatures *CapsHostMigrationFeatures `xml:"migration_features"`
  127. NUMA *CapsHostNUMATopology `xml:"topology"`
  128. Cache *CapsHostCache `xml:"cache"`
  129. MemoryBandwidth *CapsHostMemoryBandwidth `xml:"memory_bandwidth"`
  130. SecModel []CapsHostSecModel `xml:"secmodel"`
  131. }
  132. type CapsHostPowerManagement struct {
  133. SuspendMem *CapsHostPowerManagementMode `xml:"suspend_mem"`
  134. SuspendDisk *CapsHostPowerManagementMode `xml:"suspend_disk"`
  135. SuspendHybrid *CapsHostPowerManagementMode `xml:"suspend_hybrid"`
  136. }
  137. type CapsHostPowerManagementMode struct {
  138. }
  139. type CapsHostIOMMU struct {
  140. Support string `xml:"support,attr"`
  141. }
  142. type CapsHostCache struct {
  143. Banks []CapsHostCacheBank `xml:"bank"`
  144. Monitor *CapsHostCacheMonitor `xml:"monitor"`
  145. }
  146. type CapsHostCacheBank struct {
  147. ID uint `xml:"id,attr"`
  148. Level uint `xml:"level,attr"`
  149. Type string `xml:"type,attr"`
  150. Size uint `xml:"size,attr"`
  151. Unit string `xml:"unit,attr"`
  152. CPUs string `xml:"cpus,attr"`
  153. Control []CapsHostCacheControl `xml:"control"`
  154. }
  155. type CapsHostCacheMonitor struct {
  156. Level uint `xml:"level,attr,omitempty"`
  157. ResueThreshold uint `xml:"reuseThreshold,attr,omitempty"`
  158. MaxMonitors uint `xml:"maxMonitors,attr"`
  159. Features []CapsHostCacheMonitorFeature `xml:"feature"`
  160. }
  161. type CapsHostCacheMonitorFeature struct {
  162. Name string `xml:"name,attr"`
  163. }
  164. type CapsHostCacheControl struct {
  165. Granularity uint `xml:"granularity,attr"`
  166. Min uint `xml:"min,attr,omitempty"`
  167. Unit string `xml:"unit,attr"`
  168. Type string `xml:"type,attr"`
  169. MaxAllows uint `xml:"maxAllocs,attr"`
  170. }
  171. type CapsHostMemoryBandwidth struct {
  172. Nodes []CapsHostMemoryBandwidthNode `xml:"node"`
  173. Monitor *CapsHostMemoryBandwidthMonitor `xml:"monitor"`
  174. }
  175. type CapsHostMemoryBandwidthNode struct {
  176. ID uint `xml:"id,attr"`
  177. CPUs string `xml:"cpus,attr"`
  178. Control *CapsHostMemoryBandwidthNodeControl `xml:"control"`
  179. }
  180. type CapsHostMemoryBandwidthNodeControl struct {
  181. Granularity uint `xml:"granularity,attr"`
  182. Min uint `xml:"min,attr"`
  183. MaxAllocs uint `xml:"maxAllocs,attr"`
  184. }
  185. type CapsHostMemoryBandwidthMonitor struct {
  186. MaxMonitors uint `xml:"maxMonitors,attr"`
  187. Features []CapsHostMemoryBandwidthMonitorFeature `xml:"feature"`
  188. }
  189. type CapsHostMemoryBandwidthMonitorFeature struct {
  190. Name string `xml:"name,attr"`
  191. }
  192. type CapsGuestMachine struct {
  193. Name string `xml:",chardata"`
  194. MaxCPUs int `xml:"maxCpus,attr,omitempty"`
  195. Canonical string `xml:"canonical,attr,omitempty"`
  196. }
  197. type CapsGuestDomain struct {
  198. Type string `xml:"type,attr"`
  199. Emulator string `xml:"emulator,omitempty"`
  200. Machines []CapsGuestMachine `xml:"machine"`
  201. }
  202. type CapsGuestArch struct {
  203. Name string `xml:"name,attr"`
  204. WordSize string `xml:"wordsize"`
  205. Emulator string `xml:"emulator"`
  206. Loader string `xml:"loader,omitempty"`
  207. Machines []CapsGuestMachine `xml:"machine"`
  208. Domains []CapsGuestDomain `xml:"domain"`
  209. }
  210. type CapsGuestFeatureCPUSelection struct {
  211. }
  212. type CapsGuestFeatureDeviceBoot struct {
  213. }
  214. type CapsGuestFeaturePAE struct {
  215. }
  216. type CapsGuestFeatureNonPAE struct {
  217. }
  218. type CapsGuestFeatureDiskSnapshot struct {
  219. Default string `xml:"default,attr,omitempty"`
  220. Toggle string `xml:"toggle,attr,omitempty"`
  221. }
  222. type CapsGuestFeatureAPIC struct {
  223. Default string `xml:"default,attr,omitempty"`
  224. Toggle string `xml:"toggle,attr,omitempty"`
  225. }
  226. type CapsGuestFeatureACPI struct {
  227. Default string `xml:"default,attr,omitempty"`
  228. Toggle string `xml:"toggle,attr,omitempty"`
  229. }
  230. type CapsGuestFeatureIA64BE struct {
  231. }
  232. type CapsGuestFeatures struct {
  233. CPUSelection *CapsGuestFeatureCPUSelection `xml:"cpuselection"`
  234. DeviceBoot *CapsGuestFeatureDeviceBoot `xml:"deviceboot"`
  235. DiskSnapshot *CapsGuestFeatureDiskSnapshot `xml:"disksnapshot"`
  236. PAE *CapsGuestFeaturePAE `xml:"pae"`
  237. NonPAE *CapsGuestFeatureNonPAE `xml:"nonpae"`
  238. APIC *CapsGuestFeatureAPIC `xml:"apic"`
  239. ACPI *CapsGuestFeatureACPI `xml:"acpi"`
  240. IA64BE *CapsGuestFeatureIA64BE `xml:"ia64_be"`
  241. }
  242. type CapsGuest struct {
  243. OSType string `xml:"os_type"`
  244. Arch CapsGuestArch `xml:"arch"`
  245. Features *CapsGuestFeatures `xml:"features"`
  246. }
  247. type Caps struct {
  248. XMLName xml.Name `xml:"capabilities"`
  249. Host CapsHost `xml:"host"`
  250. Guests []CapsGuest `xml:"guest"`
  251. }
  252. func (c *CapsHostCPU) Unmarshal(doc string) error {
  253. return xml.Unmarshal([]byte(doc), c)
  254. }
  255. func (c *CapsHostCPU) Marshal() (string, error) {
  256. doc, err := xml.MarshalIndent(c, "", " ")
  257. if err != nil {
  258. return "", err
  259. }
  260. return string(doc), nil
  261. }
  262. func (c *Caps) Unmarshal(doc string) error {
  263. return xml.Unmarshal([]byte(doc), c)
  264. }
  265. func (c *Caps) Marshal() (string, error) {
  266. doc, err := xml.MarshalIndent(c, "", " ")
  267. if err != nil {
  268. return "", err
  269. }
  270. return string(doc), nil
  271. }