From nobody Thu Apr 25 06:22:48 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 1499443416592794.1525569944218; Fri, 7 Jul 2017 09:03:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0BB86C0467DC; Fri, 7 Jul 2017 16:03:33 +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 7C0D953; Fri, 7 Jul 2017 16:03:32 +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 5531C1800C94; Fri, 7 Jul 2017 16:03:31 +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 v67G3T8U011162 for ; Fri, 7 Jul 2017 12:03:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE47477D65; Fri, 7 Jul 2017 16:03:29 +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 C535777D54 for ; Fri, 7 Jul 2017 16:03:27 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 211308E753 for ; Fri, 7 Jul 2017 16:03:26 +0000 (UTC) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A10C7ABBF for ; Fri, 7 Jul 2017 16:03:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0BB86C0467DC Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ext-mx07.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 0BB86C0467DC DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 211308E753 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thipp@suse.de DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 211308E753 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Thomas Hipp To: libvir-list@redhat.com Date: Fri, 7 Jul 2017 18:03:06 +0200 Message-Id: <20170707160306.32243-1-thipp@suse.de> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 07 Jul 2017 16:03:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 07 Jul 2017 16:03:26 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx1.suse.de' FROM:'thipp@suse.de' RCPT:'' X-RedHat-Spam-Score: -1.502 (BAYES_50, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Thomas Hipp Subject: [libvirt] [PATCH go-xml] Add support for QEMU 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 07 Jul 2017 16:03:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add support for QEMU, and add test code. Signed-off-by: Thomas Hipp --- domain.go | 50 +++++++++++++++++++++++++++++++++----------------- domain_test.go | 20 ++++++++++++++++++++ 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/domain.go b/domain.go index b9b0f77..15fdb3a 100644 --- a/domain.go +++ b/domain.go @@ -590,27 +590,43 @@ type DomainFeatureList struct { SMM *DomainFeatureState `xml:"smm"` } =20 +type DomainQEMUCommandlineArg struct { + Value string `xml:"value,attr"` +} + +type DomainQEMUCommandlineEnv struct { + Name string `xml:"name,attr"` + Value string `xml:"value,attr,omitempty"` +} + +type DomainQEMUCommandline struct { + Arg DomainQEMUCommandlineArg `xml:"qemu arg"` + Env DomainQEMUCommandlineEnv `xml:"qemu env"` +} + // NB, try to keep the order of fields in this struct // matching the order of XML elements that libvirt // will generate when dumping XML. type Domain struct { - XMLName xml.Name `xml:"domain"` - Type string `xml:"type,attr,omitempty"` - Name string `xml:"name"` - UUID string `xml:"uuid,omitempty"` - Memory *DomainMemory `xml:"memory"` - CurrentMemory *DomainMemory `xml:"currentMemory"` - MaximumMemory *DomainMaxMemory `xml:"maxMemory"` - VCPU *DomainVCPU `xml:"vcpu"` - Resource *DomainResource `xml:"resource"` - SysInfo *DomainSysInfo `xml:"sysinfo"` - OS *DomainOS `xml:"os"` - Features *DomainFeatureList `xml:"features"` - CPU *DomainCPU `xml:"cpu"` - OnPoweroff string `xml:"on_poweroff,omitempty"` - OnReboot string `xml:"on_reboot,omitempty"` - OnCrash string `xml:"on_crash,omitempty"` - Devices *DomainDeviceList `xml:"devices"` + XMLName xml.Name `xml:"domain"` + XMLNS_QEMU string `xml:"xmlns qemu,attr,omitempty"` + Type string `xml:"type,attr,omitempty"` + Name string `xml:"name"` + UUID string `xml:"uuid,omitempty"` + Memory *DomainMemory `xml:"memory"` + CurrentMemory *DomainMemory `xml:"currentMemory"` + MaximumMemory *DomainMaxMemory `xml:"maxMemory"` + VCPU *DomainVCPU `xml:"vcpu"` + Resource *DomainResource `xml:"resource"` + SysInfo *DomainSysInfo `xml:"sysinfo"` + OS *DomainOS `xml:"os"` + Features *DomainFeatureList `xml:"features"` + CPU *DomainCPU `xml:"cpu"` + OnPoweroff string `xml:"on_poweroff,omitempty"` + OnReboot string `xml:"on_reboot,omitempty"` + OnCrash string `xml:"on_crash,omitempty"` + Devices *DomainDeviceList `xml:"devices"` + QEMUCommandline *DomainQEMUCommandline `xml:"qemu commandline"` } =20 func (d *Domain) Unmarshal(doc string) error { diff --git a/domain_test.go b/domain_test.go index 47e5e26..7e683a9 100644 --- a/domain_test.go +++ b/domain_test.go @@ -1141,6 +1141,26 @@ var domainTestData =3D []struct { ``, }, }, + { + Object: &Domain{ + Type: "qemu", + Name: "test", + XMLNS_QEMU: "http://libvirt.org/schemas/domain/qemu/1.0", + QEMUCommandline: &DomainQEMUCommandline{ + Arg: DomainQEMUCommandlineArg{Value: "-newarg"}, + Env: DomainQEMUCommandlineEnv{Name: "QEMU_ENV", Value: "VAL"}, + }, + }, + Expected: []string{ + ``, + ` test`, + ` `, + ` `, + ` `, + ` `, + ``, + }, + }, =20 /* Tests for sub-documents that can be hotplugged */ { --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list