Signed-off-by: zhenwei.pi <zhenwei.pi(a)youruncloud.com>
---
domain.go | 76 +++++++++++++++++++++++++++++++++++++++++++---------------
domain_test.go | 38 +++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 19 deletions(-)
diff --git a/domain.go b/domain.go
index d81ac2a..773a83e 100644
--- a/domain.go
+++ b/domain.go
@@ -459,6 +459,43 @@ type DomainMaxMemory struct {
Slots uint `xml:"slots,attr,omitempty"`
}
+type DomainMemoryHugepage struct {
+ Size uint `xml:"size,attr"`
+ Unit string `xml:"unit,attr,omitempty"`
+ Nodeset string `xml:"nodeset,attr,omitempty"`
+}
+
+type DomainMemoryHugepages struct {
+ Hugepages []DomainMemoryHugepage `xml:"page"`
+}
+
+type DomainMemoryNosharepages struct {
+}
+
+type DomainMemoryLocked struct {
+}
+
+type DomainMemorySource struct {
+ Type string `xml:"type,attr,omitempty"`
+}
+
+type DomainMemoryAccess struct {
+ Mode string `xml:"mode,attr,omitempty"`
+}
+
+type DomainMemoryAllocation struct {
+ Mode string `xml:"mode,attr,omitempty"`
+}
+
+type DomainMemoryBacking struct {
+ MemoryHugePages *DomainMemoryHugepages `xml:"hugepages"`
+ MemoryNosharepages *DomainMemoryNosharepages `xml:"nosharepages"`
+ MemoryLocked *DomainMemoryLocked `xml:"locked"`
+ MemorySource *DomainMemorySource `xml:"source"`
+ MemoryAccess *DomainMemoryAccess `xml:"access"`
+ MemoryAllocation *DomainMemoryAllocation `xml:"allocation"`
+}
+
type DomainOSType struct {
Arch string `xml:"arch,attr,omitempty"`
Machine string `xml:"machine,attr,omitempty"`
@@ -681,25 +718,26 @@ type DomainQEMUCommandline struct {
// matching the order of XML elements that libvirt
// will generate when dumping XML.
type Domain struct {
- XMLName xml.Name `xml:"domain"`
- Type string `xml:"type,attr,omitempty"`
- Name string `xml:"name"`
- UUID string `xml:"uuid,omitempty"`
- Memory *DomainMemory `xml:"memory"`
- CurrentMemory *DomainMemory `xml:"currentMemory"`
- MaximumMemory *DomainMaxMemory `xml:"maxMemory"`
- VCPU *DomainVCPU `xml:"vcpu"`
- VCPUs *DomainVCPUs `xml:"vcpus"`
- Resource *DomainResource `xml:"resource"`
- SysInfo *DomainSysInfo `xml:"sysinfo"`
- OS *DomainOS `xml:"os"`
- Features *DomainFeatureList `xml:"features"`
- CPU *DomainCPU `xml:"cpu"`
- Clock *DomainClock `xml:"clock,omitempty"`
- OnPoweroff string `xml:"on_poweroff,omitempty"`
- OnReboot string `xml:"on_reboot,omitempty"`
- OnCrash string `xml:"on_crash,omitempty"`
- Devices *DomainDeviceList `xml:"devices"`
+ XMLName xml.Name `xml:"domain"`
+ Type string `xml:"type,attr,omitempty"`
+ Name string `xml:"name"`
+ UUID string `xml:"uuid,omitempty"`
+ Memory *DomainMemory `xml:"memory"`
+ CurrentMemory *DomainMemory `xml:"currentMemory"`
+ MaximumMemory *DomainMaxMemory `xml:"maxMemory"`
+ MemoryBacking *DomainMemoryBacking `xml:"memoryBacking"`
+ VCPU *DomainVCPU `xml:"vcpu"`
+ VCPUs *DomainVCPUs `xml:"vcpus"`
+ Resource *DomainResource `xml:"resource"`
+ SysInfo *DomainSysInfo `xml:"sysinfo"`
+ OS *DomainOS `xml:"os"`
+ Features *DomainFeatureList `xml:"features"`
+ CPU *DomainCPU `xml:"cpu"`
+ Clock *DomainClock `xml:"clock,omitempty"`
+ OnPoweroff string `xml:"on_poweroff,omitempty"`
+ OnReboot string `xml:"on_reboot,omitempty"`
+ OnCrash string `xml:"on_crash,omitempty"`
+ Devices *DomainDeviceList `xml:"devices"`
QEMUCommandline *DomainQEMUCommandline
}
diff --git a/domain_test.go b/domain_test.go
index 3ff1dc1..51d413b 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -435,6 +435,33 @@ var domainTestData = []struct {
Value: 16384,
Slots: 2,
},
+ MemoryBacking: &DomainMemoryBacking{
+ MemoryHugePages: &DomainMemoryHugepages{
+ Hugepages: []DomainMemoryHugepage{
+ {
+ Size: 1,
+ Unit: "G",
+ Nodeset: "0-3,5",
+ },
+ {
+ Size: 2,
+ Unit: "M",
+ Nodeset: "4",
+ },
+ },
+ },
+ MemoryNosharepages: &DomainMemoryNosharepages{},
+ MemoryLocked: &DomainMemoryLocked{},
+ MemorySource: &DomainMemorySource{
+ Type: "file|anonymous",
+ },
+ MemoryAccess: &DomainMemoryAccess{
+ Mode: "shared|private",
+ },
+ MemoryAllocation: &DomainMemoryAllocation{
+ Mode: "immediate|ondemand",
+ },
+ },
OS: &DomainOS{
Type: &DomainOSType{
Arch: "x86_64",
@@ -532,6 +559,17 @@ var domainTestData = []struct {
` <memory unit="KiB">8192</memory>`,
` <currentMemory unit="KiB">4096</currentMemory>`,
` <maxMemory unit="KiB"
slots="2">16384</maxMemory>`,
+ ` <memoryBacking>`,
+ ` <hugepages>`,
+ ` <page size="1" unit="G"
nodeset="0-3,5"></page>`,
+ ` <page size="2" unit="M"
nodeset="4"></page>`,
+ ` </hugepages>`,
+ ` <nosharepages></nosharepages>`,
+ ` <locked></locked>`,
+ ` <source type="file|anonymous"></source>`,
+ ` <access mode="shared|private"></access>`,
+ ` <allocation mode="immediate|ondemand"></allocation>`,
+ ` </memoryBacking>`,
` <sysinfo type="smbios">`,
` <system>`,
` <entry name="manufacturer">manufacturer</entry>`,
--
2.7.4