github.com/zhaoxuat/libvirt-go-xml@v6.3.1-0.20200612053919-a025f1d30c41+incompatible/domain_test.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  	"reflect"
    30  	"strings"
    31  	"testing"
    32  )
    33  
    34  type PCIAddress struct {
    35  	Domain   uint
    36  	Bus      uint
    37  	Slot     uint
    38  	Function uint
    39  }
    40  
    41  type DriveAddress struct {
    42  	Controller uint
    43  	Bus        uint
    44  	Target     uint
    45  	Unit       uint
    46  }
    47  
    48  type ISAAddress struct {
    49  	IOBase uint
    50  }
    51  
    52  var domainID int = 3
    53  
    54  var uhciIndex uint = 0
    55  var uhciAddr = PCIAddress{0, 0, 1, 2}
    56  var nvmeAddr = PCIAddress{0, 1, 3, 0}
    57  var pciIndex uint = 0
    58  var pciTargetChassisNr uint = 7
    59  var pciTargetChassis uint = 23
    60  var pciTargetPort uint = 78
    61  var pciTargetBusNr uint = 2
    62  var pciTargetIndex uint = 3
    63  var pciTargetNUMANode uint = 2
    64  var scsiIndex uint = 0
    65  var scsiQueues uint = 3
    66  var scsiCmdPerLUN uint = 8
    67  var scsiMaxSectors uint = 512
    68  
    69  var usbHostBus uint = 14
    70  var usbHostDevice uint = 6
    71  
    72  var pciHostDomain uint = 0
    73  var pciHostBus uint = 3
    74  var pciHostSlot uint = 14
    75  var pciHostFunction uint = 5
    76  
    77  var diskAddr = PCIAddress{0, 0, 3, 0}
    78  var ifaceAddr = PCIAddress{0, 0, 4, 0}
    79  var videoAddr = PCIAddress{0, 0, 5, 0}
    80  var fsAddr = PCIAddress{0, 0, 6, 0}
    81  var balloonAddr = PCIAddress{0, 0, 7, 0}
    82  var panicAddr = ISAAddress{0x505}
    83  var duplexAddr = PCIAddress{0, 0, 8, 0}
    84  var watchdogAddr = PCIAddress{0, 0, 8, 0}
    85  var rngAddr = PCIAddress{0, 0, 9, 0}
    86  var hostdevSCSI = DriveAddress{0, 0, 3, 0}
    87  
    88  var serialPort uint = 0
    89  var parallelPort uint = 0
    90  var tabletBus uint = 0
    91  var tabletPort string = "1.1"
    92  
    93  var nicAverage int = 1000
    94  var nicBurst int = 10000
    95  
    96  var vcpuId0 uint = 0
    97  var vcpuOrder0 uint = 1
    98  var vcpuId1 uint = 1
    99  
   100  var memorydevAddressSlot uint = 0
   101  var memorydevAddressBase uint64 = 4294967296
   102  
   103  var rebootTimeout int = 0
   104  var cellID0 uint = 0
   105  var cellID1 uint = 1
   106  
   107  var ipv6Prefix uint = 24
   108  
   109  var iothreadPriority int = -3
   110  var vcpuPriority int = -5
   111  
   112  var vepaManagerID uint = 5
   113  var vepaTypeID uint = 3
   114  var vepaTypeIDVersion uint = 12
   115  var vepaInstanceID = "c7bb5ab2-d42f-4690-89d6-f590eb199d0f"
   116  
   117  var vntagProfileID = "c7bb5ab2-d42f-4690-89d6-f590eb199d0f"
   118  
   119  var ovsProfileID = "c7bb5ab2-d42f-4690-89d6-f590eb199d0f"
   120  var ovsInterfaceID = "73728ac4-53d9-44de-8438-8d8f90beca00"
   121  
   122  var midoInterfaceID = "73728ac4-53d9-44de-8438-8d8f90beca00"
   123  
   124  var nvramReg uint64 = 0x4000
   125  
   126  var smartcardController uint = 0
   127  var smartcardSlot uint = 7
   128  
   129  var redirBus uint = 0
   130  var redirPort string = "3"
   131  
   132  var redirfilterClass uint = 0x08
   133  var redirfilterProduct uint = 0x2007
   134  var redirfilterVendor uint = 0x15e1
   135  
   136  var domainTestData = []struct {
   137  	Object   Document
   138  	Expected []string
   139  }{
   140  	{
   141  		Object: &Domain{
   142  			Type: "kvm",
   143  			Name: "test",
   144  			ID:   &domainID,
   145  		},
   146  		Expected: []string{
   147  			`<domain type="kvm" id="3">`,
   148  			`  <name>test</name>`,
   149  			`</domain>`,
   150  		},
   151  	},
   152  	{
   153  		Object: &Domain{
   154  			Type:        "kvm",
   155  			Name:        "test",
   156  			Title:       "Test",
   157  			Description: "A test guest config",
   158  			Metadata: &DomainMetadata{
   159  				XML: "<myvalue xmlns='http://myapp.com/schemeas/my/1.0'><widget name='foo'/></myvalue>" +
   160  					"<myothervalue xmlns='http://myotherapp.com/schemeas/my/1.0'><gizmo name='foo'/></myothervalue>",
   161  			},
   162  			Devices: &DomainDeviceList{
   163  				Disks: []DomainDisk{
   164  					DomainDisk{
   165  						Device: "cdrom",
   166  						Driver: &DomainDiskDriver{
   167  							Name: "qemu",
   168  							Type: "qcow2",
   169  						},
   170  						Source: &DomainDiskSource{
   171  							File: &DomainDiskSourceFile{
   172  								File: "/var/lib/libvirt/images/demo.qcow2",
   173  							},
   174  						},
   175  						Target: &DomainDiskTarget{
   176  							Dev: "vda",
   177  							Bus: "virtio",
   178  						},
   179  						Serial: "fishfood",
   180  						Boot: &DomainDeviceBoot{
   181  							Order: 1,
   182  						},
   183  					},
   184  					DomainDisk{
   185  						Device: "disk",
   186  						Driver: &DomainDiskDriver{
   187  							Name: "qemu",
   188  							Type: "raw",
   189  						},
   190  						Source: &DomainDiskSource{
   191  							Block: &DomainDiskSourceBlock{
   192  								Dev: "/dev/sda1",
   193  							},
   194  						},
   195  						Target: &DomainDiskTarget{
   196  							Dev: "vdb",
   197  							Bus: "virtio",
   198  						},
   199  						Address: &DomainAddress{
   200  							PCI: &DomainAddressPCI{
   201  								Domain:   &diskAddr.Domain,
   202  								Bus:      &diskAddr.Bus,
   203  								Slot:     &diskAddr.Slot,
   204  								Function: &diskAddr.Function,
   205  							},
   206  						},
   207  					},
   208  					DomainDisk{
   209  						Device: "disk",
   210  						Auth: &DomainDiskAuth{
   211  							Username: "fred",
   212  							Secret: &DomainDiskSecret{
   213  								Type: "ceph",
   214  								UUID: "e49f09c9-119e-43fd-b5a9-000d41e65493",
   215  							},
   216  						},
   217  						Source: &DomainDiskSource{
   218  							Network: &DomainDiskSourceNetwork{
   219  								Protocol: "rbd",
   220  								Name:     "somepool/somevol",
   221  								Hosts: []DomainDiskSourceHost{
   222  									DomainDiskSourceHost{
   223  										Transport: "tcp",
   224  										Name:      "rbd1.example.com",
   225  										Port:      "3000",
   226  									},
   227  									DomainDiskSourceHost{
   228  										Transport: "tcp",
   229  										Name:      "rbd2.example.com",
   230  										Port:      "3000",
   231  									},
   232  								},
   233  							},
   234  						},
   235  						Target: &DomainDiskTarget{
   236  							Dev: "vdc",
   237  							Bus: "virtio",
   238  						},
   239  					},
   240  					DomainDisk{
   241  						Device: "disk",
   242  						Source: &DomainDiskSource{
   243  							Network: &DomainDiskSourceNetwork{
   244  								Protocol: "nbd",
   245  								Hosts: []DomainDiskSourceHost{
   246  									DomainDiskSourceHost{
   247  										Transport: "unix",
   248  										Socket:    "/var/run/nbd.sock",
   249  									},
   250  								},
   251  							},
   252  						},
   253  						Target: &DomainDiskTarget{
   254  							Dev: "vdd",
   255  							Bus: "virtio",
   256  						},
   257  						Shareable: &DomainDiskShareable{},
   258  					},
   259  					DomainDisk{
   260  						Device: "cdrom",
   261  						Driver: &DomainDiskDriver{
   262  							Cache:       "none",
   263  							IO:          "native",
   264  							ErrorPolicy: "stop",
   265  						},
   266  						Source: &DomainDiskSource{
   267  							Volume: &DomainDiskSourceVolume{
   268  								Pool:   "default",
   269  								Volume: "myvolume",
   270  							},
   271  						},
   272  						Target: &DomainDiskTarget{
   273  							Dev: "vde",
   274  							Bus: "virtio",
   275  						},
   276  						ReadOnly: &DomainDiskReadOnly{},
   277  					},
   278  				},
   279  			},
   280  		},
   281  		Expected: []string{
   282  			`<domain type="kvm">`,
   283  			`  <name>test</name>`,
   284  			`  <title>Test</title>`,
   285  			`  <description>A test guest config</description>`,
   286  			`  <metadata>` +
   287  				`<myvalue xmlns='http://myapp.com/schemeas/my/1.0'><widget name='foo'/></myvalue>` +
   288  				`<myothervalue xmlns='http://myotherapp.com/schemeas/my/1.0'><gizmo name='foo'/></myothervalue>` +
   289  				`</metadata>`,
   290  			`  <devices>`,
   291  			`    <disk type="file" device="cdrom">`,
   292  			`      <driver name="qemu" type="qcow2"></driver>`,
   293  			`      <source file="/var/lib/libvirt/images/demo.qcow2"></source>`,
   294  			`      <target dev="vda" bus="virtio"></target>`,
   295  			`      <serial>fishfood</serial>`,
   296  			`      <boot order="1"></boot>`,
   297  			`    </disk>`,
   298  			`    <disk type="block" device="disk">`,
   299  			`      <driver name="qemu" type="raw"></driver>`,
   300  			`      <source dev="/dev/sda1"></source>`,
   301  			`      <target dev="vdb" bus="virtio"></target>`,
   302  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0"></address>`,
   303  			`    </disk>`,
   304  			`    <disk type="network" device="disk">`,
   305  			`      <auth username="fred">`,
   306  			`        <secret type="ceph" uuid="e49f09c9-119e-43fd-b5a9-000d41e65493"></secret>`,
   307  			`      </auth>`,
   308  			`      <source protocol="rbd" name="somepool/somevol">`,
   309  			`        <host transport="tcp" name="rbd1.example.com" port="3000"></host>`,
   310  			`        <host transport="tcp" name="rbd2.example.com" port="3000"></host>`,
   311  			`      </source>`,
   312  			`      <target dev="vdc" bus="virtio"></target>`,
   313  			`    </disk>`,
   314  			`    <disk type="network" device="disk">`,
   315  			`      <source protocol="nbd">`,
   316  			`        <host transport="unix" socket="/var/run/nbd.sock"></host>`,
   317  			`      </source>`,
   318  			`      <target dev="vdd" bus="virtio"></target>`,
   319  			`      <shareable></shareable>`,
   320  			`    </disk>`,
   321  			`    <disk type="volume" device="cdrom">`,
   322  			`      <driver cache="none" error_policy="stop" io="native"></driver>`,
   323  			`      <source pool="default" volume="myvolume"></source>`,
   324  			`      <target dev="vde" bus="virtio"></target>`,
   325  			`      <readonly></readonly>`,
   326  			`    </disk>`,
   327  			`  </devices>`,
   328  			`</domain>`,
   329  		},
   330  	},
   331  	{
   332  		Object: &Domain{
   333  			Type: "kvm",
   334  			Name: "test",
   335  			Devices: &DomainDeviceList{
   336  				Inputs: []DomainInput{
   337  					DomainInput{
   338  						Type: "tablet",
   339  						Bus:  "usb",
   340  						Address: &DomainAddress{
   341  							USB: &DomainAddressUSB{
   342  								Bus:  &tabletBus,
   343  								Port: tabletPort,
   344  							},
   345  						},
   346  					},
   347  					DomainInput{
   348  						Type: "keyboard",
   349  						Bus:  "ps2",
   350  					},
   351  				},
   352  				Videos: []DomainVideo{
   353  					DomainVideo{
   354  						Model: DomainVideoModel{
   355  							Type:   "cirrus",
   356  							Heads:  1,
   357  							Ram:    4096,
   358  							VRam:   8192,
   359  							VGAMem: 256,
   360  						},
   361  						Address: &DomainAddress{
   362  							PCI: &DomainAddressPCI{
   363  								Domain:   &videoAddr.Domain,
   364  								Bus:      &videoAddr.Bus,
   365  								Slot:     &videoAddr.Slot,
   366  								Function: &videoAddr.Function,
   367  							},
   368  						},
   369  					},
   370  				},
   371  				TPMs: []DomainTPM{
   372  					DomainTPM{
   373  						Model: "tpm-tis",
   374  						Backend: &DomainTPMBackend{
   375  							Passthrough: &DomainTPMBackendPassthrough{
   376  								Device: &DomainTPMBackendDevice{
   377  									Path: "/dev/tpm0",
   378  								},
   379  							},
   380  						},
   381  					},
   382  				},
   383  				Graphics: []DomainGraphic{
   384  					DomainGraphic{
   385  						VNC: &DomainGraphicVNC{},
   386  					},
   387  				},
   388  				MemBalloon: &DomainMemBalloon{
   389  					Model: "virtio",
   390  					Address: &DomainAddress{
   391  						PCI: &DomainAddressPCI{
   392  							Domain:   &balloonAddr.Domain,
   393  							Bus:      &balloonAddr.Bus,
   394  							Slot:     &balloonAddr.Slot,
   395  							Function: &balloonAddr.Function,
   396  						},
   397  					},
   398  				},
   399  				Panics: []DomainPanic{
   400  					DomainPanic{
   401  						Model: "hyperv",
   402  					},
   403  					DomainPanic{
   404  						Model: "isa",
   405  						Address: &DomainAddress{
   406  							ISA: &DomainAddressISA{
   407  								IOBase: &panicAddr.IOBase,
   408  							},
   409  						},
   410  					},
   411  				},
   412  				Consoles: []DomainConsole{
   413  					DomainConsole{
   414  						Source: &DomainChardevSource{
   415  							Pty: &DomainChardevSourcePty{},
   416  						},
   417  						Target: &DomainConsoleTarget{
   418  							Type: "virtio",
   419  							Port: &serialPort,
   420  						},
   421  					},
   422  				},
   423  				Serials: []DomainSerial{
   424  					DomainSerial{
   425  						Source: &DomainChardevSource{
   426  							Pty: &DomainChardevSourcePty{},
   427  						},
   428  						Target: &DomainSerialTarget{
   429  							Type: "isa",
   430  							Port: &serialPort,
   431  						},
   432  					},
   433  					DomainSerial{
   434  						Source: &DomainChardevSource{
   435  							File: &DomainChardevSourceFile{
   436  								Path:   "/tmp/serial.log",
   437  								Append: "off",
   438  							},
   439  						},
   440  						Target: &DomainSerialTarget{
   441  							Port: &serialPort,
   442  						},
   443  					},
   444  					DomainSerial{
   445  						Source: &DomainChardevSource{
   446  							TCP: &DomainChardevSourceTCP{
   447  								Mode:    "bind",
   448  								Host:    "127.0.0.1",
   449  								Service: "1234",
   450  								TLS:     "yes",
   451  							},
   452  						},
   453  						Protocol: &DomainChardevProtocol{
   454  							Type: "telnet",
   455  						},
   456  						Target: &DomainSerialTarget{
   457  							Port: &serialPort,
   458  						},
   459  					},
   460  				},
   461  				Channels: []DomainChannel{
   462  					DomainChannel{
   463  						Source: &DomainChardevSource{
   464  							Pty: &DomainChardevSourcePty{},
   465  						},
   466  						Target: &DomainChannelTarget{
   467  							VirtIO: &DomainChannelTargetVirtIO{
   468  								Name:  "org.redhat.spice",
   469  								State: "connected",
   470  							},
   471  						},
   472  					},
   473  				},
   474  				Sounds: []DomainSound{
   475  					DomainSound{
   476  						Model: "ich6",
   477  						Codec: []DomainSoundCodec{
   478  							DomainSoundCodec{
   479  								Type: "duplex",
   480  							},
   481  						},
   482  						Address: &DomainAddress{
   483  							PCI: &DomainAddressPCI{
   484  								Domain:   &duplexAddr.Domain,
   485  								Bus:      &duplexAddr.Bus,
   486  								Slot:     &duplexAddr.Slot,
   487  								Function: &duplexAddr.Function,
   488  							},
   489  						},
   490  					},
   491  				},
   492  				RedirDevs: []DomainRedirDev{
   493  					DomainRedirDev{
   494  						Bus: "usb",
   495  						Source: &DomainChardevSource{
   496  							SpiceVMC: &DomainChardevSourceSpiceVMC{},
   497  						},
   498  						Address: &DomainAddress{
   499  							USB: &DomainAddressUSB{
   500  								Bus:  &redirBus,
   501  								Port: redirPort,
   502  							},
   503  						},
   504  					},
   505  				},
   506  				RedirFilters: []DomainRedirFilter{
   507  					DomainRedirFilter{
   508  						USB: []DomainRedirFilterUSB{
   509  							DomainRedirFilterUSB{
   510  								Class:   &redirfilterClass,
   511  								Product: &redirfilterProduct,
   512  								Vendor:  &redirfilterVendor,
   513  								Version: "1.10",
   514  								Allow:   "yes",
   515  							},
   516  							DomainRedirFilterUSB{
   517  								Version: "1.10",
   518  								Allow:   "no",
   519  							},
   520  							DomainRedirFilterUSB{
   521  								Allow: "yes",
   522  							},
   523  						},
   524  					},
   525  				},
   526  				RNGs: []DomainRNG{
   527  					DomainRNG{
   528  						Model: "virtio",
   529  						Rate: &DomainRNGRate{
   530  							Period: 2000,
   531  							Bytes:  1234,
   532  						},
   533  						Backend: &DomainRNGBackend{
   534  							EGD: &DomainRNGBackendEGD{
   535  								Source: &DomainChardevSource{
   536  									Dev: &DomainChardevSourceDev{
   537  										Path: "/dev/ttyS0",
   538  									},
   539  								},
   540  								Protocol: &DomainChardevProtocol{
   541  									Type: "raw",
   542  								},
   543  							},
   544  						},
   545  					},
   546  				},
   547  				Memorydevs: []DomainMemorydev{
   548  					DomainMemorydev{
   549  						Model:  "dimm",
   550  						Access: "private",
   551  						Target: &DomainMemorydevTarget{
   552  							Size: &DomainMemorydevTargetSize{
   553  								Value: 1,
   554  								Unit:  "GiB",
   555  							},
   556  							Node: &DomainMemorydevTargetNode{
   557  								Value: 0,
   558  							},
   559  						},
   560  						Address: &DomainAddress{
   561  							DIMM: &DomainAddressDIMM{
   562  								Slot: &memorydevAddressSlot,
   563  								Base: &memorydevAddressBase,
   564  							},
   565  						},
   566  					},
   567  				},
   568  			},
   569  		},
   570  		Expected: []string{
   571  			`<domain type="kvm">`,
   572  			`  <name>test</name>`,
   573  			`  <devices>`,
   574  			`    <serial type="pty">`,
   575  			`      <target type="isa" port="0"></target>`,
   576  			`    </serial>`,
   577  			`    <serial type="file">`,
   578  			`      <source path="/tmp/serial.log" append="off"></source>`,
   579  			`      <target port="0"></target>`,
   580  			`    </serial>`,
   581  			`    <serial type="tcp">`,
   582  			`      <source mode="bind" host="127.0.0.1" service="1234" tls="yes"></source>`,
   583  			`      <protocol type="telnet"></protocol>`,
   584  			`      <target port="0"></target>`,
   585  			`    </serial>`,
   586  			`    <console type="pty">`,
   587  			`      <target type="virtio" port="0"></target>`,
   588  			`    </console>`,
   589  			`    <channel type="pty">`,
   590  			`      <target type="virtio" name="org.redhat.spice" state="connected"></target>`,
   591  			`    </channel>`,
   592  			`    <input type="tablet" bus="usb">`,
   593  			`      <address type="usb" bus="0" port="1.1"></address>`,
   594  			`    </input>`,
   595  			`    <input type="keyboard" bus="ps2"></input>`,
   596  			`    <tpm model="tpm-tis">`,
   597  			`      <backend type="passthrough">`,
   598  			`        <device path="/dev/tpm0"></device>`,
   599  			`      </backend>`,
   600  			`    </tpm>`,
   601  			`    <graphics type="vnc"></graphics>`,
   602  			`    <sound model="ich6">`,
   603  			`      <codec type="duplex"></codec>`,
   604  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x08" function="0x0"></address>`,
   605  			`    </sound>`,
   606  			`    <video>`,
   607  			`      <model type="cirrus" heads="1" ram="4096" vram="8192" vgamem="256"></model>`,
   608  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"></address>`,
   609  			`    </video>`,
   610  			`    <redirdev type="spicevmc" bus="usb">`,
   611  			`      <address type="usb" bus="0" port="3"></address>`,
   612  			`    </redirdev>`,
   613  			`    <redirfilter>`,
   614  			`      <usbdev class="0x08" vendor="0x15e1" product="0x2007" version="1.10" allow="yes"></usbdev>`,
   615  			`      <usbdev version="1.10" allow="no"></usbdev>`,
   616  			`      <usbdev allow="yes"></usbdev>`,
   617  			`    </redirfilter>`,
   618  			`    <memballoon model="virtio">`,
   619  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"></address>`,
   620  			`    </memballoon>`,
   621  			`    <rng model="virtio">`,
   622  			`      <rate bytes="1234" period="2000"></rate>`,
   623  			`      <backend model="egd" type="dev">`,
   624  			`        <source path="/dev/ttyS0"></source>`,
   625  			`        <protocol type="raw"></protocol>`,
   626  			`      </backend>`,
   627  			`    </rng>`,
   628  			`    <panic model="hyperv"></panic>`,
   629  			`    <panic model="isa">`,
   630  			`      <address type="isa" iobase="0x505"></address>`,
   631  			`    </panic>`,
   632  			`    <memory model="dimm" access="private">`,
   633  			`      <target>`,
   634  			`        <size unit="GiB">1</size>`,
   635  			`        <node>0</node>`,
   636  			`      </target>`,
   637  			`      <address type="dimm" slot="0" base="0x100000000"></address>`,
   638  			`    </memory>`,
   639  			`  </devices>`,
   640  			`</domain>`,
   641  		},
   642  	},
   643  	{
   644  		Object: &Domain{
   645  			Type: "kvm",
   646  			Name: "test",
   647  			Memory: &DomainMemory{
   648  				Unit:     "KiB",
   649  				Value:    8192,
   650  				DumpCore: "yes",
   651  			},
   652  			CurrentMemory: &DomainCurrentMemory{
   653  				Unit:  "KiB",
   654  				Value: 4096,
   655  			},
   656  			MaximumMemory: &DomainMaxMemory{
   657  				Unit:  "KiB",
   658  				Value: 16384,
   659  				Slots: 2,
   660  			},
   661  			MemoryBacking: &DomainMemoryBacking{
   662  				MemoryHugePages: &DomainMemoryHugepages{
   663  					Hugepages: []DomainMemoryHugepage{
   664  						{
   665  							Size:    1,
   666  							Unit:    "G",
   667  							Nodeset: "0-3,5",
   668  						},
   669  						{
   670  							Size:    2,
   671  							Unit:    "M",
   672  							Nodeset: "4",
   673  						},
   674  					},
   675  				},
   676  				MemoryNosharepages: &DomainMemoryNosharepages{},
   677  				MemoryLocked:       &DomainMemoryLocked{},
   678  				MemorySource: &DomainMemorySource{
   679  					Type: "file",
   680  				},
   681  				MemoryAccess: &DomainMemoryAccess{
   682  					Mode: "shared",
   683  				},
   684  				MemoryAllocation: &DomainMemoryAllocation{
   685  					Mode: "immediate",
   686  				},
   687  			},
   688  			OS: &DomainOS{
   689  				Type: &DomainOSType{
   690  					Arch:    "x86_64",
   691  					Machine: "pc",
   692  					Type:    "hvm",
   693  				},
   694  				BootDevices: []DomainBootDevice{
   695  					DomainBootDevice{
   696  						Dev: "hd",
   697  					},
   698  				},
   699  				Loader: &DomainLoader{
   700  					Readonly: "yes",
   701  					Secure:   "no",
   702  					Type:     "rom",
   703  					Path:     "/loader",
   704  				},
   705  				DTB: "/some/path",
   706  				ACPI: &DomainACPI{
   707  					Tables: []DomainACPITable{
   708  						DomainACPITable{
   709  							Type: "slic",
   710  							Path: "/some/data",
   711  						},
   712  					},
   713  				},
   714  				SMBios: &DomainSMBios{
   715  					Mode: "sysinfo",
   716  				},
   717  				BIOS: &DomainBIOS{
   718  					UseSerial:     "yes",
   719  					RebootTimeout: &rebootTimeout,
   720  				},
   721  				Init: "/bin/systemd",
   722  				InitArgs: []string{
   723  					"--unit",
   724  					"emergency.service",
   725  				},
   726  				InitEnv: []DomainOSInitEnv{
   727  					DomainOSInitEnv{
   728  						Name:  "HOME",
   729  						Value: "/home/fred",
   730  					},
   731  					DomainOSInitEnv{
   732  						Name:  "USER",
   733  						Value: "fred",
   734  					},
   735  				},
   736  				InitUser:  "fred",
   737  				InitGroup: "fred",
   738  				InitDir:   "/home/fred",
   739  			},
   740  			SysInfo: &DomainSysInfo{
   741  				Type: "smbios",
   742  				BIOS: &DomainSysInfoBIOS{
   743  					Entry: []DomainSysInfoEntry{
   744  						DomainSysInfoEntry{
   745  							Name:  "vendor",
   746  							Value: "vendor",
   747  						},
   748  					},
   749  				},
   750  				System: &DomainSysInfoSystem{
   751  					Entry: []DomainSysInfoEntry{
   752  						DomainSysInfoEntry{
   753  							Name:  "manufacturer",
   754  							Value: "manufacturer",
   755  						},
   756  						DomainSysInfoEntry{
   757  							Name:  "product",
   758  							Value: "product",
   759  						},
   760  						DomainSysInfoEntry{
   761  							Name:  "version",
   762  							Value: "version",
   763  						},
   764  					},
   765  				},
   766  				BaseBoard: []DomainSysInfoBaseBoard{
   767  					DomainSysInfoBaseBoard{
   768  						Entry: []DomainSysInfoEntry{
   769  							DomainSysInfoEntry{
   770  								Name:  "manufacturer",
   771  								Value: "manufacturer",
   772  							},
   773  							DomainSysInfoEntry{
   774  								Name:  "product",
   775  								Value: "product",
   776  							},
   777  							DomainSysInfoEntry{
   778  								Name:  "version",
   779  								Value: "version",
   780  							},
   781  							DomainSysInfoEntry{
   782  								Name:  "serial",
   783  								Value: "serial",
   784  							},
   785  						},
   786  					},
   787  				},
   788  			},
   789  			Clock: &DomainClock{
   790  				Offset:     "variable",
   791  				Basis:      "utc",
   792  				Adjustment: "28794",
   793  				TimeZone:   "Europe/Paris",
   794  				Timer: []DomainTimer{
   795  					DomainTimer{
   796  						Name:       "rtc",
   797  						Track:      "boot",
   798  						TickPolicy: "catchup",
   799  						CatchUp: &DomainTimerCatchUp{
   800  							Threshold: 123,
   801  							Slew:      120,
   802  							Limit:     10000,
   803  						},
   804  						Frequency: 120,
   805  						Mode:      "auto",
   806  					},
   807  				},
   808  			},
   809  		},
   810  		Expected: []string{
   811  			`<domain type="kvm">`,
   812  			`  <name>test</name>`,
   813  			`  <maxMemory unit="KiB" slots="2">16384</maxMemory>`,
   814  			`  <memory unit="KiB" dumpCore="yes">8192</memory>`,
   815  			`  <currentMemory unit="KiB">4096</currentMemory>`,
   816  			`  <memoryBacking>`,
   817  			`    <hugepages>`,
   818  			`      <page size="1" unit="G" nodeset="0-3,5"></page>`,
   819  			`      <page size="2" unit="M" nodeset="4"></page>`,
   820  			`    </hugepages>`,
   821  			`    <nosharepages></nosharepages>`,
   822  			`    <locked></locked>`,
   823  			`    <source type="file"></source>`,
   824  			`    <access mode="shared"></access>`,
   825  			`    <allocation mode="immediate"></allocation>`,
   826  			`  </memoryBacking>`,
   827  			`  <sysinfo type="smbios">`,
   828  			`    <bios>`,
   829  			`      <entry name="vendor">vendor</entry>`,
   830  			`    </bios>`,
   831  			`    <system>`,
   832  			`      <entry name="manufacturer">manufacturer</entry>`,
   833  			`      <entry name="product">product</entry>`,
   834  			`      <entry name="version">version</entry>`,
   835  			`    </system>`,
   836  			`    <baseBoard>`,
   837  			`      <entry name="manufacturer">manufacturer</entry>`,
   838  			`      <entry name="product">product</entry>`,
   839  			`      <entry name="version">version</entry>`,
   840  			`      <entry name="serial">serial</entry>`,
   841  			`    </baseBoard>`,
   842  			`  </sysinfo>`,
   843  			`  <os>`,
   844  			`    <type arch="x86_64" machine="pc">hvm</type>`,
   845  			`    <init>/bin/systemd</init>`,
   846  			`    <initarg>--unit</initarg>`,
   847  			`    <initarg>emergency.service</initarg>`,
   848  			`    <initenv name="HOME">/home/fred</initenv>`,
   849  			`    <initenv name="USER">fred</initenv>`,
   850  			`    <initdir>/home/fred</initdir>`,
   851  			`    <inituser>fred</inituser>`,
   852  			`    <initgroup>fred</initgroup>`,
   853  			`    <loader readonly="yes" secure="no" type="rom">/loader</loader>`,
   854  			`    <dtb>/some/path</dtb>`,
   855  			`    <acpi>`,
   856  			`      <table type="slic">/some/data</table>`,
   857  			`    </acpi>`,
   858  			`    <boot dev="hd"></boot>`,
   859  			`    <bios useserial="yes" rebootTimeout="0"></bios>`,
   860  			`    <smbios mode="sysinfo"></smbios>`,
   861  			`  </os>`,
   862  			`  <clock offset="variable" basis="utc" adjustment="28794" timezone="Europe/Paris">`,
   863  			`    <timer name="rtc" track="boot" tickpolicy="catchup" frequency="120" mode="auto">`,
   864  			`      <catchup threshold="123" slew="120" limit="10000"></catchup>`,
   865  			`    </timer>`,
   866  			`  </clock>`,
   867  			`</domain>`,
   868  		},
   869  	},
   870  	{
   871  		Object: &Domain{
   872  			Type: "kvm",
   873  			Name: "test",
   874  			Clock: &DomainClock{
   875  				Offset:     "variable",
   876  				Basis:      "utc",
   877  				Adjustment: "reset",
   878  			},
   879  		},
   880  		Expected: []string{
   881  			`<domain type="kvm">`,
   882  			`  <name>test</name>`,
   883  			`  <clock offset="variable" basis="utc" adjustment="reset"></clock>`,
   884  			`</domain>`,
   885  		},
   886  	},
   887  	{
   888  		Object: &Domain{
   889  			Type: "kvm",
   890  			Name: "test",
   891  			OS: &DomainOS{
   892  				NVRam: &DomainNVRam{
   893  					Template: "/t.fd",
   894  					NVRam:    "/vars.fd",
   895  				},
   896  				BootMenu: &DomainBootMenu{
   897  					Enable:  "yes",
   898  					Timeout: "3000",
   899  				},
   900  			},
   901  		},
   902  		Expected: []string{
   903  			`<domain type="kvm">`,
   904  			`  <name>test</name>`,
   905  			`  <os>`,
   906  			`    <nvram template="/t.fd">/vars.fd</nvram>`,
   907  			`    <bootmenu enable="yes" timeout="3000"></bootmenu>`,
   908  			`  </os>`,
   909  			`</domain>`,
   910  		},
   911  	},
   912  	{
   913  		Object: &Domain{
   914  			Type: "kvm",
   915  			Name: "test",
   916  			BlockIOTune: &DomainBlockIOTune{
   917  				Weight: 900,
   918  				Device: []DomainBlockIOTuneDevice{
   919  					DomainBlockIOTuneDevice{
   920  						Path:          "/dev/sda",
   921  						Weight:        500,
   922  						ReadIopsSec:   300,
   923  						WriteIopsSec:  200,
   924  						ReadBytesSec:  3000,
   925  						WriteBytesSec: 2000,
   926  					},
   927  					DomainBlockIOTuneDevice{
   928  						Path:          "/dev/sdb",
   929  						Weight:        600,
   930  						ReadIopsSec:   100,
   931  						WriteIopsSec:  40,
   932  						ReadBytesSec:  1000,
   933  						WriteBytesSec: 400,
   934  					},
   935  				},
   936  			},
   937  		},
   938  		Expected: []string{
   939  			`<domain type="kvm">`,
   940  			`  <name>test</name>`,
   941  			`  <blkiotune>`,
   942  			`    <weight>900</weight>`,
   943  			`    <device>`,
   944  			`      <path>/dev/sda</path>`,
   945  			`      <weight>500</weight>`,
   946  			`      <read_iops_sec>300</read_iops_sec>`,
   947  			`      <write_iops_sec>200</write_iops_sec>`,
   948  			`      <read_bytes_sec>3000</read_bytes_sec>`,
   949  			`      <write_bytes_sec>2000</write_bytes_sec>`,
   950  			`    </device>`,
   951  			`    <device>`,
   952  			`      <path>/dev/sdb</path>`,
   953  			`      <weight>600</weight>`,
   954  			`      <read_iops_sec>100</read_iops_sec>`,
   955  			`      <write_iops_sec>40</write_iops_sec>`,
   956  			`      <read_bytes_sec>1000</read_bytes_sec>`,
   957  			`      <write_bytes_sec>400</write_bytes_sec>`,
   958  			`    </device>`,
   959  			`  </blkiotune>`,
   960  			`</domain>`,
   961  		},
   962  	},
   963  	{
   964  		Object: &Domain{
   965  			Type: "kvm",
   966  			Name: "test",
   967  			MemoryTune: &DomainMemoryTune{
   968  				HardLimit: &DomainMemoryTuneLimit{
   969  					Value: 1024,
   970  					Unit:  "MiB",
   971  				},
   972  				SoftLimit: &DomainMemoryTuneLimit{
   973  					Value: 1024,
   974  				},
   975  				MinGuarantee: &DomainMemoryTuneLimit{
   976  					Value: 1024,
   977  				},
   978  				SwapHardLimit: &DomainMemoryTuneLimit{
   979  					Value: 1024,
   980  				},
   981  			},
   982  		},
   983  		Expected: []string{
   984  			`<domain type="kvm">`,
   985  			`  <name>test</name>`,
   986  			`  <memtune>`,
   987  			`    <hard_limit unit="MiB">1024</hard_limit>`,
   988  			`    <soft_limit>1024</soft_limit>`,
   989  			`    <min_guarantee>1024</min_guarantee>`,
   990  			`    <swap_hard_limit>1024</swap_hard_limit>`,
   991  			`  </memtune>`,
   992  			`</domain>`,
   993  		},
   994  	},
   995  	{
   996  		Object: &Domain{
   997  			Type: "kvm",
   998  			Name: "test",
   999  			PM: &DomainPM{
  1000  				SuspendToMem: &DomainPMPolicy{
  1001  					Enabled: "no",
  1002  				},
  1003  				SuspendToDisk: &DomainPMPolicy{
  1004  					Enabled: "yes",
  1005  				},
  1006  			},
  1007  		},
  1008  		Expected: []string{
  1009  			`<domain type="kvm">`,
  1010  			`  <name>test</name>`,
  1011  			`  <pm>`,
  1012  			`    <suspend-to-mem enabled="no"></suspend-to-mem>`,
  1013  			`    <suspend-to-disk enabled="yes"></suspend-to-disk>`,
  1014  			`  </pm>`,
  1015  			`</domain>`,
  1016  		},
  1017  	},
  1018  	{
  1019  		Object: &Domain{
  1020  			Type: "kvm",
  1021  			Name: "test",
  1022  			SecLabel: []DomainSecLabel{
  1023  				DomainSecLabel{
  1024  					Type:       "dynamic",
  1025  					Model:      "selinux",
  1026  					Relabel:    "yes",
  1027  					Label:      "system_u:system_r:svirt_t:s0:c143,c762",
  1028  					ImageLabel: "system_u:object_r:svirt_image_t:s0:c143,c762",
  1029  					BaseLabel:  "system_u:system_r:svirt_t:s0",
  1030  				},
  1031  				DomainSecLabel{
  1032  					Type:    "dynamic",
  1033  					Model:   "dac",
  1034  					Relabel: "no",
  1035  				},
  1036  			},
  1037  		},
  1038  		Expected: []string{
  1039  			`<domain type="kvm">`,
  1040  			`  <name>test</name>`,
  1041  			`  <seclabel type="dynamic" model="selinux" relabel="yes">`,
  1042  			`    <label>system_u:system_r:svirt_t:s0:c143,c762</label>`,
  1043  			`    <imagelabel>system_u:object_r:svirt_image_t:s0:c143,c762</imagelabel>`,
  1044  			`    <baselabel>system_u:system_r:svirt_t:s0</baselabel>`,
  1045  			`  </seclabel>`,
  1046  			`  <seclabel type="dynamic" model="dac" relabel="no"></seclabel>`,
  1047  			`</domain>`,
  1048  		},
  1049  	},
  1050  	{
  1051  		Object: &Domain{
  1052  			Type: "kvm",
  1053  			Name: "test",
  1054  			OS: &DomainOS{
  1055  				Kernel:  "/vmlinuz",
  1056  				Initrd:  "/initrd",
  1057  				Cmdline: "arg",
  1058  			},
  1059  		},
  1060  		Expected: []string{
  1061  			`<domain type="kvm">`,
  1062  			`  <name>test</name>`,
  1063  			`  <os>`,
  1064  			`    <kernel>/vmlinuz</kernel>`,
  1065  			`    <initrd>/initrd</initrd>`,
  1066  			`    <cmdline>arg</cmdline>`,
  1067  			`  </os>`,
  1068  			`</domain>`,
  1069  		},
  1070  	},
  1071  	{
  1072  		Object: &Domain{
  1073  			Type: "kvm",
  1074  			Name: "test",
  1075  			Resource: &DomainResource{
  1076  				Partition: "/machines/production",
  1077  			},
  1078  		},
  1079  		Expected: []string{
  1080  			`<domain type="kvm">`,
  1081  			`  <name>test</name>`,
  1082  			`  <resource>`,
  1083  			`    <partition>/machines/production</partition>`,
  1084  			`  </resource>`,
  1085  			`</domain>`,
  1086  		},
  1087  	},
  1088  	{
  1089  		Object: &Domain{
  1090  			Type: "kvm",
  1091  			Name: "test",
  1092  			VCPU: &DomainVCPU{
  1093  				Placement: "static",
  1094  				CPUSet:    "1-4,^3,6",
  1095  				Current:   1,
  1096  				Value:     2,
  1097  			},
  1098  			VCPUs: &DomainVCPUs{
  1099  				VCPU: []DomainVCPUsVCPU{
  1100  					DomainVCPUsVCPU{
  1101  						Id:           &vcpuId0,
  1102  						Enabled:      "yes",
  1103  						Hotpluggable: "no",
  1104  						Order:        &vcpuOrder0,
  1105  					},
  1106  					DomainVCPUsVCPU{
  1107  						Id:           &vcpuId1,
  1108  						Enabled:      "no",
  1109  						Hotpluggable: "yes",
  1110  						Order:        nil,
  1111  					},
  1112  				},
  1113  			},
  1114  			Devices: &DomainDeviceList{
  1115  				Interfaces: []DomainInterface{
  1116  					DomainInterface{
  1117  						MAC: &DomainInterfaceMAC{
  1118  							Address: "00:11:22:33:44:55",
  1119  						},
  1120  						Model: &DomainInterfaceModel{
  1121  							Type: "virtio",
  1122  						},
  1123  						Source: &DomainInterfaceSource{
  1124  							Network: &DomainInterfaceSourceNetwork{
  1125  								Network: "default",
  1126  							},
  1127  						},
  1128  					},
  1129  				},
  1130  			},
  1131  		},
  1132  		Expected: []string{
  1133  			`<domain type="kvm">`,
  1134  			`  <name>test</name>`,
  1135  			`  <vcpu placement="static" cpuset="1-4,^3,6" current="1">2</vcpu>`,
  1136  			`  <vcpus>`,
  1137  			`    <vcpu id="0" enabled="yes" hotpluggable="no" order="1"></vcpu>`,
  1138  			`    <vcpu id="1" enabled="no" hotpluggable="yes"></vcpu>`,
  1139  			`  </vcpus>`,
  1140  			`  <devices>`,
  1141  			`    <interface type="network">`,
  1142  			`      <mac address="00:11:22:33:44:55"></mac>`,
  1143  			`      <source network="default"></source>`,
  1144  			`      <model type="virtio"></model>`,
  1145  			`    </interface>`,
  1146  			`  </devices>`,
  1147  			`</domain>`,
  1148  		},
  1149  	},
  1150  	{
  1151  		Object: &Domain{
  1152  			Type: "kvm",
  1153  			Name: "test",
  1154  			CPU: &DomainCPU{
  1155  				Match: "exact",
  1156  				Check: "none",
  1157  				Model: &DomainCPUModel{
  1158  					Fallback: "allow",
  1159  					Value:    "core2duo",
  1160  					VendorID: "LibvirtQEMU",
  1161  				},
  1162  				Vendor: "Intel",
  1163  				Topology: &DomainCPUTopology{
  1164  					Sockets: 1,
  1165  					Cores:   2,
  1166  					Threads: 1,
  1167  				},
  1168  				Features: []DomainCPUFeature{
  1169  					DomainCPUFeature{Policy: "disable", Name: "lahf_lm"},
  1170  				},
  1171  				Cache: &DomainCPUCache{
  1172  					Level: 1,
  1173  					Mode:  "emulate",
  1174  				},
  1175  				Numa: &DomainNuma{
  1176  					[]DomainCell{
  1177  						{
  1178  							ID:        &cellID0,
  1179  							CPUs:      "0-1",
  1180  							Memory:    512000,
  1181  							Unit:      "KiB",
  1182  							MemAccess: "private",
  1183  							Distances: &DomainCellDistances{
  1184  								Siblings: []DomainCellSibling{
  1185  									DomainCellSibling{
  1186  										ID:    1,
  1187  										Value: 20,
  1188  									},
  1189  								},
  1190  							},
  1191  						},
  1192  						{
  1193  							ID:        &cellID1,
  1194  							CPUs:      "2-3",
  1195  							Memory:    512000,
  1196  							Unit:      "KiB",
  1197  							MemAccess: "private",
  1198  							Distances: &DomainCellDistances{
  1199  								Siblings: []DomainCellSibling{
  1200  									DomainCellSibling{
  1201  										ID:    0,
  1202  										Value: 20,
  1203  									},
  1204  								},
  1205  							},
  1206  						},
  1207  					},
  1208  				},
  1209  			},
  1210  			Devices: &DomainDeviceList{
  1211  				Emulator: "/bin/qemu-kvm",
  1212  			},
  1213  		},
  1214  		Expected: []string{
  1215  			`<domain type="kvm">`,
  1216  			`  <name>test</name>`,
  1217  			`  <cpu match="exact" check="none">`,
  1218  			`    <model fallback="allow" vendor_id="LibvirtQEMU">core2duo</model>`,
  1219  			`    <vendor>Intel</vendor>`,
  1220  			`    <topology sockets="1" cores="2" threads="1"></topology>`,
  1221  			`    <cache level="1" mode="emulate"></cache>`,
  1222  			`    <feature policy="disable" name="lahf_lm"></feature>`,
  1223  			`    <numa>`,
  1224  			`      <cell id="0" cpus="0-1" memory="512000" unit="KiB" memAccess="private">`,
  1225  			`        <distances>`,
  1226  			`          <sibling id="1" value="20"></sibling>`,
  1227  			`        </distances>`,
  1228  			`      </cell>`,
  1229  			`      <cell id="1" cpus="2-3" memory="512000" unit="KiB" memAccess="private">`,
  1230  			`        <distances>`,
  1231  			`          <sibling id="0" value="20"></sibling>`,
  1232  			`        </distances>`,
  1233  			`      </cell>`,
  1234  			`    </numa>`,
  1235  			`  </cpu>`,
  1236  			`  <devices>`,
  1237  			`    <emulator>/bin/qemu-kvm</emulator>`,
  1238  			`  </devices>`,
  1239  			`</domain>`,
  1240  		},
  1241  	},
  1242  	{
  1243  		Object: &Domain{
  1244  			Type: "kvm",
  1245  			Name: "test",
  1246  			Devices: &DomainDeviceList{
  1247  				Interfaces: []DomainInterface{
  1248  					DomainInterface{
  1249  						MAC: &DomainInterfaceMAC{
  1250  							Address: "06:39:b4:00:00:46",
  1251  						},
  1252  						Model: &DomainInterfaceModel{
  1253  							Type: "virtio",
  1254  						},
  1255  						Source: &DomainInterfaceSource{
  1256  							Bridge: &DomainInterfaceSourceBridge{
  1257  								Bridge: "private",
  1258  							},
  1259  						},
  1260  						Target: &DomainInterfaceTarget{
  1261  							Dev: "vnet3",
  1262  						},
  1263  						Alias: &DomainAlias{
  1264  							Name: "net1",
  1265  						},
  1266  					},
  1267  				},
  1268  			},
  1269  		},
  1270  		Expected: []string{
  1271  			`<domain type="kvm">`,
  1272  			`  <name>test</name>`,
  1273  			`  <devices>`,
  1274  			`    <interface type="bridge">`,
  1275  			`      <mac address="06:39:b4:00:00:46"></mac>`,
  1276  			`      <source bridge="private"></source>`,
  1277  			`      <target dev="vnet3"></target>`,
  1278  			`      <model type="virtio"></model>`,
  1279  			`      <alias name="net1"></alias>`,
  1280  			`    </interface>`,
  1281  			`  </devices>`,
  1282  			`</domain>`,
  1283  		},
  1284  	},
  1285  	{
  1286  		Object: &Domain{
  1287  			Type: "vmware",
  1288  			Name: "test",
  1289  			Devices: &DomainDeviceList{
  1290  				Interfaces: []DomainInterface{
  1291  					DomainInterface{
  1292  						MAC: &DomainInterfaceMAC{
  1293  							Address: "06:39:b4:00:00:46",
  1294  						},
  1295  						Model: &DomainInterfaceModel{
  1296  							Type: "e1000",
  1297  						},
  1298  						Source: &DomainInterfaceSource{
  1299  							Bridge: &DomainInterfaceSourceBridge{
  1300  								Bridge: "",
  1301  							},
  1302  						},
  1303  					},
  1304  				},
  1305  			},
  1306  		},
  1307  		Expected: []string{
  1308  			`<domain type="vmware">`,
  1309  			`  <name>test</name>`,
  1310  			`  <devices>`,
  1311  			`    <interface type="bridge">`,
  1312  			`      <mac address="06:39:b4:00:00:46"></mac>`,
  1313  			`      <source bridge=""></source>`,
  1314  			`      <model type="e1000"></model>`,
  1315  			`    </interface>`,
  1316  			`  </devices>`,
  1317  			`</domain>`,
  1318  		},
  1319  	},
  1320  	{
  1321  		Object: &Domain{
  1322  			Type: "kvm",
  1323  			Name: "test",
  1324  			Devices: &DomainDeviceList{
  1325  				Interfaces: []DomainInterface{
  1326  					DomainInterface{
  1327  						MAC: &DomainInterfaceMAC{
  1328  							Address: "52:54:00:39:97:ac",
  1329  						},
  1330  						Model: &DomainInterfaceModel{
  1331  							Type: "e1000",
  1332  						},
  1333  						Source: &DomainInterfaceSource{
  1334  							Network: &DomainInterfaceSourceNetwork{
  1335  								Network: "default",
  1336  							},
  1337  						},
  1338  					},
  1339  				},
  1340  			},
  1341  		},
  1342  		Expected: []string{
  1343  			`<domain type="kvm">`,
  1344  			`  <name>test</name>`,
  1345  			`  <devices>`,
  1346  			`    <interface type="network">`,
  1347  			`      <mac address="52:54:00:39:97:ac"></mac>`,
  1348  			`      <source network="default"></source>`,
  1349  			`      <model type="e1000"></model>`,
  1350  			`    </interface>`,
  1351  			`  </devices>`,
  1352  			`</domain>`,
  1353  		},
  1354  	},
  1355  	{
  1356  		Object: &Domain{
  1357  			Type: "kvm",
  1358  			Name: "test",
  1359  			Devices: &DomainDeviceList{
  1360  				Interfaces: []DomainInterface{
  1361  					DomainInterface{
  1362  						MAC: &DomainInterfaceMAC{
  1363  							Address: "52:54:00:39:97:ac",
  1364  						},
  1365  						Model: &DomainInterfaceModel{
  1366  							Type: "virtio",
  1367  						},
  1368  						Source: &DomainInterfaceSource{
  1369  							UDP: &DomainInterfaceSourceUDP{
  1370  								Address: "127.0.0.1",
  1371  								Port:    1234,
  1372  								Local: &DomainInterfaceSourceLocal{
  1373  									Address: "127.0.0.1",
  1374  									Port:    1235,
  1375  								},
  1376  							},
  1377  						},
  1378  					},
  1379  				},
  1380  			},
  1381  		},
  1382  		Expected: []string{
  1383  			`<domain type="kvm">`,
  1384  			`  <name>test</name>`,
  1385  			`  <devices>`,
  1386  			`    <interface type="udp">`,
  1387  			`      <mac address="52:54:00:39:97:ac"></mac>`,
  1388  			`      <source address="127.0.0.1" port="1234">`,
  1389  			`        <local address="127.0.0.1" port="1235"></local>`,
  1390  			`      </source>`,
  1391  			`      <model type="virtio"></model>`,
  1392  			`    </interface>`,
  1393  			`  </devices>`,
  1394  			`</domain>`,
  1395  		},
  1396  	},
  1397  	{
  1398  		Object: &Domain{
  1399  			Type: "kvm",
  1400  			Name: "test",
  1401  			Devices: &DomainDeviceList{
  1402  				Interfaces: []DomainInterface{
  1403  					DomainInterface{
  1404  						Source: &DomainInterfaceSource{
  1405  							Direct: &DomainInterfaceSourceDirect{
  1406  								Dev:  "eth0",
  1407  								Mode: "bridge",
  1408  							},
  1409  						},
  1410  						VirtualPort: &DomainInterfaceVirtualPort{
  1411  							Params: &DomainInterfaceVirtualPortParams{
  1412  								VEPA8021QBG: &DomainInterfaceVirtualPortParamsVEPA8021QBG{
  1413  									ManagerID:     &vepaManagerID,
  1414  									TypeID:        &vepaTypeID,
  1415  									TypeIDVersion: &vepaTypeIDVersion,
  1416  									InstanceID:    vepaInstanceID,
  1417  								},
  1418  							},
  1419  						},
  1420  					},
  1421  				},
  1422  			},
  1423  		},
  1424  		Expected: []string{
  1425  			`<domain type="kvm">`,
  1426  			`  <name>test</name>`,
  1427  			`  <devices>`,
  1428  			`    <interface type="direct">`,
  1429  			`      <source dev="eth0" mode="bridge"></source>`,
  1430  			`      <virtualport type="802.1Qbg">`,
  1431  			`        <parameters managerid="5" typeid="3" typeidversion="12" instanceid="c7bb5ab2-d42f-4690-89d6-f590eb199d0f"></parameters>`,
  1432  			`      </virtualport>`,
  1433  			`    </interface>`,
  1434  			`  </devices>`,
  1435  			`</domain>`,
  1436  		},
  1437  	},
  1438  	{
  1439  		Object: &Domain{
  1440  			Type: "kvm",
  1441  			Name: "test",
  1442  			Devices: &DomainDeviceList{
  1443  				Interfaces: []DomainInterface{
  1444  					DomainInterface{
  1445  						Source: &DomainInterfaceSource{
  1446  							Direct: &DomainInterfaceSourceDirect{
  1447  								Dev:  "eth0",
  1448  								Mode: "bridge",
  1449  							},
  1450  						},
  1451  						VirtualPort: &DomainInterfaceVirtualPort{
  1452  							Params: &DomainInterfaceVirtualPortParams{
  1453  								VNTag8011QBH: &DomainInterfaceVirtualPortParamsVNTag8021QBH{
  1454  									ProfileID: vntagProfileID,
  1455  								},
  1456  							},
  1457  						},
  1458  					},
  1459  				},
  1460  			},
  1461  		},
  1462  		Expected: []string{
  1463  			`<domain type="kvm">`,
  1464  			`  <name>test</name>`,
  1465  			`  <devices>`,
  1466  			`    <interface type="direct">`,
  1467  			`      <source dev="eth0" mode="bridge"></source>`,
  1468  			`      <virtualport type="802.1Qbh">`,
  1469  			`        <parameters profileid="c7bb5ab2-d42f-4690-89d6-f590eb199d0f"></parameters>`,
  1470  			`      </virtualport>`,
  1471  			`    </interface>`,
  1472  			`  </devices>`,
  1473  			`</domain>`,
  1474  		},
  1475  	},
  1476  	{
  1477  		Object: &Domain{
  1478  			Type: "kvm",
  1479  			Name: "test",
  1480  			Devices: &DomainDeviceList{
  1481  				Interfaces: []DomainInterface{
  1482  					DomainInterface{
  1483  						Source: &DomainInterfaceSource{
  1484  							Direct: &DomainInterfaceSourceDirect{
  1485  								Dev:  "eth0",
  1486  								Mode: "bridge",
  1487  							},
  1488  						},
  1489  						VirtualPort: &DomainInterfaceVirtualPort{
  1490  							Params: &DomainInterfaceVirtualPortParams{
  1491  								OpenVSwitch: &DomainInterfaceVirtualPortParamsOpenVSwitch{
  1492  									ProfileID:   ovsProfileID,
  1493  									InterfaceID: ovsInterfaceID,
  1494  								},
  1495  							},
  1496  						},
  1497  					},
  1498  				},
  1499  			},
  1500  		},
  1501  		Expected: []string{
  1502  			`<domain type="kvm">`,
  1503  			`  <name>test</name>`,
  1504  			`  <devices>`,
  1505  			`    <interface type="direct">`,
  1506  			`      <source dev="eth0" mode="bridge"></source>`,
  1507  			`      <virtualport type="openvswitch">`,
  1508  			`        <parameters interfaceid="73728ac4-53d9-44de-8438-8d8f90beca00" profileid="c7bb5ab2-d42f-4690-89d6-f590eb199d0f"></parameters>`,
  1509  			`      </virtualport>`,
  1510  			`    </interface>`,
  1511  			`  </devices>`,
  1512  			`</domain>`,
  1513  		},
  1514  	},
  1515  	{
  1516  		Object: &Domain{
  1517  			Type: "kvm",
  1518  			Name: "test",
  1519  			Devices: &DomainDeviceList{
  1520  				Interfaces: []DomainInterface{
  1521  					DomainInterface{
  1522  						Source: &DomainInterfaceSource{
  1523  							Direct: &DomainInterfaceSourceDirect{
  1524  								Dev:  "eth0",
  1525  								Mode: "bridge",
  1526  							},
  1527  						},
  1528  						VirtualPort: &DomainInterfaceVirtualPort{
  1529  							Params: &DomainInterfaceVirtualPortParams{
  1530  								MidoNet: &DomainInterfaceVirtualPortParamsMidoNet{
  1531  									InterfaceID: midoInterfaceID,
  1532  								},
  1533  							},
  1534  						},
  1535  					},
  1536  				},
  1537  			},
  1538  		},
  1539  		Expected: []string{
  1540  			`<domain type="kvm">`,
  1541  			`  <name>test</name>`,
  1542  			`  <devices>`,
  1543  			`    <interface type="direct">`,
  1544  			`      <source dev="eth0" mode="bridge"></source>`,
  1545  			`      <virtualport type="midonet">`,
  1546  			`        <parameters interfaceid="73728ac4-53d9-44de-8438-8d8f90beca00"></parameters>`,
  1547  			`      </virtualport>`,
  1548  			`    </interface>`,
  1549  			`  </devices>`,
  1550  			`</domain>`,
  1551  		},
  1552  	},
  1553  	{
  1554  		Object: &Domain{
  1555  			Type: "kvm",
  1556  			Name: "test",
  1557  			Devices: &DomainDeviceList{
  1558  				Interfaces: []DomainInterface{
  1559  					DomainInterface{
  1560  						MAC: &DomainInterfaceMAC{
  1561  							Address: "52:54:00:39:97:ac",
  1562  						},
  1563  						Model: &DomainInterfaceModel{
  1564  							Type: "virtio",
  1565  						},
  1566  						Source: &DomainInterfaceSource{
  1567  							User: &DomainInterfaceSourceUser{},
  1568  						},
  1569  						Link: &DomainInterfaceLink{
  1570  							State: "up",
  1571  						},
  1572  						Boot: &DomainDeviceBoot{
  1573  							Order: 1,
  1574  						},
  1575  						Driver: &DomainInterfaceDriver{
  1576  							Name:   "vhost",
  1577  							Queues: 5,
  1578  						},
  1579  					},
  1580  				},
  1581  			},
  1582  		},
  1583  		Expected: []string{
  1584  			`<domain type="kvm">`,
  1585  			`  <name>test</name>`,
  1586  			`  <devices>`,
  1587  			`    <interface type="user">`,
  1588  			`      <mac address="52:54:00:39:97:ac"></mac>`,
  1589  			`      <boot order="1"></boot>`,
  1590  			`      <model type="virtio"></model>`,
  1591  			`      <driver name="vhost" queues="5"></driver>`,
  1592  			`      <link state="up"></link>`,
  1593  			`    </interface>`,
  1594  			`  </devices>`,
  1595  			`</domain>`,
  1596  		},
  1597  	},
  1598  	{
  1599  		Object: &Domain{
  1600  			Type: "kvm",
  1601  			Name: "test",
  1602  			Devices: &DomainDeviceList{
  1603  				Interfaces: []DomainInterface{
  1604  					DomainInterface{
  1605  						MAC: &DomainInterfaceMAC{
  1606  							Address: "52:54:00:39:97:ac",
  1607  						},
  1608  						Model: &DomainInterfaceModel{
  1609  							Type: "virtio",
  1610  						},
  1611  						Source: &DomainInterfaceSource{
  1612  							Server: &DomainInterfaceSourceServer{
  1613  								Address: "127.0.0.1",
  1614  								Port:    1234,
  1615  							},
  1616  						},
  1617  					},
  1618  				},
  1619  			},
  1620  		},
  1621  		Expected: []string{
  1622  			`<domain type="kvm">`,
  1623  			`  <name>test</name>`,
  1624  			`  <devices>`,
  1625  			`    <interface type="server">`,
  1626  			`      <mac address="52:54:00:39:97:ac"></mac>`,
  1627  			`      <source address="127.0.0.1" port="1234"></source>`,
  1628  			`      <model type="virtio"></model>`,
  1629  			`    </interface>`,
  1630  			`  </devices>`,
  1631  			`</domain>`,
  1632  		},
  1633  	},
  1634  	{
  1635  		Object: &Domain{
  1636  			Type: "kvm",
  1637  			Name: "test",
  1638  			Devices: &DomainDeviceList{
  1639  				Interfaces: []DomainInterface{
  1640  					DomainInterface{
  1641  						MAC: &DomainInterfaceMAC{
  1642  							Address: "52:54:00:39:97:ac",
  1643  						},
  1644  						Model: &DomainInterfaceModel{
  1645  							Type: "virtio",
  1646  						},
  1647  						Source: &DomainInterfaceSource{
  1648  							Ethernet: &DomainInterfaceSourceEthernet{},
  1649  						},
  1650  						Script: &DomainInterfaceScript{
  1651  							Path: "/etc/qemu-ifup",
  1652  						},
  1653  						Address: &DomainAddress{
  1654  							PCI: &DomainAddressPCI{
  1655  								Domain:   &ifaceAddr.Domain,
  1656  								Bus:      &ifaceAddr.Bus,
  1657  								Slot:     &ifaceAddr.Slot,
  1658  								Function: &ifaceAddr.Function,
  1659  							},
  1660  						},
  1661  					},
  1662  				},
  1663  			},
  1664  		},
  1665  		Expected: []string{
  1666  			`<domain type="kvm">`,
  1667  			`  <name>test</name>`,
  1668  			`  <devices>`,
  1669  			`    <interface type="ethernet">`,
  1670  			`      <mac address="52:54:00:39:97:ac"></mac>`,
  1671  			`      <script path="/etc/qemu-ifup"></script>`,
  1672  			`      <model type="virtio"></model>`,
  1673  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"></address>`,
  1674  			`    </interface>`,
  1675  			`  </devices>`,
  1676  			`</domain>`,
  1677  		},
  1678  	},
  1679  	{
  1680  		Object: &Domain{
  1681  			Type: "kvm",
  1682  			Name: "test",
  1683  			Devices: &DomainDeviceList{
  1684  				Interfaces: []DomainInterface{
  1685  					DomainInterface{
  1686  						MAC: &DomainInterfaceMAC{
  1687  							Address: "52:54:00:39:97:ac",
  1688  						},
  1689  						Model: &DomainInterfaceModel{
  1690  							Type: "virtio",
  1691  						},
  1692  						Source: &DomainInterfaceSource{
  1693  							VHostUser: &DomainChardevSource{
  1694  								UNIX: &DomainChardevSourceUNIX{
  1695  									Path: "/tmp/vhost0.sock",
  1696  									Mode: "server",
  1697  								},
  1698  							},
  1699  						},
  1700  					},
  1701  				},
  1702  			},
  1703  		},
  1704  		Expected: []string{
  1705  			`<domain type="kvm">`,
  1706  			`  <name>test</name>`,
  1707  			`  <devices>`,
  1708  			`    <interface type="vhostuser">`,
  1709  			`      <mac address="52:54:00:39:97:ac"></mac>`,
  1710  			`      <source type="unix" mode="server" path="/tmp/vhost0.sock"></source>`,
  1711  			`      <model type="virtio"></model>`,
  1712  			`    </interface>`,
  1713  			`  </devices>`,
  1714  			`</domain>`,
  1715  		},
  1716  	},
  1717  	{
  1718  		Object: &Domain{
  1719  			Type: "kvm",
  1720  			Name: "test",
  1721  			Devices: &DomainDeviceList{
  1722  				VhostUser: []DomainVhostUser{
  1723  					DomainVhostUser{
  1724  						ID:        "bsi-3455apkt",
  1725  						Path:      "/var/tmp/bsi-3455apkt.sock",
  1726  						ReConnect: 1,
  1727  						Queues:    4,
  1728  						Address: &DomainAddress{
  1729  							PCI: &DomainAddressPCI{
  1730  								Domain:   &videoAddr.Domain,
  1731  								Bus:      &videoAddr.Bus,
  1732  								Slot:     &videoAddr.Slot,
  1733  								Function: &videoAddr.Function,
  1734  							},
  1735  						},
  1736  					},
  1737  				},
  1738  			},
  1739  		},
  1740  		Expected: []string{
  1741  			`<domain type="kvm">`,
  1742  			`  <name>test</name>`,
  1743  			`  <devices>`,
  1744  			`    <vhostuser id="bsi-3455apkt" path="/var/tmp/bsi-3455apkt.sock" reconnect="1" queues="4">`,
  1745  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"></address>`,
  1746  			`    </vhostuser>`,
  1747  			`  </devices>`,
  1748  			`</domain>`,
  1749  		},
  1750  	},
  1751  	{
  1752  		Object: &Domain{
  1753  			Type: "kvm",
  1754  			Name: "test",
  1755  			Devices: &DomainDeviceList{
  1756  				VhostUser: []DomainVhostUser{
  1757  					DomainVhostUser{
  1758  						ID:        "bsi-3455apkt",
  1759  						Path:      "/var/tmp/bsi-3455apkt.sock",
  1760  						ReConnect: 1,
  1761  						Queues:    4,
  1762  						BootIndex: 1,
  1763  						Address: &DomainAddress{
  1764  							PCI: &DomainAddressPCI{
  1765  								Domain:   &videoAddr.Domain,
  1766  								Bus:      &videoAddr.Bus,
  1767  								Slot:     &videoAddr.Slot,
  1768  								Function: &videoAddr.Function,
  1769  							},
  1770  						},
  1771  					},
  1772  				},
  1773  			},
  1774  		},
  1775  		Expected: []string{
  1776  			`<domain type="kvm">`,
  1777  			`  <name>test</name>`,
  1778  			`  <devices>`,
  1779  			`    <vhostuser id="bsi-3455apkt" path="/var/tmp/bsi-3455apkt.sock" reconnect="1" queues="4" bootindex="1">`,
  1780  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"></address>`,
  1781  			`    </vhostuser>`,
  1782  			`  </devices>`,
  1783  			`</domain>`,
  1784  		},
  1785  	},
  1786  	{
  1787  		Object: &Domain{
  1788  			Type: "kvm",
  1789  			Name: "test",
  1790  			Devices: &DomainDeviceList{
  1791  				Interfaces: []DomainInterface{
  1792  					DomainInterface{
  1793  						MAC: &DomainInterfaceMAC{
  1794  							Address: "52:54:00:39:97:ac",
  1795  						},
  1796  						Model: &DomainInterfaceModel{
  1797  							Type: "virtio",
  1798  						},
  1799  						Source: &DomainInterfaceSource{
  1800  							VHostUser: &DomainChardevSource{
  1801  								UNIX: &DomainChardevSourceUNIX{
  1802  									Path: "/tmp/vhost0.sock",
  1803  									Mode: "server",
  1804  								},
  1805  							},
  1806  						},
  1807  						Bandwidth: &DomainInterfaceBandwidth{
  1808  							Inbound: &DomainInterfaceBandwidthParams{
  1809  								Average: &nicAverage,
  1810  								Burst:   &nicBurst,
  1811  							},
  1812  							Outbound: &DomainInterfaceBandwidthParams{
  1813  								Average: new(int),
  1814  								Burst:   new(int),
  1815  							},
  1816  						},
  1817  					},
  1818  				},
  1819  			},
  1820  		},
  1821  		Expected: []string{
  1822  			`<domain type="kvm">`,
  1823  			`  <name>test</name>`,
  1824  			`  <devices>`,
  1825  			`    <interface type="vhostuser">`,
  1826  			`      <mac address="52:54:00:39:97:ac"></mac>`,
  1827  			`      <source type="unix" mode="server" path="/tmp/vhost0.sock"></source>`,
  1828  			`      <model type="virtio"></model>`,
  1829  			`      <bandwidth>`,
  1830  			`        <inbound average="1000" burst="10000"></inbound>`,
  1831  			`        <outbound average="0" burst="0"></outbound>`,
  1832  			`      </bandwidth>`,
  1833  			`    </interface>`,
  1834  			`  </devices>`,
  1835  			`</domain>`,
  1836  		},
  1837  	},
  1838  	{
  1839  		Object: &Domain{
  1840  			Type: "kvm",
  1841  			Name: "test",
  1842  			Devices: &DomainDeviceList{
  1843  				Interfaces: []DomainInterface{
  1844  					DomainInterface{
  1845  						MAC: &DomainInterfaceMAC{
  1846  							Address: "52:54:00:39:97:ac",
  1847  						},
  1848  						Source: &DomainInterfaceSource{
  1849  							Hostdev: &DomainInterfaceSourceHostdev{
  1850  								PCI: &DomainHostdevSubsysPCISource{
  1851  									Address: &DomainAddressPCI{
  1852  										Domain:   &pciHostDomain,
  1853  										Bus:      &pciHostBus,
  1854  										Slot:     &pciHostSlot,
  1855  										Function: &pciHostFunction,
  1856  									},
  1857  								},
  1858  							},
  1859  						},
  1860  					},
  1861  				},
  1862  			},
  1863  		},
  1864  		Expected: []string{
  1865  			`<domain type="kvm">`,
  1866  			`  <name>test</name>`,
  1867  			`  <devices>`,
  1868  			`    <interface type="hostdev">`,
  1869  			`      <mac address="52:54:00:39:97:ac"></mac>`,
  1870  			`      <source>`,
  1871  			`        <address type="pci" domain="0x0000" bus="0x03" slot="0x0e" function="0x5"></address>`,
  1872  			`      </source>`,
  1873  			`    </interface>`,
  1874  			`  </devices>`,
  1875  			`</domain>`,
  1876  		},
  1877  	},
  1878  	{
  1879  		Object: &Domain{
  1880  			Type: "kvm",
  1881  			Name: "test",
  1882  			Devices: &DomainDeviceList{
  1883  				Filesystems: []DomainFilesystem{
  1884  					DomainFilesystem{
  1885  						AccessMode: "mapped",
  1886  						Driver: &DomainFilesystemDriver{
  1887  							Type:     "path",
  1888  							WRPolicy: "immediate",
  1889  						},
  1890  						Source: &DomainFilesystemSource{
  1891  							Mount: &DomainFilesystemSourceMount{
  1892  								Dir: "/home/user/test",
  1893  							},
  1894  						},
  1895  						Target: &DomainFilesystemTarget{
  1896  							Dir: "user-test-mount",
  1897  						},
  1898  						Address: &DomainAddress{
  1899  							PCI: &DomainAddressPCI{
  1900  								Domain:   &fsAddr.Domain,
  1901  								Bus:      &fsAddr.Bus,
  1902  								Slot:     &fsAddr.Slot,
  1903  								Function: &fsAddr.Function,
  1904  							},
  1905  						},
  1906  					},
  1907  					DomainFilesystem{
  1908  						AccessMode: "passthrough",
  1909  						Driver: &DomainFilesystemDriver{
  1910  							Name: "loop",
  1911  							Type: "raw",
  1912  						},
  1913  						Source: &DomainFilesystemSource{
  1914  							File: &DomainFilesystemSourceFile{
  1915  								File: "/home/user/test.img",
  1916  							},
  1917  						},
  1918  						Target: &DomainFilesystemTarget{
  1919  							Dir: "user-file-test-mount",
  1920  						},
  1921  					},
  1922  				},
  1923  			},
  1924  		},
  1925  		Expected: []string{
  1926  			`<domain type="kvm">`,
  1927  			`  <name>test</name>`,
  1928  			`  <devices>`,
  1929  			`    <filesystem type="mount" accessmode="mapped">`,
  1930  			`      <driver type="path" wrpolicy="immediate"></driver>`,
  1931  			`      <source dir="/home/user/test"></source>`,
  1932  			`      <target dir="user-test-mount"></target>`,
  1933  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"></address>`,
  1934  			`    </filesystem>`,
  1935  			`    <filesystem type="file" accessmode="passthrough">`,
  1936  			`      <driver type="raw" name="loop"></driver>`,
  1937  			`      <source file="/home/user/test.img"></source>`,
  1938  			`      <target dir="user-file-test-mount"></target>`,
  1939  			`    </filesystem>`,
  1940  			`  </devices>`,
  1941  			`</domain>`,
  1942  		},
  1943  	},
  1944  	{
  1945  		Object: &Domain{
  1946  			Type: "kvm",
  1947  			Name: "test",
  1948  			Features: &DomainFeatureList{
  1949  				PAE:     &DomainFeature{},
  1950  				ACPI:    &DomainFeature{},
  1951  				APIC:    &DomainFeatureAPIC{},
  1952  				HAP:     &DomainFeatureState{},
  1953  				PrivNet: &DomainFeature{},
  1954  				HyperV: &DomainFeatureHyperV{
  1955  					Relaxed: &DomainFeatureState{State: "on"},
  1956  					VAPIC:   &DomainFeatureState{State: "on"},
  1957  					Spinlocks: &DomainFeatureHyperVSpinlocks{
  1958  						DomainFeatureState{State: "on"}, 4096,
  1959  					},
  1960  					VPIndex: &DomainFeatureState{State: "on"},
  1961  					Runtime: &DomainFeatureState{State: "on"},
  1962  					Synic:   &DomainFeatureState{State: "on"},
  1963  					Reset:   &DomainFeatureState{State: "on"},
  1964  					VendorId: &DomainFeatureHyperVVendorId{
  1965  						DomainFeatureState{State: "on"}, "KVM Hv",
  1966  					},
  1967  				},
  1968  				KVM: &DomainFeatureKVM{
  1969  					Hidden: &DomainFeatureState{State: "on"},
  1970  				},
  1971  				PVSpinlock: &DomainFeatureState{State: "on"},
  1972  				GIC:        &DomainFeatureGIC{Version: "2"},
  1973  				Capabilities: &DomainFeatureCapabilities{
  1974  					Policy: "default",
  1975  					MkNod: &DomainFeatureCapability{
  1976  						State: "on",
  1977  					},
  1978  				},
  1979  			},
  1980  		},
  1981  		Expected: []string{
  1982  			`<domain type="kvm">`,
  1983  			`  <name>test</name>`,
  1984  			`  <features>`,
  1985  			`    <pae></pae>`,
  1986  			`    <acpi></acpi>`,
  1987  			`    <apic></apic>`,
  1988  			`    <hap></hap>`,
  1989  			`    <privnet></privnet>`,
  1990  			`    <hyperv>`,
  1991  			`      <relaxed state="on"></relaxed>`,
  1992  			`      <vapic state="on"></vapic>`,
  1993  			`      <spinlocks state="on" retries="4096"></spinlocks>`,
  1994  			`      <vpindex state="on"></vpindex>`,
  1995  			`      <runtime state="on"></runtime>`,
  1996  			`      <synic state="on"></synic>`,
  1997  			`      <reset state="on"></reset>`,
  1998  			`      <vendor_id state="on" value="KVM Hv"></vendor_id>`,
  1999  			`    </hyperv>`,
  2000  			`    <kvm>`,
  2001  			`      <hidden state="on"></hidden>`,
  2002  			`    </kvm>`,
  2003  			`    <pvspinlock state="on"></pvspinlock>`,
  2004  			`    <gic version="2"></gic>`,
  2005  			`    <capabilities policy="default">`,
  2006  			`      <mknod state="on"></mknod>`,
  2007  			`    </capabilities>`,
  2008  			`  </features>`,
  2009  			`</domain>`,
  2010  		},
  2011  	},
  2012  	{
  2013  		Object: &Domain{
  2014  			Type: "kvm",
  2015  			Name: "test",
  2016  			Devices: &DomainDeviceList{
  2017  				Controllers: []DomainController{
  2018  					DomainController{
  2019  						Type:  "usb",
  2020  						Index: &uhciIndex,
  2021  						Model: "piix3-uhci",
  2022  						Address: &DomainAddress{
  2023  							PCI: &DomainAddressPCI{
  2024  								Domain:   &uhciAddr.Domain,
  2025  								Bus:      &uhciAddr.Bus,
  2026  								Slot:     &uhciAddr.Slot,
  2027  								Function: &uhciAddr.Function,
  2028  							},
  2029  						},
  2030  					},
  2031  					DomainController{
  2032  						Type:  "usb",
  2033  						Index: nil,
  2034  						Model: "ehci",
  2035  						USB: &DomainControllerUSB{
  2036  							Master: &DomainControllerUSBMaster{
  2037  								StartPort: 0,
  2038  							},
  2039  						},
  2040  					},
  2041  				},
  2042  			},
  2043  		},
  2044  		Expected: []string{
  2045  			`<domain type="kvm">`,
  2046  			`  <name>test</name>`,
  2047  			`  <devices>`,
  2048  			`    <controller type="usb" index="0" model="piix3-uhci">`,
  2049  			`      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x2"></address>`,
  2050  			`    </controller>`,
  2051  			`    <controller type="usb" model="ehci">`,
  2052  			`      <master startport="0"></master>`,
  2053  			`    </controller>`,
  2054  			`  </devices>`,
  2055  			`</domain>`,
  2056  		},
  2057  	},
  2058  	{
  2059  		Object: &Domain{
  2060  			Type: "kvm",
  2061  			Name: "test",
  2062  			Devices: &DomainDeviceList{
  2063  				Controllers: []DomainController{
  2064  					DomainController{
  2065  						Type:  "pci",
  2066  						Index: &pciIndex,
  2067  						Model: "pci-expander-bus",
  2068  						PCI: &DomainControllerPCI{
  2069  							Model: &DomainControllerPCIModel{
  2070  								Name: "pxb",
  2071  							},
  2072  							Target: &DomainControllerPCITarget{
  2073  								ChassisNr: &pciTargetChassisNr,
  2074  								Chassis:   &pciTargetChassis,
  2075  								Port:      &pciTargetPort,
  2076  								BusNr:     &pciTargetBusNr,
  2077  								Index:     &pciTargetIndex,
  2078  								NUMANode:  &pciTargetNUMANode,
  2079  							},
  2080  							Hole64: &DomainControllerPCIHole64{
  2081  								Size: 1024,
  2082  							},
  2083  						},
  2084  					},
  2085  				},
  2086  			},
  2087  		},
  2088  		Expected: []string{
  2089  			`<domain type="kvm">`,
  2090  			`  <name>test</name>`,
  2091  			`  <devices>`,
  2092  			`    <controller type="pci" index="0" model="pci-expander-bus">`,
  2093  			`      <model name="pxb"></model>`,
  2094  			`      <target chassisNr="7" chassis="23" port="78" busNr="2" index="3">`,
  2095  			`        <node>2</node>`,
  2096  			`      </target>`,
  2097  			`      <pcihole64>1024</pcihole64>`,
  2098  			`    </controller>`,
  2099  			`  </devices>`,
  2100  			`</domain>`,
  2101  		},
  2102  	},
  2103  	{
  2104  		Object: &Domain{
  2105  			Type: "kvm",
  2106  			Name: "test",
  2107  			Devices: &DomainDeviceList{
  2108  				Controllers: []DomainController{
  2109  					DomainController{
  2110  						Type:  "scsi",
  2111  						Index: &scsiIndex,
  2112  						Driver: &DomainControllerDriver{
  2113  							Queues:     &scsiQueues,
  2114  							CmdPerLUN:  &scsiCmdPerLUN,
  2115  							MaxSectors: &scsiMaxSectors,
  2116  							IOEventFD:  "yes",
  2117  							IOThread:   3,
  2118  							IOMMU:      "yes",
  2119  							ATS:        "no",
  2120  						},
  2121  					},
  2122  				},
  2123  			},
  2124  		},
  2125  		Expected: []string{
  2126  			`<domain type="kvm">`,
  2127  			`  <name>test</name>`,
  2128  			`  <devices>`,
  2129  			`    <controller type="scsi" index="0">`,
  2130  			`      <driver queues="3" cmd_per_lun="8" max_sectors="512" ioeventfd="yes" iothread="3" iommu="yes" ats="no"></driver>`,
  2131  			`    </controller>`,
  2132  			`  </devices>`,
  2133  			`</domain>`,
  2134  		},
  2135  	},
  2136  	{
  2137  		Object: &Domain{
  2138  			Type: "kvm",
  2139  			Name: "test",
  2140  			Devices: &DomainDeviceList{
  2141  				Hubs: []DomainHub{
  2142  					DomainHub{
  2143  						Type: "usb",
  2144  					},
  2145  				},
  2146  			},
  2147  		},
  2148  		Expected: []string{
  2149  			`<domain type="kvm">`,
  2150  			`  <name>test</name>`,
  2151  			`  <devices>`,
  2152  			`    <hub type="usb"></hub>`,
  2153  			`  </devices>`,
  2154  			`</domain>`,
  2155  		},
  2156  	},
  2157  	{
  2158  		Object: &Domain{
  2159  			Type: "kvm",
  2160  			Name: "test",
  2161  			Devices: &DomainDeviceList{
  2162  				IOMMU: &DomainIOMMU{
  2163  					Model: "intel",
  2164  					Driver: &DomainIOMMUDriver{
  2165  						EIM:         "on",
  2166  						IntRemap:    "on",
  2167  						CachingMode: "on",
  2168  					},
  2169  				},
  2170  			},
  2171  		},
  2172  		Expected: []string{
  2173  			`<domain type="kvm">`,
  2174  			`  <name>test</name>`,
  2175  			`  <devices>`,
  2176  			`    <iommu model="intel">`,
  2177  			`      <driver intremap="on" caching_mode="on" eim="on"></driver>`,
  2178  			`    </iommu>`,
  2179  			`  </devices>`,
  2180  			`</domain>`,
  2181  		},
  2182  	},
  2183  	{
  2184  		Object: &Domain{
  2185  			Type: "kvm",
  2186  			Name: "test",
  2187  			Perf: &DomainPerf{
  2188  				Events: []DomainPerfEvent{
  2189  					DomainPerfEvent{
  2190  						Name:    "cmt",
  2191  						Enabled: "yes",
  2192  					},
  2193  					DomainPerfEvent{
  2194  						Name:    "mbmt",
  2195  						Enabled: "no",
  2196  					},
  2197  				},
  2198  			},
  2199  		},
  2200  		Expected: []string{
  2201  			`<domain type="kvm">`,
  2202  			`  <name>test</name>`,
  2203  			`  <perf>`,
  2204  			`    <event name="cmt" enabled="yes"></event>`,
  2205  			`    <event name="mbmt" enabled="no"></event>`,
  2206  			`  </perf>`,
  2207  			`</domain>`,
  2208  		},
  2209  	},
  2210  	{
  2211  		Object: &Domain{
  2212  			Type: "kvm",
  2213  			Name: "test",
  2214  			Devices: &DomainDeviceList{
  2215  				Leases: []DomainLease{
  2216  					DomainLease{
  2217  						Lockspace: "foo",
  2218  						Key:       "bar",
  2219  						Target: &DomainLeaseTarget{
  2220  							Path:   "/some/file",
  2221  							Offset: 1024,
  2222  						},
  2223  					},
  2224  				},
  2225  			},
  2226  		},
  2227  		Expected: []string{
  2228  			`<domain type="kvm">`,
  2229  			`  <name>test</name>`,
  2230  			`  <devices>`,
  2231  			`    <lease>`,
  2232  			`      <lockspace>foo</lockspace>`,
  2233  			`      <key>bar</key>`,
  2234  			`      <target path="/some/file" offset="1024"></target>`,
  2235  			`    </lease>`,
  2236  			`  </devices>`,
  2237  			`</domain>`,
  2238  		},
  2239  	},
  2240  	{
  2241  		Object: &Domain{
  2242  			Type: "kvm",
  2243  			Name: "test",
  2244  			Devices: &DomainDeviceList{
  2245  				NVRAM: &DomainNVRAM{
  2246  					Address: &DomainAddress{
  2247  						SpaprVIO: &DomainAddressSpaprVIO{
  2248  							Reg: &nvramReg,
  2249  						},
  2250  					},
  2251  				},
  2252  			},
  2253  		},
  2254  		Expected: []string{
  2255  			`<domain type="kvm">`,
  2256  			`  <name>test</name>`,
  2257  			`  <devices>`,
  2258  			`    <nvram>`,
  2259  			`      <address type="spapr-vio" reg="0x4000"></address>`,
  2260  			`    </nvram>`,
  2261  			`  </devices>`,
  2262  			`</domain>`,
  2263  		},
  2264  	},
  2265  	{
  2266  		Object: &Domain{
  2267  			Type: "qemu",
  2268  			Name: "test",
  2269  			QEMUCommandline: &DomainQEMUCommandline{
  2270  				Args: []DomainQEMUCommandlineArg{
  2271  					DomainQEMUCommandlineArg{Value: "-newarg"},
  2272  					DomainQEMUCommandlineArg{Value: "-oldarg"},
  2273  				},
  2274  				Envs: []DomainQEMUCommandlineEnv{
  2275  					DomainQEMUCommandlineEnv{Name: "QEMU_ENV", Value: "VAL"},
  2276  					DomainQEMUCommandlineEnv{Name: "QEMU_VAR", Value: "VAR"},
  2277  				},
  2278  			},
  2279  		},
  2280  		Expected: []string{
  2281  			`<domain type="qemu">`,
  2282  			`  <name>test</name>`,
  2283  			`  <commandline xmlns="http://libvirt.org/schemas/domain/qemu/1.0">`,
  2284  			`    <arg value="-newarg"></arg>`,
  2285  			`    <arg value="-oldarg"></arg>`,
  2286  			`    <env name="QEMU_ENV" value="VAL"></env>`,
  2287  			`    <env name="QEMU_VAR" value="VAR"></env>`,
  2288  			`  </commandline>`,
  2289  			`</domain>`,
  2290  		},
  2291  	},
  2292  	{
  2293  		Object: &Domain{
  2294  			Type: "lxc",
  2295  			Name: "test",
  2296  			LXCNamespace: &DomainLXCNamespace{
  2297  				ShareNet: &DomainLXCNamespaceMap{
  2298  					Type:  "netns",
  2299  					Value: "red",
  2300  				},
  2301  				ShareIPC: &DomainLXCNamespaceMap{
  2302  					Type:  "pid",
  2303  					Value: "12345",
  2304  				},
  2305  				ShareUTS: &DomainLXCNamespaceMap{
  2306  					Type:  "name",
  2307  					Value: "container1",
  2308  				},
  2309  			},
  2310  		},
  2311  		Expected: []string{
  2312  			`<domain type="lxc">`,
  2313  			`  <name>test</name>`,
  2314  			`  <namespace xmlns="http://libvirt.org/schemas/domain/lxc/1.0">`,
  2315  			`    <sharenet type="netns" value="red"></sharenet>`,
  2316  			`    <shareipc type="pid" value="12345"></shareipc>`,
  2317  			`    <shareuts type="name" value="container1"></shareuts>`,
  2318  			`  </namespace>`,
  2319  			`</domain>`,
  2320  		},
  2321  	},
  2322  	{
  2323  		Object: &Domain{
  2324  			Type: "vmware",
  2325  			Name: "test",
  2326  			VMWareDataCenterPath: &DomainVMWareDataCenterPath{
  2327  				Value: "folder1/folder2/datacenter1",
  2328  			},
  2329  		},
  2330  		Expected: []string{
  2331  			`<domain type="vmware">`,
  2332  			`  <name>test</name>`,
  2333  			`  <datacenterpath xmlns="http://libvirt.org/schemas/domain/vmware/1.0">folder1/folder2/datacenter1</datacenterpath>`,
  2334  			`</domain>`,
  2335  		},
  2336  	},
  2337  	{
  2338  		Object: &Domain{
  2339  			Name:      "test",
  2340  			IOThreads: 4,
  2341  			IOThreadIDs: &DomainIOThreadIDs{
  2342  				IOThreads: []DomainIOThread{
  2343  					DomainIOThread{
  2344  						ID: 0,
  2345  					},
  2346  					DomainIOThread{
  2347  						ID: 1,
  2348  					},
  2349  					DomainIOThread{
  2350  						ID: 2,
  2351  					},
  2352  					DomainIOThread{
  2353  						ID: 3,
  2354  					},
  2355  				},
  2356  			},
  2357  			CPUTune: &DomainCPUTune{
  2358  				Shares:         &DomainCPUTuneShares{Value: 1024},
  2359  				Period:         &DomainCPUTunePeriod{Value: 500000},
  2360  				Quota:          &DomainCPUTuneQuota{Value: -1},
  2361  				GlobalPeriod:   &DomainCPUTunePeriod{Value: 500000},
  2362  				GlobalQuota:    &DomainCPUTuneQuota{Value: 500},
  2363  				EmulatorPeriod: &DomainCPUTunePeriod{Value: 900000},
  2364  				EmulatorQuota:  &DomainCPUTuneQuota{Value: 100},
  2365  				IOThreadPeriod: &DomainCPUTunePeriod{Value: 100000},
  2366  				IOThreadQuota:  &DomainCPUTuneQuota{Value: 2000},
  2367  				VCPUPin: []DomainCPUTuneVCPUPin{
  2368  					DomainCPUTuneVCPUPin{
  2369  						VCPU:   0,
  2370  						CPUSet: "0-1",
  2371  					},
  2372  					DomainCPUTuneVCPUPin{
  2373  						VCPU:   1,
  2374  						CPUSet: "2-3",
  2375  					},
  2376  				},
  2377  				EmulatorPin: &DomainCPUTuneEmulatorPin{
  2378  					CPUSet: "0-3",
  2379  				},
  2380  				IOThreadPin: []DomainCPUTuneIOThreadPin{
  2381  					DomainCPUTuneIOThreadPin{
  2382  						IOThread: 0,
  2383  						CPUSet:   "0-1",
  2384  					},
  2385  					DomainCPUTuneIOThreadPin{
  2386  						IOThread: 1,
  2387  						CPUSet:   "2-3",
  2388  					},
  2389  				},
  2390  				VCPUSched: []DomainCPUTuneVCPUSched{
  2391  					DomainCPUTuneVCPUSched{
  2392  						VCPUs:     "0-1",
  2393  						Scheduler: "fifo",
  2394  						Priority:  &vcpuPriority,
  2395  					},
  2396  				},
  2397  				IOThreadSched: []DomainCPUTuneIOThreadSched{
  2398  					DomainCPUTuneIOThreadSched{
  2399  						IOThreads: "0-1",
  2400  						Scheduler: "fifo",
  2401  						Priority:  &iothreadPriority,
  2402  					},
  2403  				},
  2404  			},
  2405  		},
  2406  		Expected: []string{
  2407  			`<domain>`,
  2408  			`  <name>test</name>`,
  2409  			`  <iothreads>4</iothreads>`,
  2410  			`  <iothreadids>`,
  2411  			`    <iothread id="0"></iothread>`,
  2412  			`    <iothread id="1"></iothread>`,
  2413  			`    <iothread id="2"></iothread>`,
  2414  			`    <iothread id="3"></iothread>`,
  2415  			`  </iothreadids>`,
  2416  			`  <cputune>`,
  2417  			`    <shares>1024</shares>`,
  2418  			`    <period>500000</period>`,
  2419  			`    <quota>-1</quota>`,
  2420  			`    <global_period>500000</global_period>`,
  2421  			`    <global_quota>500</global_quota>`,
  2422  			`    <emulator_period>900000</emulator_period>`,
  2423  			`    <emulator_quota>100</emulator_quota>`,
  2424  			`    <iothread_period>100000</iothread_period>`,
  2425  			`    <iothread_quota>2000</iothread_quota>`,
  2426  			`    <vcpupin vcpu="0" cpuset="0-1"></vcpupin>`,
  2427  			`    <vcpupin vcpu="1" cpuset="2-3"></vcpupin>`,
  2428  			`    <emulatorpin cpuset="0-3"></emulatorpin>`,
  2429  			`    <iothreadpin iothread="0" cpuset="0-1"></iothreadpin>`,
  2430  			`    <iothreadpin iothread="1" cpuset="2-3"></iothreadpin>`,
  2431  			`    <vcpusched vcpus="0-1" scheduler="fifo" priority="-5"></vcpusched>`,
  2432  			`    <iothreadsched iothreads="0-1" scheduler="fifo" priority="-3"></iothreadsched>`,
  2433  			`  </cputune>`,
  2434  			`</domain>`,
  2435  		},
  2436  	},
  2437  	{
  2438  		Object: &Domain{
  2439  			Name: "test",
  2440  			KeyWrap: &DomainKeyWrap{
  2441  				Ciphers: []DomainKeyWrapCipher{
  2442  					DomainKeyWrapCipher{
  2443  						Name:  "aes",
  2444  						State: "on",
  2445  					},
  2446  					DomainKeyWrapCipher{
  2447  						Name:  "dea",
  2448  						State: "off",
  2449  					},
  2450  				},
  2451  			},
  2452  		},
  2453  		Expected: []string{
  2454  			`<domain>`,
  2455  			`  <name>test</name>`,
  2456  			`  <keywrap>`,
  2457  			`    <cipher name="aes" state="on"></cipher>`,
  2458  			`    <cipher name="dea" state="off"></cipher>`,
  2459  			`  </keywrap>`,
  2460  			`</domain>`,
  2461  		},
  2462  	},
  2463  	{
  2464  		Object: &Domain{
  2465  			Name: "test",
  2466  			IDMap: &DomainIDMap{
  2467  				UIDs: []DomainIDMapRange{
  2468  					DomainIDMapRange{
  2469  						Start:  0,
  2470  						Target: 1000,
  2471  						Count:  50,
  2472  					},
  2473  					DomainIDMapRange{
  2474  						Start:  1000,
  2475  						Target: 5000,
  2476  						Count:  5000,
  2477  					},
  2478  				},
  2479  				GIDs: []DomainIDMapRange{
  2480  					DomainIDMapRange{
  2481  						Start:  0,
  2482  						Target: 1000,
  2483  						Count:  50,
  2484  					},
  2485  					DomainIDMapRange{
  2486  						Start:  1000,
  2487  						Target: 5000,
  2488  						Count:  5000,
  2489  					},
  2490  				},
  2491  			},
  2492  		},
  2493  		Expected: []string{
  2494  			`<domain>`,
  2495  			`  <name>test</name>`,
  2496  			`  <idmap>`,
  2497  			`    <uid start="0" target="1000" count="50"></uid>`,
  2498  			`    <uid start="1000" target="5000" count="5000"></uid>`,
  2499  			`    <gid start="0" target="1000" count="50"></gid>`,
  2500  			`    <gid start="1000" target="5000" count="5000"></gid>`,
  2501  			`  </idmap>`,
  2502  			`</domain>`,
  2503  		},
  2504  	},
  2505  	{
  2506  		Object: &Domain{
  2507  			Name: "test",
  2508  			NUMATune: &DomainNUMATune{
  2509  				Memory: &DomainNUMATuneMemory{
  2510  					Mode:      "strict",
  2511  					Nodeset:   "2-3",
  2512  					Placement: "static",
  2513  				},
  2514  				MemNodes: []DomainNUMATuneMemNode{
  2515  					DomainNUMATuneMemNode{
  2516  						CellID:  0,
  2517  						Mode:    "strict",
  2518  						Nodeset: "2",
  2519  					},
  2520  					DomainNUMATuneMemNode{
  2521  						CellID:  1,
  2522  						Mode:    "strict",
  2523  						Nodeset: "3",
  2524  					},
  2525  				},
  2526  			},
  2527  		},
  2528  		Expected: []string{
  2529  			`<domain>`,
  2530  			`  <name>test</name>`,
  2531  			`  <numatune>`,
  2532  			`    <memory mode="strict" nodeset="2-3" placement="static"></memory>`,
  2533  			`    <memnode cellid="0" mode="strict" nodeset="2"></memnode>`,
  2534  			`    <memnode cellid="1" mode="strict" nodeset="3"></memnode>`,
  2535  
  2536  			`  </numatune>`,
  2537  			`</domain>`,
  2538  		},
  2539  	},
  2540  
  2541  	/* Tests for sub-documents that can be hotplugged */
  2542  	{
  2543  		Object: &DomainController{
  2544  			Type:  "usb",
  2545  			Index: &uhciIndex,
  2546  			Model: "piix3-uhci",
  2547  			Address: &DomainAddress{
  2548  				PCI: &DomainAddressPCI{
  2549  					Domain:   &uhciAddr.Domain,
  2550  					Bus:      &uhciAddr.Bus,
  2551  					Slot:     &uhciAddr.Slot,
  2552  					Function: &uhciAddr.Function,
  2553  				},
  2554  			},
  2555  		},
  2556  		Expected: []string{
  2557  			`<controller type="usb" index="0" model="piix3-uhci">`,
  2558  			`  <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x2"></address>`,
  2559  			`</controller>`,
  2560  		},
  2561  	},
  2562  	{
  2563  		Object: &DomainDisk{
  2564  			Device: "cdrom",
  2565  			Driver: &DomainDiskDriver{
  2566  				Name: "qemu",
  2567  				Type: "qcow2",
  2568  			},
  2569  			Source: &DomainDiskSource{
  2570  				File: &DomainDiskSourceFile{
  2571  					File: "/var/lib/libvirt/images/demo.qcow2",
  2572  				},
  2573  			},
  2574  			BackingStore: &DomainDiskBackingStore{
  2575  				Index: 1,
  2576  				Format: &DomainDiskFormat{
  2577  					Type: "qcow2",
  2578  				},
  2579  				Source: &DomainDiskSource{
  2580  					Block: &DomainDiskSourceBlock{
  2581  						Dev: "/dev/HostVG/QEMUGuest",
  2582  					},
  2583  				},
  2584  				BackingStore: &DomainDiskBackingStore{
  2585  					Index: 2,
  2586  					Format: &DomainDiskFormat{
  2587  						Type: "qcow2",
  2588  					},
  2589  					Source: &DomainDiskSource{
  2590  						File: &DomainDiskSourceFile{
  2591  							File: "/tmp/image2.qcow2",
  2592  						},
  2593  					},
  2594  					BackingStore: &DomainDiskBackingStore{
  2595  						Index: 3,
  2596  						Format: &DomainDiskFormat{
  2597  							Type: "raw",
  2598  						},
  2599  						Source: &DomainDiskSource{
  2600  							File: &DomainDiskSourceFile{
  2601  								File: "/tmp/image3.iso",
  2602  							},
  2603  						},
  2604  						BackingStore: &DomainDiskBackingStore{},
  2605  					},
  2606  				},
  2607  			},
  2608  			Target: &DomainDiskTarget{
  2609  				Dev: "vda",
  2610  				Bus: "virtio",
  2611  			},
  2612  			Serial: "fishfood",
  2613  			WWN:    "0123456789abcdef",
  2614  		},
  2615  		Expected: []string{
  2616  			`<disk type="file" device="cdrom">`,
  2617  			`  <driver name="qemu" type="qcow2"></driver>`,
  2618  			`  <source file="/var/lib/libvirt/images/demo.qcow2"></source>`,
  2619  			`  <backingStore type="block" index="1">`,
  2620  			`    <format type="qcow2"></format>`,
  2621  			`    <source dev="/dev/HostVG/QEMUGuest"></source>`,
  2622  			`    <backingStore type="file" index="2">`,
  2623  			`      <format type="qcow2"></format>`,
  2624  			`      <source file="/tmp/image2.qcow2"></source>`,
  2625  			`      <backingStore type="file" index="3">`,
  2626  			`        <format type="raw"></format>`,
  2627  			`        <source file="/tmp/image3.iso"></source>`,
  2628  			`        <backingStore></backingStore>`,
  2629  			`      </backingStore>`,
  2630  			`    </backingStore>`,
  2631  			`  </backingStore>`,
  2632  			`  <target dev="vda" bus="virtio"></target>`,
  2633  			`  <serial>fishfood</serial>`,
  2634  			`  <wwn>0123456789abcdef</wwn>`,
  2635  			`</disk>`,
  2636  		},
  2637  	},
  2638  	{
  2639  		Object: &DomainDisk{
  2640  			Device: "cdrom",
  2641  			Driver: &DomainDiskDriver{
  2642  				Name: "qemu",
  2643  				Type: "qcow2",
  2644  			},
  2645  			Source: &DomainDiskSource{
  2646  				Block: &DomainDiskSourceBlock{
  2647  					Dev: "/dev/HostVG/QEMUGuest1",
  2648  				},
  2649  			},
  2650  			Mirror: &DomainDiskMirror{
  2651  				Job:   "copy",
  2652  				Ready: "yes",
  2653  				Source: &DomainDiskSource{
  2654  					Block: &DomainDiskSourceBlock{
  2655  						Dev: "/dev/HostVG/QEMUGuest1Copy",
  2656  					},
  2657  				},
  2658  			},
  2659  			Target: &DomainDiskTarget{
  2660  				Dev: "vda",
  2661  				Bus: "virtio",
  2662  			},
  2663  		},
  2664  		Expected: []string{
  2665  			`<disk type="block" device="cdrom">`,
  2666  			`  <driver name="qemu" type="qcow2"></driver>`,
  2667  			`  <source dev="/dev/HostVG/QEMUGuest1"></source>`,
  2668  			`  <mirror type="block" job="copy" ready="yes">`,
  2669  			`    <source dev="/dev/HostVG/QEMUGuest1Copy"></source>`,
  2670  			`  </mirror>`,
  2671  			`  <target dev="vda" bus="virtio"></target>`,
  2672  			`</disk>`,
  2673  		},
  2674  	},
  2675  	{
  2676  		Object: &DomainDisk{
  2677  			Device: "cdrom",
  2678  			Driver: &DomainDiskDriver{
  2679  				Name: "qemu",
  2680  				Type: "qcow2",
  2681  			},
  2682  			Source: &DomainDiskSource{
  2683  				NVME: &DomainDiskSourceNVME{
  2684  					PCI: &DomainDiskSourceNVMEPCI{
  2685  						Managed:   "yes",
  2686  						Namespace: 15,
  2687  						Address: &DomainAddressPCI{
  2688  							Domain:   &nvmeAddr.Domain,
  2689  							Bus:      &nvmeAddr.Bus,
  2690  							Slot:     &nvmeAddr.Slot,
  2691  							Function: &nvmeAddr.Function,
  2692  						},
  2693  					},
  2694  				},
  2695  			},
  2696  			Target: &DomainDiskTarget{
  2697  				Dev: "vda",
  2698  				Bus: "virtio",
  2699  			},
  2700  		},
  2701  		Expected: []string{
  2702  			`<disk type="nvme" device="cdrom">`,
  2703  			`  <driver name="qemu" type="qcow2"></driver>`,
  2704  			`  <source type="pci" managed="yes" namespace="15">`,
  2705  			`    <address domain="0x0000" bus="0x01" slot="0x03" function="0x0"></address>`,
  2706  			`  </source>`,
  2707  			`  <target dev="vda" bus="virtio"></target>`,
  2708  			`</disk>`,
  2709  		},
  2710  	},
  2711  	{
  2712  		Object: &DomainDisk{
  2713  			Device: "cdrom",
  2714  			Driver: &DomainDiskDriver{
  2715  				Name: "qemu",
  2716  				Type: "qcow2",
  2717  			},
  2718  			Source: &DomainDiskSource{
  2719  				File: &DomainDiskSourceFile{
  2720  					File: "/var/lib/libvirt/images/demo.qcow2",
  2721  				},
  2722  			},
  2723  			Mirror: &DomainDiskMirror{
  2724  				Job: "copy",
  2725  				Format: &DomainDiskFormat{
  2726  					Type: "qcow2",
  2727  				},
  2728  				Source: &DomainDiskSource{
  2729  					File: &DomainDiskSourceFile{
  2730  						File: "/var/lib/libvirt/images/demo-copy.qcow2",
  2731  					},
  2732  				},
  2733  			},
  2734  			Target: &DomainDiskTarget{
  2735  				Dev: "vda",
  2736  				Bus: "virtio",
  2737  			},
  2738  		},
  2739  		Expected: []string{
  2740  			`<disk type="file" device="cdrom">`,
  2741  			`  <driver name="qemu" type="qcow2"></driver>`,
  2742  			`  <source file="/var/lib/libvirt/images/demo.qcow2"></source>`,
  2743  			`  <mirror type="file" file="/var/lib/libvirt/images/demo-copy.qcow2" format="qcow2" job="copy">`,
  2744  			`    <format type="qcow2"></format>`,
  2745  			`    <source file="/var/lib/libvirt/images/demo-copy.qcow2"></source>`,
  2746  			`  </mirror>`,
  2747  			`  <target dev="vda" bus="virtio"></target>`,
  2748  			`</disk>`,
  2749  		},
  2750  	},
  2751  	{
  2752  		Object: &DomainFilesystem{
  2753  			AccessMode: "mapped",
  2754  			Driver: &DomainFilesystemDriver{
  2755  				Type:     "path",
  2756  				WRPolicy: "immediate",
  2757  			},
  2758  			Source: &DomainFilesystemSource{
  2759  				Mount: &DomainFilesystemSourceMount{
  2760  					Dir: "/home/user/test",
  2761  				},
  2762  			},
  2763  			Target: &DomainFilesystemTarget{
  2764  				Dir: "user-test-mount",
  2765  			},
  2766  			Address: &DomainAddress{
  2767  				PCI: &DomainAddressPCI{
  2768  					Domain:   &fsAddr.Domain,
  2769  					Bus:      &fsAddr.Bus,
  2770  					Slot:     &fsAddr.Slot,
  2771  					Function: &fsAddr.Function,
  2772  				},
  2773  			},
  2774  		},
  2775  
  2776  		Expected: []string{
  2777  			`<filesystem type="mount" accessmode="mapped">`,
  2778  			`  <driver type="path" wrpolicy="immediate"></driver>`,
  2779  			`  <source dir="/home/user/test"></source>`,
  2780  			`  <target dir="user-test-mount"></target>`,
  2781  			`  <address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"></address>`,
  2782  			`</filesystem>`,
  2783  		},
  2784  	},
  2785  	{
  2786  		Object: &DomainInterface{
  2787  			MAC: &DomainInterfaceMAC{
  2788  				Address: "00:11:22:33:44:55",
  2789  			},
  2790  			Model: &DomainInterfaceModel{
  2791  				Type: "virtio",
  2792  			},
  2793  			Source: &DomainInterfaceSource{
  2794  				Network: &DomainInterfaceSourceNetwork{
  2795  					Network: "default",
  2796  				},
  2797  			},
  2798  		},
  2799  		Expected: []string{
  2800  			`<interface type="network">`,
  2801  			`  <mac address="00:11:22:33:44:55"></mac>`,
  2802  			`  <source network="default"></source>`,
  2803  			`  <model type="virtio"></model>`,
  2804  			`</interface>`,
  2805  		},
  2806  	},
  2807  	{
  2808  		Object: &DomainSerial{
  2809  			Source: &DomainChardevSource{
  2810  				Pty: &DomainChardevSourcePty{},
  2811  			},
  2812  			Target: &DomainSerialTarget{
  2813  				Type: "isa",
  2814  				Port: &serialPort,
  2815  				Model: &DomainSerialTargetModel{
  2816  					Name: "isa-serial",
  2817  				},
  2818  			},
  2819  			Log: &DomainChardevLog{
  2820  				File:   "/some/path",
  2821  				Append: "on",
  2822  			},
  2823  		},
  2824  
  2825  		Expected: []string{
  2826  			`<serial type="pty">`,
  2827  			`  <target type="isa" port="0">`,
  2828  			`    <model name="isa-serial"></model>`,
  2829  			`  </target>`,
  2830  			`  <log file="/some/path" append="on"></log>`,
  2831  			`</serial>`,
  2832  		},
  2833  	},
  2834  	{
  2835  		Object: &DomainParallel{
  2836  			Source: &DomainChardevSource{
  2837  				Pty: &DomainChardevSourcePty{},
  2838  			},
  2839  			Target: &DomainParallelTarget{
  2840  				Type: "isa",
  2841  				Port: &parallelPort,
  2842  			},
  2843  			Log: &DomainChardevLog{
  2844  				File:   "/some/path",
  2845  				Append: "on",
  2846  			},
  2847  		},
  2848  
  2849  		Expected: []string{
  2850  			`<parallel type="pty">`,
  2851  			`  <target type="isa" port="0"></target>`,
  2852  			`  <log file="/some/path" append="on"></log>`,
  2853  			`</parallel>`,
  2854  		},
  2855  	},
  2856  	{
  2857  		Object: &DomainConsole{
  2858  			Source: &DomainChardevSource{
  2859  				Pty: &DomainChardevSourcePty{},
  2860  			},
  2861  			Target: &DomainConsoleTarget{
  2862  				Type: "virtio",
  2863  				Port: &serialPort,
  2864  			},
  2865  		},
  2866  
  2867  		Expected: []string{
  2868  			`<console type="pty">`,
  2869  			`  <target type="virtio" port="0"></target>`,
  2870  			`</console>`,
  2871  		},
  2872  	},
  2873  	{
  2874  		Object: &DomainSmartcard{
  2875  			Host: &DomainSmartcardHost{},
  2876  			Address: &DomainAddress{
  2877  				CCID: &DomainAddressCCID{
  2878  					Controller: &smartcardController,
  2879  					Slot:       &smartcardSlot,
  2880  				},
  2881  			},
  2882  		},
  2883  
  2884  		Expected: []string{
  2885  			`<smartcard mode="host">`,
  2886  			`  <address type="ccid" controller="0" slot="7"></address>`,
  2887  			`</smartcard>`,
  2888  		},
  2889  	},
  2890  	{
  2891  		Object: &DomainSmartcard{
  2892  			Passthrough: &DomainChardevSource{
  2893  				TCP: &DomainChardevSourceTCP{
  2894  					Mode:    "connect",
  2895  					Host:    "localhost",
  2896  					Service: "12345",
  2897  				},
  2898  			},
  2899  			Protocol: &DomainChardevProtocol{
  2900  				Type: "raw",
  2901  			},
  2902  			Address: &DomainAddress{
  2903  				CCID: &DomainAddressCCID{
  2904  					Controller: &smartcardController,
  2905  					Slot:       &smartcardSlot,
  2906  				},
  2907  			},
  2908  		},
  2909  
  2910  		Expected: []string{
  2911  			`<smartcard mode="passthrough" type="tcp">`,
  2912  			`  <source mode="connect" host="localhost" service="12345"></source>`,
  2913  			`  <protocol type="raw"></protocol>`,
  2914  			`  <address type="ccid" controller="0" slot="7"></address>`,
  2915  			`</smartcard>`,
  2916  		},
  2917  	},
  2918  	{
  2919  		Object: &DomainSmartcard{
  2920  			HostCerts: []DomainSmartcardHostCert{
  2921  				DomainSmartcardHostCert{
  2922  					File: "/some/cert1",
  2923  				},
  2924  				DomainSmartcardHostCert{
  2925  					File: "/some/cert2",
  2926  				},
  2927  				DomainSmartcardHostCert{
  2928  					File: "/some/cert3",
  2929  				},
  2930  			},
  2931  			Address: &DomainAddress{
  2932  				CCID: &DomainAddressCCID{
  2933  					Controller: &smartcardController,
  2934  					Slot:       &smartcardSlot,
  2935  				},
  2936  			},
  2937  		},
  2938  
  2939  		Expected: []string{
  2940  			`<smartcard mode="host-certificates">`,
  2941  			`  <certificate>/some/cert1</certificate>`,
  2942  			`  <certificate>/some/cert2</certificate>`,
  2943  			`  <certificate>/some/cert3</certificate>`,
  2944  			`  <address type="ccid" controller="0" slot="7"></address>`,
  2945  			`</smartcard>`,
  2946  		},
  2947  	},
  2948  	{
  2949  		Object: &DomainTPM{
  2950  			Model: "tpm-tis",
  2951  			Backend: &DomainTPMBackend{
  2952  				Passthrough: &DomainTPMBackendPassthrough{
  2953  					Device: &DomainTPMBackendDevice{
  2954  						Path: "/dev/tpm0",
  2955  					},
  2956  				},
  2957  			},
  2958  		},
  2959  
  2960  		Expected: []string{
  2961  			`<tpm model="tpm-tis">`,
  2962  			`  <backend type="passthrough">`,
  2963  			`    <device path="/dev/tpm0"></device>`,
  2964  			`  </backend>`,
  2965  			`</tpm>`,
  2966  		},
  2967  	},
  2968  	{
  2969  		Object: &DomainShmem{
  2970  			Name: "demo",
  2971  			Size: &DomainShmemSize{
  2972  				Value: 1,
  2973  				Unit:  "GiB",
  2974  			},
  2975  			Model: &DomainShmemModel{
  2976  				Type: "ivshmem-doorbell",
  2977  			},
  2978  			Server: &DomainShmemServer{
  2979  				Path: "/some/server",
  2980  			},
  2981  			MSI: &DomainShmemMSI{
  2982  				Enabled:   "yes",
  2983  				Vectors:   5,
  2984  				IOEventFD: "yes",
  2985  			},
  2986  		},
  2987  
  2988  		Expected: []string{
  2989  			`<shmem name="demo">`,
  2990  			`  <size unit="GiB">1</size>`,
  2991  			`  <model type="ivshmem-doorbell"></model>`,
  2992  			`  <server path="/some/server"></server>`,
  2993  			`  <msi enabled="yes" vectors="5" ioeventfd="yes"></msi>`,
  2994  			`</shmem>`,
  2995  		},
  2996  	},
  2997  	{
  2998  		Object: &DomainInput{
  2999  			Type: "tablet",
  3000  			Bus:  "usb",
  3001  			Address: &DomainAddress{
  3002  				USB: &DomainAddressUSB{
  3003  					Bus:  &tabletBus,
  3004  					Port: tabletPort,
  3005  				},
  3006  			},
  3007  		},
  3008  
  3009  		Expected: []string{
  3010  			`<input type="tablet" bus="usb">`,
  3011  			`  <address type="usb" bus="0" port="1.1"></address>`,
  3012  			`</input>`,
  3013  		},
  3014  	},
  3015  	{
  3016  		Object: &DomainVideo{
  3017  			Driver: &DomainVideoDriver{
  3018  				VGAConf: "io",
  3019  			},
  3020  			Model: DomainVideoModel{
  3021  				Type:    "cirrus",
  3022  				Heads:   1,
  3023  				Ram:     4096,
  3024  				VRam:    8192,
  3025  				VRam64:  8192,
  3026  				VGAMem:  256,
  3027  				Primary: "yes",
  3028  				Accel: &DomainVideoAccel{
  3029  					Accel3D: "yes",
  3030  					Accel2D: "no",
  3031  				},
  3032  			},
  3033  			Address: &DomainAddress{
  3034  				PCI: &DomainAddressPCI{
  3035  					Domain:        &videoAddr.Domain,
  3036  					Bus:           &videoAddr.Bus,
  3037  					Slot:          &videoAddr.Slot,
  3038  					Function:      &videoAddr.Function,
  3039  					MultiFunction: "on",
  3040  				},
  3041  			},
  3042  		},
  3043  
  3044  		Expected: []string{
  3045  			`<video>`,
  3046  			`  <model type="cirrus" heads="1" ram="4096" vram="8192" vram64="8192" vgamem="256" primary="yes">`,
  3047  			`    <acceleration accel3d="yes" accel2d="no"></acceleration>`,
  3048  			`  </model>`,
  3049  			`  <driver vgaconf="io"></driver>`,
  3050  			`  <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0" multifunction="on"></address>`,
  3051  			`</video>`,
  3052  		},
  3053  	},
  3054  	{
  3055  		Object: &DomainChannel{
  3056  			Source: &DomainChardevSource{
  3057  				Pty: &DomainChardevSourcePty{},
  3058  			},
  3059  			Target: &DomainChannelTarget{
  3060  				VirtIO: &DomainChannelTargetVirtIO{
  3061  					Name:  "org.redhat.spice",
  3062  					State: "connected",
  3063  				},
  3064  			},
  3065  		},
  3066  
  3067  		Expected: []string{
  3068  			`<channel type="pty">`,
  3069  			`  <target type="virtio" name="org.redhat.spice" state="connected"></target>`,
  3070  			`</channel>`,
  3071  		},
  3072  	},
  3073  	{
  3074  		Object: &DomainChannel{
  3075  			Source: &DomainChardevSource{
  3076  				Pty: &DomainChardevSourcePty{},
  3077  			},
  3078  			Target: &DomainChannelTarget{
  3079  				Xen: &DomainChannelTargetXen{
  3080  					Name:  "org.redhat.spice",
  3081  					State: "connected",
  3082  				},
  3083  			},
  3084  		},
  3085  
  3086  		Expected: []string{
  3087  			`<channel type="pty">`,
  3088  			`  <target type="xen" name="org.redhat.spice" state="connected"></target>`,
  3089  			`</channel>`,
  3090  		},
  3091  	},
  3092  	{
  3093  		Object: &DomainRedirDev{
  3094  			Bus: "usb",
  3095  			Source: &DomainChardevSource{
  3096  				SpiceVMC: &DomainChardevSourceSpiceVMC{},
  3097  			},
  3098  			Address: &DomainAddress{
  3099  				USB: &DomainAddressUSB{
  3100  					Bus:  &redirBus,
  3101  					Port: redirPort,
  3102  				},
  3103  			},
  3104  		},
  3105  
  3106  		Expected: []string{
  3107  			`<redirdev type="spicevmc" bus="usb">`,
  3108  			`  <address type="usb" bus="0" port="3"></address>`,
  3109  			`</redirdev>`,
  3110  		},
  3111  	},
  3112  	{
  3113  		Object: &DomainRedirDev{
  3114  			Bus: "usb",
  3115  			Source: &DomainChardevSource{
  3116  				TCP: &DomainChardevSourceTCP{
  3117  					Mode:    "connect",
  3118  					Host:    "localhost",
  3119  					Service: "1234",
  3120  				},
  3121  			},
  3122  			Protocol: &DomainChardevProtocol{
  3123  				Type: "raw",
  3124  			},
  3125  			Boot: &DomainDeviceBoot{
  3126  				Order: 1,
  3127  			},
  3128  			Address: &DomainAddress{
  3129  				USB: &DomainAddressUSB{
  3130  					Bus:  &redirBus,
  3131  					Port: redirPort,
  3132  				},
  3133  			},
  3134  		},
  3135  
  3136  		Expected: []string{
  3137  			`<redirdev type="tcp" bus="usb">`,
  3138  			`  <source mode="connect" host="localhost" service="1234"></source>`,
  3139  			`  <protocol type="raw"></protocol>`,
  3140  			`  <boot order="1"></boot>`,
  3141  			`  <address type="usb" bus="0" port="3"></address>`,
  3142  			`</redirdev>`,
  3143  		},
  3144  	},
  3145  	{
  3146  		Object: &DomainChannel{
  3147  			Source: &DomainChardevSource{
  3148  				Pty: &DomainChardevSourcePty{},
  3149  			},
  3150  			Target: &DomainChannelTarget{
  3151  				GuestFWD: &DomainChannelTargetGuestFWD{
  3152  					Address: "192.168.1.1",
  3153  					Port:    "123",
  3154  				},
  3155  			},
  3156  		},
  3157  
  3158  		Expected: []string{
  3159  			`<channel type="pty">`,
  3160  			`  <target type="guestfwd" address="192.168.1.1" port="123"></target>`,
  3161  			`</channel>`,
  3162  		},
  3163  	},
  3164  	{
  3165  		Object: &Domain{
  3166  			Name: "demo",
  3167  			Devices: &DomainDeviceList{
  3168  				Graphics: []DomainGraphic{
  3169  					DomainGraphic{
  3170  						Spice: &DomainGraphicSpice{
  3171  							Port:        5903,
  3172  							TLSPort:     5904,
  3173  							AutoPort:    "no",
  3174  							Listen:      "127.0.0.1",
  3175  							DefaultMode: "secure",
  3176  							Listeners: []DomainGraphicListener{
  3177  								DomainGraphicListener{
  3178  									Address: &DomainGraphicListenerAddress{
  3179  										Address: "127.0.0.1",
  3180  									},
  3181  								},
  3182  							},
  3183  							Channel: []DomainGraphicSpiceChannel{
  3184  								DomainGraphicSpiceChannel{
  3185  									Name: "main",
  3186  									Mode: "secure",
  3187  								},
  3188  								DomainGraphicSpiceChannel{
  3189  									Name: "inputs",
  3190  									Mode: "insecure",
  3191  								},
  3192  							},
  3193  							Image: &DomainGraphicSpiceImage{
  3194  								Compression: "auto_glz",
  3195  							},
  3196  							JPEG: &DomainGraphicSpiceJPEG{
  3197  								Compression: "auto",
  3198  							},
  3199  							ZLib: &DomainGraphicSpiceZLib{
  3200  								Compression: "auto",
  3201  							},
  3202  							Playback: &DomainGraphicSpicePlayback{
  3203  								Compression: "on",
  3204  							},
  3205  							Streaming: &DomainGraphicSpiceStreaming{
  3206  								Mode: "filter",
  3207  							},
  3208  							ClipBoard: &DomainGraphicSpiceClipBoard{
  3209  								CopyPaste: "no",
  3210  							},
  3211  							FileTransfer: &DomainGraphicSpiceFileTransfer{
  3212  								Enable: "no",
  3213  							},
  3214  						},
  3215  					},
  3216  				},
  3217  			},
  3218  		},
  3219  		Expected: []string{
  3220  			`<domain>`,
  3221  			`  <name>demo</name>`,
  3222  			`  <devices>`,
  3223  			`    <graphics type="spice" port="5903" tlsPort="5904" autoport="no" listen="127.0.0.1" defaultMode="secure">`,
  3224  			`      <listen type="address" address="127.0.0.1"></listen>`,
  3225  			`      <channel name="main" mode="secure"></channel>`,
  3226  			`      <channel name="inputs" mode="insecure"></channel>`,
  3227  			`      <image compression="auto_glz"></image>`,
  3228  			`      <jpeg compression="auto"></jpeg>`,
  3229  			`      <zlib compression="auto"></zlib>`,
  3230  			`      <playback compression="on"></playback>`,
  3231  			`      <streaming mode="filter"></streaming>`,
  3232  			`      <clipboard copypaste="no"></clipboard>`,
  3233  			`      <filetransfer enable="no"></filetransfer>`,
  3234  			`    </graphics>`,
  3235  			`  </devices>`,
  3236  			`</domain>`,
  3237  		},
  3238  	},
  3239  	{
  3240  		Object: &Domain{
  3241  			Name: "demo",
  3242  			Devices: &DomainDeviceList{
  3243  				Graphics: []DomainGraphic{
  3244  					DomainGraphic{
  3245  						VNC: &DomainGraphicVNC{
  3246  							Port:     5903,
  3247  							AutoPort: "no",
  3248  							Listeners: []DomainGraphicListener{
  3249  								DomainGraphicListener{},
  3250  							},
  3251  						},
  3252  					},
  3253  				},
  3254  			},
  3255  		},
  3256  		Expected: []string{
  3257  			`<domain>`,
  3258  			`  <name>demo</name>`,
  3259  			`  <devices>`,
  3260  			`    <graphics type="vnc" port="5903" autoport="no">`,
  3261  			`      <listen type="none"></listen>`,
  3262  			`    </graphics>`,
  3263  			`  </devices>`,
  3264  			`</domain>`,
  3265  		},
  3266  	},
  3267  	{
  3268  		Object: &DomainMemBalloon{
  3269  			Model:       "virtio",
  3270  			AutoDeflate: "on",
  3271  			Stats: &DomainMemBalloonStats{
  3272  				Period: 10,
  3273  			},
  3274  			Address: &DomainAddress{
  3275  				PCI: &DomainAddressPCI{
  3276  					Domain:   &balloonAddr.Domain,
  3277  					Bus:      &balloonAddr.Bus,
  3278  					Slot:     &balloonAddr.Slot,
  3279  					Function: &balloonAddr.Function,
  3280  				},
  3281  			},
  3282  		},
  3283  
  3284  		Expected: []string{
  3285  			`<memballoon model="virtio" autodeflate="on">`,
  3286  			`  <stats period="10"></stats>`,
  3287  			`  <address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"></address>`,
  3288  			`</memballoon>`,
  3289  		},
  3290  	},
  3291  	{
  3292  		Object: &DomainWatchdog{
  3293  			Model:  "ib700",
  3294  			Action: "inject-nmi",
  3295  			Address: &DomainAddress{
  3296  				PCI: &DomainAddressPCI{
  3297  					Domain:   &watchdogAddr.Domain,
  3298  					Bus:      &watchdogAddr.Bus,
  3299  					Slot:     &watchdogAddr.Slot,
  3300  					Function: &watchdogAddr.Function,
  3301  				},
  3302  			},
  3303  		},
  3304  
  3305  		Expected: []string{
  3306  			`<watchdog model="ib700" action="inject-nmi">`,
  3307  			`  <address type="pci" domain="0x0000" bus="0x00" slot="0x08" function="0x0"></address>`,
  3308  			`</watchdog>`,
  3309  		},
  3310  	},
  3311  	{
  3312  		Object: &DomainSound{
  3313  			Model: "ich6",
  3314  			Codec: []DomainSoundCodec{
  3315  				DomainSoundCodec{
  3316  					Type: "duplex",
  3317  				},
  3318  				DomainSoundCodec{
  3319  					Type: "micro",
  3320  				},
  3321  			},
  3322  			Address: &DomainAddress{
  3323  				PCI: &DomainAddressPCI{
  3324  					Domain:   &duplexAddr.Domain,
  3325  					Bus:      &duplexAddr.Bus,
  3326  					Slot:     &duplexAddr.Slot,
  3327  					Function: &duplexAddr.Function,
  3328  				},
  3329  			},
  3330  		},
  3331  
  3332  		Expected: []string{
  3333  			`<sound model="ich6">`,
  3334  			`  <codec type="duplex"></codec>`,
  3335  			`  <codec type="micro"></codec>`,
  3336  			`  <address type="pci" domain="0x0000" bus="0x00" slot="0x08" function="0x0"></address>`,
  3337  			`</sound>`,
  3338  		},
  3339  	},
  3340  	{
  3341  		Object: &DomainConsole{
  3342  			Source: &DomainChardevSource{
  3343  				Null: &DomainChardevSourceNull{},
  3344  			},
  3345  		},
  3346  
  3347  		Expected: []string{
  3348  			`<console type="null"></console>`,
  3349  		},
  3350  	},
  3351  	{
  3352  		Object: &DomainConsole{
  3353  			Source: &DomainChardevSource{
  3354  				VC: &DomainChardevSourceVC{},
  3355  			},
  3356  		},
  3357  
  3358  		Expected: []string{
  3359  			`<console type="vc"></console>`,
  3360  		},
  3361  	},
  3362  	{
  3363  		Object: &DomainConsole{
  3364  			TTY: "/dev/pts/3",
  3365  			Source: &DomainChardevSource{
  3366  				Pty: &DomainChardevSourcePty{
  3367  					Path: "/dev/pts/3",
  3368  				},
  3369  			},
  3370  		},
  3371  
  3372  		Expected: []string{
  3373  			`<console type="pty" tty="/dev/pts/3">`,
  3374  			`  <source path="/dev/pts/3"></source>`,
  3375  			`</console>`,
  3376  		},
  3377  	},
  3378  	{
  3379  		Object: &DomainConsole{
  3380  			Source: &DomainChardevSource{
  3381  				Dev: &DomainChardevSourceDev{
  3382  					Path: "/dev/ttyS0",
  3383  				},
  3384  			},
  3385  		},
  3386  
  3387  		Expected: []string{
  3388  			`<console type="dev">`,
  3389  			`  <source path="/dev/ttyS0"></source>`,
  3390  			`</console>`,
  3391  		},
  3392  	},
  3393  	{
  3394  		Object: &DomainConsole{
  3395  			Source: &DomainChardevSource{
  3396  				File: &DomainChardevSourceFile{
  3397  					Path: "/tmp/file.log",
  3398  				},
  3399  			},
  3400  		},
  3401  
  3402  		Expected: []string{
  3403  			`<console type="file">`,
  3404  			`  <source path="/tmp/file.log"></source>`,
  3405  			`</console>`,
  3406  		},
  3407  	},
  3408  	{
  3409  		Object: &DomainConsole{
  3410  			Source: &DomainChardevSource{
  3411  				Pipe: &DomainChardevSourcePipe{
  3412  					Path: "/tmp/file.fifo",
  3413  				},
  3414  			},
  3415  		},
  3416  
  3417  		Expected: []string{
  3418  			`<console type="pipe">`,
  3419  			`  <source path="/tmp/file.fifo"></source>`,
  3420  			`</console>`,
  3421  		},
  3422  	},
  3423  	{
  3424  		Object: &DomainConsole{
  3425  			Source: &DomainChardevSource{
  3426  				StdIO: &DomainChardevSourceStdIO{},
  3427  			},
  3428  		},
  3429  
  3430  		Expected: []string{
  3431  			`<console type="stdio"></console>`,
  3432  		},
  3433  	},
  3434  	{
  3435  		Object: &DomainConsole{
  3436  			Source: &DomainChardevSource{
  3437  				UDP: &DomainChardevSourceUDP{
  3438  					ConnectHost:    "some.server",
  3439  					ConnectService: "4999",
  3440  					BindHost:       "my.server",
  3441  					BindService:    "5921",
  3442  				},
  3443  			},
  3444  		},
  3445  
  3446  		Expected: []string{
  3447  			`<console type="udp">`,
  3448  			`  <source mode="bind" host="my.server" service="5921"></source>`,
  3449  			`  <source mode="connect" host="some.server" service="4999"></source>`,
  3450  			`</console>`,
  3451  		},
  3452  	},
  3453  	{
  3454  		Object: &DomainConsole{
  3455  			Source: &DomainChardevSource{
  3456  				TCP: &DomainChardevSourceTCP{
  3457  					Mode:    "connect",
  3458  					Host:    "localhost",
  3459  					Service: "25",
  3460  				},
  3461  			},
  3462  		},
  3463  
  3464  		Expected: []string{
  3465  			`<console type="tcp">`,
  3466  			`  <source mode="connect" host="localhost" service="25"></source>`,
  3467  			`</console>`,
  3468  		},
  3469  	},
  3470  	{
  3471  		Object: &DomainConsole{
  3472  			Source: &DomainChardevSource{
  3473  				UNIX: &DomainChardevSourceUNIX{
  3474  					Mode: "connect",
  3475  					Path: "/tmp/myvm.sock",
  3476  				},
  3477  			},
  3478  		},
  3479  
  3480  		Expected: []string{
  3481  			`<console type="unix">`,
  3482  			`  <source mode="connect" path="/tmp/myvm.sock"></source>`,
  3483  			`</console>`,
  3484  		},
  3485  	},
  3486  	{
  3487  		Object: &DomainConsole{
  3488  			Source: &DomainChardevSource{
  3489  				SpiceVMC: &DomainChardevSourceSpiceVMC{},
  3490  			},
  3491  		},
  3492  
  3493  		Expected: []string{
  3494  			`<console type="spicevmc"></console>`,
  3495  		},
  3496  	},
  3497  	{
  3498  		Object: &DomainConsole{
  3499  			Source: &DomainChardevSource{
  3500  				SpicePort: &DomainChardevSourceSpicePort{
  3501  					Channel: "org.qemu.console.serial.0",
  3502  				},
  3503  			},
  3504  		},
  3505  
  3506  		Expected: []string{
  3507  			`<console type="spiceport">`,
  3508  			`  <source channel="org.qemu.console.serial.0"></source>`,
  3509  			`</console>`,
  3510  		},
  3511  	},
  3512  	{
  3513  		Object: &DomainConsole{
  3514  			Source: &DomainChardevSource{
  3515  				NMDM: &DomainChardevSourceNMDM{
  3516  					Master: "/dev/nmdm0A",
  3517  					Slave:  "/dev/nmdm0B",
  3518  				},
  3519  			},
  3520  		},
  3521  
  3522  		Expected: []string{
  3523  			`<console type="nmdm">`,
  3524  			`  <source master="/dev/nmdm0A" slave="/dev/nmdm0B"></source>`,
  3525  			`</console>`,
  3526  		},
  3527  	},
  3528  	{
  3529  		Object: &DomainRNG{
  3530  			Model: "virtio",
  3531  			Rate: &DomainRNGRate{
  3532  				Period: 2000,
  3533  				Bytes:  1234,
  3534  			},
  3535  			Backend: &DomainRNGBackend{
  3536  				Random: &DomainRNGBackendRandom{
  3537  					Device: "/dev/random",
  3538  				},
  3539  			},
  3540  			Address: &DomainAddress{
  3541  				PCI: &DomainAddressPCI{
  3542  					Domain:   &rngAddr.Domain,
  3543  					Bus:      &rngAddr.Bus,
  3544  					Slot:     &rngAddr.Slot,
  3545  					Function: &rngAddr.Function,
  3546  				},
  3547  			},
  3548  		},
  3549  
  3550  		Expected: []string{
  3551  			`<rng model="virtio">`,
  3552  			`  <rate bytes="1234" period="2000"></rate>`,
  3553  			`  <backend model="random">/dev/random</backend>`,
  3554  			`  <address type="pci" domain="0x0000" bus="0x00" slot="0x09" function="0x0"></address>`,
  3555  			`</rng>`,
  3556  		},
  3557  	},
  3558  	{
  3559  		Object: &DomainRNG{
  3560  			Model: "virtio",
  3561  			Rate: &DomainRNGRate{
  3562  				Period: 2000,
  3563  				Bytes:  1234,
  3564  			},
  3565  			Backend: &DomainRNGBackend{
  3566  				EGD: &DomainRNGBackendEGD{
  3567  					Source: &DomainChardevSource{
  3568  						UDP: &DomainChardevSourceUDP{
  3569  							BindService:    "1234",
  3570  							ConnectHost:    "1.2.3.4",
  3571  							ConnectService: "1234",
  3572  						},
  3573  					},
  3574  				},
  3575  			},
  3576  		},
  3577  
  3578  		Expected: []string{
  3579  			`<rng model="virtio">`,
  3580  			`  <rate bytes="1234" period="2000"></rate>`,
  3581  			`  <backend model="egd" type="udp">`,
  3582  			`    <source mode="bind" service="1234"></source>`,
  3583  			`    <source mode="connect" host="1.2.3.4" service="1234"></source>`,
  3584  			`  </backend>`,
  3585  			`</rng>`,
  3586  		},
  3587  	},
  3588  	{
  3589  		Object: &DomainHostdev{
  3590  			SubsysSCSI: &DomainHostdevSubsysSCSI{
  3591  				SGIO:  "unfiltered",
  3592  				RawIO: "yes",
  3593  				Source: &DomainHostdevSubsysSCSISource{
  3594  					Host: &DomainHostdevSubsysSCSISourceHost{
  3595  						Adapter: &DomainHostdevSubsysSCSIAdapter{
  3596  							Name: "scsi_host0",
  3597  						},
  3598  						Address: &DomainAddressDrive{
  3599  							Bus:    &hostdevSCSI.Bus,
  3600  							Target: &hostdevSCSI.Target,
  3601  							Unit:   &hostdevSCSI.Unit,
  3602  						},
  3603  					},
  3604  				},
  3605  			},
  3606  			Address: &DomainAddress{
  3607  				Drive: &DomainAddressDrive{
  3608  					Controller: &hostdevSCSI.Controller,
  3609  					Bus:        &hostdevSCSI.Bus,
  3610  					Target:     &hostdevSCSI.Target,
  3611  					Unit:       &hostdevSCSI.Unit,
  3612  				},
  3613  			},
  3614  		},
  3615  
  3616  		Expected: []string{
  3617  			`<hostdev mode="subsystem" type="scsi" sgio="unfiltered" rawio="yes">`,
  3618  			`  <source>`,
  3619  			`    <adapter name="scsi_host0"></adapter>`,
  3620  			`    <address bus="0" target="3" unit="0"></address>`,
  3621  			`  </source>`,
  3622  			`  <address type="drive" controller="0" bus="0" target="3" unit="0"></address>`,
  3623  			`</hostdev>`,
  3624  		},
  3625  	},
  3626  	{
  3627  		Object: &DomainHostdev{
  3628  			SubsysSCSI: &DomainHostdevSubsysSCSI{
  3629  				SGIO:  "unfiltered",
  3630  				RawIO: "yes",
  3631  				Source: &DomainHostdevSubsysSCSISource{
  3632  					ISCSI: &DomainHostdevSubsysSCSISourceISCSI{
  3633  						Name: "iqn.1992-01.com.example:storage/1",
  3634  						Host: []DomainDiskSourceHost{
  3635  							DomainDiskSourceHost{
  3636  								Name: "example.org",
  3637  								Port: "3260",
  3638  							},
  3639  						},
  3640  						Auth: &DomainDiskAuth{
  3641  							Username: "myname",
  3642  							Secret: &DomainDiskSecret{
  3643  								Type:  "iscsi",
  3644  								Usage: "mycluster_myname",
  3645  							},
  3646  						},
  3647  					},
  3648  				},
  3649  			},
  3650  			Address: &DomainAddress{
  3651  				Drive: &DomainAddressDrive{
  3652  					Controller: &hostdevSCSI.Controller,
  3653  					Bus:        &hostdevSCSI.Bus,
  3654  					Target:     &hostdevSCSI.Target,
  3655  					Unit:       &hostdevSCSI.Unit,
  3656  				},
  3657  			},
  3658  		},
  3659  
  3660  		Expected: []string{
  3661  			`<hostdev mode="subsystem" type="scsi" sgio="unfiltered" rawio="yes">`,
  3662  			`  <source protocol="iscsi" name="iqn.1992-01.com.example:storage/1">`,
  3663  			`    <host name="example.org" port="3260"></host>`,
  3664  			`    <auth username="myname">`,
  3665  			`      <secret type="iscsi" usage="mycluster_myname"></secret>`,
  3666  			`    </auth>`,
  3667  			`  </source>`,
  3668  			`  <address type="drive" controller="0" bus="0" target="3" unit="0"></address>`,
  3669  			`</hostdev>`,
  3670  		},
  3671  	},
  3672  	{
  3673  		Object: &DomainHostdev{
  3674  			SubsysSCSIHost: &DomainHostdevSubsysSCSIHost{
  3675  				Source: &DomainHostdevSubsysSCSIHostSource{
  3676  					Protocol: "vhost",
  3677  					WWPN:     "naa.5123456789abcde0",
  3678  				},
  3679  			},
  3680  		},
  3681  
  3682  		Expected: []string{
  3683  			`<hostdev mode="subsystem" type="scsi_host">`,
  3684  			`  <source protocol="vhost" wwpn="naa.5123456789abcde0"></source>`,
  3685  			`</hostdev>`,
  3686  		},
  3687  	},
  3688  	{
  3689  		Object: &DomainHostdev{
  3690  			SubsysUSB: &DomainHostdevSubsysUSB{
  3691  				Source: &DomainHostdevSubsysUSBSource{
  3692  					Address: &DomainAddressUSB{
  3693  						Bus:    &usbHostBus,
  3694  						Device: &usbHostDevice,
  3695  					},
  3696  				},
  3697  			},
  3698  		},
  3699  
  3700  		Expected: []string{
  3701  			`<hostdev mode="subsystem" type="usb">`,
  3702  			`  <source>`,
  3703  			`    <address bus="14" device="6"></address>`,
  3704  			`  </source>`,
  3705  			`</hostdev>`,
  3706  		},
  3707  	},
  3708  	{
  3709  		Object: &DomainHostdev{
  3710  			Managed: "yes",
  3711  			SubsysPCI: &DomainHostdevSubsysPCI{
  3712  				Source: &DomainHostdevSubsysPCISource{
  3713  					Address: &DomainAddressPCI{
  3714  						Domain:   &pciHostDomain,
  3715  						Bus:      &pciHostBus,
  3716  						Slot:     &pciHostSlot,
  3717  						Function: &pciHostFunction,
  3718  					},
  3719  				},
  3720  			},
  3721  		},
  3722  
  3723  		Expected: []string{
  3724  			`<hostdev mode="subsystem" type="pci" managed="yes">`,
  3725  			`  <source>`,
  3726  			`    <address domain="0x0000" bus="0x03" slot="0x0e" function="0x5"></address>`,
  3727  			`  </source>`,
  3728  			`</hostdev>`,
  3729  		},
  3730  	},
  3731  	{
  3732  		Object: &DomainHostdev{
  3733  			SubsysMDev: &DomainHostdevSubsysMDev{
  3734  				Model: "vfio-pci",
  3735  				Source: &DomainHostdevSubsysMDevSource{
  3736  					Address: &DomainAddressMDev{
  3737  						UUID: "53764d0e-85a0-42b4-af5c-2046b460b1dc",
  3738  					},
  3739  				},
  3740  			},
  3741  		},
  3742  
  3743  		Expected: []string{
  3744  			`<hostdev mode="subsystem" type="mdev" model="vfio-pci">`,
  3745  			`  <source>`,
  3746  			`    <address uuid="53764d0e-85a0-42b4-af5c-2046b460b1dc"></address>`,
  3747  			`  </source>`,
  3748  			`</hostdev>`,
  3749  		},
  3750  	},
  3751  	{
  3752  		Object: &DomainHostdev{
  3753  			CapsStorage: &DomainHostdevCapsStorage{
  3754  				Source: &DomainHostdevCapsStorageSource{
  3755  					Block: "/dev/sda",
  3756  				},
  3757  			},
  3758  		},
  3759  
  3760  		Expected: []string{
  3761  			`<hostdev mode="capabilities" type="storage">`,
  3762  			`  <source>`,
  3763  			`    <block>/dev/sda</block>`,
  3764  			`  </source>`,
  3765  			`</hostdev>`,
  3766  		},
  3767  	},
  3768  	{
  3769  		Object: &DomainHostdev{
  3770  			CapsMisc: &DomainHostdevCapsMisc{
  3771  				Source: &DomainHostdevCapsMiscSource{
  3772  					Char: "/dev/kvm",
  3773  				},
  3774  			},
  3775  		},
  3776  
  3777  		Expected: []string{
  3778  			`<hostdev mode="capabilities" type="misc">`,
  3779  			`  <source>`,
  3780  			`    <char>/dev/kvm</char>`,
  3781  			`  </source>`,
  3782  			`</hostdev>`,
  3783  		},
  3784  	},
  3785  	{
  3786  		Object: &DomainHostdev{
  3787  			CapsNet: &DomainHostdevCapsNet{
  3788  				Source: &DomainHostdevCapsNetSource{
  3789  					Interface: "eth0",
  3790  				},
  3791  				IP: []DomainIP{
  3792  					DomainIP{
  3793  						Address: "192.168.122.2",
  3794  						Family:  "ipv4",
  3795  					},
  3796  					DomainIP{
  3797  						Address: "2003:db8:1:0:214:1234:fe0b:3596",
  3798  						Family:  "ipv6",
  3799  						Prefix:  &ipv6Prefix,
  3800  					},
  3801  				},
  3802  				Route: []DomainRoute{
  3803  					DomainRoute{
  3804  						Family:  "ipv4",
  3805  						Address: "0.0.0.0",
  3806  						Gateway: "192.168.122.1",
  3807  					},
  3808  					DomainRoute{
  3809  						Family:  "ipv6",
  3810  						Address: "::",
  3811  						Gateway: "2003:db8:1:0:214:1234:fe0b:3595",
  3812  					},
  3813  				},
  3814  			},
  3815  		},
  3816  
  3817  		Expected: []string{
  3818  			`<hostdev mode="capabilities" type="net">`,
  3819  			`  <source>`,
  3820  			`    <interface>eth0</interface>`,
  3821  			`  </source>`,
  3822  			`  <ip address="192.168.122.2" family="ipv4"></ip>`,
  3823  			`  <ip address="2003:db8:1:0:214:1234:fe0b:3596" family="ipv6" prefix="24"></ip>`,
  3824  			`  <route family="ipv4" address="0.0.0.0" gateway="192.168.122.1"></route>`,
  3825  			`  <route family="ipv6" address="::" gateway="2003:db8:1:0:214:1234:fe0b:3595"></route>`,
  3826  			`</hostdev>`,
  3827  		},
  3828  	},
  3829  	{
  3830  		Object: &DomainMemorydev{
  3831  			Model:  "dimm",
  3832  			Access: "private",
  3833  			Source: &DomainMemorydevSource{
  3834  				PageSize: &DomainMemorydevSourcePagesize{
  3835  					Value: 2048,
  3836  					Unit:  "KiB",
  3837  				},
  3838  				Path:     "/tmp/nvdimm",
  3839  				NodeMask: "0-1",
  3840  			},
  3841  			Target: &DomainMemorydevTarget{
  3842  				Size: &DomainMemorydevTargetSize{
  3843  					Value: 1,
  3844  					Unit:  "GiB",
  3845  				},
  3846  				Node: &DomainMemorydevTargetNode{
  3847  					Value: 0,
  3848  				},
  3849  				Label: &DomainMemorydevTargetLabel{
  3850  					Size: &DomainMemorydevTargetSize{
  3851  						Value: 200,
  3852  						Unit:  "KiB",
  3853  					},
  3854  				},
  3855  			},
  3856  		},
  3857  
  3858  		Expected: []string{
  3859  			`<memory model="dimm" access="private">`,
  3860  			`  <source>`,
  3861  			`    <nodemask>0-1</nodemask>`,
  3862  			`    <pagesize unit="KiB">2048</pagesize>`,
  3863  			`    <path>/tmp/nvdimm</path>`,
  3864  			`  </source>`,
  3865  			`  <target>`,
  3866  			`    <size unit="GiB">1</size>`,
  3867  			`    <node>0</node>`,
  3868  			`    <label>`,
  3869  			`      <size unit="KiB">200</size>`,
  3870  			`    </label>`,
  3871  			`  </target>`,
  3872  			`</memory>`,
  3873  		},
  3874  	},
  3875  	/* Host Bootloader -- bhyve, Xen */
  3876  	{
  3877  		Object: &Domain{
  3878  			Type:           "bhyve",
  3879  			Name:           "test",
  3880  			Bootloader:     "/usr/local/sbin/grub-bhyve",
  3881  			BootloaderArgs: "-r cd0 -m /tmp/test-device.map -M 1024M linuxguest",
  3882  		},
  3883  		Expected: []string{
  3884  			`<domain type="bhyve">`,
  3885  			`  <name>test</name>`,
  3886  			`  <bootloader>/usr/local/sbin/grub-bhyve</bootloader>`,
  3887  			`  <bootloader_args>-r cd0 -m /tmp/test-device.map -M 1024M linuxguest</bootloader_args>`,
  3888  			`</domain>`,
  3889  		},
  3890  	},
  3891  	{
  3892  		Object: &Domain{
  3893  			Name: "demo",
  3894  			Devices: &DomainDeviceList{
  3895  				Graphics: []DomainGraphic{
  3896  					DomainGraphic{SDL: &DomainGraphicSDL{}},
  3897  					DomainGraphic{VNC: &DomainGraphicVNC{}},
  3898  					DomainGraphic{RDP: &DomainGraphicRDP{}},
  3899  					DomainGraphic{Desktop: &DomainGraphicDesktop{}},
  3900  					DomainGraphic{Spice: &DomainGraphicSpice{}},
  3901  				},
  3902  			},
  3903  		},
  3904  		Expected: []string{
  3905  			`<domain>`,
  3906  			`  <name>demo</name>`,
  3907  			`  <devices>`,
  3908  			`    <graphics type="sdl"></graphics>`,
  3909  			`    <graphics type="vnc"></graphics>`,
  3910  			`    <graphics type="rdp"></graphics>`,
  3911  			`    <graphics type="desktop"></graphics>`,
  3912  			`    <graphics type="spice"></graphics>`,
  3913  			`  </devices>`,
  3914  			`</domain>`,
  3915  		},
  3916  	},
  3917  }
  3918  
  3919  func TestDomain(t *testing.T) {
  3920  	for _, test := range domainTestData {
  3921  		doc, err := test.Object.Marshal()
  3922  		if err != nil {
  3923  			t.Fatal(err)
  3924  		}
  3925  
  3926  		expect := strings.Join(test.Expected, "\n")
  3927  
  3928  		if doc != expect {
  3929  			t.Fatal("Bad initial xml:\n", string(doc), "\n does not match\n", expect, "\n")
  3930  		}
  3931  
  3932  		typ := reflect.ValueOf(test.Object).Elem().Type()
  3933  
  3934  		newobj := reflect.New(typ)
  3935  
  3936  		newdocobj, ok := newobj.Interface().(Document)
  3937  		if !ok {
  3938  			t.Fatalf("Could not clone %s", newobj.Interface())
  3939  		}
  3940  
  3941  		err = newdocobj.Unmarshal(expect)
  3942  		if err != nil {
  3943  			t.Fatal(err)
  3944  		}
  3945  
  3946  		doc, err = newdocobj.Marshal()
  3947  		if err != nil {
  3948  			t.Fatal(err)
  3949  		}
  3950  
  3951  		if doc != expect {
  3952  			t.Fatal("Bad roundtrip xml:\n", string(doc), "\n does not match\n", expect, "\n")
  3953  		}
  3954  	}
  3955  }