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