From nobody Sun Apr 28 11:29:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1493060987538353.6122190624616; Mon, 24 Apr 2017 12:09:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE75485365; Mon, 24 Apr 2017 19:09:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0482C1899C; Mon, 24 Apr 2017 19:09:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DE5DB18523C1; Mon, 24 Apr 2017 19:09:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3OJ9bMe013798 for ; Mon, 24 Apr 2017 15:09:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A47317A40; Mon, 24 Apr 2017 19:09:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 323D660E3E for ; Mon, 24 Apr 2017 19:09:35 +0000 (UTC) Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8595461D28 for ; Mon, 24 Apr 2017 19:09:33 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id 63so6435589pgh.0 for ; Mon, 24 Apr 2017 12:09:33 -0700 (PDT) Received: from rytk.isi.edu ([128.9.184.177]) by smtp.gmail.com with ESMTPSA id r1sm32316222pfg.12.2017.04.24.12.09.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Apr 2017 12:09:32 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DE75485365 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=isi.edu Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DE75485365 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=isi-edu.20150623.gappssmtp.com header.i=@isi-edu.20150623.gappssmtp.com header.b="cUenblcr" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8595461D28 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=isi.edu Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=rgoodfel@isi.edu DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8595461D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isi-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=9w3FPcQU96n+E4mgMlTgE+Ho09iAuNAY8NzkwKqlQsE=; b=cUenblcrgg6ptD7Chyz961aHe7OeL3C8WcC4nbFLN5DSp9hqJIKHiJrfQiNxwVg8xw ohE4m2cH6IX6UMefQZGRmiqrQaSZC/BLFAhqmBDq3LB9N+GDg01COTMR45AjMVLH1PIh gdSzOJzDLjxunGFyckk5Q8malGtYKEevyKtBgp/hzJi1gigjtd8+jWjdBJV3P3l1JnE1 9KrBu/RCNlVnqWUo15i3MowJ34v+yRp8nv/ZJ0W6dYUMQnmD5sPsTEW+pD3kGT+dOB0A Lmce7zDggMHd8/n+Gn2A3I2ben8TXVXDnK8MYsPwM3NnMXHvnxK9XSUzDKDbkg3JcSx0 3ATA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9w3FPcQU96n+E4mgMlTgE+Ho09iAuNAY8NzkwKqlQsE=; b=stnSW+wmPkakpJlaN7ZkdJ/e+PXVHvM+dLTK/mYtWmwNDCvTqjGWyuXquW/8202aUb M0HEwu/owZX4HhUv9Syz9aNe+83+dgfe24mzea2GuQhVWT3sZiXBZtguu7+A/nrR39bb 38KCwGPz2Hf0y12ziDxKvDlY2rX8xA1H0PLyoj+6sm2xXGTvszdUP3KqSd76fno0YP75 tjkV0WzT0vJi6qFrm/TvqwTxkffjL/5e/4j4PQPu2kUXv5qHnXPai7bd60olsm59+STd I5bXOqAWR02l1beJ3RKxF2AqVpON5y2ofhPLZ1bzrW2Vi4YRD3YJ32s9ZycPDvt9fhh0 Ik2g== X-Gm-Message-State: AN3rC/7PPUHz39VS7BSE1pIHHZry+AIlPib+m9ml/T+S/18ovoy3C1SX CfnDTgCSW4bttxZIk04= X-Received: by 10.99.109.202 with SMTP id i193mr26509161pgc.33.1493060972750; Mon, 24 Apr 2017 12:09:32 -0700 (PDT) From: Ryan Goodfellow To: libvir-list@redhat.com Date: Mon, 24 Apr 2017 12:09:15 -0700 Message-Id: <20170424190915.25504-1-rgoodfel@isi.edu> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 24 Apr 2017 19:09:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 24 Apr 2017 19:09:33 +0000 (UTC) for IP:'74.125.83.67' DOMAIN:'mail-pg0-f67.google.com' HELO:'mail-pg0-f67.google.com' FROM:'rgoodfel@isi.edu' RCPT:'' X-RedHat-Spam-Score: 1.27 * (BAYES_50, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM) 74.125.83.67 mail-pg0-f67.google.com 74.125.83.67 mail-pg0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Ryan Goodfellow Subject: [libvirt] [PATCH go-xml] remove superfluous state & omitempty entries X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 24 Apr 2017 19:09:45 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 { } =20 type DomainFeature struct { +} + +type DomainFeatureState struct { State string `xml:"state,attr,omitempty"` } =20 type DomainFeatureAPIC struct { - DomainFeature EOI string `xml:"eio,attr,omitempty"` } =20 -type DomainFeatureVendorId struct { - DomainFeature +type DomainFeatureHyperVVendorId struct { + DomainFeatureState Value string `xml:"value,attr,omitempty"` } =20 -type DomainFeatureSpinlocks struct { - DomainFeature +type DomainFeatureHyperVSpinlocks struct { + DomainFeatureState Retries uint `xml:"retries,attr,omitempty"` } =20 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"` } =20 type DomainFeatureKVM struct { - DomainFeature - Hidden *DomainFeature `xml:"hidden,omitempty"` + Hidden *DomainFeatureState `xml:"hidden"` } =20 type DomainFeatureGIC struct { - DomainFeature Version string `xml:"version,attr,omitempty"` } =20 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"` } =20 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"` } =20 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 =3D []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"}, }, }, --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list