Skip to content

Commit

Permalink
Refactor xml definitions to match libvirt-go-xml current API
Browse files Browse the repository at this point in the history
libvirt/libvirt-go-xml@dd998da
changed the structs to be more like unions.
  • Loading branch information
dmacvicar committed Jul 12, 2018
1 parent 0ff62a2 commit 77982e7
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 139 deletions.
2 changes: 1 addition & 1 deletion libvirt/disk_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

const oui = "05abcd"

// note, source is not initialized
func newDefDisk(i int) libvirtxml.DomainDisk {
return libvirtxml.DomainDisk{
Type: "file",
Device: "disk",
Target: &libvirtxml.DomainDiskTarget{
Bus: "virtio",
Expand Down
2 changes: 1 addition & 1 deletion libvirt/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func getDomainInterfacesFromNetworks(domain libvirtxml.Domain,
var macAddresses []string

for _, networkInterface := range domain.Devices.Interfaces {
networkNames = append(networkNames, networkInterface.Source.Network)
networkNames = append(networkNames, networkInterface.Source.Network.Network)
macAddresses = append(macAddresses, strings.ToUpper(networkInterface.MAC.Address))
}

Expand Down
15 changes: 8 additions & 7 deletions libvirt/domain_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
libvirtxml "github.com/libvirt/libvirt-go-xml"
)

// note source and target are not initialized
func newFilesystemDef() libvirtxml.DomainFilesystem {
return libvirtxml.DomainFilesystem{
Type: "mount", // This is the only type used by qemu/kvm
AccessMode: "mapped", // A safe default value
ReadOnly: &libvirtxml.DomainFilesystemReadOnly{},
}
Expand All @@ -37,24 +37,25 @@ func newDomainDef() libvirtxml.Domain {
Devices: &libvirtxml.DomainDeviceList{
Graphics: []libvirtxml.DomainGraphic{
{
Type: "spice",
AutoPort: "yes",
Spice: &libvirtxml.DomainGraphicSpice{
AutoPort: "yes",
},
},
},
Channels: []libvirtxml.DomainChannel{
{
Type: "unix",
Target: &libvirtxml.DomainChannelTarget{
Type: "virtio",
Name: "org.qemu.guest_agent.0",
VirtIO: &libvirtxml.DomainChannelTargetVirtIO{
Name: "org.qemu.guest_agent.0",
},
},
},
},
RNGs: []libvirtxml.DomainRNG{
{
Model: "virtio",
Backend: &libvirtxml.DomainRNGBackend{
Model: "random",
Random: &libvirtxml.DomainRNGBackendRandom{},
},
},
},
Expand Down
Loading

0 comments on commit 77982e7

Please sign in to comment.