libvirt.org/go/libvirtxml@v1.10003.0/domain_capabilities.go (about) 1 /* 2 * This file is part of the libvirt-go-xml-module 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 DomainCaps struct { 33 XMLName xml.Name `xml:"domainCapabilities"` 34 Path string `xml:"path"` 35 Domain string `xml:"domain"` 36 Machine string `xml:"machine,omitempty"` 37 Arch string `xml:"arch"` 38 VCPU *DomainCapsVCPU `xml:"vcpu"` 39 IOThreads *DomainCapsIOThreads `xml:"iothreads"` 40 OS *DomainCapsOS `xml:"os"` 41 CPU *DomainCapsCPU `xml:"cpu"` 42 MemoryBacking *DomainCapsMemoryBacking `xml:"memoryBacking"` 43 Devices *DomainCapsDevices `xml:"devices"` 44 Features *DomainCapsFeatures `xml:"features"` 45 } 46 47 type DomainCapsVCPU struct { 48 Max uint `xml:"max,attr"` 49 } 50 51 type DomainCapsOS struct { 52 Supported string `xml:"supported,attr"` 53 Loader *DomainCapsOSLoader `xml:"loader"` 54 Enums []DomainCapsEnum `xml:"enum"` 55 } 56 57 type DomainCapsOSLoader struct { 58 Supported string `xml:"supported,attr"` 59 Values []string `xml:"value"` 60 Enums []DomainCapsEnum `xml:"enum"` 61 } 62 63 type DomainCapsIOThreads struct { 64 Supported string `xml:"supported,attr"` 65 } 66 67 type DomainCapsCPU struct { 68 Modes []DomainCapsCPUMode `xml:"mode"` 69 } 70 71 type DomainCapsCPUMaxPhysAddr struct { 72 Mode string `xml:"mode,attr"` 73 Limit uint `xml:"limit,attr"` 74 } 75 76 type DomainCapsCPUMode struct { 77 Name string `xml:"name,attr"` 78 Supported string `xml:"supported,attr"` 79 Models []DomainCapsCPUModel `xml:"model"` 80 Vendor string `xml:"vendor,omitempty"` 81 MaxPhysAddr *DomainCapsCPUMaxPhysAddr `xml:"maxphysaddr"` 82 Features []DomainCapsCPUFeature `xml:"feature"` 83 Enums []DomainCapsEnum `xml:"enum"` 84 } 85 86 type DomainCapsCPUModel struct { 87 Name string `xml:",chardata"` 88 Usable string `xml:"usable,attr,omitempty"` 89 Fallback string `xml:"fallback,attr,omitempty"` 90 Deprecated string `xml:"deprecated,attr,omitempty"` 91 Vendor string `xml:"vendor,attr,omitempty"` 92 } 93 94 type DomainCapsCPUFeature struct { 95 Policy string `xml:"policy,attr,omitempty"` 96 Name string `xml:"name,attr"` 97 } 98 99 type DomainCapsEnum struct { 100 Name string `xml:"name,attr"` 101 Values []string `xml:"value"` 102 } 103 104 type DomainCapsMemoryBacking struct { 105 Supported string `xml:"supported,attr"` 106 Enums []DomainCapsEnum `xml:"enum"` 107 } 108 109 type DomainCapsDevices struct { 110 Disk *DomainCapsDevice `xml:"disk"` 111 Graphics *DomainCapsDevice `xml:"graphics"` 112 Video *DomainCapsDevice `xml:"video"` 113 HostDev *DomainCapsDevice `xml:"hostdev"` 114 RNG *DomainCapsDevice `xml:"rng"` 115 FileSystem *DomainCapsDevice `xml:"filesystem"` 116 TPM *DomainCapsDevice `xml:"tpm"` 117 Redirdev *DomainCapsDevice `xml:"redirdev"` 118 Channel *DomainCapsDevice `xml:"channel"` 119 Crypto *DomainCapsDevice `xml:"crypto"` 120 } 121 122 type DomainCapsDevice struct { 123 Supported string `xml:"supported,attr"` 124 Enums []DomainCapsEnum `xml:"enum"` 125 } 126 127 type DomainCapsFeatures struct { 128 GIC *DomainCapsFeatureGIC `xml:"gic"` 129 VMCoreInfo *DomainCapsFeatureVMCoreInfo `xml:"vmcoreinfo"` 130 GenID *DomainCapsFeatureGenID `xml:"genid"` 131 BackingStoreInput *DomainCapsFeatureBackingStoreInput `xml:"backingStoreInput"` 132 Backup *DomainCapsFeatureBackup `xml:"backup"` 133 AsyncTeardown *DomainCapsFeatureAsyncTeardown `xml:"async-teardown"` 134 S390PV *DomainCapsFeatureS390PV `xml:"s390-pv"` 135 SEV *DomainCapsFeatureSEV `xml:"sev"` 136 SGX *DomainCapsFeatureSGX `xml:"sgx"` 137 HyperV *DomainCapsFeatureHyperV `xml:"hyperv"` 138 } 139 140 type DomainCapsFeatureGIC struct { 141 Supported string `xml:"supported,attr"` 142 Enums []DomainCapsEnum `xml:"enum"` 143 } 144 145 type DomainCapsFeatureVMCoreInfo struct { 146 Supported string `xml:"supported,attr"` 147 } 148 149 type DomainCapsFeatureGenID struct { 150 Supported string `xml:"supported,attr"` 151 } 152 153 type DomainCapsFeatureBackingStoreInput struct { 154 Supported string `xml:"supported,attr"` 155 } 156 157 type DomainCapsFeatureBackup struct { 158 Supported string `xml:"supported,attr"` 159 } 160 161 type DomainCapsFeatureAsyncTeardown struct { 162 Supported string `xml:"supported,attr"` 163 } 164 165 type DomainCapsFeatureS390PV struct { 166 Supported string `xml:"supported,attr"` 167 } 168 169 type DomainCapsFeatureSEV struct { 170 Supported string `xml:"supported,attr"` 171 CBitPos uint `xml:"cbitpos,omitempty"` 172 ReducedPhysBits uint `xml:"reducedPhysBits,omitempty"` 173 MaxGuests uint `xml:"maxGuests,omitempty"` 174 MaxESGuests uint `xml:"maxESGuests,omitempty"` 175 } 176 177 type DomainCapsFeatureSGX struct { 178 Supported string `xml:"supported,attr"` 179 FLC *DomainCapsFeatureSGXFeature `xml:"flc"` 180 SGX1 *DomainCapsFeatureSGXFeature `xml:"sgx1"` 181 SGX2 *DomainCapsFeatureSGXFeature `xml:"sgx2"` 182 SectionSize *DomainCapsFeatureSGXSectionSize `xml:"section_size"` 183 Sections *[]DomainCapsFeatureSGXSection `xml:"sections>section"` 184 } 185 186 type DomainCapsFeatureSGXFeature struct { 187 Supported string `xml:",chardata"` 188 } 189 190 type DomainCapsFeatureSGXSectionSize struct { 191 Value uint `xml:",chardata"` 192 Unit string `xml:"unit,attr,omitempty"` 193 } 194 195 type DomainCapsFeatureSGXSection struct { 196 Node uint `xml:"node,attr"` 197 Size uint `xml:"size,attr"` 198 Unit string `xml:"unit,attr"` 199 } 200 201 type DomainCapsFeatureHyperV struct { 202 Supported string `xml:"supported,attr"` 203 Enums []DomainCapsEnum `xml:"enum"` 204 } 205 206 func (c *DomainCaps) Unmarshal(doc string) error { 207 return xml.Unmarshal([]byte(doc), c) 208 } 209 210 func (c *DomainCaps) Marshal() (string, error) { 211 doc, err := xml.MarshalIndent(c, "", " ") 212 if err != nil { 213 return "", err 214 } 215 return string(doc), nil 216 }