Introduce support for parsing/formatting Xen xl config format
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v5 1/3 Introduce support for parsing/formatting Xen xl config format
Introduce a parser/formatter for the xl config format. Since the deprecation of xm/xend, the VM config file format has diverged as new features are added to libxl. This patch adds support for parsing and formating the xl config format. It supports the existing xm config format, plus adds support for spice graphics and xl disk config syntax.
Disk config is specified a bit differently in xl as compared to xm. In xl, disk config consists of comma-separated positional parameters and keyword/value pairs separated by commas. Positional parameters are specified as follows
target, format, vdev, access
Supported keys for key=value options are
devtype, backendtype
The positional paramters can also be specified in key/value form. For example the following xl disk config are equivalent
/dev/vg/guest-volume,,hda /dev/vg/guest-volume,raw,hda,rw
format=raw, vdev=hda, access=rw, target=/dev/vg/guest-volume
See $xen_sources/docs/misc/xl-disk-configuration.txt for more details.
xl disk config is parsed with the help of xlu_disk_parse() from libxlutil, libxl's utility library. Although the library exists in all Xen versions supported by the libxl virt driver, only recently has the corresponding header file been included. A check for the header is done in configure.ac. If not found, xlu_disk_parse() is declared externally.
---
V5:
Address a few V4 issues noted by eblake.
configure.ac | 3 + po/POTFILES.in | 1 + src/Makefile.am | 11 + src/libvirt_xenxlconfig.syms | 12 + src/xenconfig/xen_common.c | 3 +- src/xenconfig/xen_xl.c | 515 +++++++++++++++++++++++++++++++++++++++++++ src/xenconfig/xen_xl.h | 35 +++ 7 files changed, 579 insertions(+), 1 deletion(-)
configure.ac +3 -0
@@ -891,6 +891,9 @@ if test $fail = 1; then fi if test "$with_libxl" = "yes"; then + dnl If building with libxl, use the libxl utility header and lib too + AC_CHECK_HEADERS([libxlutil.h]) + LIBXL_LIBS="$LIBXL_LIBS -lxlutil" AC_DEFINE_UNQUOTED([WITH_LIBXL], 1, [whether libxenlight driver is enabled]) fi AM_CONDITIONAL([WITH_LIBXL], [test "$with_libxl" = "yes"])
po/POTFILES.in +1 -0
@@ -247,6 +247,7 @@ src/xenapi/xenapi_driver.c src/xenapi/xenapi_utils.c src/xenconfig/xen_common.c src/xenconfig/xen_sxpr.c +src/xenconfig/xen_xl.c src/xenconfig/xen_xm.c tests/virpolkittest.c tools/libvirt-guests.sh.in
src/Makefile.am +11 -0
@@ -1005,6 +1005,10 @@ XENCONFIG_SOURCES = \ xenconfig/xen_common.c xenconfig/xen_common.h \ xenconfig/xen_sxpr.c xenconfig/xen_sxpr.h \ xenconfig/xen_xm.c xenconfig/xen_xm.h +if WITH_LIBXL +XENCONFIG_SOURCES += \ + xenconfig/xen_xl.c xenconfig/xen_xl.h +endif WITH_LIBXL pkgdata_DATA = cpu/cpu_map.xml
@@ -1061,6 +1065,7 @@ endif WITH_VMX if WITH_XENCONFIG noinst_LTLIBRARIES += libvirt_xenconfig.la libvirt_la_BUILT_LIBADD += libvirt_xenconfig.la +libvirt_la_LIBADD += $(LIBXL_LIBS) libvirt_xenconfig_la_CFLAGS = \ -I$(srcdir)/conf $(AM_CFLAGS) libvirt_xenconfig_la_SOURCES = $(XENCONFIG_SOURCES)
@@ -1979,6 +1984,12 @@ else ! WITH_XENCONFIG SYM_FILES += $(srcdir)/libvirt_xenconfig.syms endif ! WITH_XENCONFIG +if WITH_LIBXL +USED_SYM_FILES += $(srcdir)/libvirt_xenxlconfig.syms +else ! WITH_LIBXL +SYM_FILES += $(srcdir)/libvirt_xenxlconfig.syms +endif ! WITH_LIBXL + if WITH_SASL USED_SYM_FILES += $(srcdir)/libvirt_sasl.syms else ! WITH_SASL
src/libvirt_xenxlconfig.syms new file +12 -0
@@ -0,0 +1,12 @@ +# +# These symbols are dependent upon --with-libxl via WITH_LIBXL. +# + +#xenconfig/xen_xl.h +xenFormatXL; +xenParseXL; + +# Let emacs know we want case-insensitive sorting +# Local Variables: +# sort-fold-case: t +# End:
src/xenconfig/xen_common.c +2 -1
@@ -1812,7 +1812,8 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) {int hvm =STREQ (def->os.type,"hvm" ) ?1 :0 ; -if (def->ngraphics ==1 ) { +if (def->ngraphics ==1 && + def->graphics[0 ]->type !=VIR_DOMAIN_GRAPHICS_TYPE_SPICE ) {if (hvm || (xendConfigVersion <XEND_CONFIG_MIN_VERS_PVFB_NEWCONF )) {if (def->graphics[0 ]->type ==VIR_DOMAIN_GRAPHICS_TYPE_SDL ) {if (xenConfigSetInt (conf,"sdl" ,1 ) <0 )
src/xenconfig/xen_xl.c new file +515 -0
515 lines not on this page · raw message
src/xenconfig/xen_xl.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* xen_xl.h: Xen XL parsing functions +* +* Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library. If not, see +* <http://www.gnu.org/licenses/>. +* +* Author: Kiarie Kahurani<[email protected]> +*/ + +#ifndef __VIR_XEN_XL_H__ +# define __VIR_XEN_XL_H__ + +# include "virconf.h" +# include "domain_conf.h" +# include "xen_common.h" + +virDomainDefPtr xenParseXL (virConfPtr conn,virCapsPtr caps, +int xendConfigVersion); +virConfPtr xenFormatXL (virDomainDefPtr def, +virConnectPtr ,int xendConfigVersion); + +#endif /* __VIR_XEN_XL_H__ */
Signature · 1 line
1.8.4.5
PATCH v5 2/3 tests: Tests for the xen-xl parser
In reply to a message not in the archiveFrom: Kiarie Kahurani <[email protected]>
Add disk and spice config tests for the xen_xl config parser
---
V5:
Enable spice test. Fix invalid config in the test data files and an actual bug in the spice formatting code.
tests/Makefile.am | 11 ++ tests/testutilsxen.c | 50 ++++++++ tests/testutilsxen.h | 9 +- tests/xlconfigdata/test-new-disk.cfg | 26 ++++ tests/xlconfigdata/test-new-disk.xml | 51 ++++++++ tests/xlconfigdata/test-spice.cfg | 31 +++++ tests/xlconfigdata/test-spice.xml | 46 +++++++ tests/xlconfigtest.c | 225 +++++++++++++++++++++++++++++++++++ 8 files changed, 448 insertions(+), 1 deletion(-)
tests/Makefile.am +11 -0
@@ -138,6 +138,7 @@ EXTRA_DIST = \ vmx2xmldata \ xencapsdata \ xmconfigdata \ + xlconfigdata \ xml2sexprdata \ xml2vmxdata \ vmwareverdata \
@@ -227,6 +228,11 @@ if WITH_XEN test_programs += xml2sexprtest sexpr2xmltest \ xmconfigtest xencapstest statstest reconnect endif WITH_XEN + +if WITH_LIBXL +test_programs += xlconfigtest +endif WITH_LIBXL + if WITH_QEMU test_programs += qemuxml2argvtest qemuxml2xmltest qemuxmlnstest \ qemuargv2xmltest qemuhelptest domainsnapshotxml2xmltest \
@@ -477,6 +483,11 @@ sexpr2xmltest_SOURCES = \ testutils.c testutils.h sexpr2xmltest_LDADD = $(xen_LDADDS) +xlconfigtest_SOURCES = \ + xlconfigtest.c testutilsxen.c testutilsxen.h \ + testutils.c testutils.h +xlconfigtest_LDADD =$(xen_LDADDS) + xmconfigtest_SOURCES = \ xmconfigtest.c testutilsxen.c testutilsxen.h \ testutils.c testutils.h
tests/testutilsxen.c +50 -0
53 lines not on this page · raw message
tests/testutilsxen.h +8 -1
@@ -1,3 +1,10 @@ -#include "capabilities.h" +#ifndef _TESTUTILSXEN_H_ +# define _TESTUTILSXEN_H_ + +# include "capabilities.h" virCapsPtr testXenCapsInit (void ); + +virCapsPtr testXLInitCaps (void ); + +#endif /* _TESTUTILSXEN_H_ */
tests/xlconfigdata/test-new-disk.cfg new file +26 -0
@@ -0,0 +1,26 @@ +name = "XenGuest2" +uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +vcpus = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" +pae = 1 +acpi = 1 +apic = 1 +hap = 0 +viridian = 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,type=ioemu" ] +parallel = "none" +serial = "none" +disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,qcow2,hdb,w,backendtype=qdisk", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
tests/xlconfigdata/test-new-disk.xml new file +51 -0
51 lines not on this page · raw message
tests/xlconfigdata/test-spice.cfg new file +31 -0
@@ -0,0 +1,31 @@ +name = "XenGuest2" +uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809" +maxmem = 579 +memory = 394 +vcpus = 1 +builder = "hvm" +kernel = "/usr/lib/xen/boot/hvmloader" +boot = "d" +pae = 1 +acpi = 1 +apic = 1 +hap = 0 +viridian = 0 +localtime = 0 +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +device_model = "/usr/lib/xen/bin/qemu-dm" +vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,type=ioemu" ] +parallel = "none" +serial = "none" +disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ] +sdl = 0 +vnc = 0 +spice = 1 +spiceport = 590 +spicetls_port = 500 +spicedisable_ticketing = 1 +spicepasswd = "thebeast" +spicehost = "127.0.0.1" +spiceagent_mouse = 0
tests/xlconfigdata/test-spice.xml new file +46 -0
46 lines not on this page · raw message
tests/xlconfigtest.c new file +225 -0
225 lines not on this page · raw message
Signature · 1 line
1.8.4.5
PATCH v5 3/3 libxl: Add support for parsing/formating Xen XL config
In reply to a message not in the archiveFrom: Kiarie Kahurani <[email protected]>
Now that xenconfig supports parsing and formatting Xen's XL config format, integrate it into the libxl driver's connectDomainXML{From,To}Native functions.
---
No change from V4.
src/libxl/libxl_driver.c | 32 ++++++++++++++++++++++++-------- tools/virsh.pod | 8 ++++---- 2 files changed, 28 insertions(+), 12 deletions(-)
src/libxl/libxl_driver.c +24 -8
@@ -48,6 +48,7 @@#include "libxl_migration.h" #include "xen_xm.h" #include "xen_sxpr.h" +#include "xen_xl.h" #include "virtypedparam.h" #include "viruri.h" #include "virstring.h"
@@ -67,6 +68,7 @@ VIR_LOG_INIT("libxl.libxl_driver");#define LIBXL_DOM_REQ_CRASH 3#define LIBXL_DOM_REQ_HALT 4 +#define LIBXL_CONFIG_FORMAT_XL "xen-xl"#define LIBXL_CONFIG_FORMAT_XM "xen-xm"#define LIBXL_CONFIG_FORMAT_SEXPR "xen-sxpr"
@@ -2215,7 +2217,17 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn,if (virConnectDomainXMLFromNativeEnsureACL (conn) <0 ) goto cleanup; -if (STREQ (nativeFormat,LIBXL_CONFIG_FORMAT_XM )) { +if (STREQ (nativeFormat,LIBXL_CONFIG_FORMAT_XL )) { +if (!(conf =virConfReadMem (nativeConfig,strlen (nativeConfig),0 ))) + goto cleanup; +if (!(def =xenParseXL (conf, + cfg->caps, + cfg->verInfo->xen_version_major))) { +virReportError (VIR_ERR_INTERNAL_ERROR ,"%s" , +_ ("parsing xl config failed" )); + goto cleanup; + } + }else if (STREQ (nativeFormat,LIBXL_CONFIG_FORMAT_XM )) {if (!(conf =virConfReadMem (nativeConfig,strlen (nativeConfig),0 ))) goto cleanup;
@@ -2270,20 +2282,24 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,if (virConnectDomainXMLToNativeEnsureACL (conn) <0 ) goto cleanup; -if (STRNEQ (nativeFormat,LIBXL_CONFIG_FORMAT_XM )) { -virReportError (VIR_ERR_INVALID_ARG , -_ ("unsupported config type %s" ), nativeFormat); - goto cleanup; - } -if (!(def =virDomainDefParseString (domainXml, cfg->caps, driver->xmlopt,1 <<VIR_DOMAIN_VIRT_XEN ,VIR_DOMAIN_DEF_PARSE_INACTIVE ))) goto cleanup; -if (!(conf =xenFormatXM (conn, def, cfg->verInfo->xen_version_major))) +if (STREQ (nativeFormat,LIBXL_CONFIG_FORMAT_XL )) { +if (!(conf =xenFormatXL (def, conn, cfg->verInfo->xen_version_major))) + goto cleanup; + }else if (STREQ (nativeFormat,LIBXL_CONFIG_FORMAT_XM )) { +if (!(conf =xenFormatXM (conn, def, cfg->verInfo->xen_version_major))) + goto cleanup; + }else { + +virReportError (VIR_ERR_INVALID_ARG , +_ ("unsupported config type %s" ), nativeFormat); goto cleanup; + }if (VIR_ALLOC_N (ret, len) <0 ) goto cleanup;
tools/virsh.pod +4 -4
@@ -1272,16 +1272,16 @@ in order to get or set the guest time. Convert the file I<config> in the native guest configuration format named by I<format> to a domain XML format. For QEMU/KVM hypervisor, the I<format> argument must be B<qemu-argv>. For Xen hypervisor, the -I<format> argument may be B<xen-xm> or B<xen-sxpr>. For LXC hypervisor, -the I<format> argument must be B<lxc-tools>. +I<format> argument may be B<xen-xm>, B<xen-xl>, or B<xen-sxpr>. For +LXC hypervisor, the I<format> argument must be B<lxc-tools>. =item B<domxml-to-native> I<format> I<xml> Convert the file I<xml> in domain XML format to the native guest configuration format named by I<format>. For QEMU/KVM hypervisor, the I<format> argument must be B<qemu-argv>. For Xen hypervisor, the -I<format> argument may be B<xen-xm> or B<xen-sxpr>. For LXC hypervisor, -the I<format> argument must be B<lxc-tools>. +I<format> argument may be B<xen-xm>, B<xen-xl>, or B<xen-sxpr>. For +LXC hypervisor, the I<format> argument must be B<lxc-tools>. =item B<dump> I<domain> I<corefilepath> [I<--bypass-cache>] { [I<--live>] | [I<--crash>] | [I<--reset>] } [I<--verbose>] [I<--memory-only>]
Signature · 1 line
1.8.4.5
Re: [libvirt] [PATCH V5 0/3] Parser for xen-xl config format
In reply to a message not in the archiveQuoted 7 lines · Jim Fehlig
V5 of xen-xl parser. V4 was close
https://www.redhat.com/archives/libvir-list/2015-January/msg00429.html
but the tests did not exersice the spice parsing/formatting code. It is now fixed in V5, along with addressing a few V4 comments from eblake.
Quoted 6 lines
Jim Fehlig (1):
Introduce support for parsing/formatting Xen xl config formatKiarie Kahurani (2):
tests: Tests for the xen-xl parser
libxl: Add support for parsing/formating Xen XL config
ACK series
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [libvirt] [PATCH V5 0/3] Parser for xen-xl config format
Quoted 12 lines · Eric Blake
Quoted 10 lines · Jim Fehlig
V5 of xen-xl parser. V4 was close
https://www.redhat.com/archives/libvir-list/2015-January/msg00429.html
but the tests did not exersice the spice parsing/formatting code. It is now fixed in V5, along with addressing a few V4 comments from eblake.
Jim Fehlig (1):
Introduce support for parsing/formatting Xen xl config format
Quoted 7 lines
Quoted 4 lines
Kiarie Kahurani (2):
tests: Tests for the xen-xl parser
libxl: Add support for parsing/formating Xen XL configACK series
Thanks, pushed now.
Regards,
Jim