[libvirt] [PATCH go-xml] add support for disk cache and io add support for controller model extend DomainAddress struct for PCI address and target&unit

zhenwei.pi zhenwei.pi at youruncloud.com
Fri May 26 10:50:58 UTC 2017


---
 domain.go      | 13 +++++++++++--
 domain_test.go | 31 ++++++++++++++++++++++++++++---
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/domain.go b/domain.go
index 848835a..1382cd0 100644
--- a/domain.go
+++ b/domain.go
@@ -30,8 +30,10 @@ import (
 )
 
 type DomainController struct {
-	Type  string `xml:"type,attr"`
-	Index string `xml:"index,attr"`
+	Type    string         `xml:"type,attr"`
+	Index   string         `xml:"index,attr"`
+	Model   string         `xml:"model,attr,omitempty"`
+	Address *DomainAddress `xml:"address"`
 }
 
 type DomainDiskSecret struct {
@@ -77,6 +79,8 @@ type DomainDisk struct {
 	Type     string            `xml:"type,attr"`
 	Device   string            `xml:"device,attr"`
 	Snapshot string            `xml:"snapshot,attr,omitempty"`
+	Cache    string            `xml:"cache,attr,omitempty"`
+	Io       string            `xml:"io,attr,omitempty"`
 	Driver   *DomainDiskDriver `xml:"driver"`
 	Auth     *DomainDiskAuth   `xml:"auth"`
 	Source   *DomainDiskSource `xml:"source"`
@@ -196,8 +200,13 @@ type DomainAlias struct {
 type DomainAddress struct {
 	Type       string `xml:"type,attr"`
 	Controller *uint  `xml:"controller,attr"`
+	Domain     *uint  `xml:"domain,attr"`
 	Bus        *uint  `xml:"bus,attr"`
 	Port       *uint  `xml:"port,attr"`
+	Slot       *uint  `xml:"slot,attr"`
+	Function   *uint  `xml:"function,attr"`
+	Target     *uint  `xml:"target,attr"`
+	Unit       *uint  `xml:"unit,attr"`
 }
 
 type DomainChardev struct {
diff --git a/domain_test.go b/domain_test.go
index 265cf80..fd6914e 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -130,10 +130,12 @@ var domainTestData = []struct {
 						},
 					},
 					DomainDisk{
-						Type: "volume",
+						Type:   "volume",
 						Device: "cdrom",
+						Cache:  "none",
+						Io:     "native",
 						Source: &DomainDiskSource{
-							Pool: "default",
+							Pool:   "default",
 							Volume: "myvolume",
 						},
 						Target: &DomainDiskTarget{
@@ -174,7 +176,7 @@ var domainTestData = []struct {
 			`      </source>`,
 			`      <target dev="vdd" bus="virtio"></target>`,
 			`    </disk>`,
-			`    <disk type="volume" device="cdrom">`,
+			`    <disk type="volume" device="cdrom" cache="none" io="native">`,
 			`      <source pool="default" volume="myvolume"></source>`,
 			`      <target dev="vde" bus="virtio"></target>`,
 			`    </disk>`,
@@ -820,6 +822,29 @@ var domainTestData = []struct {
 			`</domain>`,
 		},
 	},
+	{
+		Object: &Domain{
+			Type: "kvm",
+			Name: "test",
+			Devices: &DomainDeviceList{
+				Controllers: []DomainController{
+					DomainController{
+						Type:  "usb",
+						Index: "0",
+						Model: "piix3-uhci",
+					},
+				},
+			},
+		},
+		Expected: []string{
+			`<domain type="kvm">`,
+			`  <name>test</name>`,
+			`  <devices>`,
+			`    <controller type="usb" index="0" model="piix3-uhci"></controller>`,
+			`  </devices>`,
+			`</domain>`,
+		},
+	},
 }
 
 func TestDomain(t *testing.T) {
-- 
2.7.4




More information about the libvir-list mailing list