domain_capabilities.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 DomainCaps struct {
  30. XMLName xml.Name `xml:"domainCapabilities"`
  31. Path string `xml:"path"`
  32. Domain string `xml:"domain"`
  33. Machine string `xml:"machine,omitempty"`
  34. Arch string `xml:"arch"`
  35. VCPU *DomainCapsVCPU `xml:"vcpu"`
  36. IOThreads *DomainCapsIOThreads `xml:"iothreads"`
  37. OS *DomainCapsOS `xml:"os"`
  38. CPU *DomainCapsCPU `xml:"cpu"`
  39. Devices *DomainCapsDevices `xml:"devices"`
  40. Features *DomainCapsFeatures `xml:"features"`
  41. }
  42. type DomainCapsVCPU struct {
  43. Max uint `xml:"max,attr"`
  44. }
  45. type DomainCapsOS struct {
  46. Supported string `xml:"supported,attr"`
  47. Loader *DomainCapsOSLoader `xml:"loader"`
  48. }
  49. type DomainCapsOSLoader struct {
  50. Supported string `xml:"supported,attr"`
  51. Values []string `xml:"value"`
  52. Enums []DomainCapsEnum `xml:"enum"`
  53. }
  54. type DomainCapsIOThreads struct {
  55. Supported string `xml:"supported,attr"`
  56. }
  57. type DomainCapsCPU struct {
  58. Modes []DomainCapsCPUMode `xml:"mode"`
  59. }
  60. type DomainCapsCPUMode struct {
  61. Name string `xml:"name,attr"`
  62. Supported string `xml:"supported,attr"`
  63. Models []DomainCapsCPUModel `xml:"model"`
  64. Vendor string `xml:"vendor,omitempty"`
  65. Features []DomainCapsCPUFeature `xml:"feature"`
  66. }
  67. type DomainCapsCPUModel struct {
  68. Name string `xml:",chardata"`
  69. Usable string `xml:"usable,attr,omitempty"`
  70. Fallback string `xml:"fallback,attr,omitempty"`
  71. }
  72. type DomainCapsCPUFeature struct {
  73. Policy string `xml:"policy,attr,omitempty"`
  74. Name string `xml:"name,attr"`
  75. }
  76. type DomainCapsEnum struct {
  77. Name string `xml:"name,attr"`
  78. Values []string `xml:"value"`
  79. }
  80. type DomainCapsDevices struct {
  81. Disk *DomainCapsDevice `xml:"disk"`
  82. Graphics *DomainCapsDevice `xml:"graphics"`
  83. Video *DomainCapsDevice `xml:"video"`
  84. HostDev *DomainCapsDevice `xml:"hostdev"`
  85. }
  86. type DomainCapsDevice struct {
  87. Supported string `xml:"supported,attr"`
  88. Enums []DomainCapsEnum `xml:"enum"`
  89. }
  90. type DomainCapsFeatures struct {
  91. GIC *DomainCapsFeatureGIC `xml:"gic"`
  92. VMCoreInfo *DomainCapsFeatureVMCoreInfo `xml:"vmcoreinfo"`
  93. GenID *DomainCapsFeatureGenID `xml:"genid"`
  94. SEV *DomainCapsFeatureSEV `xml:"sev"`
  95. }
  96. type DomainCapsFeatureGIC struct {
  97. Supported string `xml:"supported,attr"`
  98. Enums []DomainCapsEnum `xml:"enum"`
  99. }
  100. type DomainCapsFeatureVMCoreInfo struct {
  101. Supported string `xml:"supported,attr"`
  102. }
  103. type DomainCapsFeatureGenID struct {
  104. Supported string `xml:"supported,attr"`
  105. }
  106. type DomainCapsFeatureSEV struct {
  107. Supported string `xml:"supported,attr"`
  108. CBitPos uint `xml:"cbitpos,omitempty"`
  109. ReducedPhysBits uint `xml:"reducedPhysBits,omitempty"`
  110. }
  111. func (c *DomainCaps) Unmarshal(doc string) error {
  112. return xml.Unmarshal([]byte(doc), c)
  113. }
  114. func (c *DomainCaps) Marshal() (string, error) {
  115. doc, err := xml.MarshalIndent(c, "", " ")
  116. if err != nil {
  117. return "", err
  118. }
  119. return string(doc), nil
  120. }