[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
Daniel P. Berrange
berrange at redhat.com
Fri May 26 13:35:25 UTC 2017
On Fri, May 26, 2017 at 06:50:58PM +0800, zhenwei.pi wrote:
> ---
> 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"`
This should be a *uint rather than string
> + 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"`
These look fine and you've added test coverage
> @@ -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"`
> }
These also look fine, but need test coverage added still
>
> 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",
This shoudl be an integer not string.
> + Model: "piix3-uhci",
> + },
> + },
> + },
> + },
> + Expected: []string{
> + `<domain type="kvm">`,
> + ` <name>test</name>`,
> + ` <devices>`,
> + ` <controller type="usb" index="0" model="piix3-uhci"></controller>`,
> + ` </devices>`,
> + `</domain>`,
> + },
> + },
> }
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 :|
More information about the libvir-list
mailing list