Loading domain.go +44 −28 Original line number Diff line number Diff line Loading @@ -381,6 +381,14 @@ type DomainDiskIOTune struct { GroupName string `xml:"group_name,omitempty"` } type ThrottleFilter struct { Group string `xml:"group,attr"` } type ThrottleFilters struct { ThrottleFilter []ThrottleFilter `xml:"throttlefilter"` } type DomainDiskGeometry struct { Cylinders uint `xml:"cyls,attr"` Headers uint `xml:"heads,attr"` Loading Loading @@ -435,6 +443,7 @@ type DomainDisk struct { Mirror *DomainDiskMirror `xml:"mirror"` Target *DomainDiskTarget `xml:"target"` IOTune *DomainDiskIOTune `xml:"iotune"` ThrottleFilters *ThrottleFilters `xml:"throttlefilters"` ReadOnly *DomainDiskReadOnly `xml:"readonly"` Shareable *DomainDiskShareable `xml:"shareable"` Transient *DomainDiskTransient `xml:"transient"` Loading Loading @@ -3163,6 +3172,12 @@ type DomainGenID struct { Value string `xml:",chardata"` } type DomainThrottleGroups struct { ThrottleGroups []ThrottleGroup `xml:"throttlegroup"` } type ThrottleGroup DomainDiskIOTune // NB, try to keep the order of fields in this struct // matching the order of XML elements that libvirt // will generate when dumping XML. Loading Loading @@ -3195,6 +3210,7 @@ type Domain struct { BootloaderArgs string `xml:"bootloader_args,omitempty"` OS *DomainOS `xml:"os"` IDMap *DomainIDMap `xml:"idmap"` ThrottleGroups *DomainThrottleGroups `xml:"throttlegroups"` Features *DomainFeatureList `xml:"features"` CPU *DomainCPU `xml:"cpu"` Clock *DomainClock `xml:"clock"` Loading domain_test.go +67 −0 Original line number Diff line number Diff line Loading @@ -3872,6 +3872,73 @@ var domainTestData = []struct { `</domain>`, }, }, { Object: &Domain{ Name: "domain_name1", ThrottleGroups: &DomainThrottleGroups{ ThrottleGroups: []ThrottleGroup{ ThrottleGroup{ TotalBytesSec: 125000000, TotalIopsSec: 7000, GroupName: "test", }, }, }, }, Expected: []string{ `<domain>`, ` <name>domain_name1</name>`, ` <throttlegroups>`, ` <throttlegroup>`, ` <total_bytes_sec>125000000</total_bytes_sec>`, ` <total_iops_sec>7000</total_iops_sec>`, ` <group_name>test</group_name>`, ` </throttlegroup>`, ` </throttlegroups>`, `</domain>`, }, }, { Object: &Domain{ Name: "domain_name2", Devices: &DomainDeviceList{ Disks: []DomainDisk{ DomainDisk{ Device: "disk", Source: &DomainDiskSource{ File: &DomainDiskSourceFile{ File: "/var/lib/libvirt/images/demo.qcow2", }, }, ThrottleFilters: &ThrottleFilters{ ThrottleFilter: []ThrottleFilter{ ThrottleFilter{ Group: "group_1", }, ThrottleFilter{ Group: "group_2", }, }, }, }, }, }, }, Expected: []string{ `<domain>`, ` <name>domain_name2</name>`, ` <devices>`, ` <disk type="file" device="disk">`, ` <source file="/var/lib/libvirt/images/demo.qcow2"></source>`, ` <throttlefilters>`, ` <throttlefilter group="group_1"></throttlefilter>`, ` <throttlefilter group="group_2"></throttlefilter>`, ` </throttlefilters>`, ` </disk>`, ` </devices>`, `</domain>`, }, }, } func TestDomain(t *testing.T) { Loading Loading
domain.go +44 −28 Original line number Diff line number Diff line Loading @@ -381,6 +381,14 @@ type DomainDiskIOTune struct { GroupName string `xml:"group_name,omitempty"` } type ThrottleFilter struct { Group string `xml:"group,attr"` } type ThrottleFilters struct { ThrottleFilter []ThrottleFilter `xml:"throttlefilter"` } type DomainDiskGeometry struct { Cylinders uint `xml:"cyls,attr"` Headers uint `xml:"heads,attr"` Loading Loading @@ -435,6 +443,7 @@ type DomainDisk struct { Mirror *DomainDiskMirror `xml:"mirror"` Target *DomainDiskTarget `xml:"target"` IOTune *DomainDiskIOTune `xml:"iotune"` ThrottleFilters *ThrottleFilters `xml:"throttlefilters"` ReadOnly *DomainDiskReadOnly `xml:"readonly"` Shareable *DomainDiskShareable `xml:"shareable"` Transient *DomainDiskTransient `xml:"transient"` Loading Loading @@ -3163,6 +3172,12 @@ type DomainGenID struct { Value string `xml:",chardata"` } type DomainThrottleGroups struct { ThrottleGroups []ThrottleGroup `xml:"throttlegroup"` } type ThrottleGroup DomainDiskIOTune // NB, try to keep the order of fields in this struct // matching the order of XML elements that libvirt // will generate when dumping XML. Loading Loading @@ -3195,6 +3210,7 @@ type Domain struct { BootloaderArgs string `xml:"bootloader_args,omitempty"` OS *DomainOS `xml:"os"` IDMap *DomainIDMap `xml:"idmap"` ThrottleGroups *DomainThrottleGroups `xml:"throttlegroups"` Features *DomainFeatureList `xml:"features"` CPU *DomainCPU `xml:"cpu"` Clock *DomainClock `xml:"clock"` Loading
domain_test.go +67 −0 Original line number Diff line number Diff line Loading @@ -3872,6 +3872,73 @@ var domainTestData = []struct { `</domain>`, }, }, { Object: &Domain{ Name: "domain_name1", ThrottleGroups: &DomainThrottleGroups{ ThrottleGroups: []ThrottleGroup{ ThrottleGroup{ TotalBytesSec: 125000000, TotalIopsSec: 7000, GroupName: "test", }, }, }, }, Expected: []string{ `<domain>`, ` <name>domain_name1</name>`, ` <throttlegroups>`, ` <throttlegroup>`, ` <total_bytes_sec>125000000</total_bytes_sec>`, ` <total_iops_sec>7000</total_iops_sec>`, ` <group_name>test</group_name>`, ` </throttlegroup>`, ` </throttlegroups>`, `</domain>`, }, }, { Object: &Domain{ Name: "domain_name2", Devices: &DomainDeviceList{ Disks: []DomainDisk{ DomainDisk{ Device: "disk", Source: &DomainDiskSource{ File: &DomainDiskSourceFile{ File: "/var/lib/libvirt/images/demo.qcow2", }, }, ThrottleFilters: &ThrottleFilters{ ThrottleFilter: []ThrottleFilter{ ThrottleFilter{ Group: "group_1", }, ThrottleFilter{ Group: "group_2", }, }, }, }, }, }, }, Expected: []string{ `<domain>`, ` <name>domain_name2</name>`, ` <devices>`, ` <disk type="file" device="disk">`, ` <source file="/var/lib/libvirt/images/demo.qcow2"></source>`, ` <throttlefilters>`, ` <throttlefilter group="group_1"></throttlefilter>`, ` <throttlefilter group="group_2"></throttlefilter>`, ` </throttlefilters>`, ` </disk>`, ` </devices>`, `</domain>`, }, }, } func TestDomain(t *testing.T) { Loading