From nobody Sat Apr 27 23:49:26 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.zohomail.com; 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 1503362431556787.6375666792756; Mon, 21 Aug 2017 17:40:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20EFC356CC; Tue, 22 Aug 2017 00:40:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F6EB7B154; Tue, 22 Aug 2017 00:40:27 +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 263004EE50; Tue, 22 Aug 2017 00:40:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7M0eKsO027775 for ; Mon, 21 Aug 2017 20:40:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 397A219E74; Tue, 22 Aug 2017 00:40:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33A8260466 for ; Tue, 22 Aug 2017 00:40:17 +0000 (UTC) Received: from out28-49.mail.aliyun.com (out28-49.mail.aliyun.com [115.124.28.49]) by mx1.redhat.com (Postfix) with ESMTP id 354B7806A6 for ; Tue, 22 Aug 2017 00:40:14 +0000 (UTC) Received: from 192.168.3.60(mailfrom:zhenwei.pi@youruncloud.com ip:112.95.153.98) by smtp.aliyun-inc.com(10.147.43.230); Tue, 22 Aug 2017 08:40:07 +0800 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 20EFC356CC Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=youruncloud.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 20EFC356CC DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 354B7806A6 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=youruncloud.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=zhenwei.pi@youruncloud.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 354B7806A6 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.06950995|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03295; MF=zhenwei.pi@youruncloud.com; NM=1; PH=DS; RN=2; RT=2; SR=0; TI=SMTPD_---.8jfMtQ5_1503362407; References: <1503125841-19394-1-git-send-email-zhenwei.pi@youruncloud.com> To: "Daniel P. Berrange" , libvir-list@redhat.com From: ZhenweiPi X-Forwarded-Message-Id: <1503125841-19394-1-git-send-email-zhenwei.pi@youruncloud.com> Message-ID: Date: Tue, 22 Aug 2017 08:40:07 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1503125841-19394-1-git-send-email-zhenwei.pi@youruncloud.com> X-Greylist: Delayed for 65:42:24 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 22 Aug 2017 00:40:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 22 Aug 2017 00:40:16 +0000 (UTC) for IP:'115.124.28.49' DOMAIN:'out28-49.mail.aliyun.com' HELO:'out28-49.mail.aliyun.com' FROM:'zhenwei.pi@youruncloud.com' RCPT:'' X-RedHat-Spam-Score: -2.809 (RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, UNPARSEABLE_RELAY) 115.124.28.49 out28-49.mail.aliyun.com 115.124.28.49 out28-49.mail.aliyun.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH go-xml] Add support for domain hostdev and test code 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 22 Aug 2017 00:40:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8"; format="flowed" Signed-off-by: zhenwei.pi --- domain.go | 36 ++++++++++++++++++++++++++++++++++++ domain_test.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/domain.go b/domain.go index a5d3203..2c63307 100644 --- a/domain.go +++ b/domain.go @@ -406,6 +406,29 @@ type DomainRNG struct { Backend *DomainRNGBackend `xml:"backend"` } =20 +type DomainHostdevAdapter struct { + Name string `xml:"name,attr,omitempty"` +} + +type DomainHostdevSource struct { + Protocol string `xml:"protocol,attr,omitempty"` + Name string `xml:"name,attr,omitempty"` + Wwpn string `xml:"wwpn,attr,omitempty"` + Adapter *DomainHostdevAdapter `xml:"adapter"` + Address *DomainAddress `xml:"address"` +} + +type DomainHostdev struct { + XMLName xml.Name `xml:"hostdev"` + Mode string `xml:"mode,attr"` + Type string `xml:"type,attr"` + Sgio string `xml:"sgio,attr,omitempty"` + Rawio string `xml:"rawio,attr,omitempty"` + Managed string `xml:"managed,attr,omitempty"` + Source *DomainHostdevSource `xml:"source"` + Address *DomainAddress `xml:"address"` +} + type DomainDeviceList struct { Emulator string `xml:"emulator,omitempty"` Controllers []DomainController `xml:"controller"` @@ -421,6 +444,7 @@ type DomainDeviceList struct { MemBalloon *DomainMemBalloon `xml:"memballoon"` Sounds []DomainSound `xml:"sound"` RNGs []DomainRNG `xml:"rng"` + Hostdevs []DomainHostdev `xml:"hostdev"` } =20 type DomainMemory struct { @@ -792,3 +816,15 @@ func (d *DomainRNG) Marshal() (string, error) { } return string(doc), nil } + +func (d *DomainHostdev) Unmarshal(doc string) error { + return xml.Unmarshal([]byte(doc), d) +} + +func (d *DomainHostdev) Marshal() (string, error) { + doc, err :=3D xml.MarshalIndent(d, "", " ") + if err !=3D nil { + return "", err + } + return string(doc), nil +} diff --git a/domain_test.go b/domain_test.go index 2af451f..e3abbbf 100644 --- a/domain_test.go +++ b/domain_test.go @@ -1457,6 +1457,42 @@ var domainTestData =3D []struct { ``, }, }, + { + Object: &DomainHostdev{ + Mode: "subsystem", + Type: "scsi", + Sgio: "unfiltered", + Rawio: "yes", + Source: &DomainHostdevSource{ + Adapter: &DomainHostdevAdapter{ + Name: "scsi_host0", + }, + Address: &DomainAddress{ + Type: "scsi", + Bus: &diskAddr.Bus, + Target: &diskAddr.Slot, + Unit: &diskAddr.Function, + }, + }, + Address: &DomainAddress{ + Type: "drive", + Controller: &diskAddr.Domain, + Bus: &diskAddr.Bus, + Target: &diskAddr.Slot, + Unit: &diskAddr.Function, + }, + }, + + Expected: []string{ + ``, + ` `, + ` `, + `
`, + ` `, + `
`, + ``, + }, + }, } =20 func TestDomain(t *testing.T) { --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list