[libvirt] [PATCH V3 2/4] src/xenconfig: Xen-xl parser
Michal Privoznik
mprivozn at redhat.com
Fri Dec 19 13:59:26 UTC 2014
On 16.12.2014 05:30, Jim Fehlig wrote:
> From: Kiarie Kahurani <davidkiarie4 at gmail.com>
>
> Introduce a Xen xl parser
>
> This parser allows for users to convert the new xl disk format and
> spice graphics config to libvirt xml format and vice versa. Regarding
> the spice graphics config, the code is pretty much straight forward.
> For the disk {formating, parsing}, this parser takes care of the new
> xl format which include positional parameters and key/value parameters.
> In xl format disk config a <diskspec> consists of parameters separated by
> commas. If the parameters do not contain an '=' they are automatically
> assigned to certain options following the order below
>
> target, format, vdev, access
>
> The above are the only mandatory parameters in the <diskspec> but there
> are many more disk config options. These options can be specified as
> key=value pairs. This takes care of the rest of the options such as
>
> devtype, backend, backendtype, script, direct-io-safe,
>
> The positional paramters can also be specified in key/value form
> for example
>
> /dev/vg/guest-volume,,hda
> /dev/vg/guest-volume,raw,hda,rw
> format=raw, vdev=hda, access=rw, target=/dev/vg/guest-volume
>
> are interpleted to one config.
>
> In xm format, the above diskspec would be written as
>
> phy:/dev/vg/guest-volume,hda,w
>
> The disk parser is based on the same parser used successfully by
> the Xen project for several years now. Ian Jackson authored the
> scanner, which is used by this commit with mimimal changes. Only
> the PREFIX option is changed, to produce function and file names
> more consistent with libvirt's convention.
>
> Signed-off-by: Kiarie Kahurani <davidkiarie4 at gmail.com>
> Signed-off-by: Jim Fehlig <jfehlig at suse.com>
> ---
> .gitignore | 1 +
> cfg.mk | 3 +-
> configure.ac | 1 +
> po/POTFILES.in | 1 +
> src/Makefile.am | 25 ++-
> src/libvirt_xenconfig.syms | 4 +
> src/xenconfig/xen_common.c | 3 +-
> src/xenconfig/xen_xl.c | 499 ++++++++++++++++++++++++++++++++++++++++++
> src/xenconfig/xen_xl.h | 33 +++
> src/xenconfig/xen_xl_disk.l | 256 ++++++++++++++++++++++
> src/xenconfig/xen_xl_disk_i.h | 39 ++++
> 11 files changed, 861 insertions(+), 4 deletions(-)
>
> diff --git a/.gitignore b/.gitignore
> index 9d09709..eac2203 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -140,6 +140,7 @@
> /src/remote/*_protocol.[ch]
> /src/rpc/virkeepaliveprotocol.[ch]
> /src/rpc/virnetprotocol.[ch]
> +/src/xenconfig/xen_xl_disk.[ch]
> /src/test_libvirt*.aug
> /src/test_virtlockd.aug
> /src/util/virkeymaps.h
> diff --git a/cfg.mk b/cfg.mk
> index 21f83c3..3df3dcb 100644
> --- a/cfg.mk
> +++ b/cfg.mk
> @@ -89,8 +89,9 @@ distdir: sc_vulnerable_makefile_CVE-2012-3386.z
> endif
>
> # Files that should never cause syntax check failures.
> +# (^(HACKING|docs/(news\.html\.in|.*\.patch))|\.(po|fig|gif|ico|png))$$
> VC_LIST_ALWAYS_EXCLUDE_REGEX = \
> - (^(HACKING|docs/(news\.html\.in|.*\.patch))|\.(po|fig|gif|ico|png))$$
> + (^(HACKING|docs/(news\.html\.in|.*\.patch)|src/xenconfig/xen_xl_disk.[chl])|\.(po|fig|gif|ico|png))$$
>
> # Functions like free() that are no-ops on NULL arguments.
> useless_free_options = \
> diff --git a/configure.ac b/configure.ac
> index 9fd44b2..777367e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -146,6 +146,7 @@ m4_ifndef([LT_INIT], [
> ])
> AM_PROG_CC_C_O
> AM_PROG_LD
> +AM_PROG_LEX
>
> AC_MSG_CHECKING([for how to mark DSO non-deletable at runtime])
> LIBVIRT_NODELETE=
> diff --git a/po/POTFILES.in b/po/POTFILES.in
> index e7cb2cc..094c8e3 100644
> --- a/po/POTFILES.in
> +++ b/po/POTFILES.in
> @@ -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
> diff --git a/src/Makefile.am b/src/Makefile.am
> index b6c1701..23c433d 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -999,11 +999,22 @@ CPU_SOURCES = \
> VMX_SOURCES = \
> vmx/vmx.c vmx/vmx.h
>
> +AM_LFLAGS = -Pxl_disk_ --header-file=../$*.h
> +LEX_OUTPUT_ROOT = lex.xl_disk_
> +BUILT_SOURCES += xenconfig/xen_xl_disk.c xenconfig/xen_xl_disk.h
> +# Generated header file is not implicitly added to dist
> +EXTRA_DIST += xenconfig/xen_xl_disk.h
> +CLEANFILES += xenconfig/xen_xl_disk.h xenconfig/xen_xl_disk.c
> +
> +XENXLDISKPARSER_SOURCES = xenconfig/xen_xl_disk.l
> +
> XENCONFIG_SOURCES = \
> xenconfig/xenxs_private.h \
> - xenconfig/xen_common.c xenconfig/xen_common.h \
> + xenconfig/xen_common.c xenconfig/xen_common.h \
> xenconfig/xen_sxpr.c xenconfig/xen_sxpr.h \
> - xenconfig/xen_xm.c xenconfig/xen_xm.h
> + xenconfig/xen_xm.c xenconfig/xen_xm.h \
> + xenconfig/xen_xl.c xenconfig/xen_xl.h \
> + xenconfig/xen_xl_disk_i.h
>
> pkgdata_DATA = cpu/cpu_map.xml
>
> @@ -1058,10 +1069,19 @@ libvirt_vmx_la_SOURCES = $(VMX_SOURCES)
> endif WITH_VMX
>
> if WITH_XENCONFIG
> +# Flex generated XL disk parser needs to be compiled without WARN_FLAGS
> +# Add the generated object to its own library to control CFLAGS
> +noinst_LTLIBRARIES += libvirt_xenxldiskparser.la
> +libvirt_xenxldiskparser_la_CFLAGS = \
> + -I$(top_srcdir)/src/conf
> +libvirt_xenxldiskparser_la_SOURCES = \
> + $(XENXLDISKPARSER_SOURCES)
> +
> noinst_LTLIBRARIES += libvirt_xenconfig.la
> libvirt_la_BUILT_LIBADD += libvirt_xenconfig.la
> libvirt_xenconfig_la_CFLAGS = \
> -I$(top_srcdir)/src/conf $(AM_CFLAGS)
> +libvirt_xenconfig_la_LIBADD = libvirt_xenxldiskparser.la
> libvirt_xenconfig_la_SOURCES = $(XENCONFIG_SOURCES)
> endif WITH_XENCONFIG
>
> @@ -1823,6 +1843,7 @@ EXTRA_DIST += \
> $(VBOX_DRIVER_EXTRA_DIST) \
> $(VMWARE_DRIVER_SOURCES) \
> $(XENCONFIG_SOURCES) \
> + $(XENXLDISKPARSER_SOURCES) \
> $(ACCESS_DRIVER_POLKIT_POLICY)
>
> check-local: check-augeas
> diff --git a/src/libvirt_xenconfig.syms b/src/libvirt_xenconfig.syms
> index 6541685..3e2e5d6 100644
> --- a/src/libvirt_xenconfig.syms
> +++ b/src/libvirt_xenconfig.syms
> @@ -16,6 +16,10 @@ xenParseSxprChar;
> xenParseSxprSound;
> xenParseSxprString;
>
> +#xenconfig/xen_xl.h
> +xenFormatXL;
> +xenParseXL;
> +
> # xenconfig/xen_xm.h
> xenFormatXM;
> xenParseXM;
> diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
> index 8ff10a0..b94b5db 100644
> --- a/src/xenconfig/xen_common.c
> +++ b/src/xenconfig/xen_common.c
> @@ -1801,7 +1801,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)
> diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
> new file mode 100644
> index 0000000..8d1d2a7
> --- /dev/null
> +++ b/src/xenconfig/xen_xl.c
> @@ -0,0 +1,499 @@
> +/*
> + * xen_xl.c: Xen XL parsing functions
> + *
> + * 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 <davidkiarie4 at gmail.com>
> + */
> +
> +#include <config.h>
> +
> +#include "virconf.h"
> +#include "virerror.h"
> +#include "domain_conf.h"
> +#include "viralloc.h"
> +#include "virstring.h"
> +#include "xen_xl.h"
> +#include "xen_xl_disk.h"
> +#include "xen_xl_disk_i.h"
> +
> +#define VIR_FROM_THIS VIR_FROM_NONE
> +
> +
> +static int
> +xenParseXLSpice(virConfPtr conf, virDomainDefPtr def)
> +{
> + virDomainGraphicsDefPtr graphics = NULL;
> + unsigned long port;
> + char *listenAddr = NULL;
> + int val;
> +
> + if (STREQ(def->os.type, "hvm")) {
> + if (xenConfigGetBool(conf, "spice", &val, 0) < 0)
> + return -1;
> +
> + if (val) {
> + if (VIR_ALLOC(graphics) < 0)
> + return -1;
> +
> + graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
> + if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0)
> + goto cleanup;
> + if (listenAddr &&
> + virDomainGraphicsListenSetAddress(graphics, 0, listenAddr,
> + -1, true) < 0) {
> + goto cleanup;
> + }
> + VIR_FREE(listenAddr);
> +
> + if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0)
> + goto cleanup;
> + graphics->data.spice.tlsPort = (int)port;
> +
> + if (xenConfigGetULong(conf, "spiceport", &port, 0) < 0)
> + goto cleanup;
> +
> + graphics->data.spice.port = (int)port;
> +
> + if (!graphics->data.spice.tlsPort &&
> + !graphics->data.spice.port)
> + graphics->data.spice.autoport = 1;
> +
> + if (xenConfigGetBool(conf, "spicedisable_ticketing", &val, 0) < 0)
> + goto cleanup;
> + if (val) {
> + if (xenConfigCopyStringOpt(conf, "spicepasswd",
> + &graphics->data.spice.auth.passwd) < 0)
> + goto cleanup;
> + }
> +
> + if (xenConfigGetBool(conf, "spiceagent_mouse",
> + &graphics->data.spice.mousemode, 0) < 0)
> + goto cleanup;
> + if (xenConfigGetBool(conf, "spicedvagent", &val, 0) < 0)
> + goto cleanup;
> + if (val) {
> + if (xenConfigGetBool(conf, "spice_clipboard_sharing",
> + &graphics->data.spice.copypaste,
> + 0) < 0)
> + goto cleanup;
> + }
> +
> + if (VIR_ALLOC_N(def->graphics, 1) < 0)
> + goto cleanup;
> + def->graphics[0] = graphics;
> + def->ngraphics = 1;
> + }
> + }
> +
> + return 0;
> +
> + cleanup:
> + virDomainGraphicsDefFree(graphics);
> + return -1;
> +}
> +
> +
> +void
> +xenXLDiskParserError(xenXLDiskParserContext *dpc,
> + const char *erroneous,
> + const char *message)
> +{
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> + _("disk config %s not supported: %s"),
> + erroneous, message);
> +
> + if (!dpc->err)
> + dpc->err = EINVAL;
> +}
> +
> +
> +static int
> +xenXLDiskParserPrep(xenXLDiskParserContext *dpc,
> + const char *spec,
> + virDomainDiskDefPtr disk)
> +{
> + int err;
> +
> + dpc->spec = spec;
> + dpc->disk = disk;
> + dpc->access_set = 0;
> +
> + err = xl_disk_lex_init_extra(dpc, &dpc->scanner);
> + if (err)
> + goto fail;
> +
> + dpc->buf = xl_disk__scan_bytes(spec, strlen(spec), dpc->scanner);
> + if (!dpc->buf) {
> + err = ENOMEM;
> + goto fail;
> + }
> +
> + return 0;
> +
> + fail:
> + virReportSystemError(errno, "%s",
> + _("failed to initialize disk configuration parser"));
> + return err;
> +}
> +
> +
> +static void
> +xenXLDiskParserCleanup(xenXLDiskParserContext *dpc)
> +{
> + if (dpc->buf) {
> + xl_disk__delete_buffer(dpc->buf, dpc->scanner);
> + dpc->buf = NULL;
> + }
> +
> + if (dpc->scanner) {
> + xl_disk_lex_destroy(dpc->scanner);
> + dpc->scanner = NULL;
> + }
> +}
> +
> +
> +/*
> + * positional parameters
> + * (If the <diskspec> strings are not separated by "="
> + * the string is split following ',' and assigned to
> + * the following options in the following order)
> + * target,format,vdev,access
> + * ================================================================
> + *
> + * The parameters below cannot be specified as positional parameters:
> + *
> + * other parameters
> + * devtype = <devtype>
> + * backendtype = <backend-type>
> + * parameters not taken care of
> + * backend = <domain-name>
> + * script = <script>
> + * direct-io-safe
> + *
> + * ================================================================
> + * The parser does not take any deprecated parameters
> + *
> + * For more information refer to /xen/docs/misc/xl-disk-configuration.txt
> + */
> +static int
> +xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
> +{
> + virConfValuePtr list = virConfGetValue(conf, "disk");
> + xenXLDiskParserContext dpc;
> + virDomainDiskDefPtr disk;
> +
> + memset(&dpc, 0, sizeof(dpc));
> +
> + if (list && list->type == VIR_CONF_LIST) {
> + list = list->list;
> + while (list) {
> + char *disk_spec = list->str;
> + const char *driver;
> +
> + if ((list->type != VIR_CONF_STRING) || (list->str == NULL))
> + goto skipdisk;
> +
> + if (!(disk = virDomainDiskDefNew()))
> + return -1;
> +
> + disk->src->readonly = 0;
> + disk->src->format = VIR_STORAGE_FILE_LAST;
> +
> + if (xenXLDiskParserPrep(&dpc, disk_spec, disk))
> + goto fail;
> +
> + xl_disk_lex(dpc.scanner);
> +
> + if (dpc.err)
> + goto fail;
> +
> + if (disk->src->format == VIR_STORAGE_FILE_LAST)
> + disk->src->format = VIR_STORAGE_FILE_RAW;
> +
> + if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
> + disk->removable = true;
> + disk->src->readonly = true;
> + if (virDomainDiskSetDriver(disk, "qemu") < 0)
> + goto fail;
> +
> + virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE);
> + if (!disk->src->path || STREQ(disk->src->path, ""))
> + disk->src->format = VIR_STORAGE_FILE_NONE;
> + }
> +
> + if (STRPREFIX(disk->dst, "xvd") || !STREQ(def->os.type, "hvm"))
> + disk->bus = VIR_DOMAIN_DISK_BUS_XEN;
> + else if (STRPREFIX(disk->dst, "sd"))
> + disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
> + else
> + disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
> +
> + driver = virDomainDiskGetDriver(disk);
> + if (!driver) {
> + switch (disk->src->format) {
> + case VIR_STORAGE_FILE_QCOW:
> + case VIR_STORAGE_FILE_QCOW2:
> + case VIR_STORAGE_FILE_VHD:
> + driver = "qemu";
> + if (virDomainDiskSetDriver(disk, "qemu") < 0)
> + goto fail;
> + break;
> + default:
> + driver = "phy";
> + if (virDomainDiskSetDriver(disk, "phy") < 0)
> + goto fail;
> + }
> + }
> +
> + if (STREQ(driver, "phy"))
> + virDomainDiskSetType(disk, VIR_STORAGE_TYPE_BLOCK);
> + else
> + virDomainDiskSetType(disk, VIR_STORAGE_TYPE_FILE);
> +
> + if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0)
> + goto fail;
> +
> + skipdisk:
> + list = list->next;
> + xenXLDiskParserCleanup(&dpc);
> + }
> + }
> + return 0;
> +
> + fail:
> + xenXLDiskParserCleanup(&dpc);
> + virDomainDiskDefFree(disk);
> + return -1;
> +}
> +
> +
> +virDomainDefPtr
> +xenParseXL(virConfPtr conf, virCapsPtr caps, int xendConfigVersion)
> +{
> + virDomainDefPtr def = NULL;
> +
> + if (VIR_ALLOC(def) < 0)
> + return NULL;
> +
> + def->virtType = VIR_DOMAIN_VIRT_XEN;
> + def->id = -1;
> +
> + if (xenParseConfigCommon(conf, def, caps, xendConfigVersion) < 0)
> + goto cleanup;
> +
> + if (xenParseXLDisk(conf, def) < 0)
> + goto cleanup;
> +
> + if (xenParseXLSpice(conf, def) < 0)
> + goto cleanup;
> +
> + return def;
> +
> + cleanup:
> + virDomainDefFree(def);
> + return NULL;
> +}
> +
> +
> +static int
> +xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
> +{
> + virBuffer buf = VIR_BUFFER_INITIALIZER;
> + virConfValuePtr val, tmp;
> + const char *src = virDomainDiskGetSource(disk);
> + int format = virDomainDiskGetFormat(disk);
> +
> + /* target */
> + virBufferAsprintf(&buf, "%s,", src);
> + /* format */
> + switch (format) {
> + case VIR_STORAGE_FILE_RAW:
> + virBufferAddLit(&buf, "raw,");
> + break;
> + case VIR_STORAGE_FILE_VHD:
> + virBufferAddLit(&buf, "xvhd,");
> + break;
> + case VIR_STORAGE_FILE_QCOW:
> + virBufferAddLit(&buf, "qcow,");
> + break;
> + case VIR_STORAGE_FILE_QCOW2:
> + virBufferAddLit(&buf, "qcow2,");
> + break;
> + /* set default */
> + default:
> + virBufferAddLit(&buf, "raw,");
> + }
> +
> + /* device */
> + virBufferAdd(&buf, disk->dst, -1);
> +
> + virBufferAddLit(&buf, ",");
> +
> + if (disk->src->readonly)
> + virBufferAddLit(&buf, "r,");
> + else if (disk->src->shared)
> + virBufferAddLit(&buf, "!,");
> + else
> + virBufferAddLit(&buf, "w,");
> + if (disk->transient) {
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> + _("transient disks not supported yet"));
> + goto cleanup;
> + }
> +
> + if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
> + virBufferAddLit(&buf, "devtype=cdrom");
> +
> + if (virBufferCheckError(&buf) < 0)
> + goto cleanup;
> +
> + if (VIR_ALLOC(val) < 0)
> + goto cleanup;
> +
> + val->type = VIR_CONF_STRING;
> + val->str = virBufferContentAndReset(&buf);
> + tmp = list->list;
> + while (tmp && tmp->next)
> + tmp = tmp->next;
> + if (tmp)
> + tmp->next = val;
> + else
> + list->list = val;
> + return 0;
> +
> + cleanup:
> + virBufferFreeAndReset(&buf);
> + return -1;
> +}
> +
> +
> +static int
> +xenFormatXLDomainDisks(virConfPtr conf, virDomainDefPtr def)
> +{
> + virConfValuePtr diskVal = NULL;
> + size_t i = 0;
> +
> + if (VIR_ALLOC(diskVal) < 0)
> + return -1;
> +
> + diskVal->type = VIR_CONF_LIST;
> + diskVal->list = NULL;
> +
> + for (i = 0; i < def->ndisks; i++) {
> + if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
> + continue;
> + if (xenFormatXLDisk(diskVal, def->disks[i]) < 0)
> +
> + goto cleanup;
> + }
> +
> + if (diskVal->list != NULL) {
> + int ret = virConfSetValue(conf, "disk", diskVal);
> + diskVal = NULL;
> + if (ret < 0)
> + goto cleanup;
> + }
> +
> + return 0;
> +
> + cleanup:
> + virConfFreeValue(diskVal);
> + return 0;
> +}
> +
> +
> +static int
> +xenFormatXLSpice(virConfPtr conf, virDomainDefPtr def)
> +{
> + const char *listenAddr = NULL;
> +
> + if (STREQ(def->os.type, "hvm")) {
> + if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
> + /* set others to false but may not be necessary */
> + if (xenConfigSetInt(conf, "sdl", 0) < 0)
> + return -1;
> +
> + if (xenConfigSetInt(conf, "vnc", 0) < 0)
> + return -1;
> +
> + if (xenConfigSetInt(conf, "spice", 1) < 0)
> + return -1;
> +
> + if (xenConfigSetInt(conf, "spiceport",
> + def->graphics[0]->data.spice.port) < 0)
> + return -1;
> +
> + if (xenConfigSetInt(conf, "spicetls_port",
> + def->graphics[0]->data.spice.tlsPort) < 0)
> + return -1;
> +
> + if (def->graphics[0]->data.spice.auth.passwd) {
> + if (xenConfigSetInt(conf, "spicedisable_ticketing", 1) < 0)
> + return -1;
> +
> + if (def->graphics[0]->data.spice.auth.passwd &&
> + xenConfigSetString(conf, "spicepasswd",
> + def->graphics[0]->data.spice.auth.passwd) < 0)
> + return -1;
> + }
> +
> + listenAddr = virDomainGraphicsListenGetAddress(def->graphics[0], 0);
> + if (listenAddr &&
> + xenConfigSetString(conf, "spicehost", listenAddr) < 0)
> + return -1;
> +
> + if (xenConfigSetInt(conf, "spicemouse_mouse",
> + def->graphics[0]->data.spice.mousemode) < 0)
> + return -1;
> +
> + if (def->graphics[0]->data.spice.copypaste) {
> + if (xenConfigSetInt(conf, "spicedvagent", 1) < 0)
> + return -1;
> + if (xenConfigSetInt(conf, "spice_clipboard_sharing",
> + def->graphics[0]->data.spice.copypaste) < 0)
> + return -1;
> + }
> + }
> + }
> +
> + return 0;
> +}
> +
> +
> +virConfPtr
> +xenFormatXL(virDomainDefPtr def, virConnectPtr conn, int xendConfigVersion)
> +{
> + virConfPtr conf = NULL;
> +
> + if (!(conf = virConfNew()))
> + goto cleanup;
> +
> + if (xenFormatConfigCommon(conf, def, conn, xendConfigVersion) < 0)
> + goto cleanup;
> +
> + if (xenFormatXLDomainDisks(conf, def) < 0)
> + goto cleanup;
> +
> + if (xenFormatXLSpice(conf, def) < 0)
> + goto cleanup;
> +
> + return conf;
> +
> + cleanup:
> + if (conf)
> + virConfFree(conf);
> + return NULL;
> +}
> diff --git a/src/xenconfig/xen_xl.h b/src/xenconfig/xen_xl.h
> new file mode 100644
> index 0000000..536e9b7
> --- /dev/null
> +++ b/src/xenconfig/xen_xl.h
> @@ -0,0 +1,33 @@
> +/*
> + * xen_xl.h: Xen XL parsing functions
> + *
> + * 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<davidkiarie4 at gmail.com>
> + */
> +
> +#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__ */
> diff --git a/src/xenconfig/xen_xl_disk.l b/src/xenconfig/xen_xl_disk.l
> new file mode 100644
> index 0000000..164aa32
> --- /dev/null
> +++ b/src/xenconfig/xen_xl_disk.l
> @@ -0,0 +1,256 @@
> +/*
> + * xen_xl_disk.l - parser for disk specification strings
> + *
> + * Copyright (C) 2011 Citrix Ltd.
> + * Author Ian Jackson <ian.jackson at eu.citrix.com>
> + *
> + * This program 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; version 2.1 only. with the special
> + * exception on linking described in file LICENSE.
> + *
> + * This program 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.
> + */
> +
> +/*
> + * Parsing the old xm/xend/xl-4.1 disk specs is a tricky problem,
> + * because the target string might in theory contain "," which is the
> + * delimiter we use for stripping off things on the RHS, and ":",
> + * which is the delimiter we use for stripping off things on the LHS.
> + *
> + * In this parser we do not support such target strings in the old
> + * syntax; if the target string has to contain "," or ":" the new
> + * syntax's "target=" should be used.
> + */
> +%{
> +# include <config.h>
> +
> +# include <stdio.h>
> +
> +# include "viralloc.h"
> +# include "virstoragefile.h"
With this, you need to -I$(LIBXML_CFLAGS), otherwise you'll get an compile error:
CC xenconfig/libvirt_xenxldiskparser_la-xen_xl_disk.lo
In file included from ../src/util/virstoragefile.h:29:0,
from xenconfig/xen_xl_disk.l:34:
../src/util/virstorageencryption.h:30:26: fatal error: libxml/tree.h: No such file or directory
# include <libxml/tree.h>
^
However, that alone is not enough:
make[3]: Entering directory '/home/zippy/work/libvirt/libvirt.git/src'
CC xenconfig/libvirt_xenxldiskparser_la-xen_xl_disk.lo
xenconfig/xen_xl_disk.c: In function 'yy_fatal_error':
xenconfig/xen_xl_disk.c:2143:58: error: unused parameter 'yyscanner' [-Werror=unused-parameter]
static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
^
xenconfig/xen_xl_disk.c: In function 'xl_disk_alloc':
xenconfig/xen_xl_disk.c:2471:49: error: unused parameter 'yyscanner' [-Werror=unused-parameter]
void *xl_disk_alloc (yy_size_t size , yyscan_t yyscanner)
^
xenconfig/xen_xl_disk.c: In function 'xl_disk_realloc':
xenconfig/xen_xl_disk.c:2476:64: error: unused parameter 'yyscanner' [-Werror=unused-parameter]
void *xl_disk_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
^
xenconfig/xen_xl_disk.c: In function 'xl_disk_free':
xenconfig/xen_xl_disk.c:2488:42: error: unused parameter 'yyscanner' [-Werror=unused-parameter]
void xl_disk_free (void * ptr , yyscan_t yyscanner)
^
cc1: all warnings being treated as errors
So we are aiming at this diff:
diff --git a/src/Makefile.am b/src/Makefile.am
index 3eb9a18..8ccc273 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1074,7 +1074,7 @@ if WITH_XENCONFIG
# Add the generated object to its own library to control CFLAGS
noinst_LTLIBRARIES += libvirt_xenxldiskparser.la
libvirt_xenxldiskparser_la_CFLAGS = \
- -I$(top_srcdir)/src/conf
+ -I$(top_srcdir)/src/conf $(AM_CFLAGS) -Wno-unused-parameter
libvirt_xenxldiskparser_la_SOURCES = \
$(XENXLDISKPARSER_SOURCES)
ACK with that squashed in.
Michal
More information about the libvir-list
mailing list