libvirt.org/go/libvirtxml@v1.10003.0/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 CapsHostCPUTopology struct {
    33  	Sockets  int `xml:"sockets,attr"`
    34  	Dies     int `xml:"dies,attr,omitempty"`
    35  	Clusters int `xml:"clusters,attr,omitempty"`
    36  	Cores    int `xml:"cores,attr"`
    37  	Threads  int `xml:"threads,attr"`
    38  }
    39  
    40  type CapsHostCPUFeatureFlag struct {
    41  	Name string `xml:"name,attr"`
    42  }
    43  
    44  type CapsHostCPUPageSize struct {
    45  	Size int    `xml:"size,attr"`
    46  	Unit string `xml:"unit,attr"`
    47  }
    48  
    49  type CapsHostCPUMicrocode struct {
    50  	Version int `xml:"version,attr"`
    51  }
    52  
    53  type CapsHostCPUSignature struct {
    54  	Family   int `xml:"family,attr"`
    55  	Model    int `xml:"model,attr"`
    56  	Stepping int `xml:"stepping,attr"`
    57  }
    58  
    59  type CapsHostCPUCounter struct {
    60  	Name      string `xml:"name,attr"`
    61  	Frequency uint   `xml:"frequency,attr"`
    62  	Scaling   string `xml:"scaling,attr,omitempty"`
    63  }
    64  
    65  type CapsHostCPUCache struct {
    66  	Level *uint  `xml:"level,attr,omitempty"`
    67  	Mode  string `xml:"mode,attr"`
    68  }
    69  
    70  type CapsHostCPUMaxPhysAddr struct {
    71  	Mode string `xml:"mode,attr"`
    72  	Bits uint   `xml:"bits,attr,omitempty"`
    73  }
    74  
    75  type CapsHostCPU struct {
    76  	XMLName      xml.Name                 `xml:"cpu"`
    77  	Arch         string                   `xml:"arch,omitempty"`
    78  	Model        string                   `xml:"model,omitempty"`
    79  	Vendor       string                   `xml:"vendor,omitempty"`
    80  	Microcode    *CapsHostCPUMicrocode    `xml:"microcode"`
    81  	Signature    *CapsHostCPUSignature    `xml:"signature"`
    82  	Counter      *CapsHostCPUCounter      `xml:"counter"`
    83  	Topology     *CapsHostCPUTopology     `xml:"topology"`
    84  	Cache        *CapsHostCPUCache        `xml:"cache"`
    85  	MaxPhysAddr  *CapsHostCPUMaxPhysAddr  `xml:"maxphysaddr"`
    86  	FeatureFlags []CapsHostCPUFeatureFlag `xml:"feature"`
    87  	Features     *CapsHostCPUFeatures     `xml:"features"`
    88  	PageSizes    []CapsHostCPUPageSize    `xml:"pages"`
    89  }
    90  
    91  type CapsHostCPUFeature struct {
    92  }
    93  
    94  type CapsHostCPUFeatures struct {
    95  	PAE    *CapsHostCPUFeature `xml:"pae"`
    96  	NonPAE *CapsHostCPUFeature `xml:"nonpae"`
    97  	SVM    *CapsHostCPUFeature `xml:"svm"`
    98  	VMX    *CapsHostCPUFeature `xml:"vmx"`
    99  }
   100  
   101  type CapsHostNUMAMemory struct {
   102  	Size uint64 `xml:",chardata"`
   103  	Unit string `xml:"unit,attr"`
   104  }
   105  
   106  type CapsHostNUMAPageInfo struct {
   107  	Size  int    `xml:"size,attr"`
   108  	Unit  string `xml:"unit,attr"`
   109  	Count uint64 `xml:",chardata"`
   110  }
   111  
   112  type CapsHostNUMACPU struct {
   113  	ID        int    `xml:"id,attr"`
   114  	SocketID  *int   `xml:"socket_id,attr"`
   115  	DieID     *int   `xml:"die_id,attr"`
   116  	ClusterID *int   `xml:"cluster_id,attr"`
   117  	CoreID    *int   `xml:"core_id,attr"`
   118  	Siblings  string `xml:"siblings,attr,omitempty"`
   119  }
   120  
   121  type CapsHostNUMASibling struct {
   122  	ID    int `xml:"id,attr"`
   123  	Value int `xml:"value,attr"`
   124  }
   125  
   126  type CapsHostNUMACacheSize struct {
   127  	Value uint   `xml:"value,attr,omitempty"`
   128  	Unit  string `xml:"unit,attr,omitempty"`
   129  }
   130  
   131  type CapsHostNUMACacheLine struct {
   132  	Value uint   `xml:"value,attr,omitempty"`
   133  	Unit  string `xml:"unit,attr,omitempty"`
   134  }
   135  
   136  type CapsHostNUMACache struct {
   137  	Level         int                    `xml:"level,attr,omitempty"`
   138  	Associativity string                 `xml:"associativity,attr,omitempty"`
   139  	Policy        string                 `xml:"policy,attr,omitempty"`
   140  	Size          *CapsHostNUMACacheSize `xml:"size"`
   141  	Line          *CapsHostNUMACacheLine `xml:"line"`
   142  }
   143  
   144  type CapsHostNUMACell struct {
   145  	ID        int                    `xml:"id,attr"`
   146  	Memory    *CapsHostNUMAMemory    `xml:"memory"`
   147  	PageInfo  []CapsHostNUMAPageInfo `xml:"pages"`
   148  	Distances *CapsHostNUMADistances `xml:"distances"`
   149  	Cache     []CapsHostNUMACache    `xml:"cache"`
   150  	CPUS      *CapsHostNUMACPUs      `xml:"cpus"`
   151  }
   152  
   153  type CapsHostNUMADistances struct {
   154  	Siblings []CapsHostNUMASibling `xml:"sibling"`
   155  }
   156  
   157  type CapsHostNUMACPUs struct {
   158  	Num  uint              `xml:"num,attr"`
   159  	CPUs []CapsHostNUMACPU `xml:"cpu"`
   160  }
   161  
   162  type CapsHostNUMAInterconnects struct {
   163  	Latency   []CapsHostNUMAInterconnectLatency   `xml:"latency"`
   164  	Bandwidth []CapsHostNUMAInterconnectBandwidth `xml:"bandwidth"`
   165  }
   166  
   167  type CapsHostNUMAInterconnectLatency struct {
   168  	Initiator uint   `xml:"initiator,attr"`
   169  	Target    uint   `xml:"target,attr"`
   170  	Type      string `xml:"type,attr"`
   171  	Value     uint   `xml:"value,attr"`
   172  }
   173  
   174  type CapsHostNUMAInterconnectBandwidth struct {
   175  	Initiator uint   `xml:"initiator,attr"`
   176  	Target    uint   `xml:"target,attr"`
   177  	Type      string `xml:"type,attr"`
   178  	Value     uint   `xml:"value,attr"`
   179  	Unit      string `xml:"unit,attr"`
   180  }
   181  
   182  type CapsHostNUMATopology struct {
   183  	Cells         *CapsHostNUMACells         `xml:"cells"`
   184  	Interconnects *CapsHostNUMAInterconnects `xml:"interconnects"`
   185  }
   186  
   187  type CapsHostNUMACells struct {
   188  	Num   uint               `xml:"num,attr,omitempty"`
   189  	Cells []CapsHostNUMACell `xml:"cell"`
   190  }
   191  
   192  type CapsHostSecModelLabel struct {
   193  	Type  string `xml:"type,attr"`
   194  	Value string `xml:",chardata"`
   195  }
   196  
   197  type CapsHostSecModel struct {
   198  	Name   string                  `xml:"model"`
   199  	DOI    string                  `xml:"doi"`
   200  	Labels []CapsHostSecModelLabel `xml:"baselabel"`
   201  }
   202  
   203  type CapsHostMigrationFeatures struct {
   204  	Live          *CapsHostMigrationLive          `xml:"live"`
   205  	URITransports *CapsHostMigrationURITransports `xml:"uri_transports"`
   206  }
   207  
   208  type CapsHostMigrationLive struct {
   209  }
   210  
   211  type CapsHostMigrationURITransports struct {
   212  	URI []string `xml:"uri_transport"`
   213  }
   214  
   215  type CapsHost struct {
   216  	UUID              string                     `xml:"uuid,omitempty"`
   217  	CPU               *CapsHostCPU               `xml:"cpu"`
   218  	PowerManagement   *CapsHostPowerManagement   `xml:"power_management"`
   219  	IOMMU             *CapsHostIOMMU             `xml:"iommu"`
   220  	MigrationFeatures *CapsHostMigrationFeatures `xml:"migration_features"`
   221  	NUMA              *CapsHostNUMATopology      `xml:"topology"`
   222  	Cache             *CapsHostCache             `xml:"cache"`
   223  	MemoryBandwidth   *CapsHostMemoryBandwidth   `xml:"memory_bandwidth"`
   224  	SecModel          []CapsHostSecModel         `xml:"secmodel"`
   225  }
   226  
   227  type CapsHostPowerManagement struct {
   228  	SuspendMem    *CapsHostPowerManagementMode `xml:"suspend_mem"`
   229  	SuspendDisk   *CapsHostPowerManagementMode `xml:"suspend_disk"`
   230  	SuspendHybrid *CapsHostPowerManagementMode `xml:"suspend_hybrid"`
   231  }
   232  
   233  type CapsHostPowerManagementMode struct {
   234  }
   235  
   236  type CapsHostIOMMU struct {
   237  	Support string `xml:"support,attr"`
   238  }
   239  
   240  type CapsHostCache struct {
   241  	Banks   []CapsHostCacheBank   `xml:"bank"`
   242  	Monitor *CapsHostCacheMonitor `xml:"monitor"`
   243  }
   244  
   245  type CapsHostCacheBank struct {
   246  	ID      uint                   `xml:"id,attr"`
   247  	Level   uint                   `xml:"level,attr"`
   248  	Type    string                 `xml:"type,attr"`
   249  	Size    uint                   `xml:"size,attr"`
   250  	Unit    string                 `xml:"unit,attr"`
   251  	CPUs    string                 `xml:"cpus,attr"`
   252  	Control []CapsHostCacheControl `xml:"control"`
   253  }
   254  
   255  type CapsHostCacheMonitor struct {
   256  	Level          uint                          `xml:"level,attr,omitempty"`
   257  	ResueThreshold uint                          `xml:"reuseThreshold,attr,omitempty"`
   258  	MaxMonitors    uint                          `xml:"maxMonitors,attr"`
   259  	Features       []CapsHostCacheMonitorFeature `xml:"feature"`
   260  }
   261  
   262  type CapsHostCacheMonitorFeature struct {
   263  	Name string `xml:"name,attr"`
   264  }
   265  
   266  type CapsHostCacheControl struct {
   267  	Granularity uint   `xml:"granularity,attr"`
   268  	Min         uint   `xml:"min,attr,omitempty"`
   269  	Unit        string `xml:"unit,attr"`
   270  	Type        string `xml:"type,attr"`
   271  	MaxAllows   uint   `xml:"maxAllocs,attr"`
   272  }
   273  
   274  type CapsHostMemoryBandwidth struct {
   275  	Nodes   []CapsHostMemoryBandwidthNode   `xml:"node"`
   276  	Monitor *CapsHostMemoryBandwidthMonitor `xml:"monitor"`
   277  }
   278  
   279  type CapsHostMemoryBandwidthNode struct {
   280  	ID      uint                                `xml:"id,attr"`
   281  	CPUs    string                              `xml:"cpus,attr"`
   282  	Control *CapsHostMemoryBandwidthNodeControl `xml:"control"`
   283  }
   284  
   285  type CapsHostMemoryBandwidthNodeControl struct {
   286  	Granularity uint `xml:"granularity,attr"`
   287  	Min         uint `xml:"min,attr"`
   288  	MaxAllocs   uint `xml:"maxAllocs,attr"`
   289  }
   290  
   291  type CapsHostMemoryBandwidthMonitor struct {
   292  	MaxMonitors uint                                    `xml:"maxMonitors,attr"`
   293  	Features    []CapsHostMemoryBandwidthMonitorFeature `xml:"feature"`
   294  }
   295  
   296  type CapsHostMemoryBandwidthMonitorFeature struct {
   297  	Name string `xml:"name,attr"`
   298  }
   299  
   300  type CapsGuestMachine struct {
   301  	Name      string `xml:",chardata"`
   302  	MaxCPUs   int    `xml:"maxCpus,attr,omitempty"`
   303  	Canonical string `xml:"canonical,attr,omitempty"`
   304  }
   305  
   306  type CapsGuestDomain struct {
   307  	Type     string             `xml:"type,attr"`
   308  	Emulator string             `xml:"emulator,omitempty"`
   309  	Machines []CapsGuestMachine `xml:"machine"`
   310  }
   311  
   312  type CapsGuestArch struct {
   313  	Name     string             `xml:"name,attr"`
   314  	WordSize string             `xml:"wordsize"`
   315  	Emulator string             `xml:"emulator"`
   316  	Loader   string             `xml:"loader,omitempty"`
   317  	Machines []CapsGuestMachine `xml:"machine"`
   318  	Domains  []CapsGuestDomain  `xml:"domain"`
   319  }
   320  
   321  type CapsGuestFeatureCPUSelection struct {
   322  }
   323  
   324  type CapsGuestFeatureDeviceBoot struct {
   325  }
   326  
   327  type CapsGuestFeaturePAE struct {
   328  }
   329  
   330  type CapsGuestFeatureNonPAE struct {
   331  }
   332  
   333  type CapsGuestFeatureDiskSnapshot struct {
   334  	Default string `xml:"default,attr,omitempty"`
   335  	Toggle  string `xml:"toggle,attr,omitempty"`
   336  }
   337  
   338  type CapsGuestFeatureAPIC struct {
   339  	Default string `xml:"default,attr,omitempty"`
   340  	Toggle  string `xml:"toggle,attr,omitempty"`
   341  }
   342  
   343  type CapsGuestFeatureACPI struct {
   344  	Default string `xml:"default,attr,omitempty"`
   345  	Toggle  string `xml:"toggle,attr,omitempty"`
   346  }
   347  
   348  type CapsGuestFeatureIA64BE struct {
   349  }
   350  
   351  type CapsGuestFeatures struct {
   352  	CPUSelection *CapsGuestFeatureCPUSelection `xml:"cpuselection"`
   353  	DeviceBoot   *CapsGuestFeatureDeviceBoot   `xml:"deviceboot"`
   354  	DiskSnapshot *CapsGuestFeatureDiskSnapshot `xml:"disksnapshot"`
   355  	PAE          *CapsGuestFeaturePAE          `xml:"pae"`
   356  	NonPAE       *CapsGuestFeatureNonPAE       `xml:"nonpae"`
   357  	APIC         *CapsGuestFeatureAPIC         `xml:"apic"`
   358  	ACPI         *CapsGuestFeatureACPI         `xml:"acpi"`
   359  	IA64BE       *CapsGuestFeatureIA64BE       `xml:"ia64_be"`
   360  }
   361  
   362  type CapsGuest struct {
   363  	OSType   string             `xml:"os_type"`
   364  	Arch     CapsGuestArch      `xml:"arch"`
   365  	Features *CapsGuestFeatures `xml:"features"`
   366  }
   367  
   368  type Caps struct {
   369  	XMLName xml.Name    `xml:"capabilities"`
   370  	Host    CapsHost    `xml:"host"`
   371  	Guests  []CapsGuest `xml:"guest"`
   372  }
   373  
   374  func (c *CapsHostCPU) Unmarshal(doc string) error {
   375  	return xml.Unmarshal([]byte(doc), c)
   376  }
   377  
   378  func (c *CapsHostCPU) Marshal() (string, error) {
   379  	doc, err := xml.MarshalIndent(c, "", "  ")
   380  	if err != nil {
   381  		return "", err
   382  	}
   383  	return string(doc), nil
   384  }
   385  
   386  func (c *Caps) Unmarshal(doc string) error {
   387  	return xml.Unmarshal([]byte(doc), c)
   388  }
   389  
   390  func (c *Caps) Marshal() (string, error) {
   391  	doc, err := xml.MarshalIndent(c, "", "  ")
   392  	if err != nil {
   393  		return "", err
   394  	}
   395  	return string(doc), nil
   396  }