This commit removes the superfluous state and omit entries from my last commit. It factors the 'state' data member into a DomainFeatureState struct and only uses that struct where necessary e.g. HyperV features as well as a few top level features such as PMU, HAP etc. The HyperV suffix has also been added to features that are specific to HyperV. --- domain.go | 62 +++++++++++++++++++++++++++++----------------------------- domain_test.go | 26 +++++++++++++----------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/domain.go b/domain.go index c9ffaef..b4b2256 100644 --- a/domain.go +++ b/domain.go @@ -372,61 +372,61 @@ type DomainCPU struct { } type DomainFeature struct { +} + +type DomainFeatureState struct { State string `xml:"state,attr,omitempty"` } type DomainFeatureAPIC struct { - DomainFeature EOI string `xml:"eio,attr,omitempty"` } -type DomainFeatureVendorId struct { - DomainFeature +type DomainFeatureHyperVVendorId struct { + DomainFeatureState Value string `xml:"value,attr,omitempty"` } -type DomainFeatureSpinlocks struct { - DomainFeature +type DomainFeatureHyperVSpinlocks struct { + DomainFeatureState Retries uint `xml:"retries,attr,omitempty"` } type DomainFeatureHyperV struct { DomainFeature - Relaxed *DomainFeature `xml:"relaxed,omitempty"` - VAPIC *DomainFeature `xml:"vapic,omitempty"` - Spinlocks *DomainFeatureSpinlocks `xml:"spinlocks,omitempty"` - VPIndex *DomainFeature `xml:"vpindex,omitempty"` - Runtime *DomainFeature `xml:"runtime,omitempty"` - Synic *DomainFeature `xml:"synic,omitempty"` - STimer *DomainFeature `xml:"stimer,omitempty"` - Reset *DomainFeature `xml:"reset,omitempty"` - VendorId *DomainFeatureVendorId `xml:"vendor_id,omitempty"` + Relaxed *DomainFeatureState `xml:"relaxed"` + VAPIC *DomainFeatureState `xml:"vapic"` + Spinlocks *DomainFeatureHyperVSpinlocks `xml:"spinlocks"` + VPIndex *DomainFeatureState `xml:"vpindex"` + Runtime *DomainFeatureState `xml:"runtime"` + Synic *DomainFeatureState `xml:"synic"` + STimer *DomainFeatureState `xml:"stimer"` + Reset *DomainFeatureState `xml:"reset"` + VendorId *DomainFeatureHyperVVendorId `xml:"vendor_id"` } type DomainFeatureKVM struct { - DomainFeature - Hidden *DomainFeature `xml:"hidden,omitempty"` + Hidden *DomainFeatureState `xml:"hidden"` } type DomainFeatureGIC struct { - DomainFeature Version string `xml:"version,attr,omitempty"` } type DomainFeatureList struct { - PAE *DomainFeature `xml:"pae,omitempty"` - ACPI *DomainFeature `xml:"acpi,omitempty"` - APIC *DomainFeatureAPIC `xml:"apic,omitempty"` - HAP *DomainFeature `xml:"hap,omitempty"` - Viridian *DomainFeature `xml:"viridian,omitempty"` - PrivNet *DomainFeature `xml:"privnet,omitempty"` - HyperV *DomainFeatureHyperV `xml:"hyperv,omitempty"` - KVM *DomainFeatureKVM `xml:"kvm,omitempty"` - PVSpinlock *DomainFeature `xml:"pvspinlock,omitempty"` - PMU *DomainFeature `xml:"pmu,omitempty"` - VMPort *DomainFeature `xml:"vmport,omitempty"` - GIC *DomainFeatureGIC `xml:"gic,omitempty"` - SMM *DomainFeature `xml:"smm,omitempty"` + PAE *DomainFeature `xml:"pae"` + ACPI *DomainFeature `xml:"acpi"` + APIC *DomainFeatureAPIC `xml:"apic"` + HAP *DomainFeatureState `xml:"hap"` + Viridian *DomainFeature `xml:"viridian"` + PrivNet *DomainFeature `xml:"privnet"` + HyperV *DomainFeatureHyperV `xml:"hyperv"` + KVM *DomainFeatureKVM `xml:"kvm"` + PVSpinlock *DomainFeatureState `xml:"pvspinlock"` + PMU *DomainFeatureState `xml:"pmu"` + VMPort *DomainFeatureState `xml:"vmport"` + GIC *DomainFeatureGIC `xml:"gic"` + SMM *DomainFeatureState `xml:"smm"` } type Domain struct { @@ -446,7 +446,7 @@ type Domain struct { OnPoweroff string `xml:"on_poweroff,omitempty"` OnReboot string `xml:"on_reboot,omitempty"` OnCrash string `xml:"on_crash,omitempty"` - Features *DomainFeatureList `xml:"features,omitempty"` + Features *DomainFeatureList `xml:"features"` } func (d *Domain) Unmarshal(doc string) error { diff --git a/domain_test.go b/domain_test.go index e25007e..11156c1 100644 --- a/domain_test.go +++ b/domain_test.go @@ -753,22 +753,26 @@ var domainTestData = []struct { PAE: &DomainFeature{}, ACPI: &DomainFeature{}, APIC: &DomainFeatureAPIC{}, - HAP: &DomainFeature{}, + HAP: &DomainFeatureState{}, PrivNet: &DomainFeature{}, HyperV: &DomainFeatureHyperV{ - Relaxed: &DomainFeature{State: "on"}, - VAPIC: &DomainFeature{State: "on"}, - Spinlocks: &DomainFeatureSpinlocks{DomainFeature{State: "on"}, 4096}, - VPIndex: &DomainFeature{State: "on"}, - Runtime: &DomainFeature{State: "on"}, - Synic: &DomainFeature{State: "on"}, - Reset: &DomainFeature{State: "on"}, - VendorId: &DomainFeatureVendorId{DomainFeature{State: "on"}, "KVM Hv"}, + Relaxed: &DomainFeatureState{State: "on"}, + VAPIC: &DomainFeatureState{State: "on"}, + Spinlocks: &DomainFeatureHyperVSpinlocks{ + DomainFeatureState{State: "on"}, 4096, + }, + VPIndex: &DomainFeatureState{State: "on"}, + Runtime: &DomainFeatureState{State: "on"}, + Synic: &DomainFeatureState{State: "on"}, + Reset: &DomainFeatureState{State: "on"}, + VendorId: &DomainFeatureHyperVVendorId{ + DomainFeatureState{State: "on"}, "KVM Hv", + }, }, KVM: &DomainFeatureKVM{ - Hidden: &DomainFeature{State: "on"}, + Hidden: &DomainFeatureState{State: "on"}, }, - PVSpinlock: &DomainFeature{State: "on"}, + PVSpinlock: &DomainFeatureState{State: "on"}, GIC: &DomainFeatureGIC{Version: "2"}, }, }, -- 2.11.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list