[libvirt] [PATCH go-xml] Add support for CPUTune in Domain

Michal Rostecki michal.rostecki at gmail.com
Wed Oct 25 15:32:32 UTC 2017


From: Michal Rostecki <michal.rostecki at gmail.com>

Signed-off-by: Victoria Efimova <neverpushthisbutton at yandex.ru>
Signed-off-by: Ivan Shvedunov <ischvedunov at mirantis.com>
Signed-off-by: Miha Pleško <miha.plesko at xlab.si>
Signed-off-by: Michal Rostecki <michal.rostecki at gmail.com>
---
 domain.go      | 19 +++++++++++++++++++
 domain_test.go | 20 ++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/domain.go b/domain.go
index bacab11..3efd68c 100644
--- a/domain.go
+++ b/domain.go
@@ -722,6 +722,24 @@ type DomainFeatureList struct {
 	SMM        *DomainFeatureState  `xml:"smm"`
 }
 
+type DomainCPUTuneShares struct {
+	Value uint `xml:",chardata"`
+}
+
+type DomainCPUTunePeriod struct {
+	Value uint64 `xml:",chardata"`
+}
+
+type DomainCPUTuneQuota struct {
+	Value int64 `xml:",chardata"`
+}
+
+type DomainCPUTune struct {
+	Shares *DomainCPUTuneShares `xml:"shares"`
+	Period *DomainCPUTunePeriod `xml:"period"`
+	Quota  *DomainCPUTuneQuota  `xml:"quota"`
+}
+
 type DomainQEMUCommandlineArg struct {
 	Value string `xml:"value,attr"`
 }
@@ -751,6 +769,7 @@ type Domain struct {
 	MemoryBacking   *DomainMemoryBacking `xml:"memoryBacking"`
 	VCPU            *DomainVCPU          `xml:"vcpu"`
 	VCPUs           *DomainVCPUs         `xml:"vcpus"`
+	CPUTune         *DomainCPUTune       `xml:"cputune"`
 	Resource        *DomainResource      `xml:"resource"`
 	SysInfo         *DomainSysInfo       `xml:"sysinfo"`
 	OS              *DomainOS            `xml:"os"`
diff --git a/domain_test.go b/domain_test.go
index dbebe42..b427b50 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -1335,6 +1335,26 @@ var domainTestData = []struct {
 			`</domain>`,
 		},
 	},
+	{
+		Object: &Domain{
+			Name: "test",
+			CPUTune: &DomainCPUTune{
+				Shares: &DomainCPUTuneShares{Value: 1024},
+				Period: &DomainCPUTunePeriod{Value: 500000},
+				Quota:  &DomainCPUTuneQuota{Value: -1},
+			},
+		},
+		Expected: []string{
+			`<domain>`,
+			`  <name>test</name>`,
+			`  <cputune>`,
+			`    <shares>1024</shares>`,
+			`    <period>500000</period>`,
+			`    <quota>-1</quota>`,
+			`  </cputune>`,
+			`</domain>`,
+		},
+	},
 
 	/* Tests for sub-documents that can be hotplugged */
 	{
-- 
2.13.6




More information about the libvir-list mailing list