github.com/libvirt/libvirt-go-xml@v7.4.0+incompatible/domain_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 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 Devices *DomainCapsDevices `xml:"devices"` 43 Features *DomainCapsFeatures `xml:"features"` 44 } 45 46 type DomainCapsVCPU struct { 47 Max uint `xml:"max,attr"` 48 } 49 50 type DomainCapsOS struct { 51 Supported string `xml:"supported,attr"` 52 Loader *DomainCapsOSLoader `xml:"loader"` 53 Enums []DomainCapsEnum `xml:"enum"` 54 } 55 56 type DomainCapsOSLoader struct { 57 Supported string `xml:"supported,attr"` 58 Values []string `xml:"value"` 59 Enums []DomainCapsEnum `xml:"enum"` 60 } 61 62 type DomainCapsIOThreads struct { 63 Supported string `xml:"supported,attr"` 64 } 65 66 type DomainCapsCPU struct { 67 Modes []DomainCapsCPUMode `xml:"mode"` 68 } 69 70 type DomainCapsCPUMode struct { 71 Name string `xml:"name,attr"` 72 Supported string `xml:"supported,attr"` 73 Models []DomainCapsCPUModel `xml:"model"` 74 Vendor string `xml:"vendor,omitempty"` 75 Features []DomainCapsCPUFeature `xml:"feature"` 76 Enums []DomainCapsEnum `xml:"enum"` 77 } 78 79 type DomainCapsCPUModel struct { 80 Name string `xml:",chardata"` 81 Usable string `xml:"usable,attr,omitempty"` 82 Fallback string `xml:"fallback,attr,omitempty"` 83 Deprecated string `xml:"deprecated,attr,omitempty"` 84 } 85 86 type DomainCapsCPUFeature struct { 87 Policy string `xml:"policy,attr,omitempty"` 88 Name string `xml:"name,attr"` 89 } 90 91 type DomainCapsEnum struct { 92 Name string `xml:"name,attr"` 93 Values []string `xml:"value"` 94 } 95 96 type DomainCapsDevices struct { 97 Disk *DomainCapsDevice `xml:"disk"` 98 Graphics *DomainCapsDevice `xml:"graphics"` 99 Video *DomainCapsDevice `xml:"video"` 100 HostDev *DomainCapsDevice `xml:"hostdev"` 101 RNG *DomainCapsDevice `xml:"rng"` 102 FileSystem *DomainCapsDevice `xml:"filesystem"` 103 } 104 105 type DomainCapsDevice struct { 106 Supported string `xml:"supported,attr"` 107 Enums []DomainCapsEnum `xml:"enum"` 108 } 109 110 type DomainCapsFeatures struct { 111 GIC *DomainCapsFeatureGIC `xml:"gic"` 112 VMCoreInfo *DomainCapsFeatureVMCoreInfo `xml:"vmcoreinfo"` 113 GenID *DomainCapsFeatureGenID `xml:"genid"` 114 BackingStoreInput *DomainCapsFeatureBackingStoreInput `xml:"backingStoreInput"` 115 Backup *DomainCapsFeatureBackup `xml:"backup"` 116 SEV *DomainCapsFeatureSEV `xml:"sev"` 117 } 118 119 type DomainCapsFeatureGIC struct { 120 Supported string `xml:"supported,attr"` 121 Enums []DomainCapsEnum `xml:"enum"` 122 } 123 124 type DomainCapsFeatureVMCoreInfo struct { 125 Supported string `xml:"supported,attr"` 126 } 127 128 type DomainCapsFeatureGenID struct { 129 Supported string `xml:"supported,attr"` 130 } 131 132 type DomainCapsFeatureBackingStoreInput struct { 133 Supported string `xml:"supported,attr"` 134 } 135 136 type DomainCapsFeatureBackup struct { 137 Supported string `xml:"supported,attr"` 138 } 139 140 type DomainCapsFeatureSEV struct { 141 Supported string `xml:"supported,attr"` 142 CBitPos uint `xml:"cbitpos,omitempty"` 143 ReducedPhysBits uint `xml:"reducedPhysBits,omitempty"` 144 } 145 146 func (c *DomainCaps) Unmarshal(doc string) error { 147 return xml.Unmarshal([]byte(doc), c) 148 } 149 150 func (c *DomainCaps) Marshal() (string, error) { 151 doc, err := xml.MarshalIndent(c, "", " ") 152 if err != nil { 153 return "", err 154 } 155 return string(doc), nil 156 }