github.com/zhaoxuat/libvirt-go-xml@v6.3.1-0.20200612053919-a025f1d30c41+incompatible/domain.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  	"fmt"
    31  	"io"
    32  	"strconv"
    33  	"strings"
    34  )
    35  
    36  type DomainControllerPCIHole64 struct {
    37  	Size uint64 `xml:",chardata"`
    38  	Unit string `xml:"unit,attr,omitempty"`
    39  }
    40  
    41  type DomainControllerPCIModel struct {
    42  	Name string `xml:"name,attr"`
    43  }
    44  
    45  type DomainControllerPCITarget struct {
    46  	ChassisNr *uint
    47  	Chassis   *uint
    48  	Port      *uint
    49  	BusNr     *uint
    50  	Index     *uint
    51  	NUMANode  *uint
    52  	Hotplug   string
    53  }
    54  
    55  type DomainControllerPCI struct {
    56  	Model  *DomainControllerPCIModel  `xml:"model"`
    57  	Target *DomainControllerPCITarget `xml:"target"`
    58  	Hole64 *DomainControllerPCIHole64 `xml:"pcihole64"`
    59  }
    60  
    61  type DomainControllerUSBMaster struct {
    62  	StartPort uint `xml:"startport,attr"`
    63  }
    64  
    65  type DomainControllerUSB struct {
    66  	Port   *uint                      `xml:"ports,attr"`
    67  	Master *DomainControllerUSBMaster `xml:"master"`
    68  }
    69  
    70  type DomainControllerVirtIOSerial struct {
    71  	Ports   *uint `xml:"ports,attr"`
    72  	Vectors *uint `xml:"vectors,attr"`
    73  }
    74  
    75  type DomainControllerXenBus struct {
    76  	MaxGrantFrames   uint `xml:"maxGrantFrames,attr,omitempty"`
    77  	MaxEventChannels uint `xml:"maxEventChannels,attr,omitempty"`
    78  }
    79  
    80  type DomainControllerDriver struct {
    81  	Queues     *uint  `xml:"queues,attr"`
    82  	CmdPerLUN  *uint  `xml:"cmd_per_lun,attr"`
    83  	MaxSectors *uint  `xml:"max_sectors,attr"`
    84  	IOEventFD  string `xml:"ioeventfd,attr,omitempty"`
    85  	IOThread   uint   `xml:"iothread,attr,omitempty"`
    86  	IOMMU      string `xml:"iommu,attr,omitempty"`
    87  	ATS        string `xml:"ats,attr,omitempty"`
    88  	Packed     string `xml:"packed,attr,omitempty"`
    89  }
    90  
    91  type DomainController struct {
    92  	XMLName      xml.Name                      `xml:"controller"`
    93  	Type         string                        `xml:"type,attr"`
    94  	Index        *uint                         `xml:"index,attr"`
    95  	Model        string                        `xml:"model,attr,omitempty"`
    96  	Driver       *DomainControllerDriver       `xml:"driver"`
    97  	PCI          *DomainControllerPCI          `xml:"-"`
    98  	USB          *DomainControllerUSB          `xml:"-"`
    99  	VirtIOSerial *DomainControllerVirtIOSerial `xml:"-"`
   100  	XenBus       *DomainControllerXenBus       `xml:"-"`
   101  	Alias        *DomainAlias                  `xml:"alias"`
   102  	Address      *DomainAddress                `xml:"address"`
   103  }
   104  
   105  type DomainDiskSecret struct {
   106  	Type  string `xml:"type,attr,omitempty"`
   107  	Usage string `xml:"usage,attr,omitempty"`
   108  	UUID  string `xml:"uuid,attr,omitempty"`
   109  }
   110  
   111  type DomainDiskAuth struct {
   112  	Username string            `xml:"username,attr,omitempty"`
   113  	Secret   *DomainDiskSecret `xml:"secret"`
   114  }
   115  
   116  type DomainDiskSourceHost struct {
   117  	Transport string `xml:"transport,attr,omitempty"`
   118  	Name      string `xml:"name,attr,omitempty"`
   119  	Port      string `xml:"port,attr,omitempty"`
   120  	Socket    string `xml:"socket,attr,omitempty"`
   121  }
   122  
   123  type DomainDiskSourceSSL struct {
   124  	Verify string `xml:"verify,attr"`
   125  }
   126  
   127  type DomainDiskCookie struct {
   128  	Name  string `xml:"name,attr"`
   129  	Value string `xml:",chardata"`
   130  }
   131  
   132  type DomainDiskCookies struct {
   133  	Cookies []DomainDiskCookie `xml:"cookie"`
   134  }
   135  
   136  type DomainDiskSourceReadahead struct {
   137  	Size string `xml:"size,attr"`
   138  }
   139  
   140  type DomainDiskSourceTimeout struct {
   141  	Seconds string `xml:"seconds,attr"`
   142  }
   143  
   144  type DomainDiskReservationsSource DomainChardevSource
   145  
   146  type DomainDiskReservations struct {
   147  	Enabled string                        `xml:"enabled,attr,omitempty"`
   148  	Managed string                        `xml:"managed,attr,omitempty"`
   149  	Source  *DomainDiskReservationsSource `xml:"source"`
   150  }
   151  
   152  type DomainDiskSource struct {
   153  	File          *DomainDiskSourceFile      `xml:"-"`
   154  	Block         *DomainDiskSourceBlock     `xml:"-"`
   155  	Dir           *DomainDiskSourceDir       `xml:"-"`
   156  	Network       *DomainDiskSourceNetwork   `xml:"-"`
   157  	Volume        *DomainDiskSourceVolume    `xml:"-"`
   158  	NVME          *DomainDiskSourceNVME      `xml:"-"`
   159  	StartupPolicy string                     `xml:"startupPolicy,attr,omitempty"`
   160  	Index         uint                       `xml:"index,attr,omitempty"`
   161  	Encryption    *DomainDiskEncryption      `xml:"encryption"`
   162  	Reservations  *DomainDiskReservations    `xml:"reservations"`
   163  	Slices        *DomainDiskSlices          `xml:"slices"`
   164  	SSL           *DomainDiskSourceSSL       `xml:"ssl"`
   165  	Cookies       *DomainDiskCookies         `xml:"cookies"`
   166  	Readahead     *DomainDiskSourceReadahead `xml:"readahead"`
   167  	Timeout       *DomainDiskSourceTimeout   `xml:"timeout"`
   168  }
   169  
   170  type DomainDiskSlices struct {
   171  	Slices []DomainDiskSlice `xml:"slice"`
   172  }
   173  
   174  type DomainDiskSlice struct {
   175  	Type   string `xml:"type,attr"`
   176  	Offset uint   `xml:"offset,attr"`
   177  	Size   uint   `xml:"size,attr"`
   178  }
   179  
   180  type DomainDiskSourceFile struct {
   181  	File     string                 `xml:"file,attr,omitempty"`
   182  	SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
   183  }
   184  
   185  type DomainDiskSourceNVME struct {
   186  	PCI *DomainDiskSourceNVMEPCI
   187  }
   188  
   189  type DomainDiskSourceNVMEPCI struct {
   190  	Managed   string            `xml:"managed,attr,omitempty"`
   191  	Namespace uint64            `xml:"namespace,attr,omitempty"`
   192  	Address   *DomainAddressPCI `xml:"address"`
   193  }
   194  
   195  type DomainDiskSourceBlock struct {
   196  	Dev      string                 `xml:"dev,attr,omitempty"`
   197  	SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
   198  }
   199  
   200  type DomainDiskSourceDir struct {
   201  	Dir string `xml:"dir,attr,omitempty"`
   202  }
   203  
   204  type DomainDiskSourceNetwork struct {
   205  	Protocol  string                            `xml:"protocol,attr,omitempty"`
   206  	Name      string                            `xml:"name,attr,omitempty"`
   207  	Query     string                            `xml:"query,attr,omitempty"`
   208  	TLS       string                            `xml:"tls,attr,omitempty"`
   209  	Hosts     []DomainDiskSourceHost            `xml:"host"`
   210  	Initiator *DomainDiskSourceNetworkInitiator `xml:"initiator"`
   211  	Snapshot  *DomainDiskSourceNetworkSnapshot  `xml:"snapshot"`
   212  	Config    *DomainDiskSourceNetworkConfig    `xml:"config"`
   213  	Auth      *DomainDiskAuth                   `xml:"auth"`
   214  }
   215  
   216  type DomainDiskSourceNetworkInitiator struct {
   217  	IQN *DomainDiskSourceNetworkIQN `xml:"iqn"`
   218  }
   219  
   220  type DomainDiskSourceNetworkIQN struct {
   221  	Name string `xml:"name,attr,omitempty"`
   222  }
   223  
   224  type DomainDiskSourceNetworkSnapshot struct {
   225  	Name string `xml:"name,attr"`
   226  }
   227  
   228  type DomainDiskSourceNetworkConfig struct {
   229  	File string `xml:"file,attr"`
   230  }
   231  
   232  type DomainDiskSourceVolume struct {
   233  	Pool     string                 `xml:"pool,attr,omitempty"`
   234  	Volume   string                 `xml:"volume,attr,omitempty"`
   235  	Mode     string                 `xml:"mode,attr,omitempty"`
   236  	SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
   237  }
   238  
   239  type DomainDiskDriver struct {
   240  	Name         string `xml:"name,attr,omitempty"`
   241  	Type         string `xml:"type,attr,omitempty"`
   242  	Cache        string `xml:"cache,attr,omitempty"`
   243  	ErrorPolicy  string `xml:"error_policy,attr,omitempty"`
   244  	RErrorPolicy string `xml:"rerror_policy,attr,omitempty"`
   245  	IO           string `xml:"io,attr,omitempty"`
   246  	IOEventFD    string `xml:"ioeventfd,attr,omitempty"`
   247  	EventIDX     string `xml:"event_idx,attr,omitempty"`
   248  	CopyOnRead   string `xml:"copy_on_read,attr,omitempty"`
   249  	Discard      string `xml:"discard,attr,omitempty"`
   250  	IOThread     *uint  `xml:"iothread,attr"`
   251  	DetectZeros  string `xml:"detect_zeroes,attr,omitempty"`
   252  	Queues       *uint  `xml:"queues,attr"`
   253  	IOMMU        string `xml:"iommu,attr,omitempty"`
   254  	ATS          string `xml:"ats,attr,omitempty"`
   255  	Packed       string `xml:"packed,attr,omitempty"`
   256  }
   257  
   258  type DomainDiskTarget struct {
   259  	Dev       string `xml:"dev,attr,omitempty"`
   260  	Bus       string `xml:"bus,attr,omitempty"`
   261  	Tray      string `xml:"tray,attr,omitempty"`
   262  	Removable string `xml:"removable,attr,omitempty"`
   263  }
   264  
   265  type DomainDiskEncryption struct {
   266  	Format string            `xml:"format,attr,omitempty"`
   267  	Secret *DomainDiskSecret `xml:"secret"`
   268  }
   269  
   270  type DomainDiskReadOnly struct {
   271  }
   272  
   273  type DomainDiskShareable struct {
   274  }
   275  
   276  type DomainDiskTransient struct {
   277  }
   278  
   279  type DomainDiskIOTune struct {
   280  	TotalBytesSec          uint64 `xml:"total_bytes_sec,omitempty"`
   281  	ReadBytesSec           uint64 `xml:"read_bytes_sec,omitempty"`
   282  	WriteBytesSec          uint64 `xml:"write_bytes_sec,omitempty"`
   283  	TotalIopsSec           uint64 `xml:"total_iops_sec,omitempty"`
   284  	ReadIopsSec            uint64 `xml:"read_iops_sec,omitempty"`
   285  	WriteIopsSec           uint64 `xml:"write_iops_sec,omitempty"`
   286  	TotalBytesSecMax       uint64 `xml:"total_bytes_sec_max,omitempty"`
   287  	ReadBytesSecMax        uint64 `xml:"read_bytes_sec_max,omitempty"`
   288  	WriteBytesSecMax       uint64 `xml:"write_bytes_sec_max,omitempty"`
   289  	TotalIopsSecMax        uint64 `xml:"total_iops_sec_max,omitempty"`
   290  	ReadIopsSecMax         uint64 `xml:"read_iops_sec_max,omitempty"`
   291  	WriteIopsSecMax        uint64 `xml:"write_iops_sec_max,omitempty"`
   292  	TotalBytesSecMaxLength uint64 `xml:"total_bytes_sec_max_length,omitempty"`
   293  	ReadBytesSecMaxLength  uint64 `xml:"read_bytes_sec_max_length,omitempty"`
   294  	WriteBytesSecMaxLength uint64 `xml:"write_bytes_sec_max_length,omitempty"`
   295  	TotalIopsSecMaxLength  uint64 `xml:"total_iops_sec_max_length,omitempty"`
   296  	ReadIopsSecMaxLength   uint64 `xml:"read_iops_sec_max_length,omitempty"`
   297  	WriteIopsSecMaxLength  uint64 `xml:"write_iops_sec_max_length,omitempty"`
   298  	SizeIopsSec            uint64 `xml:"size_iops_sec,omitempty"`
   299  	GroupName              string `xml:"group_name,omitempty"`
   300  }
   301  
   302  type DomainDiskGeometry struct {
   303  	Cylinders uint   `xml:"cyls,attr"`
   304  	Headers   uint   `xml:"heads,attr"`
   305  	Sectors   uint   `xml:"secs,attr"`
   306  	Trans     string `xml:"trans,attr,omitempty"`
   307  }
   308  
   309  type DomainDiskBlockIO struct {
   310  	LogicalBlockSize  uint `xml:"logical_block_size,attr,omitempty"`
   311  	PhysicalBlockSize uint `xml:"physical_block_size,attr,omitempty"`
   312  }
   313  
   314  type DomainDiskFormat struct {
   315  	Type string `xml:"type,attr"`
   316  }
   317  
   318  type DomainDiskBackingStore struct {
   319  	Index        uint                    `xml:"index,attr,omitempty"`
   320  	Format       *DomainDiskFormat       `xml:"format"`
   321  	Source       *DomainDiskSource       `xml:"source"`
   322  	BackingStore *DomainDiskBackingStore `xml:"backingStore"`
   323  }
   324  
   325  type DomainDiskMirror struct {
   326  	Job          string                  `xml:"job,attr,omitempty"`
   327  	Ready        string                  `xml:"ready,attr,omitempty"`
   328  	Format       *DomainDiskFormat       `xml:"format"`
   329  	Source       *DomainDiskSource       `xml:"source"`
   330  	BackingStore *DomainDiskBackingStore `xml:"backingStore"`
   331  }
   332  
   333  type DomainDisk struct {
   334  	XMLName      xml.Name                `xml:"disk"`
   335  	Device       string                  `xml:"device,attr,omitempty"`
   336  	RawIO        string                  `xml:"rawio,attr,omitempty"`
   337  	SGIO         string                  `xml:"sgio,attr,omitempty"`
   338  	Snapshot     string                  `xml:"snapshot,attr,omitempty"`
   339  	Model        string                  `xml:"model,attr,omitempty"`
   340  	Driver       *DomainDiskDriver       `xml:"driver"`
   341  	Auth         *DomainDiskAuth         `xml:"auth"`
   342  	Source       *DomainDiskSource       `xml:"source"`
   343  	BackingStore *DomainDiskBackingStore `xml:"backingStore"`
   344  	Geometry     *DomainDiskGeometry     `xml:"geometry"`
   345  	BlockIO      *DomainDiskBlockIO      `xml:"blockio"`
   346  	Mirror       *DomainDiskMirror       `xml:"mirror"`
   347  	Target       *DomainDiskTarget       `xml:"target"`
   348  	IOTune       *DomainDiskIOTune       `xml:"iotune"`
   349  	ReadOnly     *DomainDiskReadOnly     `xml:"readonly"`
   350  	Shareable    *DomainDiskShareable    `xml:"shareable"`
   351  	Transient    *DomainDiskTransient    `xml:"transient"`
   352  	Serial       string                  `xml:"serial,omitempty"`
   353  	WWN          string                  `xml:"wwn,omitempty"`
   354  	Vendor       string                  `xml:"vendor,omitempty"`
   355  	Product      string                  `xml:"product,omitempty"`
   356  	Encryption   *DomainDiskEncryption   `xml:"encryption"`
   357  	Boot         *DomainDeviceBoot       `xml:"boot"`
   358  	Alias        *DomainAlias            `xml:"alias"`
   359  	Address      *DomainAddress          `xml:"address"`
   360  }
   361  
   362  type DomainFilesystemDriver struct {
   363  	Type     string `xml:"type,attr,omitempty"`
   364  	Format   string `xml:"format,attr,omitempty"`
   365  	Name     string `xml:"name,attr,omitempty"`
   366  	WRPolicy string `xml:"wrpolicy,attr,omitempty"`
   367  	IOMMU    string `xml:"iommu,attr,omitempty"`
   368  	ATS      string `xml:"ats,attr,omitempty"`
   369  	Packed   string `xml:"packed,attr,omitempty"`
   370  	Queue    uint   `xml:"queue,attr,omitempty"`
   371  }
   372  
   373  type DomainFilesystemSource struct {
   374  	Mount    *DomainFilesystemSourceMount    `xml:"-"`
   375  	Block    *DomainFilesystemSourceBlock    `xml:"-"`
   376  	File     *DomainFilesystemSourceFile     `xml:"-"`
   377  	Template *DomainFilesystemSourceTemplate `xml:"-"`
   378  	RAM      *DomainFilesystemSourceRAM      `xml:"-"`
   379  	Bind     *DomainFilesystemSourceBind     `xml:"-"`
   380  	Volume   *DomainFilesystemSourceVolume   `xml:"-"`
   381  }
   382  
   383  type DomainFilesystemSourceMount struct {
   384  	Dir string `xml:"dir,attr"`
   385  }
   386  
   387  type DomainFilesystemSourceBlock struct {
   388  	Dev string `xml:"dev,attr"`
   389  }
   390  
   391  type DomainFilesystemSourceFile struct {
   392  	File string `xml:"file,attr"`
   393  }
   394  
   395  type DomainFilesystemSourceTemplate struct {
   396  	Name string `xml:"name,attr"`
   397  }
   398  
   399  type DomainFilesystemSourceRAM struct {
   400  	Usage uint   `xml:"usage,attr"`
   401  	Units string `xml:"units,attr,omitempty"`
   402  }
   403  
   404  type DomainFilesystemSourceBind struct {
   405  	Dir string `xml:"dir,attr"`
   406  }
   407  
   408  type DomainFilesystemSourceVolume struct {
   409  	Pool   string `xml:"pool,attr"`
   410  	Volume string `xml:"volume,attr"`
   411  }
   412  
   413  type DomainFilesystemTarget struct {
   414  	Dir string `xml:"dir,attr"`
   415  }
   416  
   417  type DomainFilesystemReadOnly struct {
   418  }
   419  
   420  type DomainFilesystemSpaceHardLimit struct {
   421  	Value uint   `xml:",chardata"`
   422  	Unit  string `xml:"unit,attr,omitempty"`
   423  }
   424  
   425  type DomainFilesystemSpaceSoftLimit struct {
   426  	Value uint   `xml:",chardata"`
   427  	Unit  string `xml:"unit,attr,omitempty"`
   428  }
   429  
   430  type DomainFilesystemBinaryCache struct {
   431  	Mode string `xml:"mode,attr"`
   432  }
   433  
   434  type DomainFilesystemBinaryLock struct {
   435  	POSIX string `xml:"posix,attr,omitempty"`
   436  	Flock string `xml:"flock,attr,omitempty"`
   437  }
   438  
   439  type DomainFilesystemBinary struct {
   440  	Path  string                       `xml:"path,attr,omitempty"`
   441  	XAttr string                       `xml:"xattr,attr,omitempty"`
   442  	Cache *DomainFilesystemBinaryCache `xml:"cache"`
   443  	Lock  *DomainFilesystemBinaryLock  `xml:"lock"`
   444  }
   445  
   446  type DomainFilesystem struct {
   447  	XMLName        xml.Name                        `xml:"filesystem"`
   448  	AccessMode     string                          `xml:"accessmode,attr,omitempty"`
   449  	Model          string                          `xml:"model,attr,omitempty"`
   450  	MultiDevs      string                          `xml:"multidevs,attr,omitempty"`
   451  	Driver         *DomainFilesystemDriver         `xml:"driver"`
   452  	Binary         *DomainFilesystemBinary         `xml:"binary"`
   453  	Source         *DomainFilesystemSource         `xml:"source"`
   454  	Target         *DomainFilesystemTarget         `xml:"target"`
   455  	ReadOnly       *DomainFilesystemReadOnly       `xml:"readonly"`
   456  	SpaceHardLimit *DomainFilesystemSpaceHardLimit `xml:"space_hard_limit"`
   457  	SpaceSoftLimit *DomainFilesystemSpaceSoftLimit `xml:"space_soft_limit"`
   458  	Alias          *DomainAlias                    `xml:"alias"`
   459  	Address        *DomainAddress                  `xml:"address"`
   460  }
   461  
   462  type DomainInterfaceMAC struct {
   463  	Address string `xml:"address,attr"`
   464  }
   465  
   466  type DomainInterfaceModel struct {
   467  	Type string `xml:"type,attr"`
   468  }
   469  
   470  type DomainInterfaceSource struct {
   471  	User      *DomainInterfaceSourceUser     `xml:"-"`
   472  	Ethernet  *DomainInterfaceSourceEthernet `xml:"-"`
   473  	VHostUser *DomainChardevSource           `xml:"-"`
   474  	Server    *DomainInterfaceSourceServer   `xml:"-"`
   475  	Client    *DomainInterfaceSourceClient   `xml:"-"`
   476  	MCast     *DomainInterfaceSourceMCast    `xml:"-"`
   477  	Network   *DomainInterfaceSourceNetwork  `xml:"-"`
   478  	Bridge    *DomainInterfaceSourceBridge   `xml:"-"`
   479  	Internal  *DomainInterfaceSourceInternal `xml:"-"`
   480  	Direct    *DomainInterfaceSourceDirect   `xml:"-"`
   481  	Hostdev   *DomainInterfaceSourceHostdev  `xml:"-"`
   482  	UDP       *DomainInterfaceSourceUDP      `xml:"-"`
   483  }
   484  
   485  type DomainInterfaceSourceUser struct {
   486  }
   487  
   488  type DomainInterfaceSourceEthernet struct {
   489  	IP    []DomainInterfaceIP    `xml:"ip"`
   490  	Route []DomainInterfaceRoute `xml:"route"`
   491  }
   492  
   493  type DomainInterfaceSourceServer struct {
   494  	Address string                      `xml:"address,attr,omitempty"`
   495  	Port    uint                        `xml:"port,attr,omitempty"`
   496  	Local   *DomainInterfaceSourceLocal `xml:"local"`
   497  }
   498  
   499  type DomainInterfaceSourceClient struct {
   500  	Address string                      `xml:"address,attr,omitempty"`
   501  	Port    uint                        `xml:"port,attr,omitempty"`
   502  	Local   *DomainInterfaceSourceLocal `xml:"local"`
   503  }
   504  
   505  type DomainInterfaceSourceMCast struct {
   506  	Address string                      `xml:"address,attr,omitempty"`
   507  	Port    uint                        `xml:"port,attr,omitempty"`
   508  	Local   *DomainInterfaceSourceLocal `xml:"local"`
   509  }
   510  
   511  type DomainInterfaceSourceNetwork struct {
   512  	Network   string `xml:"network,attr,omitempty"`
   513  	PortGroup string `xml:"portgroup,attr,omitempty"`
   514  	Bridge    string `xml:"bridge,attr,omitempty"`
   515  	PortID    string `xml:"portid,attr,omitempty"`
   516  }
   517  
   518  type DomainInterfaceSourceBridge struct {
   519  	Bridge string `xml:"bridge,attr"`
   520  }
   521  
   522  type DomainInterfaceSourceInternal struct {
   523  	Name string `xml:"name,attr,omitempty"`
   524  }
   525  
   526  type DomainInterfaceSourceDirect struct {
   527  	Dev  string `xml:"dev,attr,omitempty"`
   528  	Mode string `xml:"mode,attr,omitempty"`
   529  }
   530  
   531  type DomainInterfaceSourceHostdev struct {
   532  	PCI *DomainHostdevSubsysPCISource `xml:"-"`
   533  	USB *DomainHostdevSubsysUSBSource `xml:"-"`
   534  }
   535  
   536  type DomainInterfaceSourceUDP struct {
   537  	Address string                      `xml:"address,attr,omitempty"`
   538  	Port    uint                        `xml:"port,attr,omitempty"`
   539  	Local   *DomainInterfaceSourceLocal `xml:"local"`
   540  }
   541  
   542  type DomainInterfaceSourceLocal struct {
   543  	Address string `xml:"address,attr,omitempty"`
   544  	Port    uint   `xml:"port,attr,omitempty"`
   545  }
   546  
   547  type DomainInterfaceTarget struct {
   548  	Dev     string `xml:"dev,attr"`
   549  	Managed string `xml:"managed,attr,omitempty"`
   550  }
   551  
   552  type DomainInterfaceLink struct {
   553  	State string `xml:"state,attr"`
   554  }
   555  
   556  type DomainDeviceBoot struct {
   557  	Order    uint   `xml:"order,attr"`
   558  	LoadParm string `xml:"loadparm,attr,omitempty"`
   559  }
   560  
   561  type DomainInterfaceScript struct {
   562  	Path string `xml:"path,attr"`
   563  }
   564  
   565  type DomainInterfaceDriver struct {
   566  	Name        string                      `xml:"name,attr,omitempty"`
   567  	TXMode      string                      `xml:"txmode,attr,omitempty"`
   568  	IOEventFD   string                      `xml:"ioeventfd,attr,omitempty"`
   569  	EventIDX    string                      `xml:"event_idx,attr,omitempty"`
   570  	Queues      uint                        `xml:"queues,attr,omitempty"`
   571  	RXQueueSize uint                        `xml:"rx_queue_size,attr,omitempty"`
   572  	TXQueueSize uint                        `xml:"tx_queue_size,attr,omitempty"`
   573  	IOMMU       string                      `xml:"iommu,attr,omitempty"`
   574  	ATS         string                      `xml:"ats,attr,omitempty"`
   575  	Packed      string                      `xml:"packed,attr,omitempty"`
   576  	Host        *DomainInterfaceDriverHost  `xml:"host"`
   577  	Guest       *DomainInterfaceDriverGuest `xml:"guest"`
   578  }
   579  
   580  type DomainInterfaceDriverHost struct {
   581  	CSum     string `xml:"csum,attr,omitempty"`
   582  	GSO      string `xml:"gso,attr,omitempty"`
   583  	TSO4     string `xml:"tso4,attr,omitempty"`
   584  	TSO6     string `xml:"tso6,attr,omitempty"`
   585  	ECN      string `xml:"ecn,attr,omitempty"`
   586  	UFO      string `xml:"ufo,attr,omitempty"`
   587  	MrgRXBuf string `xml:"mrg_rxbuf,attr,omitempty"`
   588  	StandBy  string `xml:"standby,attr,omitempty"`
   589  }
   590  
   591  type DomainInterfaceDriverGuest struct {
   592  	CSum string `xml:"csum,attr,omitempty"`
   593  	TSO4 string `xml:"tso4,attr,omitempty"`
   594  	TSO6 string `xml:"tso6,attr,omitempty"`
   595  	ECN  string `xml:"ecn,attr,omitempty"`
   596  	UFO  string `xml:"ufo,attr,omitempty"`
   597  }
   598  
   599  type DomainInterfaceVirtualPort struct {
   600  	Params *DomainInterfaceVirtualPortParams `xml:"parameters"`
   601  }
   602  
   603  type DomainInterfaceVirtualPortParams struct {
   604  	Any          *DomainInterfaceVirtualPortParamsAny          `xml:"-"`
   605  	VEPA8021QBG  *DomainInterfaceVirtualPortParamsVEPA8021QBG  `xml:"-"`
   606  	VNTag8011QBH *DomainInterfaceVirtualPortParamsVNTag8021QBH `xml:"-"`
   607  	OpenVSwitch  *DomainInterfaceVirtualPortParamsOpenVSwitch  `xml:"-"`
   608  	MidoNet      *DomainInterfaceVirtualPortParamsMidoNet      `xml:"-"`
   609  }
   610  
   611  type DomainInterfaceVirtualPortParamsAny struct {
   612  	ManagerID     *uint  `xml:"managerid,attr"`
   613  	TypeID        *uint  `xml:"typeid,attr"`
   614  	TypeIDVersion *uint  `xml:"typeidversion,attr"`
   615  	InstanceID    string `xml:"instanceid,attr,omitempty"`
   616  	ProfileID     string `xml:"profileid,attr,omitempty"`
   617  	InterfaceID   string `xml:"interfaceid,attr,omitempty"`
   618  }
   619  
   620  type DomainInterfaceVirtualPortParamsVEPA8021QBG struct {
   621  	ManagerID     *uint  `xml:"managerid,attr"`
   622  	TypeID        *uint  `xml:"typeid,attr"`
   623  	TypeIDVersion *uint  `xml:"typeidversion,attr"`
   624  	InstanceID    string `xml:"instanceid,attr,omitempty"`
   625  }
   626  
   627  type DomainInterfaceVirtualPortParamsVNTag8021QBH struct {
   628  	ProfileID string `xml:"profileid,attr,omitempty"`
   629  }
   630  
   631  type DomainInterfaceVirtualPortParamsOpenVSwitch struct {
   632  	InterfaceID string `xml:"interfaceid,attr,omitempty"`
   633  	ProfileID   string `xml:"profileid,attr,omitempty"`
   634  }
   635  
   636  type DomainInterfaceVirtualPortParamsMidoNet struct {
   637  	InterfaceID string `xml:"interfaceid,attr,omitempty"`
   638  }
   639  
   640  type DomainInterfaceBandwidthParams struct {
   641  	Average *int `xml:"average,attr"`
   642  	Peak    *int `xml:"peak,attr"`
   643  	Burst   *int `xml:"burst,attr"`
   644  	Floor   *int `xml:"floor,attr"`
   645  }
   646  
   647  type DomainInterfaceBandwidth struct {
   648  	Inbound  *DomainInterfaceBandwidthParams `xml:"inbound"`
   649  	Outbound *DomainInterfaceBandwidthParams `xml:"outbound"`
   650  }
   651  
   652  type DomainInterfaceVLan struct {
   653  	Trunk string                   `xml:"trunk,attr,omitempty"`
   654  	Tags  []DomainInterfaceVLanTag `xml:"tag"`
   655  }
   656  
   657  type DomainInterfaceVLanTag struct {
   658  	ID         uint   `xml:"id,attr"`
   659  	NativeMode string `xml:"nativeMode,attr,omitempty"`
   660  }
   661  
   662  type DomainInterfaceGuest struct {
   663  	Dev    string `xml:"dev,attr,omitempty"`
   664  	Actual string `xml:"actual,attr,omitempty"`
   665  }
   666  
   667  type DomainInterfaceFilterRef struct {
   668  	Filter     string                       `xml:"filter,attr"`
   669  	Parameters []DomainInterfaceFilterParam `xml:"parameter"`
   670  }
   671  
   672  type DomainInterfaceFilterParam struct {
   673  	Name  string `xml:"name,attr"`
   674  	Value string `xml:"value,attr"`
   675  }
   676  
   677  type DomainInterfaceBackend struct {
   678  	Tap   string `xml:"tap,attr,omitempty"`
   679  	VHost string `xml:"vhost,attr,omitempty"`
   680  }
   681  
   682  type DomainInterfaceTune struct {
   683  	SndBuf uint `xml:"sndbuf"`
   684  }
   685  
   686  type DomainInterfaceMTU struct {
   687  	Size uint `xml:"size,attr"`
   688  }
   689  
   690  type DomainInterfaceCoalesce struct {
   691  	RX *DomainInterfaceCoalesceRX `xml:"rx"`
   692  }
   693  
   694  type DomainInterfaceCoalesceRX struct {
   695  	Frames *DomainInterfaceCoalesceRXFrames `xml:"frames"`
   696  }
   697  
   698  type DomainInterfaceCoalesceRXFrames struct {
   699  	Max *uint `xml:"max,attr"`
   700  }
   701  
   702  type DomainROM struct {
   703  	Bar     string `xml:"bar,attr,omitempty"`
   704  	File    string `xml:"file,attr,omitempty"`
   705  	Enabled string `xml:"enabled,attr,omitempty"`
   706  }
   707  
   708  type DomainInterfaceIP struct {
   709  	Address string `xml:"address,attr"`
   710  	Family  string `xml:"family,attr,omitempty"`
   711  	Prefix  uint   `xml:"prefix,attr,omitempty"`
   712  	Peer    string `xml:"peer,attr,omitempty"`
   713  }
   714  
   715  type DomainInterfaceRoute struct {
   716  	Family  string `xml:"family,attr,omitempty"`
   717  	Address string `xml:"address,attr"`
   718  	Netmask string `xml:"netmask,attr,omitempty"`
   719  	Prefix  uint   `xml:"prefix,attr,omitempty"`
   720  	Gateway string `xml:"gateway,attr"`
   721  	Metric  uint   `xml:"metric,attr,omitempty"`
   722  }
   723  
   724  type DomainInterfaceTeaming struct {
   725  	Type       string `xml:"type,attr"`
   726  	Persistent string `xml:"persistent,attr,omitempty"`
   727  }
   728  
   729  type DomainInterfacePortOptions struct {
   730  	Isolated string `xml:"isolated,attr,omitempty"`
   731  }
   732  
   733  type DomainInterface struct {
   734  	XMLName             xml.Name                    `xml:"interface"`
   735  	Managed             string                      `xml:"managed,attr,omitempty"`
   736  	TrustGuestRXFilters string                      `xml:"trustGuestRxFilters,attr,omitempty"`
   737  	MAC                 *DomainInterfaceMAC         `xml:"mac"`
   738  	Source              *DomainInterfaceSource      `xml:"source"`
   739  	Boot                *DomainDeviceBoot           `xml:"boot"`
   740  	VLan                *DomainInterfaceVLan        `xml:"vlan"`
   741  	VirtualPort         *DomainInterfaceVirtualPort `xml:"virtualport"`
   742  	IP                  []DomainInterfaceIP         `xml:"ip"`
   743  	Route               []DomainInterfaceRoute      `xml:"route"`
   744  	Script              *DomainInterfaceScript      `xml:"script"`
   745  	DownScript          *DomainInterfaceScript      `xml:"downscript"`
   746  	Target              *DomainInterfaceTarget      `xml:"target"`
   747  	Guest               *DomainInterfaceGuest       `xml:"guest"`
   748  	Model               *DomainInterfaceModel       `xml:"model"`
   749  	Driver              *DomainInterfaceDriver      `xml:"driver"`
   750  	Backend             *DomainInterfaceBackend     `xml:"backend"`
   751  	FilterRef           *DomainInterfaceFilterRef   `xml:"filterref"`
   752  	Tune                *DomainInterfaceTune        `xml:"tune"`
   753  	Teaming             *DomainInterfaceTeaming     `xml:"teaming"`
   754  	Link                *DomainInterfaceLink        `xml:"link"`
   755  	MTU                 *DomainInterfaceMTU         `xml:"mtu"`
   756  	Bandwidth           *DomainInterfaceBandwidth   `xml:"bandwidth"`
   757  	PortOptions         *DomainInterfacePortOptions `xml:"port"`
   758  	Coalesce            *DomainInterfaceCoalesce    `xml:"coalesce"`
   759  	ROM                 *DomainROM                  `xml:"rom"`
   760  	Alias               *DomainAlias                `xml:"alias"`
   761  	Address             *DomainAddress              `xml:"address"`
   762  }
   763  
   764  type DomainChardevSource struct {
   765  	Null      *DomainChardevSourceNull      `xml:"-"`
   766  	VC        *DomainChardevSourceVC        `xml:"-"`
   767  	Pty       *DomainChardevSourcePty       `xml:"-"`
   768  	Dev       *DomainChardevSourceDev       `xml:"-"`
   769  	File      *DomainChardevSourceFile      `xml:"-"`
   770  	Pipe      *DomainChardevSourcePipe      `xml:"-"`
   771  	StdIO     *DomainChardevSourceStdIO     `xml:"-"`
   772  	UDP       *DomainChardevSourceUDP       `xml:"-"`
   773  	TCP       *DomainChardevSourceTCP       `xml:"-"`
   774  	UNIX      *DomainChardevSourceUNIX      `xml:"-"`
   775  	SpiceVMC  *DomainChardevSourceSpiceVMC  `xml:"-"`
   776  	SpicePort *DomainChardevSourceSpicePort `xml:"-"`
   777  	NMDM      *DomainChardevSourceNMDM      `xml:"-"`
   778  }
   779  
   780  type DomainChardevSourceNull struct {
   781  }
   782  
   783  type DomainChardevSourceVC struct {
   784  }
   785  
   786  type DomainChardevSourcePty struct {
   787  	Path     string                 `xml:"path,attr"`
   788  	SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
   789  }
   790  
   791  type DomainChardevSourceDev struct {
   792  	Path     string                 `xml:"path,attr"`
   793  	SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
   794  }
   795  
   796  type DomainChardevSourceFile struct {
   797  	Path     string                 `xml:"path,attr"`
   798  	Append   string                 `xml:"append,attr,omitempty"`
   799  	SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
   800  }
   801  
   802  type DomainChardevSourcePipe struct {
   803  	Path     string                 `xml:"path,attr"`
   804  	SecLabel []DomainDeviceSecLabel `xml:"seclabel"`
   805  }
   806  
   807  type DomainChardevSourceStdIO struct {
   808  }
   809  
   810  type DomainChardevSourceUDP struct {
   811  	BindHost       string `xml:"-"`
   812  	BindService    string `xml:"-"`
   813  	ConnectHost    string `xml:"-"`
   814  	ConnectService string `xml:"-"`
   815  }
   816  
   817  type DomainChardevSourceReconnect struct {
   818  	Enabled string `xml:"enabled,attr"`
   819  	Timeout *uint  `xml:"timeout,attr"`
   820  }
   821  
   822  type DomainChardevSourceTCP struct {
   823  	Mode      string                        `xml:"mode,attr,omitempty"`
   824  	Host      string                        `xml:"host,attr,omitempty"`
   825  	Service   string                        `xml:"service,attr,omitempty"`
   826  	TLS       string                        `xml:"tls,attr,omitempty"`
   827  	Reconnect *DomainChardevSourceReconnect `xml:"reconnect"`
   828  }
   829  
   830  type DomainChardevSourceUNIX struct {
   831  	Mode      string                        `xml:"mode,attr,omitempty"`
   832  	Path      string                        `xml:"path,attr,omitempty"`
   833  	Reconnect *DomainChardevSourceReconnect `xml:"reconnect"`
   834  	SecLabel  []DomainDeviceSecLabel        `xml:"seclabel"`
   835  }
   836  
   837  type DomainChardevSourceSpiceVMC struct {
   838  }
   839  
   840  type DomainChardevSourceSpicePort struct {
   841  	Channel string `xml:"channel,attr"`
   842  }
   843  
   844  type DomainChardevSourceNMDM struct {
   845  	Master string `xml:"master,attr"`
   846  	Slave  string `xml:"slave,attr"`
   847  }
   848  
   849  type DomainChardevTarget struct {
   850  	Type  string `xml:"type,attr,omitempty"`
   851  	Name  string `xml:"name,attr,omitempty"`
   852  	State string `xml:"state,attr,omitempty"` // is guest agent connected?
   853  	Port  *uint  `xml:"port,attr"`
   854  }
   855  
   856  type DomainConsoleTarget struct {
   857  	Type string `xml:"type,attr,omitempty"`
   858  	Port *uint  `xml:"port,attr"`
   859  }
   860  
   861  type DomainSerialTarget struct {
   862  	Type  string                   `xml:"type,attr,omitempty"`
   863  	Port  *uint                    `xml:"port,attr"`
   864  	Model *DomainSerialTargetModel `xml:"model"`
   865  }
   866  
   867  type DomainSerialTargetModel struct {
   868  	Name string `xml:"name,attr,omitempty"`
   869  }
   870  
   871  type DomainParallelTarget struct {
   872  	Type string `xml:"type,attr,omitempty"`
   873  	Port *uint  `xml:"port,attr"`
   874  }
   875  
   876  type DomainChannelTarget struct {
   877  	VirtIO   *DomainChannelTargetVirtIO   `xml:"-"`
   878  	Xen      *DomainChannelTargetXen      `xml:"-"`
   879  	GuestFWD *DomainChannelTargetGuestFWD `xml:"-"`
   880  }
   881  
   882  type DomainChannelTargetVirtIO struct {
   883  	Name  string `xml:"name,attr,omitempty"`
   884  	State string `xml:"state,attr,omitempty"` // is guest agent connected?
   885  }
   886  
   887  type DomainChannelTargetXen struct {
   888  	Name  string `xml:"name,attr,omitempty"`
   889  	State string `xml:"state,attr,omitempty"` // is guest agent connected?
   890  }
   891  
   892  type DomainChannelTargetGuestFWD struct {
   893  	Address string `xml:"address,attr,omitempty"`
   894  	Port    string `xml:"port,attr,omitempty"`
   895  }
   896  
   897  type DomainAlias struct {
   898  	Name string `xml:"name,attr"`
   899  }
   900  
   901  type DomainAddressPCI struct {
   902  	Domain        *uint              `xml:"domain,attr"`
   903  	Bus           *uint              `xml:"bus,attr"`
   904  	Slot          *uint              `xml:"slot,attr"`
   905  	Function      *uint              `xml:"function,attr"`
   906  	MultiFunction string             `xml:"multifunction,attr,omitempty"`
   907  	ZPCI          *DomainAddressZPCI `xml:"zpci"`
   908  }
   909  
   910  type DomainAddressZPCI struct {
   911  	UID *uint `xml:"uid,attr,omitempty"`
   912  	FID *uint `xml:"fid,attr,omitempty"`
   913  }
   914  
   915  type DomainAddressUSB struct {
   916  	Bus    *uint  `xml:"bus,attr"`
   917  	Port   string `xml:"port,attr,omitempty"`
   918  	Device *uint  `xml:"device,attr"`
   919  }
   920  
   921  type DomainAddressDrive struct {
   922  	Controller *uint `xml:"controller,attr"`
   923  	Bus        *uint `xml:"bus,attr"`
   924  	Target     *uint `xml:"target,attr"`
   925  	Unit       *uint `xml:"unit,attr"`
   926  }
   927  
   928  type DomainAddressDIMM struct {
   929  	Slot *uint   `xml:"slot,attr"`
   930  	Base *uint64 `xml:"base,attr"`
   931  }
   932  
   933  type DomainAddressISA struct {
   934  	IOBase *uint `xml:"iobase,attr"`
   935  	IRQ    *uint `xml:"irq,attr"`
   936  }
   937  
   938  type DomainAddressVirtioMMIO struct {
   939  }
   940  
   941  type DomainAddressCCW struct {
   942  	CSSID *uint `xml:"cssid,attr"`
   943  	SSID  *uint `xml:"ssid,attr"`
   944  	DevNo *uint `xml:"devno,attr"`
   945  }
   946  
   947  type DomainAddressVirtioSerial struct {
   948  	Controller *uint `xml:"controller,attr"`
   949  	Bus        *uint `xml:"bus,attr"`
   950  	Port       *uint `xml:"port,attr"`
   951  }
   952  
   953  type DomainAddressSpaprVIO struct {
   954  	Reg *uint64 `xml:"reg,attr"`
   955  }
   956  
   957  type DomainAddressCCID struct {
   958  	Controller *uint `xml:"controller,attr"`
   959  	Slot       *uint `xml:"slot,attr"`
   960  }
   961  
   962  type DomainAddressVirtioS390 struct {
   963  }
   964  
   965  type DomainAddressUnassigned struct {
   966  }
   967  
   968  type DomainAddress struct {
   969  	PCI          *DomainAddressPCI
   970  	Drive        *DomainAddressDrive
   971  	VirtioSerial *DomainAddressVirtioSerial
   972  	CCID         *DomainAddressCCID
   973  	USB          *DomainAddressUSB
   974  	SpaprVIO     *DomainAddressSpaprVIO
   975  	VirtioS390   *DomainAddressVirtioS390
   976  	CCW          *DomainAddressCCW
   977  	VirtioMMIO   *DomainAddressVirtioMMIO
   978  	ISA          *DomainAddressISA
   979  	DIMM         *DomainAddressDIMM
   980  	Unassigned   *DomainAddressUnassigned
   981  }
   982  
   983  type DomainChardevLog struct {
   984  	File   string `xml:"file,attr"`
   985  	Append string `xml:"append,attr,omitempty"`
   986  }
   987  
   988  type DomainConsole struct {
   989  	XMLName  xml.Name               `xml:"console"`
   990  	TTY      string                 `xml:"tty,attr,omitempty"`
   991  	Source   *DomainChardevSource   `xml:"source"`
   992  	Protocol *DomainChardevProtocol `xml:"protocol"`
   993  	Target   *DomainConsoleTarget   `xml:"target"`
   994  	Log      *DomainChardevLog      `xml:"log"`
   995  	Alias    *DomainAlias           `xml:"alias"`
   996  	Address  *DomainAddress         `xml:"address"`
   997  }
   998  
   999  type DomainSerial struct {
  1000  	XMLName  xml.Name               `xml:"serial"`
  1001  	Source   *DomainChardevSource   `xml:"source"`
  1002  	Protocol *DomainChardevProtocol `xml:"protocol"`
  1003  	Target   *DomainSerialTarget    `xml:"target"`
  1004  	Log      *DomainChardevLog      `xml:"log"`
  1005  	Alias    *DomainAlias           `xml:"alias"`
  1006  	Address  *DomainAddress         `xml:"address"`
  1007  }
  1008  
  1009  type DomainParallel struct {
  1010  	XMLName  xml.Name               `xml:"parallel"`
  1011  	Source   *DomainChardevSource   `xml:"source"`
  1012  	Protocol *DomainChardevProtocol `xml:"protocol"`
  1013  	Target   *DomainParallelTarget  `xml:"target"`
  1014  	Log      *DomainChardevLog      `xml:"log"`
  1015  	Alias    *DomainAlias           `xml:"alias"`
  1016  	Address  *DomainAddress         `xml:"address"`
  1017  }
  1018  
  1019  type DomainChardevProtocol struct {
  1020  	Type string `xml:"type,attr"`
  1021  }
  1022  
  1023  type DomainChannel struct {
  1024  	XMLName  xml.Name               `xml:"channel"`
  1025  	Source   *DomainChardevSource   `xml:"source"`
  1026  	Protocol *DomainChardevProtocol `xml:"protocol"`
  1027  	Target   *DomainChannelTarget   `xml:"target"`
  1028  	Log      *DomainChardevLog      `xml:"log"`
  1029  	Alias    *DomainAlias           `xml:"alias"`
  1030  	Address  *DomainAddress         `xml:"address"`
  1031  }
  1032  
  1033  type DomainRedirDev struct {
  1034  	XMLName  xml.Name               `xml:"redirdev"`
  1035  	Bus      string                 `xml:"bus,attr,omitempty"`
  1036  	Source   *DomainChardevSource   `xml:"source"`
  1037  	Protocol *DomainChardevProtocol `xml:"protocol"`
  1038  	Boot     *DomainDeviceBoot      `xml:"boot"`
  1039  	Alias    *DomainAlias           `xml:"alias"`
  1040  	Address  *DomainAddress         `xml:"address"`
  1041  }
  1042  
  1043  type DomainRedirFilter struct {
  1044  	USB []DomainRedirFilterUSB `xml:"usbdev"`
  1045  }
  1046  
  1047  type DomainRedirFilterUSB struct {
  1048  	Class   *uint  `xml:"class,attr"`
  1049  	Vendor  *uint  `xml:"vendor,attr"`
  1050  	Product *uint  `xml:"product,attr"`
  1051  	Version string `xml:"version,attr,omitempty"`
  1052  	Allow   string `xml:"allow,attr"`
  1053  }
  1054  
  1055  type DomainInput struct {
  1056  	XMLName xml.Name           `xml:"input"`
  1057  	Type    string             `xml:"type,attr"`
  1058  	Bus     string             `xml:"bus,attr,omitempty"`
  1059  	Model   string             `xml:"model,attr,omitempty"`
  1060  	Driver  *DomainInputDriver `xml:"driver"`
  1061  	Source  *DomainInputSource `xml:"source"`
  1062  	Alias   *DomainAlias       `xml:"alias"`
  1063  	Address *DomainAddress     `xml:"address"`
  1064  }
  1065  
  1066  type DomainInputDriver struct {
  1067  	IOMMU  string `xml:"iommu,attr,omitempty"`
  1068  	ATS    string `xml:"ats,attr,omitempty"`
  1069  	Packed string `xml:"packed,attr,omitempty"`
  1070  }
  1071  
  1072  type DomainInputSource struct {
  1073  	EVDev string `xml:"evdev,attr"`
  1074  }
  1075  
  1076  type DomainGraphicListenerAddress struct {
  1077  	Address string `xml:"address,attr,omitempty"`
  1078  }
  1079  
  1080  type DomainGraphicListenerNetwork struct {
  1081  	Address string `xml:"address,attr,omitempty"`
  1082  	Network string `xml:"network,attr,omitempty"`
  1083  }
  1084  
  1085  type DomainGraphicListenerSocket struct {
  1086  	Socket string `xml:"socket,attr,omitempty"`
  1087  }
  1088  
  1089  type DomainGraphicListener struct {
  1090  	Address *DomainGraphicListenerAddress `xml:"-"`
  1091  	Network *DomainGraphicListenerNetwork `xml:"-"`
  1092  	Socket  *DomainGraphicListenerSocket  `xml:"-"`
  1093  }
  1094  
  1095  type DomainGraphicChannel struct {
  1096  	Name string `xml:"name,attr,omitempty"`
  1097  	Mode string `xml:"mode,attr,omitempty"`
  1098  }
  1099  
  1100  type DomainGraphicFileTransfer struct {
  1101  	Enable string `xml:"enable,attr,omitempty"`
  1102  }
  1103  
  1104  type DomainGraphicsSDLGL struct {
  1105  	Enable string `xml:"enable,attr,omitempty"`
  1106  }
  1107  
  1108  type DomainGraphicSDL struct {
  1109  	Display    string               `xml:"display,attr,omitempty"`
  1110  	XAuth      string               `xml:"xauth,attr,omitempty"`
  1111  	FullScreen string               `xml:"fullscreen,attr,omitempty"`
  1112  	GL         *DomainGraphicsSDLGL `xml:"gl"`
  1113  }
  1114  
  1115  type DomainGraphicVNC struct {
  1116  	Socket        string                  `xml:"socket,attr,omitempty"`
  1117  	Port          int                     `xml:"port,attr,omitempty"`
  1118  	AutoPort      string                  `xml:"autoport,attr,omitempty"`
  1119  	WebSocket     int                     `xml:"websocket,attr,omitempty"`
  1120  	Keymap        string                  `xml:"keymap,attr,omitempty"`
  1121  	SharePolicy   string                  `xml:"sharePolicy,attr,omitempty"`
  1122  	Passwd        string                  `xml:"passwd,attr,omitempty"`
  1123  	PasswdValidTo string                  `xml:"passwdValidTo,attr,omitempty"`
  1124  	Connected     string                  `xml:"connected,attr,omitempty"`
  1125  	Listen        string                  `xml:"listen,attr,omitempty"`
  1126  	Listeners     []DomainGraphicListener `xml:"listen"`
  1127  }
  1128  
  1129  type DomainGraphicRDP struct {
  1130  	Port        int                     `xml:"port,attr,omitempty"`
  1131  	AutoPort    string                  `xml:"autoport,attr,omitempty"`
  1132  	ReplaceUser string                  `xml:"replaceUser,attr,omitempty"`
  1133  	MultiUser   string                  `xml:"multiUser,attr,omitempty"`
  1134  	Listen      string                  `xml:"listen,attr,omitempty"`
  1135  	Listeners   []DomainGraphicListener `xml:"listen"`
  1136  }
  1137  
  1138  type DomainGraphicDesktop struct {
  1139  	Display    string `xml:"display,attr,omitempty"`
  1140  	FullScreen string `xml:"fullscreen,attr,omitempty"`
  1141  }
  1142  
  1143  type DomainGraphicSpiceChannel struct {
  1144  	Name string `xml:"name,attr"`
  1145  	Mode string `xml:"mode,attr"`
  1146  }
  1147  
  1148  type DomainGraphicSpiceImage struct {
  1149  	Compression string `xml:"compression,attr"`
  1150  }
  1151  
  1152  type DomainGraphicSpiceJPEG struct {
  1153  	Compression string `xml:"compression,attr"`
  1154  }
  1155  
  1156  type DomainGraphicSpiceZLib struct {
  1157  	Compression string `xml:"compression,attr"`
  1158  }
  1159  
  1160  type DomainGraphicSpicePlayback struct {
  1161  	Compression string `xml:"compression,attr"`
  1162  }
  1163  
  1164  type DomainGraphicSpiceStreaming struct {
  1165  	Mode string `xml:"mode,attr"`
  1166  }
  1167  
  1168  type DomainGraphicSpiceMouse struct {
  1169  	Mode string `xml:"mode,attr"`
  1170  }
  1171  
  1172  type DomainGraphicSpiceClipBoard struct {
  1173  	CopyPaste string `xml:"copypaste,attr"`
  1174  }
  1175  
  1176  type DomainGraphicSpiceFileTransfer struct {
  1177  	Enable string `xml:"enable,attr"`
  1178  }
  1179  
  1180  type DomainGraphicSpiceGL struct {
  1181  	Enable     string `xml:"enable,attr,omitempty"`
  1182  	RenderNode string `xml:"rendernode,attr,omitempty"`
  1183  }
  1184  
  1185  type DomainGraphicSpice struct {
  1186  	Port          int                             `xml:"port,attr,omitempty"`
  1187  	TLSPort       int                             `xml:"tlsPort,attr,omitempty"`
  1188  	AutoPort      string                          `xml:"autoport,attr,omitempty"`
  1189  	Listen        string                          `xml:"listen,attr,omitempty"`
  1190  	Keymap        string                          `xml:"keymap,attr,omitempty"`
  1191  	DefaultMode   string                          `xml:"defaultMode,attr,omitempty"`
  1192  	Passwd        string                          `xml:"passwd,attr,omitempty"`
  1193  	PasswdValidTo string                          `xml:"passwdValidTo,attr,omitempty"`
  1194  	Connected     string                          `xml:"connected,attr,omitempty"`
  1195  	Listeners     []DomainGraphicListener         `xml:"listen"`
  1196  	Channel       []DomainGraphicSpiceChannel     `xml:"channel"`
  1197  	Image         *DomainGraphicSpiceImage        `xml:"image"`
  1198  	JPEG          *DomainGraphicSpiceJPEG         `xml:"jpeg"`
  1199  	ZLib          *DomainGraphicSpiceZLib         `xml:"zlib"`
  1200  	Playback      *DomainGraphicSpicePlayback     `xml:"playback"`
  1201  	Streaming     *DomainGraphicSpiceStreaming    `xml:"streaming"`
  1202  	Mouse         *DomainGraphicSpiceMouse        `xml:"mouse"`
  1203  	ClipBoard     *DomainGraphicSpiceClipBoard    `xml:"clipboard"`
  1204  	FileTransfer  *DomainGraphicSpiceFileTransfer `xml:"filetransfer"`
  1205  	GL            *DomainGraphicSpiceGL           `xml:"gl"`
  1206  }
  1207  
  1208  type DomainGraphicEGLHeadlessGL struct {
  1209  	RenderNode string `xml:"rendernode,attr,omitempty"`
  1210  }
  1211  
  1212  type DomainGraphicEGLHeadless struct {
  1213  	GL *DomainGraphicEGLHeadlessGL `xml:"gl"`
  1214  }
  1215  
  1216  type DomainGraphic struct {
  1217  	XMLName     xml.Name                  `xml:"graphics"`
  1218  	SDL         *DomainGraphicSDL         `xml:"-"`
  1219  	VNC         *DomainGraphicVNC         `xml:"-"`
  1220  	RDP         *DomainGraphicRDP         `xml:"-"`
  1221  	Desktop     *DomainGraphicDesktop     `xml:"-"`
  1222  	Spice       *DomainGraphicSpice       `xml:"-"`
  1223  	EGLHeadless *DomainGraphicEGLHeadless `xml:"-"`
  1224  }
  1225  
  1226  type DomainVideoAccel struct {
  1227  	Accel3D    string `xml:"accel3d,attr,omitempty"`
  1228  	Accel2D    string `xml:"accel2d,attr,omitempty"`
  1229  	RenderNode string `xml:"rendernode,attr,omitempty"`
  1230  }
  1231  
  1232  type DomainVideoResolution struct {
  1233  	X uint `xml:"x,attr"`
  1234  	Y uint `xml:"y,attr"`
  1235  }
  1236  
  1237  type DomainVideoModel struct {
  1238  	Type       string                 `xml:"type,attr"`
  1239  	Heads      uint                   `xml:"heads,attr,omitempty"`
  1240  	Ram        uint                   `xml:"ram,attr,omitempty"`
  1241  	VRam       uint                   `xml:"vram,attr,omitempty"`
  1242  	VRam64     uint                   `xml:"vram64,attr,omitempty"`
  1243  	VGAMem     uint                   `xml:"vgamem,attr,omitempty"`
  1244  	Primary    string                 `xml:"primary,attr,omitempty"`
  1245  	Accel      *DomainVideoAccel      `xml:"acceleration"`
  1246  	Resolution *DomainVideoResolution `xml:"resolution"`
  1247  }
  1248  
  1249  type DomainVideo struct {
  1250  	XMLName xml.Name           `xml:"video"`
  1251  	Model   DomainVideoModel   `xml:"model"`
  1252  	Driver  *DomainVideoDriver `xml:"driver"`
  1253  	Alias   *DomainAlias       `xml:"alias"`
  1254  	Address *DomainAddress     `xml:"address"`
  1255  }
  1256  
  1257  type DomainVideoDriver struct {
  1258  	Name    string `xml:"name,attr,omitempty"`
  1259  	VGAConf string `xml:"vgaconf,attr,omitempty"`
  1260  	IOMMU   string `xml:"iommu,attr,omitempty"`
  1261  	ATS     string `xml:"ats,attr,omitempty"`
  1262  	Packed  string `xml:"packed,attr,omitempty"`
  1263  }
  1264  
  1265  type DomainMemBalloonStats struct {
  1266  	Period uint `xml:"period,attr"`
  1267  }
  1268  
  1269  type DomainMemBalloon struct {
  1270  	XMLName     xml.Name                `xml:"memballoon"`
  1271  	Model       string                  `xml:"model,attr"`
  1272  	AutoDeflate string                  `xml:"autodeflate,attr,omitempty"`
  1273  	Driver      *DomainMemBalloonDriver `xml:"driver"`
  1274  	Stats       *DomainMemBalloonStats  `xml:"stats"`
  1275  	Alias       *DomainAlias            `xml:"alias"`
  1276  	Address     *DomainAddress          `xml:"address"`
  1277  }
  1278  
  1279  type DomainVSockCID struct {
  1280  	Auto    string `xml:"auto,attr,omitempty"`
  1281  	Address string `xml:"address,attr,omitempty"`
  1282  }
  1283  
  1284  type DomainVSock struct {
  1285  	XMLName xml.Name        `xml:"vsock"`
  1286  	Model   string          `xml:"model,attr,omitempty"`
  1287  	CID     *DomainVSockCID `xml:"cid"`
  1288  	Alias   *DomainAlias    `xml:"alias"`
  1289  	Address *DomainAddress  `xml:"address"`
  1290  }
  1291  
  1292  type DomainMemBalloonDriver struct {
  1293  	IOMMU  string `xml:"iommu,attr,omitempty"`
  1294  	ATS    string `xml:"ats,attr,omitempty"`
  1295  	Packed string `xml:"packed,attr,omitempty"`
  1296  }
  1297  
  1298  type DomainPanic struct {
  1299  	XMLName xml.Name       `xml:"panic"`
  1300  	Model   string         `xml:"model,attr,omitempty"`
  1301  	Alias   *DomainAlias   `xml:"alias"`
  1302  	Address *DomainAddress `xml:"address"`
  1303  }
  1304  
  1305  type DomainSoundCodec struct {
  1306  	Type string `xml:"type,attr"`
  1307  }
  1308  
  1309  type DomainSound struct {
  1310  	XMLName xml.Name           `xml:"sound"`
  1311  	Model   string             `xml:"model,attr"`
  1312  	Codec   []DomainSoundCodec `xml:"codec"`
  1313  	Alias   *DomainAlias       `xml:"alias"`
  1314  	Address *DomainAddress     `xml:"address"`
  1315  }
  1316  
  1317  type DomainRNGRate struct {
  1318  	Bytes  uint `xml:"bytes,attr"`
  1319  	Period uint `xml:"period,attr,omitempty"`
  1320  }
  1321  
  1322  type DomainRNGBackend struct {
  1323  	Random  *DomainRNGBackendRandom  `xml:"-"`
  1324  	EGD     *DomainRNGBackendEGD     `xml:"-"`
  1325  	BuiltIn *DomainRNGBackendBuiltIn `xml:"-"`
  1326  }
  1327  
  1328  type DomainRNGBackendEGD struct {
  1329  	Source   *DomainChardevSource   `xml:"source"`
  1330  	Protocol *DomainChardevProtocol `xml:"protocol"`
  1331  }
  1332  
  1333  type DomainRNGBackendRandom struct {
  1334  	Device string `xml:",chardata"`
  1335  }
  1336  
  1337  type DomainRNGBackendBuiltIn struct {
  1338  }
  1339  
  1340  type DomainRNG struct {
  1341  	XMLName xml.Name          `xml:"rng"`
  1342  	Model   string            `xml:"model,attr"`
  1343  	Driver  *DomainRNGDriver  `xml:"driver"`
  1344  	Rate    *DomainRNGRate    `xml:"rate"`
  1345  	Backend *DomainRNGBackend `xml:"backend"`
  1346  	Alias   *DomainAlias      `xml:"alias"`
  1347  	Address *DomainAddress    `xml:"address"`
  1348  }
  1349  
  1350  type DomainRNGDriver struct {
  1351  	IOMMU  string `xml:"iommu,attr,omitempty"`
  1352  	ATS    string `xml:"ats,attr,omitempty"`
  1353  	Packed string `xml:"packed,attr,omitempty"`
  1354  }
  1355  
  1356  type DomainHostdevSubsysUSB struct {
  1357  	Source *DomainHostdevSubsysUSBSource `xml:"source"`
  1358  }
  1359  
  1360  type DomainHostdevSubsysUSBSource struct {
  1361  	Address *DomainAddressUSB `xml:"address"`
  1362  }
  1363  
  1364  type DomainHostdevSubsysSCSI struct {
  1365  	SGIO      string                         `xml:"sgio,attr,omitempty"`
  1366  	RawIO     string                         `xml:"rawio,attr,omitempty"`
  1367  	Source    *DomainHostdevSubsysSCSISource `xml:"source"`
  1368  	ReadOnly  *DomainDiskReadOnly            `xml:"readonly"`
  1369  	Shareable *DomainDiskShareable           `xml:"shareable"`
  1370  }
  1371  
  1372  type DomainHostdevSubsysSCSISource struct {
  1373  	Host  *DomainHostdevSubsysSCSISourceHost  `xml:"-"`
  1374  	ISCSI *DomainHostdevSubsysSCSISourceISCSI `xml:"-"`
  1375  }
  1376  
  1377  type DomainHostdevSubsysSCSIAdapter struct {
  1378  	Name string `xml:"name,attr"`
  1379  }
  1380  
  1381  type DomainHostdevSubsysSCSISourceHost struct {
  1382  	Adapter *DomainHostdevSubsysSCSIAdapter `xml:"adapter"`
  1383  	Address *DomainAddressDrive             `xml:"address"`
  1384  }
  1385  
  1386  type DomainHostdevSubsysSCSISourceISCSI struct {
  1387  	Name string                 `xml:"name,attr"`
  1388  	Host []DomainDiskSourceHost `xml:"host"`
  1389  	Auth *DomainDiskAuth        `xml:"auth"`
  1390  }
  1391  
  1392  type DomainHostdevSubsysSCSIHost struct {
  1393  	Model  string                             `xml:"model,attr,omitempty"`
  1394  	Source *DomainHostdevSubsysSCSIHostSource `xml:"source"`
  1395  }
  1396  
  1397  type DomainHostdevSubsysSCSIHostSource struct {
  1398  	Protocol string `xml:"protocol,attr,omitempty"`
  1399  	WWPN     string `xml:"wwpn,attr,omitempty"`
  1400  }
  1401  
  1402  type DomainHostdevSubsysPCISource struct {
  1403  	Address *DomainAddressPCI `xml:"address"`
  1404  }
  1405  
  1406  type DomainHostdevSubsysPCIDriver struct {
  1407  	Name string `xml:"name,attr,omitempty"`
  1408  }
  1409  
  1410  type DomainHostdevSubsysPCI struct {
  1411  	Driver *DomainHostdevSubsysPCIDriver `xml:"driver"`
  1412  	Source *DomainHostdevSubsysPCISource `xml:"source"`
  1413  }
  1414  
  1415  type DomainAddressMDev struct {
  1416  	UUID string `xml:"uuid,attr"`
  1417  }
  1418  
  1419  type DomainHostdevSubsysMDevSource struct {
  1420  	Address *DomainAddressMDev `xml:"address"`
  1421  }
  1422  
  1423  type DomainHostdevSubsysMDev struct {
  1424  	Model   string                         `xml:"model,attr,omitempty"`
  1425  	Display string                         `xml:"display,attr,omitempty"`
  1426  	RamFB   string                         `xml:"ramfb,attr,omitempty"`
  1427  	Source  *DomainHostdevSubsysMDevSource `xml:"source"`
  1428  }
  1429  
  1430  type DomainHostdevCapsStorage struct {
  1431  	Source *DomainHostdevCapsStorageSource `xml:"source"`
  1432  }
  1433  
  1434  type DomainHostdevCapsStorageSource struct {
  1435  	Block string `xml:"block"`
  1436  }
  1437  
  1438  type DomainHostdevCapsMisc struct {
  1439  	Source *DomainHostdevCapsMiscSource `xml:"source"`
  1440  }
  1441  
  1442  type DomainHostdevCapsMiscSource struct {
  1443  	Char string `xml:"char"`
  1444  }
  1445  
  1446  type DomainIP struct {
  1447  	Address string `xml:"address,attr,omitempty"`
  1448  	Family  string `xml:"family,attr,omitempty"`
  1449  	Prefix  *uint  `xml:"prefix,attr"`
  1450  }
  1451  
  1452  type DomainRoute struct {
  1453  	Family  string `xml:"family,attr,omitempty"`
  1454  	Address string `xml:"address,attr,omitempty"`
  1455  	Gateway string `xml:"gateway,attr,omitempty"`
  1456  }
  1457  
  1458  type DomainHostdevCapsNet struct {
  1459  	Source *DomainHostdevCapsNetSource `xml:"source"`
  1460  	IP     []DomainIP                  `xml:"ip"`
  1461  	Route  []DomainRoute               `xml:"route"`
  1462  }
  1463  
  1464  type DomainHostdevCapsNetSource struct {
  1465  	Interface string `xml:"interface"`
  1466  }
  1467  
  1468  type DomainHostdev struct {
  1469  	Managed        string                       `xml:"managed,attr,omitempty"`
  1470  	SubsysUSB      *DomainHostdevSubsysUSB      `xml:"-"`
  1471  	SubsysSCSI     *DomainHostdevSubsysSCSI     `xml:"-"`
  1472  	SubsysSCSIHost *DomainHostdevSubsysSCSIHost `xml:"-"`
  1473  	SubsysPCI      *DomainHostdevSubsysPCI      `xml:"-"`
  1474  	SubsysMDev     *DomainHostdevSubsysMDev     `xml:"-"`
  1475  	CapsStorage    *DomainHostdevCapsStorage    `xml:"-"`
  1476  	CapsMisc       *DomainHostdevCapsMisc       `xml:"-"`
  1477  	CapsNet        *DomainHostdevCapsNet        `xml:"-"`
  1478  	Boot           *DomainDeviceBoot            `xml:"boot"`
  1479  	ROM            *DomainROM                   `xml:"rom"`
  1480  	Alias          *DomainAlias                 `xml:"alias"`
  1481  	Address        *DomainAddress               `xml:"address"`
  1482  }
  1483  
  1484  type DomainMemorydevSource struct {
  1485  	NodeMask  string                          `xml:"nodemask,omitempty"`
  1486  	PageSize  *DomainMemorydevSourcePagesize  `xml:"pagesize"`
  1487  	Path      string                          `xml:"path,omitempty"`
  1488  	AlignSize *DomainMemorydevSourceAlignsize `xml:"alignsize"`
  1489  	PMem      *DomainMemorydevSourcePMem      `xml:"pmem"`
  1490  }
  1491  
  1492  type DomainMemorydevSourcePMem struct {
  1493  }
  1494  
  1495  type DomainMemorydevSourcePagesize struct {
  1496  	Value uint64 `xml:",chardata"`
  1497  	Unit  string `xml:"unit,attr,omitempty"`
  1498  }
  1499  
  1500  type DomainMemorydevSourceAlignsize struct {
  1501  	Value uint64 `xml:",chardata"`
  1502  	Unit  string `xml:"unit,attr,omitempty"`
  1503  }
  1504  
  1505  type DomainMemorydevTargetNode struct {
  1506  	Value uint `xml:",chardata"`
  1507  }
  1508  
  1509  type DomainMemorydevTargetReadOnly struct {
  1510  }
  1511  
  1512  type DomainMemorydevTargetSize struct {
  1513  	Value uint   `xml:",chardata"`
  1514  	Unit  string `xml:"unit,attr,omitempty"`
  1515  }
  1516  
  1517  type DomainMemorydevTargetLabel struct {
  1518  	Size *DomainMemorydevTargetSize `xml:"size"`
  1519  }
  1520  
  1521  type DomainMemorydevTarget struct {
  1522  	Size     *DomainMemorydevTargetSize     `xml:"size"`
  1523  	Node     *DomainMemorydevTargetNode     `xml:"node"`
  1524  	Label    *DomainMemorydevTargetLabel    `xml:"label"`
  1525  	ReadOnly *DomainMemorydevTargetReadOnly `xml:"readonly"`
  1526  }
  1527  
  1528  type DomainMemorydev struct {
  1529  	XMLName xml.Name               `xml:"memory"`
  1530  	Model   string                 `xml:"model,attr"`
  1531  	Access  string                 `xml:"access,attr,omitempty"`
  1532  	Discard string                 `xml:"discard,attr,omitempty"`
  1533  	UUID    string                 `xml:"uuid,omitempty"`
  1534  	Source  *DomainMemorydevSource `xml:"source"`
  1535  	Target  *DomainMemorydevTarget `xml:"target"`
  1536  	Alias   *DomainAlias           `xml:"alias"`
  1537  	Address *DomainAddress         `xml:"address"`
  1538  }
  1539  
  1540  type DomainVhostUser struct {
  1541  	XMLName   xml.Name       `xml:"vhostuser"`
  1542  	ID        string         `xml:"id,attr"`
  1543  	Path      string         `xml:"path,attr"`
  1544  	ReConnect uint           `xml:"reconnect,attr"`
  1545  	Queues    uint           `xml:"queues,attr"`
  1546  	BootIndex uint           `xml:"bootindex,attr,omitempty"`
  1547  	Address   *DomainAddress `xml:"address"`
  1548  }
  1549  
  1550  type DomainWatchdog struct {
  1551  	XMLName xml.Name       `xml:"watchdog"`
  1552  	Model   string         `xml:"model,attr"`
  1553  	Action  string         `xml:"action,attr,omitempty"`
  1554  	Alias   *DomainAlias   `xml:"alias"`
  1555  	Address *DomainAddress `xml:"address"`
  1556  }
  1557  
  1558  type DomainHub struct {
  1559  	Type    string         `xml:"type,attr"`
  1560  	Alias   *DomainAlias   `xml:"alias"`
  1561  	Address *DomainAddress `xml:"address"`
  1562  }
  1563  
  1564  type DomainIOMMU struct {
  1565  	Model  string             `xml:"model,attr"`
  1566  	Driver *DomainIOMMUDriver `xml:"driver"`
  1567  }
  1568  
  1569  type DomainIOMMUDriver struct {
  1570  	IntRemap    string `xml:"intremap,attr,omitempty"`
  1571  	CachingMode string `xml:"caching_mode,attr,omitempty"`
  1572  	EIM         string `xml:"eim,attr,omitempty"`
  1573  	IOTLB       string `xml:"iotlb,attr,omitempty"`
  1574  }
  1575  
  1576  type DomainNVRAM struct {
  1577  	Alias   *DomainAlias   `xml:"alias"`
  1578  	Address *DomainAddress `xml:"address"`
  1579  }
  1580  
  1581  type DomainLease struct {
  1582  	Lockspace string             `xml:"lockspace"`
  1583  	Key       string             `xml:"key"`
  1584  	Target    *DomainLeaseTarget `xml:"target"`
  1585  }
  1586  
  1587  type DomainLeaseTarget struct {
  1588  	Path   string `xml:"path,attr"`
  1589  	Offset uint64 `xml:"offset,attr,omitempty"`
  1590  }
  1591  
  1592  type DomainSmartcard struct {
  1593  	XMLName     xml.Name                  `xml:"smartcard"`
  1594  	Passthrough *DomainChardevSource      `xml:"source"`
  1595  	Protocol    *DomainChardevProtocol    `xml:"protocol"`
  1596  	Host        *DomainSmartcardHost      `xml:"-"`
  1597  	HostCerts   []DomainSmartcardHostCert `xml:"certificate"`
  1598  	Database    string                    `xml:"database,omitempty"`
  1599  	Alias       *DomainAlias              `xml:"alias"`
  1600  	Address     *DomainAddress            `xml:"address"`
  1601  }
  1602  
  1603  type DomainSmartcardHost struct {
  1604  }
  1605  
  1606  type DomainSmartcardHostCert struct {
  1607  	File string `xml:",chardata"`
  1608  }
  1609  
  1610  type DomainTPM struct {
  1611  	XMLName xml.Name          `xml:"tpm"`
  1612  	Model   string            `xml:"model,attr,omitempty"`
  1613  	Backend *DomainTPMBackend `xml:"backend"`
  1614  	Alias   *DomainAlias      `xml:"alias"`
  1615  	Address *DomainAddress    `xml:"address"`
  1616  }
  1617  
  1618  type DomainTPMBackend struct {
  1619  	Passthrough *DomainTPMBackendPassthrough `xml:"-"`
  1620  	Emulator    *DomainTPMBackendEmulator    `xml:"-"`
  1621  }
  1622  
  1623  type DomainTPMBackendPassthrough struct {
  1624  	Device *DomainTPMBackendDevice `xml:"device"`
  1625  }
  1626  
  1627  type DomainTPMBackendEmulator struct {
  1628  	Version    string                      `xml:"version,attr,omitempty"`
  1629  	Encryption *DomainTPMBackendEncryption `xml:"encryption"`
  1630  }
  1631  
  1632  type DomainTPMBackendEncryption struct {
  1633  	Secret string `xml:"secret,attr"`
  1634  }
  1635  
  1636  type DomainTPMBackendDevice struct {
  1637  	Path string `xml:"path,attr"`
  1638  }
  1639  
  1640  type DomainShmem struct {
  1641  	XMLName xml.Name           `xml:"shmem"`
  1642  	Name    string             `xml:"name,attr"`
  1643  	Size    *DomainShmemSize   `xml:"size"`
  1644  	Model   *DomainShmemModel  `xml:"model"`
  1645  	Server  *DomainShmemServer `xml:"server"`
  1646  	MSI     *DomainShmemMSI    `xml:"msi"`
  1647  	Alias   *DomainAlias       `xml:"alias"`
  1648  	Address *DomainAddress     `xml:"address"`
  1649  }
  1650  
  1651  type DomainShmemSize struct {
  1652  	Value uint   `xml:",chardata"`
  1653  	Unit  string `xml:"unit,attr,omitempty"`
  1654  }
  1655  
  1656  type DomainShmemModel struct {
  1657  	Type string `xml:"type,attr"`
  1658  }
  1659  
  1660  type DomainShmemServer struct {
  1661  	Path string `xml:"path,attr,omitempty"`
  1662  }
  1663  
  1664  type DomainShmemMSI struct {
  1665  	Enabled   string `xml:"enabled,attr,omitempty"`
  1666  	Vectors   uint   `xml:"vectors,attr,omitempty"`
  1667  	IOEventFD string `xml:"ioeventfd,attr,omitempty"`
  1668  }
  1669  
  1670  type DomainDeviceList struct {
  1671  	Emulator     string              `xml:"emulator,omitempty"`
  1672  	Disks        []DomainDisk        `xml:"disk"`
  1673  	Controllers  []DomainController  `xml:"controller"`
  1674  	Leases       []DomainLease       `xml:"lease"`
  1675  	Filesystems  []DomainFilesystem  `xml:"filesystem"`
  1676  	Interfaces   []DomainInterface   `xml:"interface"`
  1677  	Smartcards   []DomainSmartcard   `xml:"smartcard"`
  1678  	Serials      []DomainSerial      `xml:"serial"`
  1679  	Parallels    []DomainParallel    `xml:"parallel"`
  1680  	Consoles     []DomainConsole     `xml:"console"`
  1681  	Channels     []DomainChannel     `xml:"channel"`
  1682  	Inputs       []DomainInput       `xml:"input"`
  1683  	TPMs         []DomainTPM         `xml:"tpm"`
  1684  	Graphics     []DomainGraphic     `xml:"graphics"`
  1685  	Sounds       []DomainSound       `xml:"sound"`
  1686  	Videos       []DomainVideo       `xml:"video"`
  1687  	Hostdevs     []DomainHostdev     `xml:"hostdev"`
  1688  	RedirDevs    []DomainRedirDev    `xml:"redirdev"`
  1689  	RedirFilters []DomainRedirFilter `xml:"redirfilter"`
  1690  	Hubs         []DomainHub         `xml:"hub"`
  1691  	Watchdog     *DomainWatchdog     `xml:"watchdog"`
  1692  	MemBalloon   *DomainMemBalloon   `xml:"memballoon"`
  1693  	RNGs         []DomainRNG         `xml:"rng"`
  1694  	NVRAM        *DomainNVRAM        `xml:"nvram"`
  1695  	Panics       []DomainPanic       `xml:"panic"`
  1696  	Shmems       []DomainShmem       `xml:"shmem"`
  1697  	Memorydevs   []DomainMemorydev   `xml:"memory"`
  1698  	IOMMU        *DomainIOMMU        `xml:"iommu"`
  1699  	VSock        *DomainVSock        `xml:"vsock"`
  1700  	VhostUser    []DomainVhostUser   `xml:"vhostuser"`
  1701  }
  1702  
  1703  type DomainMemory struct {
  1704  	Value    uint   `xml:",chardata"`
  1705  	Unit     string `xml:"unit,attr,omitempty"`
  1706  	DumpCore string `xml:"dumpCore,attr,omitempty"`
  1707  }
  1708  
  1709  type DomainCurrentMemory struct {
  1710  	Value uint   `xml:",chardata"`
  1711  	Unit  string `xml:"unit,attr,omitempty"`
  1712  }
  1713  
  1714  type DomainMaxMemory struct {
  1715  	Value uint   `xml:",chardata"`
  1716  	Unit  string `xml:"unit,attr,omitempty"`
  1717  	Slots uint   `xml:"slots,attr,omitempty"`
  1718  }
  1719  
  1720  type DomainMemoryHugepage struct {
  1721  	Size    uint   `xml:"size,attr"`
  1722  	Unit    string `xml:"unit,attr,omitempty"`
  1723  	Nodeset string `xml:"nodeset,attr,omitempty"`
  1724  }
  1725  
  1726  type DomainMemoryHugepages struct {
  1727  	Hugepages []DomainMemoryHugepage `xml:"page"`
  1728  }
  1729  
  1730  type DomainMemoryNosharepages struct {
  1731  }
  1732  
  1733  type DomainMemoryLocked struct {
  1734  }
  1735  
  1736  type DomainMemorySource struct {
  1737  	Type string `xml:"type,attr,omitempty"`
  1738  }
  1739  
  1740  type DomainMemoryAccess struct {
  1741  	Mode string `xml:"mode,attr,omitempty"`
  1742  }
  1743  
  1744  type DomainMemoryAllocation struct {
  1745  	Mode string `xml:"mode,attr,omitempty"`
  1746  }
  1747  
  1748  type DomainMemoryDiscard struct {
  1749  }
  1750  
  1751  type DomainMemoryBacking struct {
  1752  	MemoryHugePages    *DomainMemoryHugepages    `xml:"hugepages"`
  1753  	MemoryNosharepages *DomainMemoryNosharepages `xml:"nosharepages"`
  1754  	MemoryLocked       *DomainMemoryLocked       `xml:"locked"`
  1755  	MemorySource       *DomainMemorySource       `xml:"source"`
  1756  	MemoryAccess       *DomainMemoryAccess       `xml:"access"`
  1757  	MemoryAllocation   *DomainMemoryAllocation   `xml:"allocation"`
  1758  	MemoryDiscard      *DomainMemoryDiscard      `xml:"discard"`
  1759  }
  1760  
  1761  type DomainOSType struct {
  1762  	Arch    string `xml:"arch,attr,omitempty"`
  1763  	Machine string `xml:"machine,attr,omitempty"`
  1764  	Type    string `xml:",chardata"`
  1765  }
  1766  
  1767  type DomainSMBios struct {
  1768  	Mode string `xml:"mode,attr"`
  1769  }
  1770  
  1771  type DomainNVRam struct {
  1772  	NVRam    string `xml:",chardata"`
  1773  	Template string `xml:"template,attr,omitempty"`
  1774  }
  1775  
  1776  type DomainBootDevice struct {
  1777  	Dev string `xml:"dev,attr"`
  1778  }
  1779  
  1780  type DomainBootMenu struct {
  1781  	Enable  string `xml:"enable,attr,omitempty"`
  1782  	Timeout string `xml:"timeout,attr,omitempty"`
  1783  }
  1784  
  1785  type DomainSysInfoBIOS struct {
  1786  	Entry []DomainSysInfoEntry `xml:"entry"`
  1787  }
  1788  
  1789  type DomainSysInfoSystem struct {
  1790  	Entry []DomainSysInfoEntry `xml:"entry"`
  1791  }
  1792  
  1793  type DomainSysInfoBaseBoard struct {
  1794  	Entry []DomainSysInfoEntry `xml:"entry"`
  1795  }
  1796  
  1797  type DomainSysInfoProcessor struct {
  1798  	Entry []DomainSysInfoEntry `xml:"entry"`
  1799  }
  1800  
  1801  type DomainSysInfoMemory struct {
  1802  	Entry []DomainSysInfoEntry `xml:"entry"`
  1803  }
  1804  
  1805  type DomainSysInfoChassis struct {
  1806  	Entry []DomainSysInfoEntry `xml:"entry"`
  1807  }
  1808  
  1809  type DomainSysInfoOEMStrings struct {
  1810  	Entry []string `xml:"entry"`
  1811  }
  1812  
  1813  type DomainSysInfo struct {
  1814  	Type       string                   `xml:"type,attr"`
  1815  	BIOS       *DomainSysInfoBIOS       `xml:"bios"`
  1816  	System     *DomainSysInfoSystem     `xml:"system"`
  1817  	BaseBoard  []DomainSysInfoBaseBoard `xml:"baseBoard"`
  1818  	Chassis    *DomainSysInfoChassis    `xml:"chassis"`
  1819  	Processor  []DomainSysInfoProcessor `xml:"processor"`
  1820  	Memory     []DomainSysInfoMemory    `xml:"memory"`
  1821  	OEMStrings *DomainSysInfoOEMStrings `xml:"oemStrings"`
  1822  }
  1823  
  1824  type DomainSysInfoEntry struct {
  1825  	Name  string `xml:"name,attr"`
  1826  	Value string `xml:",chardata"`
  1827  }
  1828  
  1829  type DomainBIOS struct {
  1830  	UseSerial     string `xml:"useserial,attr,omitempty"`
  1831  	RebootTimeout *int   `xml:"rebootTimeout,attr"`
  1832  }
  1833  
  1834  type DomainLoader struct {
  1835  	Path     string `xml:",chardata"`
  1836  	Readonly string `xml:"readonly,attr,omitempty"`
  1837  	Secure   string `xml:"secure,attr,omitempty"`
  1838  	Type     string `xml:"type,attr,omitempty"`
  1839  }
  1840  
  1841  type DomainACPI struct {
  1842  	Tables []DomainACPITable `xml:"table"`
  1843  }
  1844  
  1845  type DomainACPITable struct {
  1846  	Type string `xml:"type,attr"`
  1847  	Path string `xml:",chardata"`
  1848  }
  1849  
  1850  type DomainOSInitEnv struct {
  1851  	Name  string `xml:"name,attr"`
  1852  	Value string `xml:",chardata"`
  1853  }
  1854  
  1855  type DomainOS struct {
  1856  	Type        *DomainOSType      `xml:"type"`
  1857  	Firmware    string             `xml:"firmware,attr,omitempty"`
  1858  	Init        string             `xml:"init,omitempty"`
  1859  	InitArgs    []string           `xml:"initarg"`
  1860  	InitEnv     []DomainOSInitEnv  `xml:"initenv"`
  1861  	InitDir     string             `xml:"initdir,omitempty"`
  1862  	InitUser    string             `xml:"inituser,omitempty"`
  1863  	InitGroup   string             `xml:"initgroup,omitempty"`
  1864  	Loader      *DomainLoader      `xml:"loader"`
  1865  	NVRam       *DomainNVRam       `xml:"nvram"`
  1866  	Kernel      string             `xml:"kernel,omitempty"`
  1867  	Initrd      string             `xml:"initrd,omitempty"`
  1868  	Cmdline     string             `xml:"cmdline,omitempty"`
  1869  	DTB         string             `xml:"dtb,omitempty"`
  1870  	ACPI        *DomainACPI        `xml:"acpi"`
  1871  	BootDevices []DomainBootDevice `xml:"boot"`
  1872  	BootMenu    *DomainBootMenu    `xml:"bootmenu"`
  1873  	BIOS        *DomainBIOS        `xml:"bios"`
  1874  	SMBios      *DomainSMBios      `xml:"smbios"`
  1875  }
  1876  
  1877  type DomainResource struct {
  1878  	Partition string `xml:"partition,omitempty"`
  1879  }
  1880  
  1881  type DomainVCPU struct {
  1882  	Placement string `xml:"placement,attr,omitempty"`
  1883  	CPUSet    string `xml:"cpuset,attr,omitempty"`
  1884  	Current   uint   `xml:"current,attr,omitempty"`
  1885  	Value     uint   `xml:",chardata"`
  1886  }
  1887  
  1888  type DomainVCPUsVCPU struct {
  1889  	Id           *uint  `xml:"id,attr"`
  1890  	Enabled      string `xml:"enabled,attr,omitempty"`
  1891  	Hotpluggable string `xml:"hotpluggable,attr,omitempty"`
  1892  	Order        *uint  `xml:"order,attr"`
  1893  }
  1894  
  1895  type DomainVCPUs struct {
  1896  	VCPU []DomainVCPUsVCPU `xml:"vcpu"`
  1897  }
  1898  
  1899  type DomainCPUModel struct {
  1900  	Fallback string `xml:"fallback,attr,omitempty"`
  1901  	Value    string `xml:",chardata"`
  1902  	VendorID string `xml:"vendor_id,attr,omitempty"`
  1903  }
  1904  
  1905  type DomainCPUTopology struct {
  1906  	Sockets int `xml:"sockets,attr,omitempty"`
  1907  	Dies    int `xml:"dies,attr,omitempty"`
  1908  	Cores   int `xml:"cores,attr,omitempty"`
  1909  	Threads int `xml:"threads,attr,omitempty"`
  1910  }
  1911  
  1912  type DomainCPUFeature struct {
  1913  	Policy string `xml:"policy,attr,omitempty"`
  1914  	Name   string `xml:"name,attr,omitempty"`
  1915  }
  1916  
  1917  type DomainCPUCache struct {
  1918  	Level uint   `xml:"level,attr,omitempty"`
  1919  	Mode  string `xml:"mode,attr"`
  1920  }
  1921  
  1922  type DomainCPU struct {
  1923  	XMLName  xml.Name           `xml:"cpu"`
  1924  	Match    string             `xml:"match,attr,omitempty"`
  1925  	Mode     string             `xml:"mode,attr,omitempty"`
  1926  	Check    string             `xml:"check,attr,omitempty"`
  1927  	Model    *DomainCPUModel    `xml:"model"`
  1928  	Vendor   string             `xml:"vendor,omitempty"`
  1929  	Topology *DomainCPUTopology `xml:"topology"`
  1930  	Cache    *DomainCPUCache    `xml:"cache"`
  1931  	Features []DomainCPUFeature `xml:"feature"`
  1932  	Numa     *DomainNuma        `xml:"numa"`
  1933  }
  1934  
  1935  type DomainNuma struct {
  1936  	Cell []DomainCell `xml:"cell"`
  1937  }
  1938  
  1939  type DomainCell struct {
  1940  	ID        *uint                `xml:"id,attr"`
  1941  	CPUs      string               `xml:"cpus,attr"`
  1942  	Memory    uint                 `xml:"memory,attr"`
  1943  	Unit      string               `xml:"unit,attr,omitempty"`
  1944  	MemAccess string               `xml:"memAccess,attr,omitempty"`
  1945  	Discard   string               `xml:"discard,attr,omitempty"`
  1946  	Distances *DomainCellDistances `xml:"distances"`
  1947  }
  1948  
  1949  type DomainCellDistances struct {
  1950  	Siblings []DomainCellSibling `xml:"sibling"`
  1951  }
  1952  
  1953  type DomainCellSibling struct {
  1954  	ID    uint `xml:"id,attr"`
  1955  	Value uint `xml:"value,attr"`
  1956  }
  1957  
  1958  type DomainClock struct {
  1959  	Offset     string        `xml:"offset,attr,omitempty"`
  1960  	Basis      string        `xml:"basis,attr,omitempty"`
  1961  	Adjustment string        `xml:"adjustment,attr,omitempty"`
  1962  	TimeZone   string        `xml:"timezone,attr,omitempty"`
  1963  	Timer      []DomainTimer `xml:"timer"`
  1964  }
  1965  
  1966  type DomainTimer struct {
  1967  	Name       string              `xml:"name,attr"`
  1968  	Track      string              `xml:"track,attr,omitempty"`
  1969  	TickPolicy string              `xml:"tickpolicy,attr,omitempty"`
  1970  	CatchUp    *DomainTimerCatchUp `xml:"catchup"`
  1971  	Frequency  uint32              `xml:"frequency,attr,omitempty"`
  1972  	Mode       string              `xml:"mode,attr,omitempty"`
  1973  	Present    string              `xml:"present,attr,omitempty"`
  1974  }
  1975  
  1976  type DomainTimerCatchUp struct {
  1977  	Threshold uint `xml:"threshold,attr,omitempty"`
  1978  	Slew      uint `xml:"slew,attr,omitempty"`
  1979  	Limit     uint `xml:"limit,attr,omitempty"`
  1980  }
  1981  
  1982  type DomainFeature struct {
  1983  }
  1984  
  1985  type DomainFeatureState struct {
  1986  	State string `xml:"state,attr,omitempty"`
  1987  }
  1988  
  1989  type DomainFeatureAPIC struct {
  1990  	EOI string `xml:"eoi,attr,omitempty"`
  1991  }
  1992  
  1993  type DomainFeatureHyperVVendorId struct {
  1994  	DomainFeatureState
  1995  	Value string `xml:"value,attr,omitempty"`
  1996  }
  1997  
  1998  type DomainFeatureHyperVSpinlocks struct {
  1999  	DomainFeatureState
  2000  	Retries uint `xml:"retries,attr,omitempty"`
  2001  }
  2002  
  2003  type DomainFeatureHyperVSTimer struct {
  2004  	DomainFeatureState
  2005  	Direct *DomainFeatureState `xml:"direct"`
  2006  }
  2007  
  2008  type DomainFeatureHyperV struct {
  2009  	DomainFeature
  2010  	Relaxed         *DomainFeatureState           `xml:"relaxed"`
  2011  	VAPIC           *DomainFeatureState           `xml:"vapic"`
  2012  	Spinlocks       *DomainFeatureHyperVSpinlocks `xml:"spinlocks"`
  2013  	VPIndex         *DomainFeatureState           `xml:"vpindex"`
  2014  	Runtime         *DomainFeatureState           `xml:"runtime"`
  2015  	Synic           *DomainFeatureState           `xml:"synic"`
  2016  	STimer          *DomainFeatureHyperVSTimer    `xml:"stimer"`
  2017  	Reset           *DomainFeatureState           `xml:"reset"`
  2018  	VendorId        *DomainFeatureHyperVVendorId  `xml:"vendor_id"`
  2019  	Frequencies     *DomainFeatureState           `xml:"frequencies"`
  2020  	ReEnlightenment *DomainFeatureState           `xml:"reenlightenment"`
  2021  	TLBFlush        *DomainFeatureState           `xml:"tlbflush"`
  2022  	IPI             *DomainFeatureState           `xml:"ipi"`
  2023  	EVMCS           *DomainFeatureState           `xml:"evmcs"`
  2024  }
  2025  
  2026  type DomainFeatureKVM struct {
  2027  	Hidden        *DomainFeatureState `xml:"hidden"`
  2028  	HintDedicated *DomainFeatureState `xml:"hint-dedicated"`
  2029  }
  2030  
  2031  type DomainFeatureXenPassthrough struct {
  2032  	State string `xml:"state,attr,omitempty"`
  2033  	Mode  string `xml:"mode,attr,omitempty"`
  2034  }
  2035  
  2036  type DomainFeatureXenE820Host struct {
  2037  	State string `xml:"state,attr"`
  2038  }
  2039  
  2040  type DomainFeatureXen struct {
  2041  	E820Host    *DomainFeatureXenE820Host    `xml:"e820_host"`
  2042  	Passthrough *DomainFeatureXenPassthrough `xml:"passthrough"`
  2043  }
  2044  
  2045  type DomainFeatureGIC struct {
  2046  	Version string `xml:"version,attr,omitempty"`
  2047  }
  2048  
  2049  type DomainFeatureIOAPIC struct {
  2050  	Driver string `xml:"driver,attr,omitempty"`
  2051  }
  2052  
  2053  type DomainFeatureHPT struct {
  2054  	Resizing    string                    `xml:"resizing,attr,omitempty"`
  2055  	MaxPageSize *DomainFeatureHPTPageSize `xml:"maxpagesize"`
  2056  }
  2057  
  2058  type DomainFeatureHPTPageSize struct {
  2059  	Unit  string `xml:"unit,attr,omitempty"`
  2060  	Value string `xml:",chardata"`
  2061  }
  2062  
  2063  type DomainFeatureSMM struct {
  2064  	State string                `xml:"state,attr,omitempty"`
  2065  	TSeg  *DomainFeatureSMMTSeg `xml:"tseg"`
  2066  }
  2067  
  2068  type DomainFeatureSMMTSeg struct {
  2069  	Unit  string `xml:"unit,attr,omitempty"`
  2070  	Value uint   `xml:",chardata"`
  2071  }
  2072  
  2073  type DomainFeatureCapability struct {
  2074  	State string `xml:"state,attr,omitempty"`
  2075  }
  2076  
  2077  type DomainLaunchSecurity struct {
  2078  	SEV *DomainLaunchSecuritySEV `xml:"-"`
  2079  }
  2080  
  2081  type DomainLaunchSecuritySEV struct {
  2082  	CBitPos         *uint  `xml:"cbitpos"`
  2083  	ReducedPhysBits *uint  `xml:"reducedPhysBits"`
  2084  	Policy          *uint  `xml:"policy"`
  2085  	DHCert          string `xml:"dhCert"`
  2086  	Session         string `xml:"sesion"`
  2087  }
  2088  
  2089  type DomainFeatureCapabilities struct {
  2090  	Policy         string                   `xml:"policy,attr,omitempty"`
  2091  	AuditControl   *DomainFeatureCapability `xml:"audit_control"`
  2092  	AuditWrite     *DomainFeatureCapability `xml:"audit_write"`
  2093  	BlockSuspend   *DomainFeatureCapability `xml:"block_suspend"`
  2094  	Chown          *DomainFeatureCapability `xml:"chown"`
  2095  	DACOverride    *DomainFeatureCapability `xml:"dac_override"`
  2096  	DACReadSearch  *DomainFeatureCapability `xml:"dac_read_Search"`
  2097  	FOwner         *DomainFeatureCapability `xml:"fowner"`
  2098  	FSetID         *DomainFeatureCapability `xml:"fsetid"`
  2099  	IPCLock        *DomainFeatureCapability `xml:"ipc_lock"`
  2100  	IPCOwner       *DomainFeatureCapability `xml:"ipc_owner"`
  2101  	Kill           *DomainFeatureCapability `xml:"kill"`
  2102  	Lease          *DomainFeatureCapability `xml:"lease"`
  2103  	LinuxImmutable *DomainFeatureCapability `xml:"linux_immutable"`
  2104  	MACAdmin       *DomainFeatureCapability `xml:"mac_admin"`
  2105  	MACOverride    *DomainFeatureCapability `xml:"mac_override"`
  2106  	MkNod          *DomainFeatureCapability `xml:"mknod"`
  2107  	NetAdmin       *DomainFeatureCapability `xml:"net_admin"`
  2108  	NetBindService *DomainFeatureCapability `xml:"net_bind_service"`
  2109  	NetBroadcast   *DomainFeatureCapability `xml:"net_broadcast"`
  2110  	NetRaw         *DomainFeatureCapability `xml:"net_raw"`
  2111  	SetGID         *DomainFeatureCapability `xml:"setgid"`
  2112  	SetFCap        *DomainFeatureCapability `xml:"setfcap"`
  2113  	SetPCap        *DomainFeatureCapability `xml:"setpcap"`
  2114  	SetUID         *DomainFeatureCapability `xml:"setuid"`
  2115  	SysAdmin       *DomainFeatureCapability `xml:"sys_admin"`
  2116  	SysBoot        *DomainFeatureCapability `xml:"sys_boot"`
  2117  	SysChRoot      *DomainFeatureCapability `xml:"sys_chroot"`
  2118  	SysModule      *DomainFeatureCapability `xml:"sys_module"`
  2119  	SysNice        *DomainFeatureCapability `xml:"sys_nice"`
  2120  	SysPAcct       *DomainFeatureCapability `xml:"sys_pacct"`
  2121  	SysPTrace      *DomainFeatureCapability `xml:"sys_ptrace"`
  2122  	SysRawIO       *DomainFeatureCapability `xml:"sys_rawio"`
  2123  	SysResource    *DomainFeatureCapability `xml:"sys_resource"`
  2124  	SysTime        *DomainFeatureCapability `xml:"sys_time"`
  2125  	SysTTYCnofig   *DomainFeatureCapability `xml:"sys_tty_config"`
  2126  	SysLog         *DomainFeatureCapability `xml:"syslog"`
  2127  	WakeAlarm      *DomainFeatureCapability `xml:"wake_alarm"`
  2128  }
  2129  
  2130  type DomainFeatureMSRS struct {
  2131  	Unknown string `xml:"unknown,attr"`
  2132  }
  2133  
  2134  type DomainFeatureCFPC struct {
  2135  	Value string `xml:"value,attr"`
  2136  }
  2137  
  2138  type DomainFeatureSBBC struct {
  2139  	Value string `xml:"value,attr"`
  2140  }
  2141  
  2142  type DomainFeatureIBS struct {
  2143  	Value string `xml:"value,attr"`
  2144  }
  2145  
  2146  type DomainFeatureList struct {
  2147  	PAE          *DomainFeature             `xml:"pae"`
  2148  	ACPI         *DomainFeature             `xml:"acpi"`
  2149  	APIC         *DomainFeatureAPIC         `xml:"apic"`
  2150  	HAP          *DomainFeatureState        `xml:"hap"`
  2151  	Viridian     *DomainFeature             `xml:"viridian"`
  2152  	PrivNet      *DomainFeature             `xml:"privnet"`
  2153  	HyperV       *DomainFeatureHyperV       `xml:"hyperv"`
  2154  	KVM          *DomainFeatureKVM          `xml:"kvm"`
  2155  	Xen          *DomainFeatureXen          `xml:"xen"`
  2156  	PVSpinlock   *DomainFeatureState        `xml:"pvspinlock"`
  2157  	PMU          *DomainFeatureState        `xml:"pmu"`
  2158  	VMPort       *DomainFeatureState        `xml:"vmport"`
  2159  	GIC          *DomainFeatureGIC          `xml:"gic"`
  2160  	SMM          *DomainFeatureSMM          `xml:"smm"`
  2161  	IOAPIC       *DomainFeatureIOAPIC       `xml:"ioapic"`
  2162  	HPT          *DomainFeatureHPT          `xml:"hpt"`
  2163  	HTM          *DomainFeatureState        `xml:"htm"`
  2164  	NestedHV     *DomainFeatureState        `xml:"nested-hv"`
  2165  	Capabilities *DomainFeatureCapabilities `xml:"capabilities"`
  2166  	VMCoreInfo   *DomainFeatureState        `xml:"vmcoreinfo"`
  2167  	MSRS         *DomainFeatureMSRS         `xml:"msrs"`
  2168  	CCFAssist    *DomainFeatureState        `xml:"ccf-assist"`
  2169  	CFPC         *DomainFeatureCFPC         `xml:"cfpc"`
  2170  	SBBC         *DomainFeatureSBBC         `xml:"sbbc"`
  2171  	IBS          *DomainFeatureIBS          `xml:"ibs"`
  2172  }
  2173  
  2174  type DomainCPUTuneShares struct {
  2175  	Value uint `xml:",chardata"`
  2176  }
  2177  
  2178  type DomainCPUTunePeriod struct {
  2179  	Value uint64 `xml:",chardata"`
  2180  }
  2181  
  2182  type DomainCPUTuneQuota struct {
  2183  	Value int64 `xml:",chardata"`
  2184  }
  2185  
  2186  type DomainCPUTuneVCPUPin struct {
  2187  	VCPU   uint   `xml:"vcpu,attr"`
  2188  	CPUSet string `xml:"cpuset,attr"`
  2189  }
  2190  
  2191  type DomainCPUTuneEmulatorPin struct {
  2192  	CPUSet string `xml:"cpuset,attr"`
  2193  }
  2194  
  2195  type DomainCPUTuneIOThreadPin struct {
  2196  	IOThread uint   `xml:"iothread,attr"`
  2197  	CPUSet   string `xml:"cpuset,attr"`
  2198  }
  2199  
  2200  type DomainCPUTuneVCPUSched struct {
  2201  	VCPUs     string `xml:"vcpus,attr"`
  2202  	Scheduler string `xml:"scheduler,attr,omitempty"`
  2203  	Priority  *int   `xml:"priority,attr"`
  2204  }
  2205  
  2206  type DomainCPUTuneIOThreadSched struct {
  2207  	IOThreads string `xml:"iothreads,attr"`
  2208  	Scheduler string `xml:"scheduler,attr,omitempty"`
  2209  	Priority  *int   `xml:"priority,attr"`
  2210  }
  2211  
  2212  type DomainCPUTuneEmulatorSched struct {
  2213  	Scheduler string `xml:"scheduler,attr,omitempty"`
  2214  	Priority  *int   `xml:"priority,attr"`
  2215  }
  2216  
  2217  type DomainCPUCacheTune struct {
  2218  	VCPUs   string                      `xml:"vcpus,attr,omitempty"`
  2219  	Cache   []DomainCPUCacheTuneCache   `xml:"cache"`
  2220  	Monitor []DomainCPUCacheTuneMonitor `xml:"monitor"`
  2221  }
  2222  
  2223  type DomainCPUCacheTuneCache struct {
  2224  	ID    uint   `xml:"id,attr"`
  2225  	Level uint   `xml:"level,attr"`
  2226  	Type  string `xml:"type,attr"`
  2227  	Size  uint   `xml:"size,attr"`
  2228  	Unit  string `xml:"unit,attr"`
  2229  }
  2230  
  2231  type DomainCPUCacheTuneMonitor struct {
  2232  	Level uint   `xml:"level,attr,omitempty"`
  2233  	VCPUs string `xml:"vcpus,attr,omitempty"`
  2234  }
  2235  
  2236  type DomainCPUMemoryTune struct {
  2237  	VCPUs   string                       `xml:"vcpus,attr"`
  2238  	Nodes   []DomainCPUMemoryTuneNode    `xml:"node"`
  2239  	Monitor []DomainCPUMemoryTuneMonitor `xml:"monitor"`
  2240  }
  2241  
  2242  type DomainCPUMemoryTuneNode struct {
  2243  	ID        uint `xml:"id,attr"`
  2244  	Bandwidth uint `xml:"bandwidth,attr"`
  2245  }
  2246  
  2247  type DomainCPUMemoryTuneMonitor struct {
  2248  	Level uint   `xml:"level,attr,omitempty"`
  2249  	VCPUs string `xml:"vcpus,attr,omitempty"`
  2250  }
  2251  
  2252  type DomainCPUTune struct {
  2253  	Shares         *DomainCPUTuneShares         `xml:"shares"`
  2254  	Period         *DomainCPUTunePeriod         `xml:"period"`
  2255  	Quota          *DomainCPUTuneQuota          `xml:"quota"`
  2256  	GlobalPeriod   *DomainCPUTunePeriod         `xml:"global_period"`
  2257  	GlobalQuota    *DomainCPUTuneQuota          `xml:"global_quota"`
  2258  	EmulatorPeriod *DomainCPUTunePeriod         `xml:"emulator_period"`
  2259  	EmulatorQuota  *DomainCPUTuneQuota          `xml:"emulator_quota"`
  2260  	IOThreadPeriod *DomainCPUTunePeriod         `xml:"iothread_period"`
  2261  	IOThreadQuota  *DomainCPUTuneQuota          `xml:"iothread_quota"`
  2262  	VCPUPin        []DomainCPUTuneVCPUPin       `xml:"vcpupin"`
  2263  	EmulatorPin    *DomainCPUTuneEmulatorPin    `xml:"emulatorpin"`
  2264  	IOThreadPin    []DomainCPUTuneIOThreadPin   `xml:"iothreadpin"`
  2265  	VCPUSched      []DomainCPUTuneVCPUSched     `xml:"vcpusched"`
  2266  	EmulatorSched  *DomainCPUTuneEmulatorSched  `xml:"emulatorsched"`
  2267  	IOThreadSched  []DomainCPUTuneIOThreadSched `xml:"iothreadsched"`
  2268  	CacheTune      []DomainCPUCacheTune         `xml:"cachetune"`
  2269  	MemoryTune     []DomainCPUMemoryTune        `xml:"memorytune"`
  2270  }
  2271  
  2272  type DomainQEMUCommandlineArg struct {
  2273  	Value string `xml:"value,attr"`
  2274  }
  2275  
  2276  type DomainQEMUCommandlineEnv struct {
  2277  	Name  string `xml:"name,attr"`
  2278  	Value string `xml:"value,attr,omitempty"`
  2279  }
  2280  
  2281  type DomainQEMUCommandline struct {
  2282  	XMLName xml.Name                   `xml:"http://libvirt.org/schemas/domain/qemu/1.0 commandline"`
  2283  	Args    []DomainQEMUCommandlineArg `xml:"arg"`
  2284  	Envs    []DomainQEMUCommandlineEnv `xml:"env"`
  2285  }
  2286  
  2287  type DomainQEMUCapabilitiesEntry struct {
  2288  	Name string `xml:"capability,attr"`
  2289  }
  2290  type DomainQEMUCapabilities struct {
  2291  	XMLName xml.Name                      `xml:"http://libvirt.org/schemas/domain/qemu/1.0 capabilities"`
  2292  	Add     []DomainQEMUCapabilitiesEntry `xml:"add"`
  2293  	Del     []DomainQEMUCapabilitiesEntry `xml:"del"`
  2294  }
  2295  
  2296  type DomainLXCNamespace struct {
  2297  	XMLName  xml.Name               `xml:"http://libvirt.org/schemas/domain/lxc/1.0 namespace"`
  2298  	ShareNet *DomainLXCNamespaceMap `xml:"sharenet"`
  2299  	ShareIPC *DomainLXCNamespaceMap `xml:"shareipc"`
  2300  	ShareUTS *DomainLXCNamespaceMap `xml:"shareuts"`
  2301  }
  2302  
  2303  type DomainLXCNamespaceMap struct {
  2304  	Type  string `xml:"type,attr"`
  2305  	Value string `xml:"value,attr"`
  2306  }
  2307  
  2308  type DomainBHyveCommandlineArg struct {
  2309  	Value string `xml:"value,attr"`
  2310  }
  2311  
  2312  type DomainBHyveCommandlineEnv struct {
  2313  	Name  string `xml:"name,attr"`
  2314  	Value string `xml:"value,attr,omitempty"`
  2315  }
  2316  
  2317  type DomainBHyveCommandline struct {
  2318  	XMLName xml.Name                    `xml:"http://libvirt.org/schemas/domain/bhyve/1.0 commandline"`
  2319  	Args    []DomainBHyveCommandlineArg `xml:"arg"`
  2320  	Envs    []DomainBHyveCommandlineEnv `xml:"env"`
  2321  }
  2322  
  2323  type DomainBlockIOTune struct {
  2324  	Weight uint                      `xml:"weight,omitempty"`
  2325  	Device []DomainBlockIOTuneDevice `xml:"device"`
  2326  }
  2327  
  2328  type DomainBlockIOTuneDevice struct {
  2329  	Path          string `xml:"path"`
  2330  	Weight        uint   `xml:"weight,omitempty"`
  2331  	ReadIopsSec   uint   `xml:"read_iops_sec,omitempty"`
  2332  	WriteIopsSec  uint   `xml:"write_iops_sec,omitempty"`
  2333  	ReadBytesSec  uint   `xml:"read_bytes_sec,omitempty"`
  2334  	WriteBytesSec uint   `xml:"write_bytes_sec,omitempty"`
  2335  }
  2336  
  2337  type DomainPM struct {
  2338  	SuspendToMem  *DomainPMPolicy `xml:"suspend-to-mem"`
  2339  	SuspendToDisk *DomainPMPolicy `xml:"suspend-to-disk"`
  2340  }
  2341  
  2342  type DomainPMPolicy struct {
  2343  	Enabled string `xml:"enabled,attr"`
  2344  }
  2345  
  2346  type DomainSecLabel struct {
  2347  	Type       string `xml:"type,attr,omitempty"`
  2348  	Model      string `xml:"model,attr,omitempty"`
  2349  	Relabel    string `xml:"relabel,attr,omitempty"`
  2350  	Label      string `xml:"label,omitempty"`
  2351  	ImageLabel string `xml:"imagelabel,omitempty"`
  2352  	BaseLabel  string `xml:"baselabel,omitempty"`
  2353  }
  2354  
  2355  type DomainDeviceSecLabel struct {
  2356  	Model     string `xml:"model,attr,omitempty"`
  2357  	LabelSkip string `xml:"labelskip,attr,omitempty"`
  2358  	Relabel   string `xml:"relabel,attr,omitempty"`
  2359  	Label     string `xml:"label,omitempty"`
  2360  }
  2361  
  2362  type DomainNUMATune struct {
  2363  	Memory   *DomainNUMATuneMemory   `xml:"memory"`
  2364  	MemNodes []DomainNUMATuneMemNode `xml:"memnode"`
  2365  }
  2366  
  2367  type DomainNUMATuneMemory struct {
  2368  	Mode      string `xml:"mode,attr,omitempty"`
  2369  	Nodeset   string `xml:"nodeset,attr,omitempty"`
  2370  	Placement string `xml:"placement,attr,omitempty"`
  2371  }
  2372  
  2373  type DomainNUMATuneMemNode struct {
  2374  	CellID  uint   `xml:"cellid,attr"`
  2375  	Mode    string `xml:"mode,attr"`
  2376  	Nodeset string `xml:"nodeset,attr"`
  2377  }
  2378  
  2379  type DomainIOThreadIDs struct {
  2380  	IOThreads []DomainIOThread `xml:"iothread"`
  2381  }
  2382  
  2383  type DomainIOThread struct {
  2384  	ID uint `xml:"id,attr"`
  2385  }
  2386  
  2387  type DomainKeyWrap struct {
  2388  	Ciphers []DomainKeyWrapCipher `xml:"cipher"`
  2389  }
  2390  
  2391  type DomainKeyWrapCipher struct {
  2392  	Name  string `xml:"name,attr"`
  2393  	State string `xml:"state,attr"`
  2394  }
  2395  
  2396  type DomainIDMap struct {
  2397  	UIDs []DomainIDMapRange `xml:"uid"`
  2398  	GIDs []DomainIDMapRange `xml:"gid"`
  2399  }
  2400  
  2401  type DomainIDMapRange struct {
  2402  	Start  uint `xml:"start,attr"`
  2403  	Target uint `xml:"target,attr"`
  2404  	Count  uint `xml:"count,attr"`
  2405  }
  2406  
  2407  type DomainMemoryTuneLimit struct {
  2408  	Value uint64 `xml:",chardata"`
  2409  	Unit  string `xml:"unit,attr,omitempty"`
  2410  }
  2411  
  2412  type DomainMemoryTune struct {
  2413  	HardLimit     *DomainMemoryTuneLimit `xml:"hard_limit"`
  2414  	SoftLimit     *DomainMemoryTuneLimit `xml:"soft_limit"`
  2415  	MinGuarantee  *DomainMemoryTuneLimit `xml:"min_guarantee"`
  2416  	SwapHardLimit *DomainMemoryTuneLimit `xml:"swap_hard_limit"`
  2417  }
  2418  
  2419  type DomainMetadata struct {
  2420  	XML string `xml:",innerxml"`
  2421  }
  2422  
  2423  type DomainVMWareDataCenterPath struct {
  2424  	XMLName xml.Name `xml:"http://libvirt.org/schemas/domain/vmware/1.0 datacenterpath"`
  2425  	Value   string   `xml:",chardata"`
  2426  }
  2427  
  2428  type DomainPerf struct {
  2429  	Events []DomainPerfEvent `xml:"event"`
  2430  }
  2431  
  2432  type DomainPerfEvent struct {
  2433  	Name    string `xml:"name,attr"`
  2434  	Enabled string `xml:"enabled,attr"`
  2435  }
  2436  
  2437  type DomainGenID struct {
  2438  	Value string `xml:",chardata"`
  2439  }
  2440  
  2441  // NB, try to keep the order of fields in this struct
  2442  // matching the order of XML elements that libvirt
  2443  // will generate when dumping XML.
  2444  type Domain struct {
  2445  	XMLName        xml.Name              `xml:"domain"`
  2446  	Type           string                `xml:"type,attr,omitempty"`
  2447  	ID             *int                  `xml:"id,attr"`
  2448  	Name           string                `xml:"name,omitempty"`
  2449  	UUID           string                `xml:"uuid,omitempty"`
  2450  	GenID          *DomainGenID          `xml:"genid"`
  2451  	Title          string                `xml:"title,omitempty"`
  2452  	Description    string                `xml:"description,omitempty"`
  2453  	Metadata       *DomainMetadata       `xml:"metadata"`
  2454  	MaximumMemory  *DomainMaxMemory      `xml:"maxMemory"`
  2455  	Memory         *DomainMemory         `xml:"memory"`
  2456  	CurrentMemory  *DomainCurrentMemory  `xml:"currentMemory"`
  2457  	BlockIOTune    *DomainBlockIOTune    `xml:"blkiotune"`
  2458  	MemoryTune     *DomainMemoryTune     `xml:"memtune"`
  2459  	MemoryBacking  *DomainMemoryBacking  `xml:"memoryBacking"`
  2460  	VCPU           *DomainVCPU           `xml:"vcpu"`
  2461  	VCPUs          *DomainVCPUs          `xml:"vcpus"`
  2462  	IOThreads      uint                  `xml:"iothreads,omitempty"`
  2463  	IOThreadIDs    *DomainIOThreadIDs    `xml:"iothreadids"`
  2464  	CPUTune        *DomainCPUTune        `xml:"cputune"`
  2465  	NUMATune       *DomainNUMATune       `xml:"numatune"`
  2466  	Resource       *DomainResource       `xml:"resource"`
  2467  	SysInfo        *DomainSysInfo        `xml:"sysinfo"`
  2468  	Bootloader     string                `xml:"bootloader,omitempty"`
  2469  	BootloaderArgs string                `xml:"bootloader_args,omitempty"`
  2470  	OS             *DomainOS             `xml:"os"`
  2471  	IDMap          *DomainIDMap          `xml:"idmap"`
  2472  	Features       *DomainFeatureList    `xml:"features"`
  2473  	CPU            *DomainCPU            `xml:"cpu"`
  2474  	Clock          *DomainClock          `xml:"clock"`
  2475  	OnPoweroff     string                `xml:"on_poweroff,omitempty"`
  2476  	OnReboot       string                `xml:"on_reboot,omitempty"`
  2477  	OnCrash        string                `xml:"on_crash,omitempty"`
  2478  	PM             *DomainPM             `xml:"pm"`
  2479  	Perf           *DomainPerf           `xml:"perf"`
  2480  	Devices        *DomainDeviceList     `xml:"devices"`
  2481  	SecLabel       []DomainSecLabel      `xml:"seclabel"`
  2482  	KeyWrap        *DomainKeyWrap        `xml:"keywrap"`
  2483  	LaunchSecurity *DomainLaunchSecurity `xml:"launchSecurity"`
  2484  
  2485  	/* Hypervisor namespaces must all be last */
  2486  	QEMUCommandline      *DomainQEMUCommandline
  2487  	QEMUCapabilities     *DomainQEMUCapabilities
  2488  	LXCNamespace         *DomainLXCNamespace
  2489  	BHyveCommandline     *DomainBHyveCommandline
  2490  	VMWareDataCenterPath *DomainVMWareDataCenterPath
  2491  }
  2492  
  2493  func (d *Domain) Unmarshal(doc string) error {
  2494  	return xml.Unmarshal([]byte(doc), d)
  2495  }
  2496  
  2497  func (d *Domain) Marshal() (string, error) {
  2498  	doc, err := xml.MarshalIndent(d, "", "  ")
  2499  	if err != nil {
  2500  		return "", err
  2501  	}
  2502  	return string(doc), nil
  2503  }
  2504  
  2505  type domainController DomainController
  2506  
  2507  type domainControllerPCI struct {
  2508  	DomainControllerPCI
  2509  	domainController
  2510  }
  2511  
  2512  type domainControllerUSB struct {
  2513  	DomainControllerUSB
  2514  	domainController
  2515  }
  2516  
  2517  type domainControllerVirtIOSerial struct {
  2518  	DomainControllerVirtIOSerial
  2519  	domainController
  2520  }
  2521  
  2522  type domainControllerXenBus struct {
  2523  	DomainControllerXenBus
  2524  	domainController
  2525  }
  2526  
  2527  func (a *DomainControllerPCITarget) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2528  	marshalUintAttr(&start, "chassisNr", a.ChassisNr, "%d")
  2529  	marshalUintAttr(&start, "chassis", a.Chassis, "%d")
  2530  	marshalUintAttr(&start, "port", a.Port, "%d")
  2531  	marshalUintAttr(&start, "busNr", a.BusNr, "%d")
  2532  	marshalUintAttr(&start, "index", a.Index, "%d")
  2533  	if a.Hotplug != "" {
  2534  		start.Attr = append(start.Attr, xml.Attr{
  2535  			xml.Name{Local: "hotplug"}, a.Hotplug,
  2536  		})
  2537  	}
  2538  	e.EncodeToken(start)
  2539  	if a.NUMANode != nil {
  2540  		node := xml.StartElement{
  2541  			Name: xml.Name{Local: "node"},
  2542  		}
  2543  		e.EncodeToken(node)
  2544  		e.EncodeToken(xml.CharData(fmt.Sprintf("%d", *a.NUMANode)))
  2545  		e.EncodeToken(node.End())
  2546  	}
  2547  	e.EncodeToken(start.End())
  2548  	return nil
  2549  }
  2550  
  2551  func (a *DomainControllerPCITarget) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2552  	for _, attr := range start.Attr {
  2553  		if attr.Name.Local == "chassisNr" {
  2554  			if err := unmarshalUintAttr(attr.Value, &a.ChassisNr, 10); err != nil {
  2555  				return err
  2556  			}
  2557  		} else if attr.Name.Local == "chassis" {
  2558  			if err := unmarshalUintAttr(attr.Value, &a.Chassis, 10); err != nil {
  2559  				return err
  2560  			}
  2561  		} else if attr.Name.Local == "port" {
  2562  			if err := unmarshalUintAttr(attr.Value, &a.Port, 0); err != nil {
  2563  				return err
  2564  			}
  2565  		} else if attr.Name.Local == "busNr" {
  2566  			if err := unmarshalUintAttr(attr.Value, &a.BusNr, 10); err != nil {
  2567  				return err
  2568  			}
  2569  		} else if attr.Name.Local == "index" {
  2570  			if err := unmarshalUintAttr(attr.Value, &a.Index, 10); err != nil {
  2571  				return err
  2572  			}
  2573  		} else if attr.Name.Local == "hotplug" {
  2574  			a.Hotplug = attr.Value
  2575  		}
  2576  	}
  2577  	for {
  2578  		tok, err := d.Token()
  2579  		if err == io.EOF {
  2580  			break
  2581  		}
  2582  		if err != nil {
  2583  			return err
  2584  		}
  2585  
  2586  		switch tok := tok.(type) {
  2587  		case xml.StartElement:
  2588  			if tok.Name.Local == "node" {
  2589  				data, err := d.Token()
  2590  				if err != nil {
  2591  					return err
  2592  				}
  2593  				switch data := data.(type) {
  2594  				case xml.CharData:
  2595  					val, err := strconv.ParseUint(string(data), 10, 64)
  2596  					if err != nil {
  2597  						return err
  2598  					}
  2599  					vali := uint(val)
  2600  					a.NUMANode = &vali
  2601  				}
  2602  			}
  2603  		}
  2604  	}
  2605  	return nil
  2606  }
  2607  
  2608  func (a *DomainController) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2609  	start.Name.Local = "controller"
  2610  	if a.Type == "pci" {
  2611  		pci := domainControllerPCI{}
  2612  		pci.domainController = domainController(*a)
  2613  		if a.PCI != nil {
  2614  			pci.DomainControllerPCI = *a.PCI
  2615  		}
  2616  		return e.EncodeElement(pci, start)
  2617  	} else if a.Type == "usb" {
  2618  		usb := domainControllerUSB{}
  2619  		usb.domainController = domainController(*a)
  2620  		if a.USB != nil {
  2621  			usb.DomainControllerUSB = *a.USB
  2622  		}
  2623  		return e.EncodeElement(usb, start)
  2624  	} else if a.Type == "virtio-serial" {
  2625  		vioserial := domainControllerVirtIOSerial{}
  2626  		vioserial.domainController = domainController(*a)
  2627  		if a.VirtIOSerial != nil {
  2628  			vioserial.DomainControllerVirtIOSerial = *a.VirtIOSerial
  2629  		}
  2630  		return e.EncodeElement(vioserial, start)
  2631  	} else if a.Type == "xenbus" {
  2632  		xenbus := domainControllerXenBus{}
  2633  		xenbus.domainController = domainController(*a)
  2634  		if a.XenBus != nil {
  2635  			xenbus.DomainControllerXenBus = *a.XenBus
  2636  		}
  2637  		return e.EncodeElement(xenbus, start)
  2638  	} else {
  2639  		gen := domainController(*a)
  2640  		return e.EncodeElement(gen, start)
  2641  	}
  2642  }
  2643  
  2644  func getAttr(attrs []xml.Attr, name string) (string, bool) {
  2645  	for _, attr := range attrs {
  2646  		if attr.Name.Local == name {
  2647  			return attr.Value, true
  2648  		}
  2649  	}
  2650  	return "", false
  2651  }
  2652  
  2653  func (a *DomainController) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2654  	typ, ok := getAttr(start.Attr, "type")
  2655  	if !ok {
  2656  		return fmt.Errorf("Missing 'type' attribute on domain controller")
  2657  	}
  2658  	if typ == "pci" {
  2659  		var pci domainControllerPCI
  2660  		err := d.DecodeElement(&pci, &start)
  2661  		if err != nil {
  2662  			return err
  2663  		}
  2664  		*a = DomainController(pci.domainController)
  2665  		a.PCI = &pci.DomainControllerPCI
  2666  		return nil
  2667  	} else if typ == "usb" {
  2668  		var usb domainControllerUSB
  2669  		err := d.DecodeElement(&usb, &start)
  2670  		if err != nil {
  2671  			return err
  2672  		}
  2673  		*a = DomainController(usb.domainController)
  2674  		a.USB = &usb.DomainControllerUSB
  2675  		return nil
  2676  	} else if typ == "virtio-serial" {
  2677  		var vioserial domainControllerVirtIOSerial
  2678  		err := d.DecodeElement(&vioserial, &start)
  2679  		if err != nil {
  2680  			return err
  2681  		}
  2682  		*a = DomainController(vioserial.domainController)
  2683  		a.VirtIOSerial = &vioserial.DomainControllerVirtIOSerial
  2684  		return nil
  2685  	} else if typ == "xenbus" {
  2686  		var xenbus domainControllerXenBus
  2687  		err := d.DecodeElement(&xenbus, &start)
  2688  		if err != nil {
  2689  			return err
  2690  		}
  2691  		*a = DomainController(xenbus.domainController)
  2692  		a.XenBus = &xenbus.DomainControllerXenBus
  2693  		return nil
  2694  	} else {
  2695  		var gen domainController
  2696  		err := d.DecodeElement(&gen, &start)
  2697  		if err != nil {
  2698  			return err
  2699  		}
  2700  		*a = DomainController(gen)
  2701  		return nil
  2702  	}
  2703  }
  2704  
  2705  func (d *DomainGraphic) Unmarshal(doc string) error {
  2706  	return xml.Unmarshal([]byte(doc), d)
  2707  }
  2708  
  2709  func (d *DomainGraphic) Marshal() (string, error) {
  2710  	doc, err := xml.MarshalIndent(d, "", "  ")
  2711  	if err != nil {
  2712  		return "", err
  2713  	}
  2714  	return string(doc), nil
  2715  }
  2716  
  2717  func (d *DomainController) Unmarshal(doc string) error {
  2718  	return xml.Unmarshal([]byte(doc), d)
  2719  }
  2720  
  2721  func (d *DomainController) Marshal() (string, error) {
  2722  	doc, err := xml.MarshalIndent(d, "", "  ")
  2723  	if err != nil {
  2724  		return "", err
  2725  	}
  2726  	return string(doc), nil
  2727  }
  2728  
  2729  func (a *DomainDiskReservationsSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2730  	start.Name.Local = "source"
  2731  	src := DomainChardevSource(*a)
  2732  	typ := getChardevSourceType(&src)
  2733  	if typ != "" {
  2734  		start.Attr = append(start.Attr, xml.Attr{
  2735  			xml.Name{Local: "type"}, typ,
  2736  		})
  2737  	}
  2738  	return e.EncodeElement(&src, start)
  2739  }
  2740  
  2741  func (a *DomainDiskReservationsSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2742  	typ, ok := getAttr(start.Attr, "type")
  2743  	if !ok {
  2744  		typ = "unix"
  2745  	}
  2746  	src := createChardevSource(typ)
  2747  	err := d.DecodeElement(&src, &start)
  2748  	if err != nil {
  2749  		return err
  2750  	}
  2751  	*a = DomainDiskReservationsSource(*src)
  2752  	return nil
  2753  }
  2754  
  2755  type domainDiskSource DomainDiskSource
  2756  
  2757  type domainDiskSourceFile struct {
  2758  	DomainDiskSourceFile
  2759  	domainDiskSource
  2760  }
  2761  
  2762  type domainDiskSourceBlock struct {
  2763  	DomainDiskSourceBlock
  2764  	domainDiskSource
  2765  }
  2766  
  2767  type domainDiskSourceDir struct {
  2768  	DomainDiskSourceDir
  2769  	domainDiskSource
  2770  }
  2771  
  2772  type domainDiskSourceNetwork struct {
  2773  	DomainDiskSourceNetwork
  2774  	domainDiskSource
  2775  }
  2776  
  2777  type domainDiskSourceVolume struct {
  2778  	DomainDiskSourceVolume
  2779  	domainDiskSource
  2780  }
  2781  
  2782  type domainDiskSourceNVMEPCI struct {
  2783  	DomainDiskSourceNVMEPCI
  2784  	domainDiskSource
  2785  }
  2786  
  2787  func (a *DomainDiskSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2788  	if a.File != nil {
  2789  		if a.StartupPolicy == "" && a.Encryption == nil && a.File.File == "" {
  2790  			return nil
  2791  		}
  2792  		file := domainDiskSourceFile{
  2793  			*a.File, domainDiskSource(*a),
  2794  		}
  2795  		return e.EncodeElement(&file, start)
  2796  	} else if a.Block != nil {
  2797  		if a.StartupPolicy == "" && a.Encryption == nil && a.Block.Dev == "" {
  2798  			return nil
  2799  		}
  2800  		block := domainDiskSourceBlock{
  2801  			*a.Block, domainDiskSource(*a),
  2802  		}
  2803  		return e.EncodeElement(&block, start)
  2804  	} else if a.Dir != nil {
  2805  		dir := domainDiskSourceDir{
  2806  			*a.Dir, domainDiskSource(*a),
  2807  		}
  2808  		return e.EncodeElement(&dir, start)
  2809  	} else if a.Network != nil {
  2810  		network := domainDiskSourceNetwork{
  2811  			*a.Network, domainDiskSource(*a),
  2812  		}
  2813  		return e.EncodeElement(&network, start)
  2814  	} else if a.Volume != nil {
  2815  		if a.StartupPolicy == "" && a.Encryption == nil && a.Volume.Pool == "" && a.Volume.Volume == "" {
  2816  			return nil
  2817  		}
  2818  		volume := domainDiskSourceVolume{
  2819  			*a.Volume, domainDiskSource(*a),
  2820  		}
  2821  		return e.EncodeElement(&volume, start)
  2822  	} else if a.NVME != nil {
  2823  		if a.NVME.PCI != nil {
  2824  			nvme := domainDiskSourceNVMEPCI{
  2825  				*a.NVME.PCI, domainDiskSource(*a),
  2826  			}
  2827  			start.Attr = append(start.Attr, xml.Attr{
  2828  				xml.Name{Local: "type"}, "pci",
  2829  			})
  2830  			return e.EncodeElement(&nvme, start)
  2831  		}
  2832  	}
  2833  	return nil
  2834  }
  2835  
  2836  func (a *DomainDiskSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2837  	if a.File != nil {
  2838  		file := domainDiskSourceFile{
  2839  			*a.File, domainDiskSource(*a),
  2840  		}
  2841  		err := d.DecodeElement(&file, &start)
  2842  		if err != nil {
  2843  			return err
  2844  		}
  2845  		*a = DomainDiskSource(file.domainDiskSource)
  2846  		a.File = &file.DomainDiskSourceFile
  2847  	} else if a.Block != nil {
  2848  		block := domainDiskSourceBlock{
  2849  			*a.Block, domainDiskSource(*a),
  2850  		}
  2851  		err := d.DecodeElement(&block, &start)
  2852  		if err != nil {
  2853  			return err
  2854  		}
  2855  		*a = DomainDiskSource(block.domainDiskSource)
  2856  		a.Block = &block.DomainDiskSourceBlock
  2857  	} else if a.Dir != nil {
  2858  		dir := domainDiskSourceDir{
  2859  			*a.Dir, domainDiskSource(*a),
  2860  		}
  2861  		err := d.DecodeElement(&dir, &start)
  2862  		if err != nil {
  2863  			return err
  2864  		}
  2865  		*a = DomainDiskSource(dir.domainDiskSource)
  2866  		a.Dir = &dir.DomainDiskSourceDir
  2867  	} else if a.Network != nil {
  2868  		network := domainDiskSourceNetwork{
  2869  			*a.Network, domainDiskSource(*a),
  2870  		}
  2871  		err := d.DecodeElement(&network, &start)
  2872  		if err != nil {
  2873  			return err
  2874  		}
  2875  		*a = DomainDiskSource(network.domainDiskSource)
  2876  		a.Network = &network.DomainDiskSourceNetwork
  2877  	} else if a.Volume != nil {
  2878  		volume := domainDiskSourceVolume{
  2879  			*a.Volume, domainDiskSource(*a),
  2880  		}
  2881  		err := d.DecodeElement(&volume, &start)
  2882  		if err != nil {
  2883  			return err
  2884  		}
  2885  		*a = DomainDiskSource(volume.domainDiskSource)
  2886  		a.Volume = &volume.DomainDiskSourceVolume
  2887  	} else if a.NVME != nil {
  2888  		typ, ok := getAttr(start.Attr, "type")
  2889  		if !ok {
  2890  			return fmt.Errorf("Missing nvme source type")
  2891  		}
  2892  		if typ == "pci" {
  2893  			a.NVME.PCI = &DomainDiskSourceNVMEPCI{}
  2894  			nvme := domainDiskSourceNVMEPCI{
  2895  				*a.NVME.PCI, domainDiskSource(*a),
  2896  			}
  2897  			err := d.DecodeElement(&nvme, &start)
  2898  			if err != nil {
  2899  				return err
  2900  			}
  2901  			*a = DomainDiskSource(nvme.domainDiskSource)
  2902  			a.NVME.PCI = &nvme.DomainDiskSourceNVMEPCI
  2903  		}
  2904  	}
  2905  	return nil
  2906  }
  2907  
  2908  type domainDiskBackingStore DomainDiskBackingStore
  2909  
  2910  func (a *DomainDiskBackingStore) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2911  	start.Name.Local = "backingStore"
  2912  	if a.Source != nil {
  2913  		if a.Source.File != nil {
  2914  			start.Attr = append(start.Attr, xml.Attr{
  2915  				xml.Name{Local: "type"}, "file",
  2916  			})
  2917  		} else if a.Source.Block != nil {
  2918  			start.Attr = append(start.Attr, xml.Attr{
  2919  				xml.Name{Local: "type"}, "block",
  2920  			})
  2921  		} else if a.Source.Dir != nil {
  2922  			start.Attr = append(start.Attr, xml.Attr{
  2923  				xml.Name{Local: "type"}, "dir",
  2924  			})
  2925  		} else if a.Source.Network != nil {
  2926  			start.Attr = append(start.Attr, xml.Attr{
  2927  				xml.Name{Local: "type"}, "network",
  2928  			})
  2929  		} else if a.Source.Volume != nil {
  2930  			start.Attr = append(start.Attr, xml.Attr{
  2931  				xml.Name{Local: "type"}, "volume",
  2932  			})
  2933  		}
  2934  	}
  2935  	disk := domainDiskBackingStore(*a)
  2936  	return e.EncodeElement(disk, start)
  2937  }
  2938  
  2939  func (a *DomainDiskBackingStore) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  2940  	typ, ok := getAttr(start.Attr, "type")
  2941  	if !ok {
  2942  		typ = "file"
  2943  	}
  2944  	a.Source = &DomainDiskSource{}
  2945  	if typ == "file" {
  2946  		a.Source.File = &DomainDiskSourceFile{}
  2947  	} else if typ == "block" {
  2948  		a.Source.Block = &DomainDiskSourceBlock{}
  2949  	} else if typ == "network" {
  2950  		a.Source.Network = &DomainDiskSourceNetwork{}
  2951  	} else if typ == "dir" {
  2952  		a.Source.Dir = &DomainDiskSourceDir{}
  2953  	} else if typ == "volume" {
  2954  		a.Source.Volume = &DomainDiskSourceVolume{}
  2955  	}
  2956  	disk := domainDiskBackingStore(*a)
  2957  	err := d.DecodeElement(&disk, &start)
  2958  	if err != nil {
  2959  		return err
  2960  	}
  2961  	*a = DomainDiskBackingStore(disk)
  2962  	if !ok && a.Source.File.File == "" {
  2963  		a.Source.File = nil
  2964  	}
  2965  	return nil
  2966  }
  2967  
  2968  type domainDiskMirror DomainDiskMirror
  2969  
  2970  func (a *DomainDiskMirror) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  2971  	start.Name.Local = "mirror"
  2972  	if a.Source != nil {
  2973  		if a.Source.File != nil {
  2974  			start.Attr = append(start.Attr, xml.Attr{
  2975  				xml.Name{Local: "type"}, "file",
  2976  			})
  2977  			if a.Source.File.File != "" {
  2978  				start.Attr = append(start.Attr, xml.Attr{
  2979  					xml.Name{Local: "file"}, a.Source.File.File,
  2980  				})
  2981  			}
  2982  			if a.Format != nil && a.Format.Type != "" {
  2983  				start.Attr = append(start.Attr, xml.Attr{
  2984  					xml.Name{Local: "format"}, a.Format.Type,
  2985  				})
  2986  			}
  2987  		} else if a.Source.Block != nil {
  2988  			start.Attr = append(start.Attr, xml.Attr{
  2989  				xml.Name{Local: "type"}, "block",
  2990  			})
  2991  		} else if a.Source.Dir != nil {
  2992  			start.Attr = append(start.Attr, xml.Attr{
  2993  				xml.Name{Local: "type"}, "dir",
  2994  			})
  2995  		} else if a.Source.Network != nil {
  2996  			start.Attr = append(start.Attr, xml.Attr{
  2997  				xml.Name{Local: "type"}, "network",
  2998  			})
  2999  		} else if a.Source.Volume != nil {
  3000  			start.Attr = append(start.Attr, xml.Attr{
  3001  				xml.Name{Local: "type"}, "volume",
  3002  			})
  3003  		}
  3004  	}
  3005  	disk := domainDiskMirror(*a)
  3006  	return e.EncodeElement(disk, start)
  3007  }
  3008  
  3009  func (a *DomainDiskMirror) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3010  	typ, ok := getAttr(start.Attr, "type")
  3011  	if !ok {
  3012  		typ = "file"
  3013  	}
  3014  	a.Source = &DomainDiskSource{}
  3015  	if typ == "file" {
  3016  		a.Source.File = &DomainDiskSourceFile{}
  3017  	} else if typ == "block" {
  3018  		a.Source.Block = &DomainDiskSourceBlock{}
  3019  	} else if typ == "network" {
  3020  		a.Source.Network = &DomainDiskSourceNetwork{}
  3021  	} else if typ == "dir" {
  3022  		a.Source.Dir = &DomainDiskSourceDir{}
  3023  	} else if typ == "volume" {
  3024  		a.Source.Volume = &DomainDiskSourceVolume{}
  3025  	}
  3026  	disk := domainDiskMirror(*a)
  3027  	err := d.DecodeElement(&disk, &start)
  3028  	if err != nil {
  3029  		return err
  3030  	}
  3031  	*a = DomainDiskMirror(disk)
  3032  	if !ok {
  3033  		if a.Source.File.File == "" {
  3034  			file, ok := getAttr(start.Attr, "file")
  3035  			if ok {
  3036  				a.Source.File.File = file
  3037  			} else {
  3038  				a.Source.File = nil
  3039  			}
  3040  		}
  3041  		if a.Format == nil {
  3042  			format, ok := getAttr(start.Attr, "format")
  3043  			if ok {
  3044  				a.Format = &DomainDiskFormat{
  3045  					Type: format,
  3046  				}
  3047  			}
  3048  		}
  3049  	}
  3050  	return nil
  3051  }
  3052  
  3053  type domainDisk DomainDisk
  3054  
  3055  func (a *DomainDisk) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3056  	start.Name.Local = "disk"
  3057  	if a.Source != nil {
  3058  		if a.Source.File != nil {
  3059  			start.Attr = append(start.Attr, xml.Attr{
  3060  				xml.Name{Local: "type"}, "file",
  3061  			})
  3062  		} else if a.Source.Block != nil {
  3063  			start.Attr = append(start.Attr, xml.Attr{
  3064  				xml.Name{Local: "type"}, "block",
  3065  			})
  3066  		} else if a.Source.Dir != nil {
  3067  			start.Attr = append(start.Attr, xml.Attr{
  3068  				xml.Name{Local: "type"}, "dir",
  3069  			})
  3070  		} else if a.Source.Network != nil {
  3071  			start.Attr = append(start.Attr, xml.Attr{
  3072  				xml.Name{Local: "type"}, "network",
  3073  			})
  3074  		} else if a.Source.Volume != nil {
  3075  			start.Attr = append(start.Attr, xml.Attr{
  3076  				xml.Name{Local: "type"}, "volume",
  3077  			})
  3078  		} else if a.Source.NVME != nil {
  3079  			start.Attr = append(start.Attr, xml.Attr{
  3080  				xml.Name{Local: "type"}, "nvme",
  3081  			})
  3082  		}
  3083  	}
  3084  	disk := domainDisk(*a)
  3085  	return e.EncodeElement(disk, start)
  3086  }
  3087  
  3088  func (a *DomainDisk) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3089  	typ, ok := getAttr(start.Attr, "type")
  3090  	if !ok {
  3091  		typ = "file"
  3092  	}
  3093  	a.Source = &DomainDiskSource{}
  3094  	if typ == "file" {
  3095  		a.Source.File = &DomainDiskSourceFile{}
  3096  	} else if typ == "block" {
  3097  		a.Source.Block = &DomainDiskSourceBlock{}
  3098  	} else if typ == "network" {
  3099  		a.Source.Network = &DomainDiskSourceNetwork{}
  3100  	} else if typ == "dir" {
  3101  		a.Source.Dir = &DomainDiskSourceDir{}
  3102  	} else if typ == "volume" {
  3103  		a.Source.Volume = &DomainDiskSourceVolume{}
  3104  	} else if typ == "nvme" {
  3105  		a.Source.NVME = &DomainDiskSourceNVME{}
  3106  	}
  3107  	disk := domainDisk(*a)
  3108  	err := d.DecodeElement(&disk, &start)
  3109  	if err != nil {
  3110  		return err
  3111  	}
  3112  	*a = DomainDisk(disk)
  3113  	return nil
  3114  }
  3115  
  3116  func (d *DomainDisk) Unmarshal(doc string) error {
  3117  	return xml.Unmarshal([]byte(doc), d)
  3118  }
  3119  
  3120  func (d *DomainDisk) Marshal() (string, error) {
  3121  	doc, err := xml.MarshalIndent(d, "", "  ")
  3122  	if err != nil {
  3123  		return "", err
  3124  	}
  3125  	return string(doc), nil
  3126  }
  3127  
  3128  func (a *DomainFilesystemSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3129  	if a.Mount != nil {
  3130  		return e.EncodeElement(a.Mount, start)
  3131  	} else if a.Block != nil {
  3132  		return e.EncodeElement(a.Block, start)
  3133  	} else if a.File != nil {
  3134  		return e.EncodeElement(a.File, start)
  3135  	} else if a.Template != nil {
  3136  		return e.EncodeElement(a.Template, start)
  3137  	} else if a.RAM != nil {
  3138  		return e.EncodeElement(a.RAM, start)
  3139  	} else if a.Bind != nil {
  3140  		return e.EncodeElement(a.Bind, start)
  3141  	} else if a.Volume != nil {
  3142  		return e.EncodeElement(a.Volume, start)
  3143  	}
  3144  	return nil
  3145  }
  3146  
  3147  func (a *DomainFilesystemSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3148  	if a.Mount != nil {
  3149  		return d.DecodeElement(a.Mount, &start)
  3150  	} else if a.Block != nil {
  3151  		return d.DecodeElement(a.Block, &start)
  3152  	} else if a.File != nil {
  3153  		return d.DecodeElement(a.File, &start)
  3154  	} else if a.Template != nil {
  3155  		return d.DecodeElement(a.Template, &start)
  3156  	} else if a.RAM != nil {
  3157  		return d.DecodeElement(a.RAM, &start)
  3158  	} else if a.Bind != nil {
  3159  		return d.DecodeElement(a.Bind, &start)
  3160  	} else if a.Volume != nil {
  3161  		return d.DecodeElement(a.Volume, &start)
  3162  	}
  3163  	return nil
  3164  }
  3165  
  3166  type domainFilesystem DomainFilesystem
  3167  
  3168  func (a *DomainFilesystem) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3169  	start.Name.Local = "filesystem"
  3170  	if a.Source != nil {
  3171  		if a.Source.Mount != nil {
  3172  			start.Attr = append(start.Attr, xml.Attr{
  3173  				xml.Name{Local: "type"}, "mount",
  3174  			})
  3175  		} else if a.Source.Block != nil {
  3176  			start.Attr = append(start.Attr, xml.Attr{
  3177  				xml.Name{Local: "type"}, "block",
  3178  			})
  3179  		} else if a.Source.File != nil {
  3180  			start.Attr = append(start.Attr, xml.Attr{
  3181  				xml.Name{Local: "type"}, "file",
  3182  			})
  3183  		} else if a.Source.Template != nil {
  3184  			start.Attr = append(start.Attr, xml.Attr{
  3185  				xml.Name{Local: "type"}, "template",
  3186  			})
  3187  		} else if a.Source.RAM != nil {
  3188  			start.Attr = append(start.Attr, xml.Attr{
  3189  				xml.Name{Local: "type"}, "ram",
  3190  			})
  3191  		} else if a.Source.Bind != nil {
  3192  			start.Attr = append(start.Attr, xml.Attr{
  3193  				xml.Name{Local: "type"}, "bind",
  3194  			})
  3195  		} else if a.Source.Volume != nil {
  3196  			start.Attr = append(start.Attr, xml.Attr{
  3197  				xml.Name{Local: "type"}, "volume",
  3198  			})
  3199  		}
  3200  	}
  3201  	fs := domainFilesystem(*a)
  3202  	return e.EncodeElement(fs, start)
  3203  }
  3204  
  3205  func (a *DomainFilesystem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3206  	typ, ok := getAttr(start.Attr, "type")
  3207  	if !ok {
  3208  		typ = "mount"
  3209  	}
  3210  	a.Source = &DomainFilesystemSource{}
  3211  	if typ == "mount" {
  3212  		a.Source.Mount = &DomainFilesystemSourceMount{}
  3213  	} else if typ == "block" {
  3214  		a.Source.Block = &DomainFilesystemSourceBlock{}
  3215  	} else if typ == "file" {
  3216  		a.Source.File = &DomainFilesystemSourceFile{}
  3217  	} else if typ == "template" {
  3218  		a.Source.Template = &DomainFilesystemSourceTemplate{}
  3219  	} else if typ == "ram" {
  3220  		a.Source.RAM = &DomainFilesystemSourceRAM{}
  3221  	} else if typ == "bind" {
  3222  		a.Source.Bind = &DomainFilesystemSourceBind{}
  3223  	} else if typ == "volume" {
  3224  		a.Source.Volume = &DomainFilesystemSourceVolume{}
  3225  	}
  3226  	fs := domainFilesystem(*a)
  3227  	err := d.DecodeElement(&fs, &start)
  3228  	if err != nil {
  3229  		return err
  3230  	}
  3231  	*a = DomainFilesystem(fs)
  3232  	return nil
  3233  }
  3234  
  3235  func (d *DomainFilesystem) Unmarshal(doc string) error {
  3236  	return xml.Unmarshal([]byte(doc), d)
  3237  }
  3238  
  3239  func (d *DomainFilesystem) Marshal() (string, error) {
  3240  	doc, err := xml.MarshalIndent(d, "", "  ")
  3241  	if err != nil {
  3242  		return "", err
  3243  	}
  3244  	return string(doc), nil
  3245  }
  3246  
  3247  func (a *DomainInterfaceVirtualPortParams) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3248  	start.Name.Local = "parameters"
  3249  	if a.Any != nil {
  3250  		return e.EncodeElement(a.Any, start)
  3251  	} else if a.VEPA8021QBG != nil {
  3252  		return e.EncodeElement(a.VEPA8021QBG, start)
  3253  	} else if a.VNTag8011QBH != nil {
  3254  		return e.EncodeElement(a.VNTag8011QBH, start)
  3255  	} else if a.OpenVSwitch != nil {
  3256  		return e.EncodeElement(a.OpenVSwitch, start)
  3257  	} else if a.MidoNet != nil {
  3258  		return e.EncodeElement(a.MidoNet, start)
  3259  	}
  3260  	return nil
  3261  }
  3262  
  3263  func (a *DomainInterfaceVirtualPortParams) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3264  	if a.Any != nil {
  3265  		return d.DecodeElement(a.Any, &start)
  3266  	} else if a.VEPA8021QBG != nil {
  3267  		return d.DecodeElement(a.VEPA8021QBG, &start)
  3268  	} else if a.VNTag8011QBH != nil {
  3269  		return d.DecodeElement(a.VNTag8011QBH, &start)
  3270  	} else if a.OpenVSwitch != nil {
  3271  		return d.DecodeElement(a.OpenVSwitch, &start)
  3272  	} else if a.MidoNet != nil {
  3273  		return d.DecodeElement(a.MidoNet, &start)
  3274  	}
  3275  	return nil
  3276  }
  3277  
  3278  type domainInterfaceVirtualPort DomainInterfaceVirtualPort
  3279  
  3280  func (a *DomainInterfaceVirtualPort) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3281  	start.Name.Local = "virtualport"
  3282  	if a.Params != nil {
  3283  		if a.Params.Any != nil {
  3284  			/* no type attr wanted */
  3285  		} else if a.Params.VEPA8021QBG != nil {
  3286  			start.Attr = append(start.Attr, xml.Attr{
  3287  				xml.Name{Local: "type"}, "802.1Qbg",
  3288  			})
  3289  		} else if a.Params.VNTag8011QBH != nil {
  3290  			start.Attr = append(start.Attr, xml.Attr{
  3291  				xml.Name{Local: "type"}, "802.1Qbh",
  3292  			})
  3293  		} else if a.Params.OpenVSwitch != nil {
  3294  			start.Attr = append(start.Attr, xml.Attr{
  3295  				xml.Name{Local: "type"}, "openvswitch",
  3296  			})
  3297  		} else if a.Params.MidoNet != nil {
  3298  			start.Attr = append(start.Attr, xml.Attr{
  3299  				xml.Name{Local: "type"}, "midonet",
  3300  			})
  3301  		}
  3302  	}
  3303  	vp := domainInterfaceVirtualPort(*a)
  3304  	return e.EncodeElement(&vp, start)
  3305  }
  3306  
  3307  func (a *DomainInterfaceVirtualPort) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3308  	typ, ok := getAttr(start.Attr, "type")
  3309  	a.Params = &DomainInterfaceVirtualPortParams{}
  3310  	if !ok {
  3311  		var any DomainInterfaceVirtualPortParamsAny
  3312  		a.Params.Any = &any
  3313  	} else if typ == "802.1Qbg" {
  3314  		var vepa DomainInterfaceVirtualPortParamsVEPA8021QBG
  3315  		a.Params.VEPA8021QBG = &vepa
  3316  	} else if typ == "802.1Qbh" {
  3317  		var vntag DomainInterfaceVirtualPortParamsVNTag8021QBH
  3318  		a.Params.VNTag8011QBH = &vntag
  3319  	} else if typ == "openvswitch" {
  3320  		var ovs DomainInterfaceVirtualPortParamsOpenVSwitch
  3321  		a.Params.OpenVSwitch = &ovs
  3322  	} else if typ == "midonet" {
  3323  		var mido DomainInterfaceVirtualPortParamsMidoNet
  3324  		a.Params.MidoNet = &mido
  3325  	}
  3326  
  3327  	vp := domainInterfaceVirtualPort(*a)
  3328  	err := d.DecodeElement(&vp, &start)
  3329  	if err != nil {
  3330  		return err
  3331  	}
  3332  	*a = DomainInterfaceVirtualPort(vp)
  3333  	return nil
  3334  }
  3335  
  3336  func (a *DomainInterfaceSourceHostdev) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3337  	e.EncodeToken(start)
  3338  	if a.PCI != nil {
  3339  		addr := xml.StartElement{
  3340  			Name: xml.Name{Local: "address"},
  3341  		}
  3342  		addr.Attr = append(addr.Attr, xml.Attr{
  3343  			xml.Name{Local: "type"}, "pci",
  3344  		})
  3345  		e.EncodeElement(a.PCI.Address, addr)
  3346  	} else if a.USB != nil {
  3347  		addr := xml.StartElement{
  3348  			Name: xml.Name{Local: "address"},
  3349  		}
  3350  		addr.Attr = append(addr.Attr, xml.Attr{
  3351  			xml.Name{Local: "type"}, "usb",
  3352  		})
  3353  		e.EncodeElement(a.USB.Address, addr)
  3354  	}
  3355  	e.EncodeToken(start.End())
  3356  	return nil
  3357  }
  3358  
  3359  func (a *DomainInterfaceSourceHostdev) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3360  	for {
  3361  		tok, err := d.Token()
  3362  		if err != nil {
  3363  			if err == io.EOF {
  3364  				break
  3365  			}
  3366  			return err
  3367  		}
  3368  
  3369  		switch tok := tok.(type) {
  3370  		case xml.StartElement:
  3371  			if tok.Name.Local == "address" {
  3372  				typ, ok := getAttr(tok.Attr, "type")
  3373  				if !ok {
  3374  					return fmt.Errorf("Missing hostdev address type attribute")
  3375  				}
  3376  
  3377  				if typ == "pci" {
  3378  					a.PCI = &DomainHostdevSubsysPCISource{
  3379  						&DomainAddressPCI{},
  3380  					}
  3381  					err := d.DecodeElement(a.PCI.Address, &tok)
  3382  					if err != nil {
  3383  						return err
  3384  					}
  3385  				} else if typ == "usb" {
  3386  					a.USB = &DomainHostdevSubsysUSBSource{
  3387  						&DomainAddressUSB{},
  3388  					}
  3389  					err := d.DecodeElement(a.USB, &tok)
  3390  					if err != nil {
  3391  						return err
  3392  					}
  3393  				}
  3394  			}
  3395  		}
  3396  	}
  3397  	d.Skip()
  3398  	return nil
  3399  }
  3400  
  3401  func (a *DomainInterfaceSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3402  	if a.User != nil {
  3403  		/* We don't want an empty <source></source> for User mode */
  3404  		//return e.EncodeElement(a.User, start)
  3405  		return nil
  3406  	} else if a.Ethernet != nil {
  3407  		if len(a.Ethernet.IP) > 0 && len(a.Ethernet.Route) > 0 {
  3408  			return e.EncodeElement(a.Ethernet, start)
  3409  		}
  3410  		return nil
  3411  	} else if a.VHostUser != nil {
  3412  		typ := getChardevSourceType(a.VHostUser)
  3413  		if typ != "" {
  3414  			start.Attr = append(start.Attr, xml.Attr{
  3415  				xml.Name{Local: "type"}, typ,
  3416  			})
  3417  		}
  3418  		return e.EncodeElement(a.VHostUser, start)
  3419  	} else if a.Server != nil {
  3420  		return e.EncodeElement(a.Server, start)
  3421  	} else if a.Client != nil {
  3422  		return e.EncodeElement(a.Client, start)
  3423  	} else if a.MCast != nil {
  3424  		return e.EncodeElement(a.MCast, start)
  3425  	} else if a.Network != nil {
  3426  		return e.EncodeElement(a.Network, start)
  3427  	} else if a.Bridge != nil {
  3428  		return e.EncodeElement(a.Bridge, start)
  3429  	} else if a.Internal != nil {
  3430  		return e.EncodeElement(a.Internal, start)
  3431  	} else if a.Direct != nil {
  3432  		return e.EncodeElement(a.Direct, start)
  3433  	} else if a.Hostdev != nil {
  3434  		return e.EncodeElement(a.Hostdev, start)
  3435  	} else if a.UDP != nil {
  3436  		return e.EncodeElement(a.UDP, start)
  3437  	}
  3438  	return nil
  3439  }
  3440  
  3441  func (a *DomainInterfaceSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3442  	if a.User != nil {
  3443  		return d.DecodeElement(a.User, &start)
  3444  	} else if a.Ethernet != nil {
  3445  		return d.DecodeElement(a.Ethernet, &start)
  3446  	} else if a.VHostUser != nil {
  3447  		typ, ok := getAttr(start.Attr, "type")
  3448  		if !ok {
  3449  			typ = "pty"
  3450  		}
  3451  		a.VHostUser = createChardevSource(typ)
  3452  		return d.DecodeElement(a.VHostUser, &start)
  3453  	} else if a.Server != nil {
  3454  		return d.DecodeElement(a.Server, &start)
  3455  	} else if a.Client != nil {
  3456  		return d.DecodeElement(a.Client, &start)
  3457  	} else if a.MCast != nil {
  3458  		return d.DecodeElement(a.MCast, &start)
  3459  	} else if a.Network != nil {
  3460  		return d.DecodeElement(a.Network, &start)
  3461  	} else if a.Bridge != nil {
  3462  		return d.DecodeElement(a.Bridge, &start)
  3463  	} else if a.Internal != nil {
  3464  		return d.DecodeElement(a.Internal, &start)
  3465  	} else if a.Direct != nil {
  3466  		return d.DecodeElement(a.Direct, &start)
  3467  	} else if a.Hostdev != nil {
  3468  		return d.DecodeElement(a.Hostdev, &start)
  3469  	} else if a.UDP != nil {
  3470  		return d.DecodeElement(a.UDP, &start)
  3471  	}
  3472  	return nil
  3473  }
  3474  
  3475  type domainInterface DomainInterface
  3476  
  3477  func (a *DomainInterface) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3478  	start.Name.Local = "interface"
  3479  	if a.Source != nil {
  3480  		if a.Source.User != nil {
  3481  			start.Attr = append(start.Attr, xml.Attr{
  3482  				xml.Name{Local: "type"}, "user",
  3483  			})
  3484  		} else if a.Source.Ethernet != nil {
  3485  			start.Attr = append(start.Attr, xml.Attr{
  3486  				xml.Name{Local: "type"}, "ethernet",
  3487  			})
  3488  		} else if a.Source.VHostUser != nil {
  3489  			start.Attr = append(start.Attr, xml.Attr{
  3490  				xml.Name{Local: "type"}, "vhostuser",
  3491  			})
  3492  		} else if a.Source.Server != nil {
  3493  			start.Attr = append(start.Attr, xml.Attr{
  3494  				xml.Name{Local: "type"}, "server",
  3495  			})
  3496  		} else if a.Source.Client != nil {
  3497  			start.Attr = append(start.Attr, xml.Attr{
  3498  				xml.Name{Local: "type"}, "client",
  3499  			})
  3500  		} else if a.Source.MCast != nil {
  3501  			start.Attr = append(start.Attr, xml.Attr{
  3502  				xml.Name{Local: "type"}, "mcast",
  3503  			})
  3504  		} else if a.Source.Network != nil {
  3505  			start.Attr = append(start.Attr, xml.Attr{
  3506  				xml.Name{Local: "type"}, "network",
  3507  			})
  3508  		} else if a.Source.Bridge != nil {
  3509  			start.Attr = append(start.Attr, xml.Attr{
  3510  				xml.Name{Local: "type"}, "bridge",
  3511  			})
  3512  		} else if a.Source.Internal != nil {
  3513  			start.Attr = append(start.Attr, xml.Attr{
  3514  				xml.Name{Local: "type"}, "internal",
  3515  			})
  3516  		} else if a.Source.Direct != nil {
  3517  			start.Attr = append(start.Attr, xml.Attr{
  3518  				xml.Name{Local: "type"}, "direct",
  3519  			})
  3520  		} else if a.Source.Hostdev != nil {
  3521  			start.Attr = append(start.Attr, xml.Attr{
  3522  				xml.Name{Local: "type"}, "hostdev",
  3523  			})
  3524  		} else if a.Source.UDP != nil {
  3525  			start.Attr = append(start.Attr, xml.Attr{
  3526  				xml.Name{Local: "type"}, "udp",
  3527  			})
  3528  		}
  3529  	}
  3530  	fs := domainInterface(*a)
  3531  	return e.EncodeElement(fs, start)
  3532  }
  3533  
  3534  func (a *DomainInterface) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3535  	typ, ok := getAttr(start.Attr, "type")
  3536  	if !ok {
  3537  		return fmt.Errorf("Missing interface type attribute")
  3538  	}
  3539  	a.Source = &DomainInterfaceSource{}
  3540  	if typ == "user" {
  3541  		a.Source.User = &DomainInterfaceSourceUser{}
  3542  	} else if typ == "ethernet" {
  3543  		a.Source.Ethernet = &DomainInterfaceSourceEthernet{}
  3544  	} else if typ == "vhostuser" {
  3545  		a.Source.VHostUser = &DomainChardevSource{}
  3546  	} else if typ == "server" {
  3547  		a.Source.Server = &DomainInterfaceSourceServer{}
  3548  	} else if typ == "client" {
  3549  		a.Source.Client = &DomainInterfaceSourceClient{}
  3550  	} else if typ == "mcast" {
  3551  		a.Source.MCast = &DomainInterfaceSourceMCast{}
  3552  	} else if typ == "network" {
  3553  		a.Source.Network = &DomainInterfaceSourceNetwork{}
  3554  	} else if typ == "bridge" {
  3555  		a.Source.Bridge = &DomainInterfaceSourceBridge{}
  3556  	} else if typ == "internal" {
  3557  		a.Source.Internal = &DomainInterfaceSourceInternal{}
  3558  	} else if typ == "direct" {
  3559  		a.Source.Direct = &DomainInterfaceSourceDirect{}
  3560  	} else if typ == "hostdev" {
  3561  		a.Source.Hostdev = &DomainInterfaceSourceHostdev{}
  3562  	} else if typ == "udp" {
  3563  		a.Source.UDP = &DomainInterfaceSourceUDP{}
  3564  	}
  3565  	fs := domainInterface(*a)
  3566  	err := d.DecodeElement(&fs, &start)
  3567  	if err != nil {
  3568  		return err
  3569  	}
  3570  	*a = DomainInterface(fs)
  3571  	return nil
  3572  }
  3573  
  3574  func (d *DomainInterface) Unmarshal(doc string) error {
  3575  	return xml.Unmarshal([]byte(doc), d)
  3576  }
  3577  
  3578  func (d *DomainInterface) Marshal() (string, error) {
  3579  	doc, err := xml.MarshalIndent(d, "", "  ")
  3580  	if err != nil {
  3581  		return "", err
  3582  	}
  3583  	return string(doc), nil
  3584  }
  3585  
  3586  type domainSmartcard DomainSmartcard
  3587  
  3588  func (a *DomainSmartcard) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3589  	start.Name.Local = "smartcard"
  3590  	if a.Passthrough != nil {
  3591  		start.Attr = append(start.Attr, xml.Attr{
  3592  			xml.Name{Local: "mode"}, "passthrough",
  3593  		})
  3594  		typ := getChardevSourceType(a.Passthrough)
  3595  		if typ != "" {
  3596  			start.Attr = append(start.Attr, xml.Attr{
  3597  				xml.Name{Local: "type"}, typ,
  3598  			})
  3599  		}
  3600  	} else if a.Host != nil {
  3601  		start.Attr = append(start.Attr, xml.Attr{
  3602  			xml.Name{Local: "mode"}, "host",
  3603  		})
  3604  	} else if len(a.HostCerts) != 0 {
  3605  		start.Attr = append(start.Attr, xml.Attr{
  3606  			xml.Name{Local: "mode"}, "host-certificates",
  3607  		})
  3608  	}
  3609  	smartcard := domainSmartcard(*a)
  3610  	return e.EncodeElement(smartcard, start)
  3611  }
  3612  
  3613  func (a *DomainSmartcard) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3614  	mode, ok := getAttr(start.Attr, "mode")
  3615  	if !ok {
  3616  		return fmt.Errorf("Missing mode on smartcard device")
  3617  	}
  3618  	if mode == "host" {
  3619  		a.Host = &DomainSmartcardHost{}
  3620  	} else if mode == "passthrough" {
  3621  		typ, ok := getAttr(start.Attr, "type")
  3622  		if !ok {
  3623  			typ = "pty"
  3624  		}
  3625  		a.Passthrough = createChardevSource(typ)
  3626  	}
  3627  	smartcard := domainSmartcard(*a)
  3628  	err := d.DecodeElement(&smartcard, &start)
  3629  	if err != nil {
  3630  		return err
  3631  	}
  3632  	*a = DomainSmartcard(smartcard)
  3633  	return nil
  3634  }
  3635  
  3636  func (d *DomainSmartcard) Unmarshal(doc string) error {
  3637  	return xml.Unmarshal([]byte(doc), d)
  3638  }
  3639  
  3640  func (d *DomainSmartcard) Marshal() (string, error) {
  3641  	doc, err := xml.MarshalIndent(d, "", "  ")
  3642  	if err != nil {
  3643  		return "", err
  3644  	}
  3645  	return string(doc), nil
  3646  }
  3647  
  3648  func (a *DomainTPMBackend) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3649  	start.Name.Local = "backend"
  3650  	if a.Passthrough != nil {
  3651  		start.Attr = append(start.Attr, xml.Attr{
  3652  			xml.Name{Local: "type"}, "passthrough",
  3653  		})
  3654  		err := e.EncodeElement(a.Passthrough, start)
  3655  		if err != nil {
  3656  			return err
  3657  		}
  3658  	} else if a.Emulator != nil {
  3659  		start.Attr = append(start.Attr, xml.Attr{
  3660  			xml.Name{Local: "type"}, "emulator",
  3661  		})
  3662  		err := e.EncodeElement(a.Emulator, start)
  3663  		if err != nil {
  3664  			return err
  3665  		}
  3666  	}
  3667  	return nil
  3668  }
  3669  
  3670  func (a *DomainTPMBackend) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3671  	typ, ok := getAttr(start.Attr, "type")
  3672  	if !ok {
  3673  		return fmt.Errorf("Missing TPM backend type")
  3674  	}
  3675  	if typ == "passthrough" {
  3676  		a.Passthrough = &DomainTPMBackendPassthrough{}
  3677  		err := d.DecodeElement(a.Passthrough, &start)
  3678  		if err != nil {
  3679  			return err
  3680  		}
  3681  	} else if typ == "emulator" {
  3682  		a.Emulator = &DomainTPMBackendEmulator{}
  3683  		err := d.DecodeElement(a.Emulator, &start)
  3684  		if err != nil {
  3685  			return err
  3686  		}
  3687  	} else {
  3688  		d.Skip()
  3689  	}
  3690  	return nil
  3691  }
  3692  
  3693  func (d *DomainTPM) Unmarshal(doc string) error {
  3694  	return xml.Unmarshal([]byte(doc), d)
  3695  }
  3696  
  3697  func (d *DomainTPM) Marshal() (string, error) {
  3698  	doc, err := xml.MarshalIndent(d, "", "  ")
  3699  	if err != nil {
  3700  		return "", err
  3701  	}
  3702  	return string(doc), nil
  3703  }
  3704  
  3705  func (d *DomainShmem) Unmarshal(doc string) error {
  3706  	return xml.Unmarshal([]byte(doc), d)
  3707  }
  3708  
  3709  func (d *DomainShmem) Marshal() (string, error) {
  3710  	doc, err := xml.MarshalIndent(d, "", "  ")
  3711  	if err != nil {
  3712  		return "", err
  3713  	}
  3714  	return string(doc), nil
  3715  }
  3716  
  3717  func getChardevSourceType(s *DomainChardevSource) string {
  3718  	if s.Null != nil {
  3719  		return "null"
  3720  	} else if s.VC != nil {
  3721  		return "vc"
  3722  	} else if s.Pty != nil {
  3723  		return "pty"
  3724  	} else if s.Dev != nil {
  3725  		return "dev"
  3726  	} else if s.File != nil {
  3727  		return "file"
  3728  	} else if s.Pipe != nil {
  3729  		return "pipe"
  3730  	} else if s.StdIO != nil {
  3731  		return "stdio"
  3732  	} else if s.UDP != nil {
  3733  		return "udp"
  3734  	} else if s.TCP != nil {
  3735  		return "tcp"
  3736  	} else if s.UNIX != nil {
  3737  		return "unix"
  3738  	} else if s.SpiceVMC != nil {
  3739  		return "spicevmc"
  3740  	} else if s.SpicePort != nil {
  3741  		return "spiceport"
  3742  	} else if s.NMDM != nil {
  3743  		return "nmdm"
  3744  	}
  3745  	return ""
  3746  }
  3747  
  3748  func createChardevSource(typ string) *DomainChardevSource {
  3749  	switch typ {
  3750  	case "null":
  3751  		return &DomainChardevSource{
  3752  			Null: &DomainChardevSourceNull{},
  3753  		}
  3754  	case "vc":
  3755  		return &DomainChardevSource{
  3756  			VC: &DomainChardevSourceVC{},
  3757  		}
  3758  	case "pty":
  3759  		return &DomainChardevSource{
  3760  			Pty: &DomainChardevSourcePty{},
  3761  		}
  3762  	case "dev":
  3763  		return &DomainChardevSource{
  3764  			Dev: &DomainChardevSourceDev{},
  3765  		}
  3766  	case "file":
  3767  		return &DomainChardevSource{
  3768  			File: &DomainChardevSourceFile{},
  3769  		}
  3770  	case "pipe":
  3771  		return &DomainChardevSource{
  3772  			Pipe: &DomainChardevSourcePipe{},
  3773  		}
  3774  	case "stdio":
  3775  		return &DomainChardevSource{
  3776  			StdIO: &DomainChardevSourceStdIO{},
  3777  		}
  3778  	case "udp":
  3779  		return &DomainChardevSource{
  3780  			UDP: &DomainChardevSourceUDP{},
  3781  		}
  3782  	case "tcp":
  3783  		return &DomainChardevSource{
  3784  			TCP: &DomainChardevSourceTCP{},
  3785  		}
  3786  	case "unix":
  3787  		return &DomainChardevSource{
  3788  			UNIX: &DomainChardevSourceUNIX{},
  3789  		}
  3790  	case "spicevmc":
  3791  		return &DomainChardevSource{
  3792  			SpiceVMC: &DomainChardevSourceSpiceVMC{},
  3793  		}
  3794  	case "spiceport":
  3795  		return &DomainChardevSource{
  3796  			SpicePort: &DomainChardevSourceSpicePort{},
  3797  		}
  3798  	case "nmdm":
  3799  		return &DomainChardevSource{
  3800  			NMDM: &DomainChardevSourceNMDM{},
  3801  		}
  3802  	}
  3803  
  3804  	return nil
  3805  }
  3806  
  3807  type domainChardevSourceUDPFlat struct {
  3808  	Mode    string `xml:"mode,attr"`
  3809  	Host    string `xml:"host,attr,omitempty"`
  3810  	Service string `xml:"service,attr,omitempty"`
  3811  }
  3812  
  3813  func (a *DomainChardevSource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3814  	if a.Null != nil {
  3815  		return nil
  3816  	} else if a.VC != nil {
  3817  		return nil
  3818  	} else if a.Pty != nil {
  3819  		if a.Pty.Path != "" {
  3820  			return e.EncodeElement(a.Pty, start)
  3821  		}
  3822  		return nil
  3823  	} else if a.Dev != nil {
  3824  		return e.EncodeElement(a.Dev, start)
  3825  	} else if a.File != nil {
  3826  		return e.EncodeElement(a.File, start)
  3827  	} else if a.Pipe != nil {
  3828  		return e.EncodeElement(a.Pipe, start)
  3829  	} else if a.StdIO != nil {
  3830  		return nil
  3831  	} else if a.UDP != nil {
  3832  		srcs := []domainChardevSourceUDPFlat{
  3833  			domainChardevSourceUDPFlat{
  3834  				Mode:    "bind",
  3835  				Host:    a.UDP.BindHost,
  3836  				Service: a.UDP.BindService,
  3837  			},
  3838  			domainChardevSourceUDPFlat{
  3839  				Mode:    "connect",
  3840  				Host:    a.UDP.ConnectHost,
  3841  				Service: a.UDP.ConnectService,
  3842  			},
  3843  		}
  3844  		if srcs[0].Host != "" || srcs[0].Service != "" {
  3845  			err := e.EncodeElement(&srcs[0], start)
  3846  			if err != nil {
  3847  				return err
  3848  			}
  3849  		}
  3850  		if srcs[1].Host != "" || srcs[1].Service != "" {
  3851  			err := e.EncodeElement(&srcs[1], start)
  3852  			if err != nil {
  3853  				return err
  3854  			}
  3855  		}
  3856  	} else if a.TCP != nil {
  3857  		return e.EncodeElement(a.TCP, start)
  3858  	} else if a.UNIX != nil {
  3859  		if a.UNIX.Path == "" && a.UNIX.Mode == "" {
  3860  			return nil
  3861  		}
  3862  		return e.EncodeElement(a.UNIX, start)
  3863  	} else if a.SpiceVMC != nil {
  3864  		return nil
  3865  	} else if a.SpicePort != nil {
  3866  		return e.EncodeElement(a.SpicePort, start)
  3867  	} else if a.NMDM != nil {
  3868  		return e.EncodeElement(a.NMDM, start)
  3869  	}
  3870  	return nil
  3871  }
  3872  
  3873  func (a *DomainChardevSource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3874  	if a.Null != nil {
  3875  		d.Skip()
  3876  		return nil
  3877  	} else if a.VC != nil {
  3878  		d.Skip()
  3879  		return nil
  3880  	} else if a.Pty != nil {
  3881  		return d.DecodeElement(a.Pty, &start)
  3882  	} else if a.Dev != nil {
  3883  		return d.DecodeElement(a.Dev, &start)
  3884  	} else if a.File != nil {
  3885  		return d.DecodeElement(a.File, &start)
  3886  	} else if a.Pipe != nil {
  3887  		return d.DecodeElement(a.Pipe, &start)
  3888  	} else if a.StdIO != nil {
  3889  		d.Skip()
  3890  		return nil
  3891  	} else if a.UDP != nil {
  3892  		src := domainChardevSourceUDPFlat{}
  3893  		err := d.DecodeElement(&src, &start)
  3894  		if src.Mode == "connect" {
  3895  			a.UDP.ConnectHost = src.Host
  3896  			a.UDP.ConnectService = src.Service
  3897  		} else {
  3898  			a.UDP.BindHost = src.Host
  3899  			a.UDP.BindService = src.Service
  3900  		}
  3901  		return err
  3902  	} else if a.TCP != nil {
  3903  		return d.DecodeElement(a.TCP, &start)
  3904  	} else if a.UNIX != nil {
  3905  		return d.DecodeElement(a.UNIX, &start)
  3906  	} else if a.SpiceVMC != nil {
  3907  		d.Skip()
  3908  		return nil
  3909  	} else if a.SpicePort != nil {
  3910  		return d.DecodeElement(a.SpicePort, &start)
  3911  	} else if a.NMDM != nil {
  3912  		return d.DecodeElement(a.NMDM, &start)
  3913  	}
  3914  	return nil
  3915  }
  3916  
  3917  type domainConsole DomainConsole
  3918  
  3919  func (a *DomainConsole) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3920  	start.Name.Local = "console"
  3921  	if a.Source != nil {
  3922  		typ := getChardevSourceType(a.Source)
  3923  		if typ != "" {
  3924  			start.Attr = append(start.Attr, xml.Attr{
  3925  				xml.Name{Local: "type"}, typ,
  3926  			})
  3927  		}
  3928  	}
  3929  	fs := domainConsole(*a)
  3930  	return e.EncodeElement(fs, start)
  3931  }
  3932  
  3933  func (a *DomainConsole) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3934  	typ, ok := getAttr(start.Attr, "type")
  3935  	if !ok {
  3936  		typ = "pty"
  3937  	}
  3938  	a.Source = createChardevSource(typ)
  3939  	con := domainConsole(*a)
  3940  	err := d.DecodeElement(&con, &start)
  3941  	if err != nil {
  3942  		return err
  3943  	}
  3944  	*a = DomainConsole(con)
  3945  	return nil
  3946  }
  3947  
  3948  func (d *DomainConsole) Unmarshal(doc string) error {
  3949  	return xml.Unmarshal([]byte(doc), d)
  3950  }
  3951  
  3952  func (d *DomainConsole) Marshal() (string, error) {
  3953  	doc, err := xml.MarshalIndent(d, "", "  ")
  3954  	if err != nil {
  3955  		return "", err
  3956  	}
  3957  	return string(doc), nil
  3958  }
  3959  
  3960  type domainSerial DomainSerial
  3961  
  3962  func (a *DomainSerial) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  3963  	start.Name.Local = "serial"
  3964  	if a.Source != nil {
  3965  		typ := getChardevSourceType(a.Source)
  3966  		if typ != "" {
  3967  			start.Attr = append(start.Attr, xml.Attr{
  3968  				xml.Name{Local: "type"}, typ,
  3969  			})
  3970  		}
  3971  	}
  3972  	s := domainSerial(*a)
  3973  	return e.EncodeElement(s, start)
  3974  }
  3975  
  3976  func (a *DomainSerial) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  3977  	typ, ok := getAttr(start.Attr, "type")
  3978  	if !ok {
  3979  		typ = "pty"
  3980  	}
  3981  	a.Source = createChardevSource(typ)
  3982  	con := domainSerial(*a)
  3983  	err := d.DecodeElement(&con, &start)
  3984  	if err != nil {
  3985  		return err
  3986  	}
  3987  	*a = DomainSerial(con)
  3988  	return nil
  3989  }
  3990  
  3991  func (d *DomainSerial) Unmarshal(doc string) error {
  3992  	return xml.Unmarshal([]byte(doc), d)
  3993  }
  3994  
  3995  func (d *DomainSerial) Marshal() (string, error) {
  3996  	doc, err := xml.MarshalIndent(d, "", "  ")
  3997  	if err != nil {
  3998  		return "", err
  3999  	}
  4000  	return string(doc), nil
  4001  }
  4002  
  4003  type domainParallel DomainParallel
  4004  
  4005  func (a *DomainParallel) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4006  	start.Name.Local = "parallel"
  4007  	if a.Source != nil {
  4008  		typ := getChardevSourceType(a.Source)
  4009  		if typ != "" {
  4010  			start.Attr = append(start.Attr, xml.Attr{
  4011  				xml.Name{Local: "type"}, typ,
  4012  			})
  4013  		}
  4014  	}
  4015  	s := domainParallel(*a)
  4016  	return e.EncodeElement(s, start)
  4017  }
  4018  
  4019  func (a *DomainParallel) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4020  	typ, ok := getAttr(start.Attr, "type")
  4021  	if !ok {
  4022  		typ = "pty"
  4023  	}
  4024  	a.Source = createChardevSource(typ)
  4025  	con := domainParallel(*a)
  4026  	err := d.DecodeElement(&con, &start)
  4027  	if err != nil {
  4028  		return err
  4029  	}
  4030  	*a = DomainParallel(con)
  4031  	return nil
  4032  }
  4033  
  4034  func (d *DomainParallel) Unmarshal(doc string) error {
  4035  	return xml.Unmarshal([]byte(doc), d)
  4036  }
  4037  
  4038  func (d *DomainParallel) Marshal() (string, error) {
  4039  	doc, err := xml.MarshalIndent(d, "", "  ")
  4040  	if err != nil {
  4041  		return "", err
  4042  	}
  4043  	return string(doc), nil
  4044  }
  4045  
  4046  func (d *DomainInput) Unmarshal(doc string) error {
  4047  	return xml.Unmarshal([]byte(doc), d)
  4048  }
  4049  
  4050  func (d *DomainInput) Marshal() (string, error) {
  4051  	doc, err := xml.MarshalIndent(d, "", "  ")
  4052  	if err != nil {
  4053  		return "", err
  4054  	}
  4055  	return string(doc), nil
  4056  }
  4057  
  4058  func (d *DomainVideo) Unmarshal(doc string) error {
  4059  	return xml.Unmarshal([]byte(doc), d)
  4060  }
  4061  
  4062  func (d *DomainVideo) Marshal() (string, error) {
  4063  	doc, err := xml.MarshalIndent(d, "", "  ")
  4064  	if err != nil {
  4065  		return "", err
  4066  	}
  4067  	return string(doc), nil
  4068  }
  4069  
  4070  type domainChannelTarget DomainChannelTarget
  4071  
  4072  func (a *DomainChannelTarget) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4073  	if a.VirtIO != nil {
  4074  		start.Attr = append(start.Attr, xml.Attr{
  4075  			xml.Name{Local: "type"}, "virtio",
  4076  		})
  4077  		return e.EncodeElement(a.VirtIO, start)
  4078  	} else if a.Xen != nil {
  4079  		start.Attr = append(start.Attr, xml.Attr{
  4080  			xml.Name{Local: "type"}, "xen",
  4081  		})
  4082  		return e.EncodeElement(a.Xen, start)
  4083  	} else if a.GuestFWD != nil {
  4084  		start.Attr = append(start.Attr, xml.Attr{
  4085  			xml.Name{Local: "type"}, "guestfwd",
  4086  		})
  4087  		return e.EncodeElement(a.GuestFWD, start)
  4088  	}
  4089  	return nil
  4090  }
  4091  
  4092  func (a *DomainChannelTarget) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4093  	typ, ok := getAttr(start.Attr, "type")
  4094  	if !ok {
  4095  		return fmt.Errorf("Missing channel target type")
  4096  	}
  4097  	if typ == "virtio" {
  4098  		a.VirtIO = &DomainChannelTargetVirtIO{}
  4099  		return d.DecodeElement(a.VirtIO, &start)
  4100  	} else if typ == "xen" {
  4101  		a.Xen = &DomainChannelTargetXen{}
  4102  		return d.DecodeElement(a.Xen, &start)
  4103  	} else if typ == "guestfwd" {
  4104  		a.GuestFWD = &DomainChannelTargetGuestFWD{}
  4105  		return d.DecodeElement(a.GuestFWD, &start)
  4106  	}
  4107  	d.Skip()
  4108  	return nil
  4109  }
  4110  
  4111  type domainChannel DomainChannel
  4112  
  4113  func (a *DomainChannel) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4114  	start.Name.Local = "channel"
  4115  	if a.Source != nil {
  4116  		typ := getChardevSourceType(a.Source)
  4117  		if typ != "" {
  4118  			start.Attr = append(start.Attr, xml.Attr{
  4119  				xml.Name{Local: "type"}, typ,
  4120  			})
  4121  		}
  4122  	}
  4123  	fs := domainChannel(*a)
  4124  	return e.EncodeElement(fs, start)
  4125  }
  4126  
  4127  func (a *DomainChannel) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4128  	typ, ok := getAttr(start.Attr, "type")
  4129  	if !ok {
  4130  		typ = "pty"
  4131  	}
  4132  	a.Source = createChardevSource(typ)
  4133  	con := domainChannel(*a)
  4134  	err := d.DecodeElement(&con, &start)
  4135  	if err != nil {
  4136  		return err
  4137  	}
  4138  	*a = DomainChannel(con)
  4139  	return nil
  4140  }
  4141  
  4142  func (d *DomainChannel) Unmarshal(doc string) error {
  4143  	return xml.Unmarshal([]byte(doc), d)
  4144  }
  4145  
  4146  func (d *DomainChannel) Marshal() (string, error) {
  4147  	doc, err := xml.MarshalIndent(d, "", "  ")
  4148  	if err != nil {
  4149  		return "", err
  4150  	}
  4151  	return string(doc), nil
  4152  }
  4153  
  4154  func (a *DomainRedirFilterUSB) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4155  	marshalUintAttr(&start, "class", a.Class, "0x%02x")
  4156  	marshalUintAttr(&start, "vendor", a.Vendor, "0x%04x")
  4157  	marshalUintAttr(&start, "product", a.Product, "0x%04x")
  4158  	if a.Version != "" {
  4159  		start.Attr = append(start.Attr, xml.Attr{
  4160  			xml.Name{Local: "version"}, a.Version,
  4161  		})
  4162  	}
  4163  	start.Attr = append(start.Attr, xml.Attr{
  4164  		xml.Name{Local: "allow"}, a.Allow,
  4165  	})
  4166  	e.EncodeToken(start)
  4167  	e.EncodeToken(start.End())
  4168  	return nil
  4169  }
  4170  
  4171  func (a *DomainRedirFilterUSB) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4172  	for _, attr := range start.Attr {
  4173  		if attr.Name.Local == "class" && attr.Value != "-1" {
  4174  			if err := unmarshalUintAttr(attr.Value, &a.Class, 0); err != nil {
  4175  				return err
  4176  			}
  4177  		} else if attr.Name.Local == "product" && attr.Value != "-1" {
  4178  			if err := unmarshalUintAttr(attr.Value, &a.Product, 0); err != nil {
  4179  				return err
  4180  			}
  4181  		} else if attr.Name.Local == "vendor" && attr.Value != "-1" {
  4182  			if err := unmarshalUintAttr(attr.Value, &a.Vendor, 0); err != nil {
  4183  				return err
  4184  			}
  4185  		} else if attr.Name.Local == "version" && attr.Value != "-1" {
  4186  			a.Version = attr.Value
  4187  		} else if attr.Name.Local == "allow" {
  4188  			a.Allow = attr.Value
  4189  		}
  4190  	}
  4191  	d.Skip()
  4192  	return nil
  4193  }
  4194  
  4195  type domainRedirDev DomainRedirDev
  4196  
  4197  func (a *DomainRedirDev) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4198  	start.Name.Local = "redirdev"
  4199  	if a.Source != nil {
  4200  		typ := getChardevSourceType(a.Source)
  4201  		if typ != "" {
  4202  			start.Attr = append(start.Attr, xml.Attr{
  4203  				xml.Name{Local: "type"}, typ,
  4204  			})
  4205  		}
  4206  	}
  4207  	fs := domainRedirDev(*a)
  4208  	return e.EncodeElement(fs, start)
  4209  }
  4210  
  4211  func (a *DomainRedirDev) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4212  	typ, ok := getAttr(start.Attr, "type")
  4213  	if !ok {
  4214  		typ = "pty"
  4215  	}
  4216  	a.Source = createChardevSource(typ)
  4217  	con := domainRedirDev(*a)
  4218  	err := d.DecodeElement(&con, &start)
  4219  	if err != nil {
  4220  		return err
  4221  	}
  4222  	*a = DomainRedirDev(con)
  4223  	return nil
  4224  }
  4225  
  4226  func (d *DomainRedirDev) Unmarshal(doc string) error {
  4227  	return xml.Unmarshal([]byte(doc), d)
  4228  }
  4229  
  4230  func (d *DomainRedirDev) Marshal() (string, error) {
  4231  	doc, err := xml.MarshalIndent(d, "", "  ")
  4232  	if err != nil {
  4233  		return "", err
  4234  	}
  4235  	return string(doc), nil
  4236  }
  4237  
  4238  func (d *DomainMemBalloon) Unmarshal(doc string) error {
  4239  	return xml.Unmarshal([]byte(doc), d)
  4240  }
  4241  
  4242  func (d *DomainMemBalloon) Marshal() (string, error) {
  4243  	doc, err := xml.MarshalIndent(d, "", "  ")
  4244  	if err != nil {
  4245  		return "", err
  4246  	}
  4247  	return string(doc), nil
  4248  }
  4249  
  4250  func (d *DomainVSock) Unmarshal(doc string) error {
  4251  	return xml.Unmarshal([]byte(doc), d)
  4252  }
  4253  
  4254  func (d *DomainVSock) Marshal() (string, error) {
  4255  	doc, err := xml.MarshalIndent(d, "", "  ")
  4256  	if err != nil {
  4257  		return "", err
  4258  	}
  4259  	return string(doc), nil
  4260  }
  4261  
  4262  func (d *DomainSound) Unmarshal(doc string) error {
  4263  	return xml.Unmarshal([]byte(doc), d)
  4264  }
  4265  
  4266  func (d *DomainSound) Marshal() (string, error) {
  4267  	doc, err := xml.MarshalIndent(d, "", "  ")
  4268  	if err != nil {
  4269  		return "", err
  4270  	}
  4271  	return string(doc), nil
  4272  }
  4273  
  4274  type domainRNGBackendEGD DomainRNGBackendEGD
  4275  
  4276  func (a *DomainRNGBackendEGD) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4277  	start.Name.Local = "backend"
  4278  	if a.Source != nil {
  4279  		typ := getChardevSourceType(a.Source)
  4280  		if typ != "" {
  4281  			start.Attr = append(start.Attr, xml.Attr{
  4282  				xml.Name{Local: "type"}, typ,
  4283  			})
  4284  		}
  4285  	}
  4286  	egd := domainRNGBackendEGD(*a)
  4287  	return e.EncodeElement(egd, start)
  4288  }
  4289  
  4290  func (a *DomainRNGBackendEGD) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4291  	typ, ok := getAttr(start.Attr, "type")
  4292  	if !ok {
  4293  		typ = "pty"
  4294  	}
  4295  	a.Source = createChardevSource(typ)
  4296  	con := domainRNGBackendEGD(*a)
  4297  	err := d.DecodeElement(&con, &start)
  4298  	if err != nil {
  4299  		return err
  4300  	}
  4301  	*a = DomainRNGBackendEGD(con)
  4302  	return nil
  4303  }
  4304  
  4305  func (a *DomainRNGBackend) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4306  	if a.Random != nil {
  4307  		start.Attr = append(start.Attr, xml.Attr{
  4308  			xml.Name{Local: "model"}, "random",
  4309  		})
  4310  		return e.EncodeElement(a.Random, start)
  4311  	} else if a.EGD != nil {
  4312  		start.Attr = append(start.Attr, xml.Attr{
  4313  			xml.Name{Local: "model"}, "egd",
  4314  		})
  4315  		return e.EncodeElement(a.EGD, start)
  4316  	} else if a.BuiltIn != nil {
  4317  		start.Attr = append(start.Attr, xml.Attr{
  4318  			xml.Name{Local: "model"}, "builtin",
  4319  		})
  4320  		return e.EncodeElement(a.BuiltIn, start)
  4321  	}
  4322  	return nil
  4323  }
  4324  
  4325  func (a *DomainRNGBackend) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4326  	model, ok := getAttr(start.Attr, "model")
  4327  	if !ok {
  4328  		return nil
  4329  	}
  4330  	if model == "random" {
  4331  		a.Random = &DomainRNGBackendRandom{}
  4332  		err := d.DecodeElement(a.Random, &start)
  4333  		if err != nil {
  4334  			return err
  4335  		}
  4336  	} else if model == "egd" {
  4337  		a.EGD = &DomainRNGBackendEGD{}
  4338  		err := d.DecodeElement(a.EGD, &start)
  4339  		if err != nil {
  4340  			return err
  4341  		}
  4342  	} else if model == "builtin" {
  4343  		a.BuiltIn = &DomainRNGBackendBuiltIn{}
  4344  		err := d.DecodeElement(a.BuiltIn, &start)
  4345  		if err != nil {
  4346  			return err
  4347  		}
  4348  	}
  4349  	d.Skip()
  4350  	return nil
  4351  }
  4352  
  4353  func (d *DomainRNG) Unmarshal(doc string) error {
  4354  	return xml.Unmarshal([]byte(doc), d)
  4355  }
  4356  
  4357  func (d *DomainRNG) Marshal() (string, error) {
  4358  	doc, err := xml.MarshalIndent(d, "", "  ")
  4359  	if err != nil {
  4360  		return "", err
  4361  	}
  4362  	return string(doc), nil
  4363  }
  4364  
  4365  func (a *DomainHostdevSubsysSCSISource) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4366  	if a.Host != nil {
  4367  		return e.EncodeElement(a.Host, start)
  4368  	} else if a.ISCSI != nil {
  4369  		start.Attr = append(start.Attr, xml.Attr{
  4370  			xml.Name{Local: "protocol"}, "iscsi",
  4371  		})
  4372  		return e.EncodeElement(a.ISCSI, start)
  4373  	}
  4374  	return nil
  4375  }
  4376  
  4377  func (a *DomainHostdevSubsysSCSISource) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4378  	proto, ok := getAttr(start.Attr, "protocol")
  4379  	if !ok {
  4380  		a.Host = &DomainHostdevSubsysSCSISourceHost{}
  4381  		err := d.DecodeElement(a.Host, &start)
  4382  		if err != nil {
  4383  			return err
  4384  		}
  4385  	}
  4386  	if proto == "iscsi" {
  4387  		a.ISCSI = &DomainHostdevSubsysSCSISourceISCSI{}
  4388  		err := d.DecodeElement(a.ISCSI, &start)
  4389  		if err != nil {
  4390  			return err
  4391  		}
  4392  	}
  4393  	d.Skip()
  4394  	return nil
  4395  }
  4396  
  4397  type domainHostdev DomainHostdev
  4398  
  4399  type domainHostdevSubsysSCSI struct {
  4400  	DomainHostdevSubsysSCSI
  4401  	domainHostdev
  4402  }
  4403  
  4404  type domainHostdevSubsysSCSIHost struct {
  4405  	DomainHostdevSubsysSCSIHost
  4406  	domainHostdev
  4407  }
  4408  
  4409  type domainHostdevSubsysUSB struct {
  4410  	DomainHostdevSubsysUSB
  4411  	domainHostdev
  4412  }
  4413  
  4414  type domainHostdevSubsysPCI struct {
  4415  	DomainHostdevSubsysPCI
  4416  	domainHostdev
  4417  }
  4418  
  4419  type domainHostdevSubsysMDev struct {
  4420  	DomainHostdevSubsysMDev
  4421  	domainHostdev
  4422  }
  4423  
  4424  type domainHostdevCapsStorage struct {
  4425  	DomainHostdevCapsStorage
  4426  	domainHostdev
  4427  }
  4428  
  4429  type domainHostdevCapsMisc struct {
  4430  	DomainHostdevCapsMisc
  4431  	domainHostdev
  4432  }
  4433  
  4434  type domainHostdevCapsNet struct {
  4435  	DomainHostdevCapsNet
  4436  	domainHostdev
  4437  }
  4438  
  4439  func (a *DomainHostdev) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4440  	start.Name.Local = "hostdev"
  4441  	if a.SubsysSCSI != nil {
  4442  		start.Attr = append(start.Attr, xml.Attr{
  4443  			xml.Name{Local: "mode"}, "subsystem",
  4444  		})
  4445  		start.Attr = append(start.Attr, xml.Attr{
  4446  			xml.Name{Local: "type"}, "scsi",
  4447  		})
  4448  		scsi := domainHostdevSubsysSCSI{}
  4449  		scsi.domainHostdev = domainHostdev(*a)
  4450  		scsi.DomainHostdevSubsysSCSI = *a.SubsysSCSI
  4451  		return e.EncodeElement(scsi, start)
  4452  	} else if a.SubsysSCSIHost != nil {
  4453  		start.Attr = append(start.Attr, xml.Attr{
  4454  			xml.Name{Local: "mode"}, "subsystem",
  4455  		})
  4456  		start.Attr = append(start.Attr, xml.Attr{
  4457  			xml.Name{Local: "type"}, "scsi_host",
  4458  		})
  4459  		scsi_host := domainHostdevSubsysSCSIHost{}
  4460  		scsi_host.domainHostdev = domainHostdev(*a)
  4461  		scsi_host.DomainHostdevSubsysSCSIHost = *a.SubsysSCSIHost
  4462  		return e.EncodeElement(scsi_host, start)
  4463  	} else if a.SubsysUSB != nil {
  4464  		start.Attr = append(start.Attr, xml.Attr{
  4465  			xml.Name{Local: "mode"}, "subsystem",
  4466  		})
  4467  		start.Attr = append(start.Attr, xml.Attr{
  4468  			xml.Name{Local: "type"}, "usb",
  4469  		})
  4470  		usb := domainHostdevSubsysUSB{}
  4471  		usb.domainHostdev = domainHostdev(*a)
  4472  		usb.DomainHostdevSubsysUSB = *a.SubsysUSB
  4473  		return e.EncodeElement(usb, start)
  4474  	} else if a.SubsysPCI != nil {
  4475  		start.Attr = append(start.Attr, xml.Attr{
  4476  			xml.Name{Local: "mode"}, "subsystem",
  4477  		})
  4478  		start.Attr = append(start.Attr, xml.Attr{
  4479  			xml.Name{Local: "type"}, "pci",
  4480  		})
  4481  		pci := domainHostdevSubsysPCI{}
  4482  		pci.domainHostdev = domainHostdev(*a)
  4483  		pci.DomainHostdevSubsysPCI = *a.SubsysPCI
  4484  		return e.EncodeElement(pci, start)
  4485  	} else if a.SubsysMDev != nil {
  4486  		start.Attr = append(start.Attr, xml.Attr{
  4487  			xml.Name{Local: "mode"}, "subsystem",
  4488  		})
  4489  		start.Attr = append(start.Attr, xml.Attr{
  4490  			xml.Name{Local: "type"}, "mdev",
  4491  		})
  4492  		mdev := domainHostdevSubsysMDev{}
  4493  		mdev.domainHostdev = domainHostdev(*a)
  4494  		mdev.DomainHostdevSubsysMDev = *a.SubsysMDev
  4495  		return e.EncodeElement(mdev, start)
  4496  	} else if a.CapsStorage != nil {
  4497  		start.Attr = append(start.Attr, xml.Attr{
  4498  			xml.Name{Local: "mode"}, "capabilities",
  4499  		})
  4500  		start.Attr = append(start.Attr, xml.Attr{
  4501  			xml.Name{Local: "type"}, "storage",
  4502  		})
  4503  		storage := domainHostdevCapsStorage{}
  4504  		storage.domainHostdev = domainHostdev(*a)
  4505  		storage.DomainHostdevCapsStorage = *a.CapsStorage
  4506  		return e.EncodeElement(storage, start)
  4507  	} else if a.CapsMisc != nil {
  4508  		start.Attr = append(start.Attr, xml.Attr{
  4509  			xml.Name{Local: "mode"}, "capabilities",
  4510  		})
  4511  		start.Attr = append(start.Attr, xml.Attr{
  4512  			xml.Name{Local: "type"}, "misc",
  4513  		})
  4514  		misc := domainHostdevCapsMisc{}
  4515  		misc.domainHostdev = domainHostdev(*a)
  4516  		misc.DomainHostdevCapsMisc = *a.CapsMisc
  4517  		return e.EncodeElement(misc, start)
  4518  	} else if a.CapsNet != nil {
  4519  		start.Attr = append(start.Attr, xml.Attr{
  4520  			xml.Name{Local: "mode"}, "capabilities",
  4521  		})
  4522  		start.Attr = append(start.Attr, xml.Attr{
  4523  			xml.Name{Local: "type"}, "net",
  4524  		})
  4525  		net := domainHostdevCapsNet{}
  4526  		net.domainHostdev = domainHostdev(*a)
  4527  		net.DomainHostdevCapsNet = *a.CapsNet
  4528  		return e.EncodeElement(net, start)
  4529  	} else {
  4530  		gen := domainHostdev(*a)
  4531  		return e.EncodeElement(gen, start)
  4532  	}
  4533  }
  4534  
  4535  func (a *DomainHostdev) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4536  	mode, ok := getAttr(start.Attr, "mode")
  4537  	if !ok {
  4538  		return fmt.Errorf("Missing 'mode' attribute on domain hostdev")
  4539  	}
  4540  	typ, ok := getAttr(start.Attr, "type")
  4541  	if !ok {
  4542  		return fmt.Errorf("Missing 'type' attribute on domain controller")
  4543  	}
  4544  	if mode == "subsystem" {
  4545  		if typ == "scsi" {
  4546  			var scsi domainHostdevSubsysSCSI
  4547  			err := d.DecodeElement(&scsi, &start)
  4548  			if err != nil {
  4549  				return err
  4550  			}
  4551  			*a = DomainHostdev(scsi.domainHostdev)
  4552  			a.SubsysSCSI = &scsi.DomainHostdevSubsysSCSI
  4553  			return nil
  4554  		} else if typ == "scsi_host" {
  4555  			var scsi_host domainHostdevSubsysSCSIHost
  4556  			err := d.DecodeElement(&scsi_host, &start)
  4557  			if err != nil {
  4558  				return err
  4559  			}
  4560  			*a = DomainHostdev(scsi_host.domainHostdev)
  4561  			a.SubsysSCSIHost = &scsi_host.DomainHostdevSubsysSCSIHost
  4562  			return nil
  4563  		} else if typ == "usb" {
  4564  			var usb domainHostdevSubsysUSB
  4565  			err := d.DecodeElement(&usb, &start)
  4566  			if err != nil {
  4567  				return err
  4568  			}
  4569  			*a = DomainHostdev(usb.domainHostdev)
  4570  			a.SubsysUSB = &usb.DomainHostdevSubsysUSB
  4571  			return nil
  4572  		} else if typ == "pci" {
  4573  			var pci domainHostdevSubsysPCI
  4574  			err := d.DecodeElement(&pci, &start)
  4575  			if err != nil {
  4576  				return err
  4577  			}
  4578  			*a = DomainHostdev(pci.domainHostdev)
  4579  			a.SubsysPCI = &pci.DomainHostdevSubsysPCI
  4580  			return nil
  4581  		} else if typ == "mdev" {
  4582  			var mdev domainHostdevSubsysMDev
  4583  			err := d.DecodeElement(&mdev, &start)
  4584  			if err != nil {
  4585  				return err
  4586  			}
  4587  			*a = DomainHostdev(mdev.domainHostdev)
  4588  			a.SubsysMDev = &mdev.DomainHostdevSubsysMDev
  4589  			return nil
  4590  		}
  4591  	} else if mode == "capabilities" {
  4592  		if typ == "storage" {
  4593  			var storage domainHostdevCapsStorage
  4594  			err := d.DecodeElement(&storage, &start)
  4595  			if err != nil {
  4596  				return err
  4597  			}
  4598  			*a = DomainHostdev(storage.domainHostdev)
  4599  			a.CapsStorage = &storage.DomainHostdevCapsStorage
  4600  			return nil
  4601  		} else if typ == "misc" {
  4602  			var misc domainHostdevCapsMisc
  4603  			err := d.DecodeElement(&misc, &start)
  4604  			if err != nil {
  4605  				return err
  4606  			}
  4607  			*a = DomainHostdev(misc.domainHostdev)
  4608  			a.CapsMisc = &misc.DomainHostdevCapsMisc
  4609  			return nil
  4610  		} else if typ == "net" {
  4611  			var net domainHostdevCapsNet
  4612  			err := d.DecodeElement(&net, &start)
  4613  			if err != nil {
  4614  				return err
  4615  			}
  4616  			*a = DomainHostdev(net.domainHostdev)
  4617  			a.CapsNet = &net.DomainHostdevCapsNet
  4618  			return nil
  4619  		}
  4620  	}
  4621  	var gen domainHostdev
  4622  	err := d.DecodeElement(&gen, &start)
  4623  	if err != nil {
  4624  		return err
  4625  	}
  4626  	*a = DomainHostdev(gen)
  4627  	return nil
  4628  }
  4629  
  4630  func (d *DomainHostdev) Unmarshal(doc string) error {
  4631  	return xml.Unmarshal([]byte(doc), d)
  4632  }
  4633  
  4634  func (d *DomainHostdev) Marshal() (string, error) {
  4635  	doc, err := xml.MarshalIndent(d, "", "  ")
  4636  	if err != nil {
  4637  		return "", err
  4638  	}
  4639  	return string(doc), nil
  4640  }
  4641  
  4642  func (a *DomainGraphicListener) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4643  	start.Name.Local = "listen"
  4644  	if a.Address != nil {
  4645  		start.Attr = append(start.Attr, xml.Attr{
  4646  			xml.Name{Local: "type"}, "address",
  4647  		})
  4648  		return e.EncodeElement(a.Address, start)
  4649  	} else if a.Network != nil {
  4650  		start.Attr = append(start.Attr, xml.Attr{
  4651  			xml.Name{Local: "type"}, "network",
  4652  		})
  4653  		return e.EncodeElement(a.Network, start)
  4654  	} else if a.Socket != nil {
  4655  		start.Attr = append(start.Attr, xml.Attr{
  4656  			xml.Name{Local: "type"}, "socket",
  4657  		})
  4658  		return e.EncodeElement(a.Socket, start)
  4659  	} else {
  4660  		start.Attr = append(start.Attr, xml.Attr{
  4661  			xml.Name{Local: "type"}, "none",
  4662  		})
  4663  		e.EncodeToken(start)
  4664  		e.EncodeToken(start.End())
  4665  	}
  4666  	return nil
  4667  }
  4668  
  4669  func (a *DomainGraphicListener) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4670  	typ, ok := getAttr(start.Attr, "type")
  4671  	if !ok {
  4672  		return fmt.Errorf("Missing 'type' attribute on domain graphics listen")
  4673  	}
  4674  	if typ == "address" {
  4675  		var addr DomainGraphicListenerAddress
  4676  		err := d.DecodeElement(&addr, &start)
  4677  		if err != nil {
  4678  			return err
  4679  		}
  4680  		a.Address = &addr
  4681  		return nil
  4682  	} else if typ == "network" {
  4683  		var net DomainGraphicListenerNetwork
  4684  		err := d.DecodeElement(&net, &start)
  4685  		if err != nil {
  4686  			return err
  4687  		}
  4688  		a.Network = &net
  4689  		return nil
  4690  	} else if typ == "socket" {
  4691  		var sock DomainGraphicListenerSocket
  4692  		err := d.DecodeElement(&sock, &start)
  4693  		if err != nil {
  4694  			return err
  4695  		}
  4696  		a.Socket = &sock
  4697  		return nil
  4698  	} else if typ == "none" {
  4699  		d.Skip()
  4700  	}
  4701  	return nil
  4702  }
  4703  
  4704  func (a *DomainGraphic) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4705  	start.Name.Local = "graphics"
  4706  	if a.SDL != nil {
  4707  		start.Attr = append(start.Attr, xml.Attr{
  4708  			xml.Name{Local: "type"}, "sdl",
  4709  		})
  4710  		return e.EncodeElement(a.SDL, start)
  4711  	} else if a.VNC != nil {
  4712  		start.Attr = append(start.Attr, xml.Attr{
  4713  			xml.Name{Local: "type"}, "vnc",
  4714  		})
  4715  		return e.EncodeElement(a.VNC, start)
  4716  	} else if a.RDP != nil {
  4717  		start.Attr = append(start.Attr, xml.Attr{
  4718  			xml.Name{Local: "type"}, "rdp",
  4719  		})
  4720  		return e.EncodeElement(a.RDP, start)
  4721  	} else if a.Desktop != nil {
  4722  		start.Attr = append(start.Attr, xml.Attr{
  4723  			xml.Name{Local: "type"}, "desktop",
  4724  		})
  4725  		return e.EncodeElement(a.Desktop, start)
  4726  	} else if a.Spice != nil {
  4727  		start.Attr = append(start.Attr, xml.Attr{
  4728  			xml.Name{Local: "type"}, "spice",
  4729  		})
  4730  		return e.EncodeElement(a.Spice, start)
  4731  	} else if a.EGLHeadless != nil {
  4732  		start.Attr = append(start.Attr, xml.Attr{
  4733  			xml.Name{Local: "type"}, "egl-headless",
  4734  		})
  4735  		return e.EncodeElement(a.EGLHeadless, start)
  4736  	}
  4737  	return nil
  4738  }
  4739  
  4740  func (a *DomainGraphic) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  4741  	typ, ok := getAttr(start.Attr, "type")
  4742  	if !ok {
  4743  		return fmt.Errorf("Missing 'type' attribute on domain graphics")
  4744  	}
  4745  	if typ == "sdl" {
  4746  		var sdl DomainGraphicSDL
  4747  		err := d.DecodeElement(&sdl, &start)
  4748  		if err != nil {
  4749  			return err
  4750  		}
  4751  		a.SDL = &sdl
  4752  		return nil
  4753  	} else if typ == "vnc" {
  4754  		var vnc DomainGraphicVNC
  4755  		err := d.DecodeElement(&vnc, &start)
  4756  		if err != nil {
  4757  			return err
  4758  		}
  4759  		a.VNC = &vnc
  4760  		return nil
  4761  	} else if typ == "rdp" {
  4762  		var rdp DomainGraphicRDP
  4763  		err := d.DecodeElement(&rdp, &start)
  4764  		if err != nil {
  4765  			return err
  4766  		}
  4767  		a.RDP = &rdp
  4768  		return nil
  4769  	} else if typ == "desktop" {
  4770  		var desktop DomainGraphicDesktop
  4771  		err := d.DecodeElement(&desktop, &start)
  4772  		if err != nil {
  4773  			return err
  4774  		}
  4775  		a.Desktop = &desktop
  4776  		return nil
  4777  	} else if typ == "spice" {
  4778  		var spice DomainGraphicSpice
  4779  		err := d.DecodeElement(&spice, &start)
  4780  		if err != nil {
  4781  			return err
  4782  		}
  4783  		a.Spice = &spice
  4784  		return nil
  4785  	} else if typ == "egl-headless" {
  4786  		var egl DomainGraphicEGLHeadless
  4787  		err := d.DecodeElement(&egl, &start)
  4788  		if err != nil {
  4789  			return err
  4790  		}
  4791  		a.EGLHeadless = &egl
  4792  		return nil
  4793  	}
  4794  	return nil
  4795  }
  4796  
  4797  func (d *DomainMemorydev) Unmarshal(doc string) error {
  4798  	return xml.Unmarshal([]byte(doc), d)
  4799  }
  4800  
  4801  func (d *DomainMemorydev) Marshal() (string, error) {
  4802  	doc, err := xml.MarshalIndent(d, "", "  ")
  4803  	if err != nil {
  4804  		return "", err
  4805  	}
  4806  	return string(doc), nil
  4807  }
  4808  
  4809  func (d *DomainWatchdog) Unmarshal(doc string) error {
  4810  	return xml.Unmarshal([]byte(doc), d)
  4811  }
  4812  
  4813  func (d *DomainWatchdog) Marshal() (string, error) {
  4814  	doc, err := xml.MarshalIndent(d, "", "  ")
  4815  	if err != nil {
  4816  		return "", err
  4817  	}
  4818  	return string(doc), nil
  4819  }
  4820  
  4821  func (d *DomainVhostUser) Unmarshal(doc string) error {
  4822  	return xml.Unmarshal([]byte(doc), d)
  4823  }
  4824  
  4825  func (d *DomainVhostUser) Marshal() (string, error) {
  4826  	doc, err := xml.MarshalIndent(d, "", "  ")
  4827  	if err != nil {
  4828  		return "", err
  4829  	}
  4830  	return string(doc), nil
  4831  }
  4832  
  4833  func marshalUintAttr(start *xml.StartElement, name string, val *uint, format string) {
  4834  	if val != nil {
  4835  		start.Attr = append(start.Attr, xml.Attr{
  4836  			xml.Name{Local: name}, fmt.Sprintf(format, *val),
  4837  		})
  4838  	}
  4839  }
  4840  
  4841  func marshalUint64Attr(start *xml.StartElement, name string, val *uint64, format string) {
  4842  	if val != nil {
  4843  		start.Attr = append(start.Attr, xml.Attr{
  4844  			xml.Name{Local: name}, fmt.Sprintf(format, *val),
  4845  		})
  4846  	}
  4847  }
  4848  
  4849  func (a *DomainAddressPCI) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4850  	marshalUintAttr(&start, "domain", a.Domain, "0x%04x")
  4851  	marshalUintAttr(&start, "bus", a.Bus, "0x%02x")
  4852  	marshalUintAttr(&start, "slot", a.Slot, "0x%02x")
  4853  	marshalUintAttr(&start, "function", a.Function, "0x%x")
  4854  	if a.MultiFunction != "" {
  4855  		start.Attr = append(start.Attr, xml.Attr{
  4856  			xml.Name{Local: "multifunction"}, a.MultiFunction,
  4857  		})
  4858  	}
  4859  	e.EncodeToken(start)
  4860  	if a.ZPCI != nil {
  4861  		zpci := xml.StartElement{}
  4862  		zpci.Name.Local = "zpci"
  4863  		err := e.EncodeElement(a.ZPCI, zpci)
  4864  		if err != nil {
  4865  			return err
  4866  		}
  4867  	}
  4868  	e.EncodeToken(start.End())
  4869  	return nil
  4870  }
  4871  
  4872  func (a *DomainAddressZPCI) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4873  	marshalUintAttr(&start, "uid", a.UID, "0x%04x")
  4874  	marshalUintAttr(&start, "fid", a.FID, "0x%04x")
  4875  	e.EncodeToken(start)
  4876  	e.EncodeToken(start.End())
  4877  	return nil
  4878  }
  4879  
  4880  func (a *DomainAddressUSB) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4881  	marshalUintAttr(&start, "bus", a.Bus, "%d")
  4882  	if a.Port != "" {
  4883  		start.Attr = append(start.Attr, xml.Attr{
  4884  			xml.Name{Local: "port"}, a.Port,
  4885  		})
  4886  	}
  4887  	marshalUintAttr(&start, "device", a.Device, "%d")
  4888  	e.EncodeToken(start)
  4889  	e.EncodeToken(start.End())
  4890  	return nil
  4891  }
  4892  
  4893  func (a *DomainAddressDrive) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4894  	marshalUintAttr(&start, "controller", a.Controller, "%d")
  4895  	marshalUintAttr(&start, "bus", a.Bus, "%d")
  4896  	marshalUintAttr(&start, "target", a.Target, "%d")
  4897  	marshalUintAttr(&start, "unit", a.Unit, "%d")
  4898  	e.EncodeToken(start)
  4899  	e.EncodeToken(start.End())
  4900  	return nil
  4901  }
  4902  
  4903  func (a *DomainAddressDIMM) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4904  	marshalUintAttr(&start, "slot", a.Slot, "%d")
  4905  	marshalUint64Attr(&start, "base", a.Base, "0x%x")
  4906  	e.EncodeToken(start)
  4907  	e.EncodeToken(start.End())
  4908  	return nil
  4909  }
  4910  
  4911  func (a *DomainAddressISA) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4912  	marshalUintAttr(&start, "iobase", a.IOBase, "0x%x")
  4913  	marshalUintAttr(&start, "irq", a.IRQ, "0x%x")
  4914  	e.EncodeToken(start)
  4915  	e.EncodeToken(start.End())
  4916  	return nil
  4917  }
  4918  
  4919  func (a *DomainAddressVirtioMMIO) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4920  	e.EncodeToken(start)
  4921  	e.EncodeToken(start.End())
  4922  	return nil
  4923  }
  4924  
  4925  func (a *DomainAddressCCW) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4926  	marshalUintAttr(&start, "cssid", a.CSSID, "0x%x")
  4927  	marshalUintAttr(&start, "ssid", a.SSID, "0x%x")
  4928  	marshalUintAttr(&start, "devno", a.DevNo, "0x%04x")
  4929  	e.EncodeToken(start)
  4930  	e.EncodeToken(start.End())
  4931  	return nil
  4932  }
  4933  
  4934  func (a *DomainAddressVirtioSerial) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4935  	marshalUintAttr(&start, "controller", a.Controller, "%d")
  4936  	marshalUintAttr(&start, "bus", a.Bus, "%d")
  4937  	marshalUintAttr(&start, "port", a.Port, "%d")
  4938  	e.EncodeToken(start)
  4939  	e.EncodeToken(start.End())
  4940  	return nil
  4941  }
  4942  
  4943  func (a *DomainAddressSpaprVIO) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4944  	marshalUint64Attr(&start, "reg", a.Reg, "0x%x")
  4945  	e.EncodeToken(start)
  4946  	e.EncodeToken(start.End())
  4947  	return nil
  4948  }
  4949  
  4950  func (a *DomainAddressCCID) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4951  	marshalUintAttr(&start, "controller", a.Controller, "%d")
  4952  	marshalUintAttr(&start, "slot", a.Slot, "%d")
  4953  	e.EncodeToken(start)
  4954  	e.EncodeToken(start.End())
  4955  	return nil
  4956  }
  4957  
  4958  func (a *DomainAddressVirtioS390) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4959  	e.EncodeToken(start)
  4960  	e.EncodeToken(start.End())
  4961  	return nil
  4962  }
  4963  
  4964  func (a *DomainAddressUnassigned) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4965  	e.EncodeToken(start)
  4966  	e.EncodeToken(start.End())
  4967  	return nil
  4968  }
  4969  
  4970  func (a *DomainAddress) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  4971  	if a.USB != nil {
  4972  		start.Attr = append(start.Attr, xml.Attr{
  4973  			xml.Name{Local: "type"}, "usb",
  4974  		})
  4975  		return e.EncodeElement(a.USB, start)
  4976  	} else if a.PCI != nil {
  4977  		start.Attr = append(start.Attr, xml.Attr{
  4978  			xml.Name{Local: "type"}, "pci",
  4979  		})
  4980  		return e.EncodeElement(a.PCI, start)
  4981  	} else if a.Drive != nil {
  4982  		start.Attr = append(start.Attr, xml.Attr{
  4983  			xml.Name{Local: "type"}, "drive",
  4984  		})
  4985  		return e.EncodeElement(a.Drive, start)
  4986  	} else if a.DIMM != nil {
  4987  		start.Attr = append(start.Attr, xml.Attr{
  4988  			xml.Name{Local: "type"}, "dimm",
  4989  		})
  4990  		return e.EncodeElement(a.DIMM, start)
  4991  	} else if a.ISA != nil {
  4992  		start.Attr = append(start.Attr, xml.Attr{
  4993  			xml.Name{Local: "type"}, "isa",
  4994  		})
  4995  		return e.EncodeElement(a.ISA, start)
  4996  	} else if a.VirtioMMIO != nil {
  4997  		start.Attr = append(start.Attr, xml.Attr{
  4998  			xml.Name{Local: "type"}, "virtio-mmio",
  4999  		})
  5000  		return e.EncodeElement(a.VirtioMMIO, start)
  5001  	} else if a.CCW != nil {
  5002  		start.Attr = append(start.Attr, xml.Attr{
  5003  			xml.Name{Local: "type"}, "ccw",
  5004  		})
  5005  		return e.EncodeElement(a.CCW, start)
  5006  	} else if a.VirtioSerial != nil {
  5007  		start.Attr = append(start.Attr, xml.Attr{
  5008  			xml.Name{Local: "type"}, "virtio-serial",
  5009  		})
  5010  		return e.EncodeElement(a.VirtioSerial, start)
  5011  	} else if a.SpaprVIO != nil {
  5012  		start.Attr = append(start.Attr, xml.Attr{
  5013  			xml.Name{Local: "type"}, "spapr-vio",
  5014  		})
  5015  		return e.EncodeElement(a.SpaprVIO, start)
  5016  	} else if a.CCID != nil {
  5017  		start.Attr = append(start.Attr, xml.Attr{
  5018  			xml.Name{Local: "type"}, "ccid",
  5019  		})
  5020  		return e.EncodeElement(a.CCID, start)
  5021  	} else if a.VirtioS390 != nil {
  5022  		start.Attr = append(start.Attr, xml.Attr{
  5023  			xml.Name{Local: "type"}, "virtio-s390",
  5024  		})
  5025  		return e.EncodeElement(a.VirtioS390, start)
  5026  	} else if a.Unassigned != nil {
  5027  		start.Attr = append(start.Attr, xml.Attr{
  5028  			xml.Name{Local: "type"}, "unassigned",
  5029  		})
  5030  		return e.EncodeElement(a.Unassigned, start)
  5031  	} else {
  5032  		return nil
  5033  	}
  5034  }
  5035  
  5036  func unmarshalUint64Attr(valstr string, valptr **uint64, base int) error {
  5037  	if base == 16 {
  5038  		valstr = strings.TrimPrefix(valstr, "0x")
  5039  	}
  5040  	val, err := strconv.ParseUint(valstr, base, 64)
  5041  	if err != nil {
  5042  		return err
  5043  	}
  5044  	*valptr = &val
  5045  	return nil
  5046  }
  5047  
  5048  func unmarshalUintAttr(valstr string, valptr **uint, base int) error {
  5049  	if base == 16 {
  5050  		valstr = strings.TrimPrefix(valstr, "0x")
  5051  	}
  5052  	val, err := strconv.ParseUint(valstr, base, 64)
  5053  	if err != nil {
  5054  		return err
  5055  	}
  5056  	vali := uint(val)
  5057  	*valptr = &vali
  5058  	return nil
  5059  }
  5060  
  5061  func (a *DomainAddressUSB) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5062  	for _, attr := range start.Attr {
  5063  		if attr.Name.Local == "bus" {
  5064  			if err := unmarshalUintAttr(attr.Value, &a.Bus, 10); err != nil {
  5065  				return err
  5066  			}
  5067  		} else if attr.Name.Local == "port" {
  5068  			a.Port = attr.Value
  5069  		} else if attr.Name.Local == "device" {
  5070  			if err := unmarshalUintAttr(attr.Value, &a.Device, 10); err != nil {
  5071  				return err
  5072  			}
  5073  		}
  5074  	}
  5075  	d.Skip()
  5076  	return nil
  5077  }
  5078  
  5079  func (a *DomainAddressPCI) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5080  	for _, attr := range start.Attr {
  5081  		if attr.Name.Local == "domain" {
  5082  			if err := unmarshalUintAttr(attr.Value, &a.Domain, 0); err != nil {
  5083  				return err
  5084  			}
  5085  		} else if attr.Name.Local == "bus" {
  5086  			if err := unmarshalUintAttr(attr.Value, &a.Bus, 0); err != nil {
  5087  				return err
  5088  			}
  5089  		} else if attr.Name.Local == "slot" {
  5090  			if err := unmarshalUintAttr(attr.Value, &a.Slot, 0); err != nil {
  5091  				return err
  5092  			}
  5093  		} else if attr.Name.Local == "function" {
  5094  			if err := unmarshalUintAttr(attr.Value, &a.Function, 0); err != nil {
  5095  				return err
  5096  			}
  5097  		} else if attr.Name.Local == "multifunction" {
  5098  			a.MultiFunction = attr.Value
  5099  		}
  5100  	}
  5101  
  5102  	for {
  5103  		tok, err := d.Token()
  5104  		if err == io.EOF {
  5105  			break
  5106  		}
  5107  		if err != nil {
  5108  			return err
  5109  		}
  5110  
  5111  		switch tok := tok.(type) {
  5112  		case xml.StartElement:
  5113  			if tok.Name.Local == "zpci" {
  5114  				a.ZPCI = &DomainAddressZPCI{}
  5115  				err = d.DecodeElement(a.ZPCI, &tok)
  5116  				if err != nil {
  5117  					return err
  5118  				}
  5119  			}
  5120  		}
  5121  	}
  5122  	return nil
  5123  }
  5124  
  5125  func (a *DomainAddressZPCI) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5126  	for _, attr := range start.Attr {
  5127  		if attr.Name.Local == "fid" {
  5128  			if err := unmarshalUintAttr(attr.Value, &a.FID, 0); err != nil {
  5129  				return err
  5130  			}
  5131  		} else if attr.Name.Local == "uid" {
  5132  			if err := unmarshalUintAttr(attr.Value, &a.UID, 0); err != nil {
  5133  				return err
  5134  			}
  5135  		}
  5136  	}
  5137  
  5138  	d.Skip()
  5139  	return nil
  5140  }
  5141  
  5142  func (a *DomainAddressDrive) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5143  	for _, attr := range start.Attr {
  5144  		if attr.Name.Local == "controller" {
  5145  			if err := unmarshalUintAttr(attr.Value, &a.Controller, 10); err != nil {
  5146  				return err
  5147  			}
  5148  		} else if attr.Name.Local == "bus" {
  5149  			if err := unmarshalUintAttr(attr.Value, &a.Bus, 10); err != nil {
  5150  				return err
  5151  			}
  5152  		} else if attr.Name.Local == "target" {
  5153  			if err := unmarshalUintAttr(attr.Value, &a.Target, 10); err != nil {
  5154  				return err
  5155  			}
  5156  		} else if attr.Name.Local == "unit" {
  5157  			if err := unmarshalUintAttr(attr.Value, &a.Unit, 10); err != nil {
  5158  				return err
  5159  			}
  5160  		}
  5161  	}
  5162  	d.Skip()
  5163  	return nil
  5164  }
  5165  
  5166  func (a *DomainAddressDIMM) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5167  	for _, attr := range start.Attr {
  5168  		if attr.Name.Local == "slot" {
  5169  			if err := unmarshalUintAttr(attr.Value, &a.Slot, 10); err != nil {
  5170  				return err
  5171  			}
  5172  		} else if attr.Name.Local == "base" {
  5173  			if err := unmarshalUint64Attr(attr.Value, &a.Base, 16); err != nil {
  5174  				return err
  5175  			}
  5176  		}
  5177  	}
  5178  	d.Skip()
  5179  	return nil
  5180  }
  5181  
  5182  func (a *DomainAddressISA) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5183  	for _, attr := range start.Attr {
  5184  		if attr.Name.Local == "iobase" {
  5185  			if err := unmarshalUintAttr(attr.Value, &a.IOBase, 16); err != nil {
  5186  				return err
  5187  			}
  5188  		} else if attr.Name.Local == "irq" {
  5189  			if err := unmarshalUintAttr(attr.Value, &a.IRQ, 16); err != nil {
  5190  				return err
  5191  			}
  5192  		}
  5193  	}
  5194  	d.Skip()
  5195  	return nil
  5196  }
  5197  
  5198  func (a *DomainAddressVirtioMMIO) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5199  	d.Skip()
  5200  	return nil
  5201  }
  5202  
  5203  func (a *DomainAddressCCW) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5204  	for _, attr := range start.Attr {
  5205  		if attr.Name.Local == "cssid" {
  5206  			if err := unmarshalUintAttr(attr.Value, &a.CSSID, 0); err != nil {
  5207  				return err
  5208  			}
  5209  		} else if attr.Name.Local == "ssid" {
  5210  			if err := unmarshalUintAttr(attr.Value, &a.SSID, 0); err != nil {
  5211  				return err
  5212  			}
  5213  		} else if attr.Name.Local == "devno" {
  5214  			if err := unmarshalUintAttr(attr.Value, &a.DevNo, 0); err != nil {
  5215  				return err
  5216  			}
  5217  		}
  5218  	}
  5219  	d.Skip()
  5220  	return nil
  5221  }
  5222  
  5223  func (a *DomainAddressVirtioSerial) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5224  	for _, attr := range start.Attr {
  5225  		if attr.Name.Local == "controller" {
  5226  			if err := unmarshalUintAttr(attr.Value, &a.Controller, 10); err != nil {
  5227  				return err
  5228  			}
  5229  		} else if attr.Name.Local == "bus" {
  5230  			if err := unmarshalUintAttr(attr.Value, &a.Bus, 10); err != nil {
  5231  				return err
  5232  			}
  5233  		} else if attr.Name.Local == "port" {
  5234  			if err := unmarshalUintAttr(attr.Value, &a.Port, 10); err != nil {
  5235  				return err
  5236  			}
  5237  		}
  5238  	}
  5239  	d.Skip()
  5240  	return nil
  5241  }
  5242  
  5243  func (a *DomainAddressSpaprVIO) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5244  	for _, attr := range start.Attr {
  5245  		if attr.Name.Local == "reg" {
  5246  			if err := unmarshalUint64Attr(attr.Value, &a.Reg, 16); err != nil {
  5247  				return err
  5248  			}
  5249  		}
  5250  	}
  5251  	d.Skip()
  5252  	return nil
  5253  }
  5254  
  5255  func (a *DomainAddressCCID) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5256  	for _, attr := range start.Attr {
  5257  		if attr.Name.Local == "controller" {
  5258  			if err := unmarshalUintAttr(attr.Value, &a.Controller, 10); err != nil {
  5259  				return err
  5260  			}
  5261  		} else if attr.Name.Local == "slot" {
  5262  			if err := unmarshalUintAttr(attr.Value, &a.Slot, 10); err != nil {
  5263  				return err
  5264  			}
  5265  		}
  5266  	}
  5267  	d.Skip()
  5268  	return nil
  5269  }
  5270  
  5271  func (a *DomainAddressVirtioS390) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5272  	d.Skip()
  5273  	return nil
  5274  }
  5275  
  5276  func (a *DomainAddressUnassigned) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5277  	d.Skip()
  5278  	return nil
  5279  }
  5280  
  5281  func (a *DomainAddress) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5282  	var typ string
  5283  	for _, attr := range start.Attr {
  5284  		if attr.Name.Local == "type" {
  5285  			typ = attr.Value
  5286  			break
  5287  		}
  5288  	}
  5289  	if typ == "" {
  5290  		d.Skip()
  5291  		return nil
  5292  	}
  5293  
  5294  	if typ == "usb" {
  5295  		a.USB = &DomainAddressUSB{}
  5296  		return d.DecodeElement(a.USB, &start)
  5297  	} else if typ == "pci" {
  5298  		a.PCI = &DomainAddressPCI{}
  5299  		return d.DecodeElement(a.PCI, &start)
  5300  	} else if typ == "drive" {
  5301  		a.Drive = &DomainAddressDrive{}
  5302  		return d.DecodeElement(a.Drive, &start)
  5303  	} else if typ == "dimm" {
  5304  		a.DIMM = &DomainAddressDIMM{}
  5305  		return d.DecodeElement(a.DIMM, &start)
  5306  	} else if typ == "isa" {
  5307  		a.ISA = &DomainAddressISA{}
  5308  		return d.DecodeElement(a.ISA, &start)
  5309  	} else if typ == "virtio-mmio" {
  5310  		a.VirtioMMIO = &DomainAddressVirtioMMIO{}
  5311  		return d.DecodeElement(a.VirtioMMIO, &start)
  5312  	} else if typ == "ccw" {
  5313  		a.CCW = &DomainAddressCCW{}
  5314  		return d.DecodeElement(a.CCW, &start)
  5315  	} else if typ == "virtio-serial" {
  5316  		a.VirtioSerial = &DomainAddressVirtioSerial{}
  5317  		return d.DecodeElement(a.VirtioSerial, &start)
  5318  	} else if typ == "spapr-vio" {
  5319  		a.SpaprVIO = &DomainAddressSpaprVIO{}
  5320  		return d.DecodeElement(a.SpaprVIO, &start)
  5321  	} else if typ == "ccid" {
  5322  		a.CCID = &DomainAddressCCID{}
  5323  		return d.DecodeElement(a.CCID, &start)
  5324  	} else if typ == "virtio-s390" {
  5325  		a.VirtioS390 = &DomainAddressVirtioS390{}
  5326  		return d.DecodeElement(a.VirtioS390, &start)
  5327  	} else if typ == "unassigned" {
  5328  		a.Unassigned = &DomainAddressUnassigned{}
  5329  		return d.DecodeElement(a.Unassigned, &start)
  5330  	}
  5331  
  5332  	return nil
  5333  }
  5334  
  5335  func (d *DomainCPU) Unmarshal(doc string) error {
  5336  	return xml.Unmarshal([]byte(doc), d)
  5337  }
  5338  
  5339  func (d *DomainCPU) Marshal() (string, error) {
  5340  	doc, err := xml.MarshalIndent(d, "", "  ")
  5341  	if err != nil {
  5342  		return "", err
  5343  	}
  5344  	return string(doc), nil
  5345  }
  5346  
  5347  func (a *DomainLaunchSecuritySEV) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  5348  	e.EncodeToken(start)
  5349  	cbitpos := xml.StartElement{
  5350  		Name: xml.Name{Local: "cbitpos"},
  5351  	}
  5352  	e.EncodeToken(cbitpos)
  5353  	e.EncodeToken(xml.CharData(fmt.Sprintf("%d", *a.CBitPos)))
  5354  	e.EncodeToken(cbitpos.End())
  5355  
  5356  	reducedPhysBits := xml.StartElement{
  5357  		Name: xml.Name{Local: "reducedPhysBits"},
  5358  	}
  5359  	e.EncodeToken(reducedPhysBits)
  5360  	e.EncodeToken(xml.CharData(fmt.Sprintf("%d", *a.ReducedPhysBits)))
  5361  	e.EncodeToken(reducedPhysBits.End())
  5362  
  5363  	if a.Policy != nil {
  5364  		policy := xml.StartElement{
  5365  			Name: xml.Name{Local: "policy"},
  5366  		}
  5367  		e.EncodeToken(policy)
  5368  		e.EncodeToken(xml.CharData(fmt.Sprintf("0x%04x", *a.Policy)))
  5369  		e.EncodeToken(policy.End())
  5370  	}
  5371  
  5372  	dhcert := xml.StartElement{
  5373  		Name: xml.Name{Local: "dhCert"},
  5374  	}
  5375  	e.EncodeToken(dhcert)
  5376  	e.EncodeToken(xml.CharData(fmt.Sprintf("%s", a.DHCert)))
  5377  	e.EncodeToken(dhcert.End())
  5378  
  5379  	session := xml.StartElement{
  5380  		Name: xml.Name{Local: "session"},
  5381  	}
  5382  	e.EncodeToken(session)
  5383  	e.EncodeToken(xml.CharData(fmt.Sprintf("%s", a.Session)))
  5384  	e.EncodeToken(session.End())
  5385  
  5386  	e.EncodeToken(start.End())
  5387  
  5388  	return nil
  5389  }
  5390  
  5391  func (a *DomainLaunchSecuritySEV) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5392  	for {
  5393  		tok, err := d.Token()
  5394  		if err == io.EOF {
  5395  			break
  5396  		}
  5397  		if err != nil {
  5398  			return err
  5399  		}
  5400  
  5401  		switch tok := tok.(type) {
  5402  		case xml.StartElement:
  5403  			if tok.Name.Local == "policy" {
  5404  				data, err := d.Token()
  5405  				if err != nil {
  5406  					return err
  5407  				}
  5408  				switch data := data.(type) {
  5409  				case xml.CharData:
  5410  					if err := unmarshalUintAttr(string(data), &a.Policy, 16); err != nil {
  5411  						return err
  5412  					}
  5413  				}
  5414  			} else if tok.Name.Local == "cbitpos" {
  5415  				data, err := d.Token()
  5416  				if err != nil {
  5417  					return err
  5418  				}
  5419  				switch data := data.(type) {
  5420  				case xml.CharData:
  5421  					if err := unmarshalUintAttr(string(data), &a.CBitPos, 10); err != nil {
  5422  						return err
  5423  					}
  5424  				}
  5425  			} else if tok.Name.Local == "reducedPhysBits" {
  5426  				data, err := d.Token()
  5427  				if err != nil {
  5428  					return err
  5429  				}
  5430  				switch data := data.(type) {
  5431  				case xml.CharData:
  5432  					if err := unmarshalUintAttr(string(data), &a.ReducedPhysBits, 10); err != nil {
  5433  						return err
  5434  					}
  5435  				}
  5436  			} else if tok.Name.Local == "dhCert" {
  5437  				data, err := d.Token()
  5438  				if err != nil {
  5439  					return err
  5440  				}
  5441  				switch data := data.(type) {
  5442  				case xml.CharData:
  5443  					a.DHCert = string(data)
  5444  				}
  5445  			} else if tok.Name.Local == "session" {
  5446  				data, err := d.Token()
  5447  				if err != nil {
  5448  					return err
  5449  				}
  5450  				switch data := data.(type) {
  5451  				case xml.CharData:
  5452  					a.Session = string(data)
  5453  				}
  5454  			}
  5455  		}
  5456  	}
  5457  	return nil
  5458  }
  5459  
  5460  func (a *DomainLaunchSecurity) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
  5461  
  5462  	if a.SEV != nil {
  5463  		start.Attr = append(start.Attr, xml.Attr{
  5464  			xml.Name{Local: "type"}, "sev",
  5465  		})
  5466  		return e.EncodeElement(a.SEV, start)
  5467  	} else {
  5468  		return nil
  5469  	}
  5470  
  5471  }
  5472  
  5473  func (a *DomainLaunchSecurity) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
  5474  	var typ string
  5475  	for _, attr := range start.Attr {
  5476  		if attr.Name.Local == "type" {
  5477  			typ = attr.Value
  5478  		}
  5479  	}
  5480  
  5481  	if typ == "" {
  5482  		d.Skip()
  5483  		return nil
  5484  	}
  5485  
  5486  	if typ == "sev" {
  5487  		a.SEV = &DomainLaunchSecuritySEV{}
  5488  		return d.DecodeElement(a.SEV, &start)
  5489  	}
  5490  
  5491  	return nil
  5492  }