From nobody Fri May 3 20:31:42 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 1499678153427857.1543084226952; Mon, 10 Jul 2017 02:15:53 -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 8D78280F95; Mon, 10 Jul 2017 09:15: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 D205B18226; Mon, 10 Jul 2017 09:15: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 6C4DB1800C8E; Mon, 10 Jul 2017 09:15: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 v6A9FiOa022115 for ; Mon, 10 Jul 2017 05:15:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1434C182E5; Mon, 10 Jul 2017 09:15:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D3A6182E7 for ; Mon, 10 Jul 2017 09:15:42 +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 998693680A for ; Mon, 10 Jul 2017 09:15:40 +0000 (UTC) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0E712AC1D for ; Mon, 10 Jul 2017 09:15:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8D78280F95 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=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8D78280F95 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 998693680A Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thipp@suse.de DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 998693680A X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Thomas Hipp To: libvir-list@redhat.com Date: Mon, 10 Jul 2017 11:15:14 +0200 Message-Id: <20170710091514.19655-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.30]); Mon, 10 Jul 2017 09:15:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 10 Jul 2017 09:15:41 +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.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Thomas Hipp Subject: [libvirt] [PATCH go-xml v2] 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.27]); Mon, 10 Jul 2017 09:15:52 +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 v1: - support multiple Args and Envs --- domain.go | 50 +++++++++++++++++++++++++++++++++----------------- domain_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/domain.go b/domain.go index b9b0f77..8c1fa76 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 { + Args []DomainQEMUCommandlineArg `xml:"qemu arg"` + Envs []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..0aa5938 100644 --- a/domain_test.go +++ b/domain_test.go @@ -1141,6 +1141,34 @@ var domainTestData =3D []struct { ``, }, }, + { + Object: &Domain{ + Type: "qemu", + Name: "test", + XMLNS_QEMU: "http://libvirt.org/schemas/domain/qemu/1.0", + 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