[libvirt] [PATCH go-xml] add VCPUs support in Domain

zhenwei.pi posted 1 patch 6 years, 6 months ago
Failed in applying to current master (apply log)
domain.go      | 12 ++++++++++++
domain_test.go | 24 ++++++++++++++++++++++++
2 files changed, 36 insertions(+)
[libvirt] [PATCH go-xml] add VCPUs support in Domain
Posted by zhenwei.pi 6 years, 6 months ago
Signed-off-by: zhenwei.pi <zhenwei.pi@youruncloud.com>
---
 domain.go      | 12 ++++++++++++
 domain_test.go | 24 ++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/domain.go b/domain.go
index 3ab54a1..d81ac2a 100644
--- a/domain.go
+++ b/domain.go
@@ -533,6 +533,17 @@ type DomainVCPU struct {
 	Value     int    `xml:",chardata"`
 }
 
+type DomainVCPUsVCPU struct {
+	Id           *uint  `xml:"id,attr,omitempty"`
+	Enabled      string `xml:"enabled,attr,omitempty"`
+	Hotpluggable string `xml:"hotpluggable,attr,omitempty"`
+	Order        *uint  `xml:"order,attr,omitempty"`
+}
+
+type DomainVCPUs struct {
+	VCPU []DomainVCPUsVCPU `xml:"vcpu"`
+}
+
 type DomainCPUModel struct {
 	Fallback string `xml:"fallback,attr,omitempty"`
 	Value    string `xml:",chardata"`
@@ -678,6 +689,7 @@ type Domain struct {
 	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"`
diff --git a/domain_test.go b/domain_test.go
index 0ae9594..3ff1dc1 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -62,6 +62,10 @@ var tabletPort uint = 1
 var nicAverage int = 1000
 var nicBurst int = 10000
 
+var vcpuId0 uint = 0
+var vcpuOrder0 uint = 1
+var vcpuId1 uint = 1
+
 var domainTestData = []struct {
 	Object   Document
 	Expected []string
@@ -635,6 +639,22 @@ var domainTestData = []struct {
 				Current:   "1",
 				Value:     2,
 			},
+			VCPUs: &DomainVCPUs{
+				VCPU: []DomainVCPUsVCPU{
+					DomainVCPUsVCPU{
+						Id:           &vcpuId0,
+						Enabled:      "yes",
+						Hotpluggable: "no",
+						Order:        &vcpuOrder0,
+					},
+					DomainVCPUsVCPU{
+						Id:           &vcpuId1,
+						Enabled:      "no",
+						Hotpluggable: "yes",
+						Order:        nil,
+					},
+				},
+			},
 			Devices: &DomainDeviceList{
 				Interfaces: []DomainInterface{
 					DomainInterface{
@@ -656,6 +676,10 @@ var domainTestData = []struct {
 			`<domain type="kvm">`,
 			`  <name>test</name>`,
 			`  <vcpu placement="static" cpuset="1-4,^3,6" current="1">2</vcpu>`,
+			`  <vcpus>`,
+			`    <vcpu id="0" enabled="yes" hotpluggable="no" order="1"></vcpu>`,
+			`    <vcpu id="1" enabled="no" hotpluggable="yes"></vcpu>`,
+			`  </vcpus>`,
 			`  <devices>`,
 			`    <interface type="network">`,
 			`      <mac address="00:11:22:33:44:55"></mac>`,
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH go-xml] add VCPUs support in Domain
Posted by Daniel P. Berrange 6 years, 6 months ago
On Mon, Sep 25, 2017 at 04:21:14PM +0800, zhenwei.pi wrote:
> Signed-off-by: zhenwei.pi <zhenwei.pi@youruncloud.com>
> ---
>  domain.go      | 12 ++++++++++++
>  domain_test.go | 24 ++++++++++++++++++++++++
>  2 files changed, 36 insertions(+)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>

I'll push to git shortly.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list