From nobody Sat Apr 27 15:36:30 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 1499682548886249.38089113040473; Mon, 10 Jul 2017 03:29:08 -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 BB77981233; Mon, 10 Jul 2017 10:29:06 +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 0995218A61; Mon, 10 Jul 2017 10:29:06 +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 1DA3E1800C8B; Mon, 10 Jul 2017 10:29:04 +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 v6AASl5A001863 for ; Mon, 10 Jul 2017 06:28:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E1237D4EA; Mon, 10 Jul 2017 10:28:47 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59D0D19E36 for ; Mon, 10 Jul 2017 10:28:45 +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 8B04381127 for ; Mon, 10 Jul 2017 10:28:43 +0000 (UTC) Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 22126ABB3 for ; Mon, 10 Jul 2017 10:28:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BB77981233 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de 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 BB77981233 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B04381127 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thipp@suse.de DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8B04381127 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Thomas Hipp To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 12:28:23 +0200 Message-Id: <20170710102823.32141-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.27]); Mon, 10 Jul 2017 10:28:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 10 Jul 2017 10:28:44 +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.902 (BAYES_50, DCC_REPUT_00_12, 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.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Thomas Hipp Subject: [libvirt] [PATCH go-xml v3] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 10 Jul 2017 10:29:07 +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 --- Changes since v2: - set default ns in commandline subtree - remove ns prefix "qemu:" --- domain.go | 50 +++++++++++++++++++++++++++++++++----------------- domain_test.go | 27 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/domain.go b/domain.go index b9b0f77..d5d358a 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 { + XMLName xml.Name `xml:"http://libvirt.org/schemas/domai= n/qemu/1.0 commandline"` + Args []DomainQEMUCommandlineArg `xml:"arg"` + Envs []DomainQEMUCommandlineEnv `xml:"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"` + 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 } =20 func (d *Domain) Unmarshal(doc string) error { diff --git a/domain_test.go b/domain_test.go index 47e5e26..f2d83fc 100644 --- a/domain_test.go +++ b/domain_test.go @@ -1141,6 +1141,33 @@ var domainTestData =3D []struct { ``, }, }, + { + Object: &Domain{ + Type: "qemu", + Name: "test", + QEMUCommandline: &DomainQEMUCommandline{ + Args: []DomainQEMUCommandlineArg{ + DomainQEMUCommandlineArg{Value: "-newarg"}, + DomainQEMUCommandlineArg{Value: "-oldarg"}, + }, + Envs: []DomainQEMUCommandlineEnv{ + DomainQEMUCommandlineEnv{Name: "QEMU_ENV", Value: "VAL"}, + DomainQEMUCommandlineEnv{Name: "QEMU_VAR", Value: "VAR"}, + }, + }, + }, + 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