github.com/libvirt/libvirt-go-xml@v7.4.0+incompatible/capabilities.go (about) 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 26 package libvirtxml 27 28 import ( 29 "encoding/xml" 30 ) 31 32 type CapsHostCPUTopology struct { 33 Sockets int `xml:"sockets,attr"` 34 Cores int `xml:"cores,attr"` 35 Threads int `xml:"threads,attr"` 36 } 37 38 type CapsHostCPUFeatureFlag struct { 39 Name string `xml:"name,attr"` 40 } 41 42 type CapsHostCPUPageSize struct { 43 Size int `xml:"size,attr"` 44 Unit string `xml:"unit,attr"` 45 } 46 47 type CapsHostCPUMicrocode struct { 48 Version int `xml:"version,attr"` 49 } 50 51 type CapsHostCPU struct { 52 XMLName xml.Name `xml:"cpu"` 53 Arch string `xml:"arch,omitempty"` 54 Model string `xml:"model,omitempty"` 55 Vendor string `xml:"vendor,omitempty"` 56 Topology *CapsHostCPUTopology `xml:"topology"` 57 FeatureFlags []CapsHostCPUFeatureFlag `xml:"feature"` 58 Features *CapsHostCPUFeatures `xml:"features"` 59 PageSizes []CapsHostCPUPageSize `xml:"pages"` 60 Microcode *CapsHostCPUMicrocode `xml:"microcode"` 61 } 62 63 type CapsHostCPUFeature struct { 64 } 65 66 type CapsHostCPUFeatures struct { 67 PAE *CapsHostCPUFeature `xml:"pae"` 68 NonPAE *CapsHostCPUFeature `xml:"nonpae"` 69 SVM *CapsHostCPUFeature `xml:"svm"` 70 VMX *CapsHostCPUFeature `xml:"vmx"` 71 } 72 73 type CapsHostNUMAMemory struct { 74 Size uint64 `xml:",chardata"` 75 Unit string `xml:"unit,attr"` 76 } 77 78 type CapsHostNUMAPageInfo struct { 79 Size int `xml:"size,attr"` 80 Unit string `xml:"unit,attr"` 81 Count uint64 `xml:",chardata"` 82 } 83 84 type CapsHostNUMACPU struct { 85 ID int `xml:"id,attr"` 86 SocketID *int `xml:"socket_id,attr"` 87 DieID *int `xml:"die_id,attr"` 88 CoreID *int `xml:"core_id,attr"` 89 Siblings string `xml:"siblings,attr,omitempty"` 90 } 91 92 type CapsHostNUMASibling struct { 93 ID int `xml:"id,attr"` 94 Value int `xml:"value,attr"` 95 } 96 97 type CapsHostNUMACell struct { 98 ID int `xml:"id,attr"` 99 Memory *CapsHostNUMAMemory `xml:"memory"` 100 PageInfo []CapsHostNUMAPageInfo `xml:"pages"` 101 Distances *CapsHostNUMADistances `xml:"distances"` 102 CPUS *CapsHostNUMACPUs `xml:"cpus"` 103 } 104 105 type CapsHostNUMADistances struct { 106 Siblings []CapsHostNUMASibling `xml:"sibling"` 107 } 108 109 type CapsHostNUMACPUs struct { 110 Num uint `xml:"num,attr,omitempty"` 111 CPUs []CapsHostNUMACPU `xml:"cpu"` 112 } 113 114 type CapsHostNUMATopology struct { 115 Cells *CapsHostNUMACells `xml:"cells"` 116 } 117 118 type CapsHostNUMACells struct { 119 Num uint `xml:"num,attr,omitempty"` 120 Cells []CapsHostNUMACell `xml:"cell"` 121 } 122 123 type CapsHostSecModelLabel struct { 124 Type string `xml:"type,attr"` 125 Value string `xml:",chardata"` 126 } 127 128 type CapsHostSecModel struct { 129 Name string `xml:"model"` 130 DOI string `xml:"doi"` 131 Labels []CapsHostSecModelLabel `xml:"baselabel"` 132 } 133 134 type CapsHostMigrationFeatures struct { 135 Live *CapsHostMigrationLive `xml:"live"` 136 URITransports *CapsHostMigrationURITransports `xml:"uri_transports"` 137 } 138 139 type CapsHostMigrationLive struct { 140 } 141 142 type CapsHostMigrationURITransports struct { 143 URI []string `xml:"uri_transport"` 144 } 145 146 type CapsHost struct { 147 UUID string `xml:"uuid,omitempty"` 148 CPU *CapsHostCPU `xml:"cpu"` 149 PowerManagement *CapsHostPowerManagement `xml:"power_management"` 150 IOMMU *CapsHostIOMMU `xml:"iommu"` 151 MigrationFeatures *CapsHostMigrationFeatures `xml:"migration_features"` 152 NUMA *CapsHostNUMATopology `xml:"topology"` 153 Cache *CapsHostCache `xml:"cache"` 154 MemoryBandwidth *CapsHostMemoryBandwidth `xml:"memory_bandwidth"` 155 SecModel []CapsHostSecModel `xml:"secmodel"` 156 } 157 158 type CapsHostPowerManagement struct { 159 SuspendMem *CapsHostPowerManagementMode `xml:"suspend_mem"` 160 SuspendDisk *CapsHostPowerManagementMode `xml:"suspend_disk"` 161 SuspendHybrid *CapsHostPowerManagementMode `xml:"suspend_hybrid"` 162 } 163 164 type CapsHostPowerManagementMode struct { 165 } 166 167 type CapsHostIOMMU struct { 168 Support string `xml:"support,attr"` 169 } 170 171 type CapsHostCache struct { 172 Banks []CapsHostCacheBank `xml:"bank"` 173 Monitor *CapsHostCacheMonitor `xml:"monitor"` 174 } 175 176 type CapsHostCacheBank struct { 177 ID uint `xml:"id,attr"` 178 Level uint `xml:"level,attr"` 179 Type string `xml:"type,attr"` 180 Size uint `xml:"size,attr"` 181 Unit string `xml:"unit,attr"` 182 CPUs string `xml:"cpus,attr"` 183 Control []CapsHostCacheControl `xml:"control"` 184 } 185 186 type CapsHostCacheMonitor struct { 187 Level uint `xml:"level,attr,omitempty"` 188 ResueThreshold uint `xml:"reuseThreshold,attr,omitempty"` 189 MaxMonitors uint `xml:"maxMonitors,attr"` 190 Features []CapsHostCacheMonitorFeature `xml:"feature"` 191 } 192 193 type CapsHostCacheMonitorFeature struct { 194 Name string `xml:"name,attr"` 195 } 196 197 type CapsHostCacheControl struct { 198 Granularity uint `xml:"granularity,attr"` 199 Min uint `xml:"min,attr,omitempty"` 200 Unit string `xml:"unit,attr"` 201 Type string `xml:"type,attr"` 202 MaxAllows uint `xml:"maxAllocs,attr"` 203 } 204 205 type CapsHostMemoryBandwidth struct { 206 Nodes []CapsHostMemoryBandwidthNode `xml:"node"` 207 Monitor *CapsHostMemoryBandwidthMonitor `xml:"monitor"` 208 } 209 210 type CapsHostMemoryBandwidthNode struct { 211 ID uint `xml:"id,attr"` 212 CPUs string `xml:"cpus,attr"` 213 Control *CapsHostMemoryBandwidthNodeControl `xml:"control"` 214 } 215 216 type CapsHostMemoryBandwidthNodeControl struct { 217 Granularity uint `xml:"granularity,attr"` 218 Min uint `xml:"min,attr"` 219 MaxAllocs uint `xml:"maxAllocs,attr"` 220 } 221 222 type CapsHostMemoryBandwidthMonitor struct { 223 MaxMonitors uint `xml:"maxMonitors,attr"` 224 Features []CapsHostMemoryBandwidthMonitorFeature `xml:"feature"` 225 } 226 227 type CapsHostMemoryBandwidthMonitorFeature struct { 228 Name string `xml:"name,attr"` 229 } 230 231 type CapsGuestMachine struct { 232 Name string `xml:",chardata"` 233 MaxCPUs int `xml:"maxCpus,attr,omitempty"` 234 Canonical string `xml:"canonical,attr,omitempty"` 235 } 236 237 type CapsGuestDomain struct { 238 Type string `xml:"type,attr"` 239 Emulator string `xml:"emulator,omitempty"` 240 Machines []CapsGuestMachine `xml:"machine"` 241 } 242 243 type CapsGuestArch struct { 244 Name string `xml:"name,attr"` 245 WordSize string `xml:"wordsize"` 246 Emulator string `xml:"emulator"` 247 Loader string `xml:"loader,omitempty"` 248 Machines []CapsGuestMachine `xml:"machine"` 249 Domains []CapsGuestDomain `xml:"domain"` 250 } 251 252 type CapsGuestFeatureCPUSelection struct { 253 } 254 255 type CapsGuestFeatureDeviceBoot struct { 256 } 257 258 type CapsGuestFeaturePAE struct { 259 } 260 261 type CapsGuestFeatureNonPAE struct { 262 } 263 264 type CapsGuestFeatureDiskSnapshot struct { 265 Default string `xml:"default,attr,omitempty"` 266 Toggle string `xml:"toggle,attr,omitempty"` 267 } 268 269 type CapsGuestFeatureAPIC struct { 270 Default string `xml:"default,attr,omitempty"` 271 Toggle string `xml:"toggle,attr,omitempty"` 272 } 273 274 type CapsGuestFeatureACPI struct { 275 Default string `xml:"default,attr,omitempty"` 276 Toggle string `xml:"toggle,attr,omitempty"` 277 } 278 279 type CapsGuestFeatureIA64BE struct { 280 } 281 282 type CapsGuestFeatures struct { 283 CPUSelection *CapsGuestFeatureCPUSelection `xml:"cpuselection"` 284 DeviceBoot *CapsGuestFeatureDeviceBoot `xml:"deviceboot"` 285 DiskSnapshot *CapsGuestFeatureDiskSnapshot `xml:"disksnapshot"` 286 PAE *CapsGuestFeaturePAE `xml:"pae"` 287 NonPAE *CapsGuestFeatureNonPAE `xml:"nonpae"` 288 APIC *CapsGuestFeatureAPIC `xml:"apic"` 289 ACPI *CapsGuestFeatureACPI `xml:"acpi"` 290 IA64BE *CapsGuestFeatureIA64BE `xml:"ia64_be"` 291 } 292 293 type CapsGuest struct { 294 OSType string `xml:"os_type"` 295 Arch CapsGuestArch `xml:"arch"` 296 Features *CapsGuestFeatures `xml:"features"` 297 } 298 299 type Caps struct { 300 XMLName xml.Name `xml:"capabilities"` 301 Host CapsHost `xml:"host"` 302 Guests []CapsGuest `xml:"guest"` 303 } 304 305 func (c *CapsHostCPU) Unmarshal(doc string) error { 306 return xml.Unmarshal([]byte(doc), c) 307 } 308 309 func (c *CapsHostCPU) Marshal() (string, error) { 310 doc, err := xml.MarshalIndent(c, "", " ") 311 if err != nil { 312 return "", err 313 } 314 return string(doc), nil 315 } 316 317 func (c *Caps) Unmarshal(doc string) error { 318 return xml.Unmarshal([]byte(doc), c) 319 } 320 321 func (c *Caps) Marshal() (string, error) { 322 doc, err := xml.MarshalIndent(c, "", " ") 323 if err != nil { 324 return "", err 325 } 326 return string(doc), nil 327 }