From nobody Wed May 1 18:31:03 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 1510797653307352.036180367925; Wed, 15 Nov 2017 18:00:53 -0800 (PST) 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 1F6EAC01FA8A; Thu, 16 Nov 2017 02:00:51 +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 1B2CD60176; Thu, 16 Nov 2017 02:00:49 +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 18D391800BD3; Thu, 16 Nov 2017 02:00:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAG20iQP013947 for ; Wed, 15 Nov 2017 21:00:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 367D86266D; Thu, 16 Nov 2017 02:00:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B08A173BA; Thu, 16 Nov 2017 02:00:41 +0000 (UTC) Received: from out3140-230.mail.aliyun.com (out3140-230.mail.aliyun.com [42.120.140.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73AEE7EA8F; Thu, 16 Nov 2017 02:00:38 +0000 (UTC) Received: from localhost.localdomain(mailfrom:zhenwei.pi@youruncloud.com ip:112.95.153.98) by smtp.aliyun-inc.com(10.147.40.26); Thu, 16 Nov 2017 09:55:29 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.04445707|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03308; MF=zhenwei.pi@youruncloud.com; NM=1; PH=DS; RN=3; RT=3; SR=0; TI=SMTPD_---.9QH6DgD_1510797328; From: "zhenwei.pi" To: berrange@redhat.com, libvir-list@redhat.com Date: Thu, 16 Nov 2017 09:55:26 +0800 Message-Id: <1510797326-26391-1-git-send-email-zhenwei.pi@youruncloud.com> X-Greylist: Delayed for 00:05:04 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 16 Nov 2017 02:00:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 16 Nov 2017 02:00:39 +0000 (UTC) for IP:'42.120.140.230' DOMAIN:'out3140-230.mail.aliyun.com' HELO:'out3140-230.mail.aliyun.com' FROM:'zhenwei.pi@youruncloud.com' RCPT:'' X-RedHat-Spam-Score: -0.019 (RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, UNPARSEABLE_RELAY) 42.120.140.230 out3140-230.mail.aliyun.com 42.120.140.230 out3140-230.mail.aliyun.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: zhenwei.pi@youruncloud.com Subject: [libvirt] [PATCH go-xml] Add support for panic device 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.31]); Thu, 16 Nov 2017 02:00:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add DomainAddressISA for panic device address. Add DomainPanic. Add test code. Signed-off-by: zhenwei.pi Reviewed-by: Daniel P. Berrange --- domain.go | 38 ++++++++++++++++++++++++++++++++++++++ domain_test.go | 28 +++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/domain.go b/domain.go index f4ef35c..8086e28 100644 --- a/domain.go +++ b/domain.go @@ -312,11 +312,16 @@ type DomainAddressDIMM struct { Base *uint64 `xml:"base,attr"` } =20 +type DomainAddressISA struct { + Iobase *uint `xml:"iobase,attr"` +} + type DomainAddress struct { USB *DomainAddressUSB PCI *DomainAddressPCI Drive *DomainAddressDrive DIMM *DomainAddressDIMM + ISA *DomainAddressISA } =20 type DomainConsole struct { @@ -403,6 +408,12 @@ type DomainMemBalloon struct { Address *DomainAddress `xml:"address"` } =20 +type DomainPanic struct { + XMLName xml.Name `xml:"panic"` + Model string `xml:"model,attr"` + Address *DomainAddress `xml:"address"` +} + type DomainSoundCodec struct { Type string `xml:"type,attr"` } @@ -486,6 +497,7 @@ type DomainDeviceList struct { Videos []DomainVideo `xml:"video"` Channels []DomainChannel `xml:"channel"` MemBalloon *DomainMemBalloon `xml:"memballoon"` + Panics []DomainPanic `xml:"panic"` Sounds []DomainSound `xml:"sound"` RNGs []DomainRNG `xml:"rng"` Hostdevs []DomainHostdev `xml:"hostdev"` @@ -1058,6 +1070,16 @@ func (a *DomainAddressDIMM) MarshalXML(e *xml.Encode= r, start xml.StartElement) e return nil } =20 +func (a *DomainAddressISA) MarshalXML(e *xml.Encoder, start xml.StartEleme= nt) error { + start.Attr =3D append(start.Attr, xml.Attr{ + xml.Name{Local: "type"}, "isa", + }) + marshallUintAttr(&start, "iobase", a.Iobase, 16) + e.EncodeToken(start) + e.EncodeToken(start.End()) + return nil +} + func (a *DomainAddress) MarshalXML(e *xml.Encoder, start xml.StartElement)= error { if a.USB !=3D nil { return a.USB.MarshalXML(e, start) @@ -1067,6 +1089,8 @@ func (a *DomainAddress) MarshalXML(e *xml.Encoder, st= art xml.StartElement) error return a.Drive.MarshalXML(e, start) } else if a.DIMM !=3D nil { return a.DIMM.MarshalXML(e, start) + } else if a.ISA !=3D nil { + return a.ISA.MarshalXML(e, start) } else { return nil } @@ -1173,6 +1197,17 @@ func (a *DomainAddressDIMM) UnmarshalXML(d *xml.Deco= der, start xml.StartElement) return nil } =20 +func (a *DomainAddressISA) UnmarshalXML(d *xml.Decoder, start xml.StartEle= ment) error { + for _, attr :=3D range start.Attr { + if attr.Name.Local =3D=3D "iobase" { + if err :=3D unmarshallUintAttr(attr.Value, &a.Iobase, 16); err !=3D nil= { + return err + } + } + } + return nil +} + func (a *DomainAddress) UnmarshalXML(d *xml.Decoder, start xml.StartElemen= t) error { var typ string d.Skip() @@ -1198,6 +1233,9 @@ func (a *DomainAddress) UnmarshalXML(d *xml.Decoder, = start xml.StartElement) err } else if typ =3D=3D "dimm" { a.DIMM =3D &DomainAddressDIMM{} return a.DIMM.UnmarshalXML(d, start) + } else if typ =3D=3D "isa" { + a.ISA =3D &DomainAddressISA{} + return a.ISA.UnmarshalXML(d, start) } =20 return nil diff --git a/domain_test.go b/domain_test.go index 1ad5125..31787a5 100644 --- a/domain_test.go +++ b/domain_test.go @@ -45,6 +45,10 @@ type DriveAddress struct { Unit uint } =20 +type ISAAddress struct { + Iobase uint +} + var uhciIndex uint =3D 0 var uhciAddr =3D PCIAddress{0, 0, 1, 2} =20 @@ -53,6 +57,7 @@ var ifaceAddr =3D PCIAddress{0, 0, 4, 0} var videoAddr =3D PCIAddress{0, 0, 5, 0} var fsAddr =3D PCIAddress{0, 0, 6, 0} var balloonAddr =3D PCIAddress{0, 0, 7, 0} +var panicAddr =3D ISAAddress{0x505} var duplexAddr =3D PCIAddress{0, 0, 8, 0} var hostdevSCSI =3D DriveAddress{0, 0, 3, 0} =20 @@ -303,6 +308,19 @@ var domainTestData =3D []struct { }, }, }, + Panics: []DomainPanic{ + DomainPanic{ + Model: "hyperv", + }, + DomainPanic{ + Model: "isa", + Address: &DomainAddress{ + ISA: &DomainAddressISA{ + Iobase: &panicAddr.Iobase, + }, + }, + }, + }, Consoles: []DomainConsole{ DomainConsole{ Type: "pty", @@ -433,6 +451,10 @@ var domainTestData =3D []struct { ` `, `
`, `
`, + ` `, + ` `, + `
`, + `
`, ` `, ` `, `
`, @@ -1725,9 +1747,9 @@ var domainTestData =3D []struct { /* Host Bootloader -- bhyve, Xen */ { Object: &Domain{ - Type: "bhyve", - Name: "test", - Bootloader: "/usr/local/sbin/grub-bhyve", + Type: "bhyve", + Name: "test", + Bootloader: "/usr/local/sbin/grub-bhyve", BootloaderArgs: "-r cd0 -m /tmp/test-device.map -M 1024M linuxguest", }, Expected: []string{ --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list