github.com/zhaoxuat/libvirt-go-xml@v6.3.1-0.20200612053919-a025f1d30c41+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  }
    77  
    78  type DomainCapsCPUModel struct {
    79  	Name     string `xml:",chardata"`
    80  	Usable   string `xml:"usable,attr,omitempty"`
    81  	Fallback string `xml:"fallback,attr,omitempty"`
    82  }
    83  
    84  type DomainCapsCPUFeature struct {
    85  	Policy string `xml:"policy,attr,omitempty"`
    86  	Name   string `xml:"name,attr"`
    87  }
    88  
    89  type DomainCapsEnum struct {
    90  	Name   string   `xml:"name,attr"`
    91  	Values []string `xml:"value"`
    92  }
    93  
    94  type DomainCapsDevices struct {
    95  	Disk     *DomainCapsDevice `xml:"disk"`
    96  	Graphics *DomainCapsDevice `xml:"graphics"`
    97  	Video    *DomainCapsDevice `xml:"video"`
    98  	HostDev  *DomainCapsDevice `xml:"hostdev"`
    99  	RNG      *DomainCapsDevice `xml:"rng"`
   100  }
   101  
   102  type DomainCapsDevice struct {
   103  	Supported string           `xml:"supported,attr"`
   104  	Enums     []DomainCapsEnum `xml:"enum"`
   105  }
   106  
   107  type DomainCapsFeatures struct {
   108  	GIC               *DomainCapsFeatureGIC               `xml:"gic"`
   109  	VMCoreInfo        *DomainCapsFeatureVMCoreInfo        `xml:"vmcoreinfo"`
   110  	GenID             *DomainCapsFeatureGenID             `xml:"genid"`
   111  	BackingStoreInput *DomainCapsFeatureBackingStoreInput `xml:"backingStoreInput"`
   112  	Backup            *DomainCapsFeatureBackup            `xml:"backup"`
   113  	SEV               *DomainCapsFeatureSEV               `xml:"sev"`
   114  }
   115  
   116  type DomainCapsFeatureGIC struct {
   117  	Supported string           `xml:"supported,attr"`
   118  	Enums     []DomainCapsEnum `xml:"enum"`
   119  }
   120  
   121  type DomainCapsFeatureVMCoreInfo struct {
   122  	Supported string `xml:"supported,attr"`
   123  }
   124  
   125  type DomainCapsFeatureGenID struct {
   126  	Supported string `xml:"supported,attr"`
   127  }
   128  
   129  type DomainCapsFeatureBackingStoreInput struct {
   130  	Supported string `xml:"supported,attr"`
   131  }
   132  
   133  type DomainCapsFeatureBackup struct {
   134  	Supported string `xml:"supported,attr"`
   135  }
   136  
   137  type DomainCapsFeatureSEV struct {
   138  	Supported       string `xml:"supported,attr"`
   139  	CBitPos         uint   `xml:"cbitpos,omitempty"`
   140  	ReducedPhysBits uint   `xml:"reducedPhysBits,omitempty"`
   141  }
   142  
   143  func (c *DomainCaps) Unmarshal(doc string) error {
   144  	return xml.Unmarshal([]byte(doc), c)
   145  }
   146  
   147  func (c *DomainCaps) Marshal() (string, error) {
   148  	doc, err := xml.MarshalIndent(c, "", "  ")
   149  	if err != nil {
   150  		return "", err
   151  	}
   152  	return string(doc), nil
   153  }