From patchwork Tue Feb 16 21:45:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Fehlig X-Patchwork-Id: 8332601 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E4C81C02AA for ; Tue, 16 Feb 2016 21:48:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A43A202BE for ; Tue, 16 Feb 2016 21:48:39 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E38B6202E9 for ; Tue, 16 Feb 2016 21:48:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aVnRK-0001fy-Cv; Tue, 16 Feb 2016 21:45:46 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aVnRI-0001fA-DW for xen-devel@lists.xen.org; Tue, 16 Feb 2016 21:45:44 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 25/FC-29293-78893C65; Tue, 16 Feb 2016 21:45:43 +0000 X-Env-Sender: jfehlig@suse.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1455659140!22623087!1 X-Originating-IP: [137.65.250.81] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25766 invoked from network); 16 Feb 2016 21:45:42 -0000 Received: from smtp2.provo.novell.com (HELO smtp2.provo.novell.com) (137.65.250.81) by server-7.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 16 Feb 2016 21:45:42 -0000 Received: from jfehlig2.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Tue, 16 Feb 2016 14:45:39 -0700 From: Jim Fehlig To: libvir-list@redhat.com Date: Tue, 16 Feb 2016 14:45:57 -0700 Message-Id: <1455659159-11931-3-git-send-email-jfehlig@suse.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1455659159-11931-1-git-send-email-jfehlig@suse.com> References: <1455659159-11931-1-git-send-email-jfehlig@suse.com> Cc: Jim Fehlig , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH 2/4] xenconfig: produce key=value disk config syntax in xl formatter X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The most formal form of xl disk configuration uses key=value syntax to define each configuration item, e.g. format=raw, vdev=xvda, access=rw, backendtype=phy, target=disksrc Change the xl disk formatter to produce this syntax, which allows target= to contain meta info needed to setup a network-based disksrc (e.g. rbd, nbd, iscsi). For details on xl disk config format, see $xen-src/docs/misc/xl-disk-configuration.txt Update the disk config in the tests to use the formal syntax. But add tests to ensure disks specified with the positional parameter syntax are correctly converted to XML. Signed-off-by: Jim Fehlig --- src/xenconfig/xen_xl.c | 27 ++++++----- .../test-disk-positional-parms-full.cfg | 26 +++++++++++ .../test-disk-positional-parms-full.xml | 54 ++++++++++++++++++++++ .../test-disk-positional-parms-partial.cfg | 26 +++++++++++ .../test-disk-positional-parms-partial.xml | 54 ++++++++++++++++++++++ .../test-fullvirt-direct-kernel-boot.cfg | 2 +- tests/xlconfigdata/test-fullvirt-multiusb.cfg | 2 +- tests/xlconfigdata/test-new-disk.cfg | 2 +- tests/xlconfigdata/test-paravirt-cmdline.cfg | 2 +- tests/xlconfigdata/test-paravirt-maxvcpus.cfg | 2 +- tests/xlconfigdata/test-spice-features.cfg | 2 +- tests/xlconfigdata/test-spice.cfg | 2 +- tests/xlconfigdata/test-vif-rate.cfg | 2 +- tests/xlconfigtest.c | 2 + 14 files changed, 186 insertions(+), 19 deletions(-) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index be194e3..f3e8b55 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -587,9 +587,8 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) int format = virDomainDiskGetFormat(disk); const char *driver = virDomainDiskGetDriver(disk); - /* target */ - virBufferAsprintf(&buf, "%s,", src); /* format */ + virBufferAddLit(&buf, "format="); switch (format) { case VIR_STORAGE_FILE_RAW: virBufferAddLit(&buf, "raw,"); @@ -609,31 +608,37 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) } /* device */ - virBufferAdd(&buf, disk->dst, -1); - - virBufferAddLit(&buf, ","); + virBufferAsprintf(&buf, "vdev=%s,", disk->dst); + /* access */ + virBufferAddLit(&buf, "access="); if (disk->src->readonly) - virBufferAddLit(&buf, "r,"); + virBufferAddLit(&buf, "ro,"); else if (disk->src->shared) virBufferAddLit(&buf, "!,"); else - virBufferAddLit(&buf, "w,"); + virBufferAddLit(&buf, "rw,"); if (disk->transient) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("transient disks not supported yet")); goto cleanup; } + /* backendtype */ + virBufferAddLit(&buf, "backendtype="); if (STREQ_NULLABLE(driver, "qemu")) - virBufferAddLit(&buf, "backendtype=qdisk"); + virBufferAddLit(&buf, "qdisk,"); else if (STREQ_NULLABLE(driver, "tap")) - virBufferAddLit(&buf, "backendtype=tap"); + virBufferAddLit(&buf, "tap,"); else if (STREQ_NULLABLE(driver, "phy")) - virBufferAddLit(&buf, "backendtype=phy"); + virBufferAddLit(&buf, "phy,"); + /* devtype */ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&buf, ",devtype=cdrom"); + virBufferAddLit(&buf, "devtype=cdrom,"); + + /* target */ + virBufferAsprintf(&buf, "target=%s", src); if (virBufferCheckError(&buf) < 0) goto cleanup; diff --git a/tests/xlconfigdata/test-disk-positional-parms-full.cfg b/tests/xlconfigdata/test-disk-positional-parms-full.cfg new file mode 100644 index 0000000..026e451 --- /dev/null +++ b/tests/xlconfigdata/test-disk-positional-parms-full.cfg @@ -0,0 +1,26 @@ +name = "XenGuest2" +uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +vcpus = 1 +pae = 1 +acpi = 1 +apic = 1 +hap = 0 +viridian = 0 +rtc_timeoffset = 0 +localtime = 0 +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +device_model = "/usr/lib/xen/bin/qemu-dm" +sdl = 0 +vnc = 1 +vncunused = 1 +vnclisten = "127.0.0.1" +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000" ] +parallel = "none" +serial = "none" +builder = "hvm" +boot = "d" +disk = [ "/dev/HostVG/XenGuest2,raw,hda,rw,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,qcow2,hdb,rw", "/root/boot.iso,raw,hdc,ro,devtype=cdrom" ] diff --git a/tests/xlconfigdata/test-disk-positional-parms-full.xml b/tests/xlconfigdata/test-disk-positional-parms-full.xml new file mode 100644 index 0000000..49f6dbe --- /dev/null +++ b/tests/xlconfigdata/test-disk-positional-parms-full.xml @@ -0,0 +1,54 @@ + + XenGuest2 + c7a5fdb2-cdaf-9455-926a-d65c16db1809 + 592896 + 403456 + 1 + + hvm + /usr/lib/xen/boot/hvmloader + + + + + + + + + destroy + restart + restart + + /usr/lib/xen/bin/qemu-dm + + + + +
+ + + + + +
+ + + + + + +
+ + + + +