diff --git a/configure.ac b/configure.ac index 9d12079458..f37047599b 100644 --- a/configure.ac +++ b/configure.ac @@ -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"]) diff --git a/po/POTFILES.in b/po/POTFILES.in index e7cb2cc197..094c8e3704 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 e0e47d0658..216abac0e3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/libvirt_xenxlconfig.syms b/src/libvirt_xenxlconfig.syms new file mode 100644 index 0000000000..dbe43aac79 --- /dev/null +++ b/src/libvirt_xenxlconfig.syms @@ -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: diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index b40a72237b..a2a1474f56 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -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) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c new file mode 100644 index 0000000000..7913118fa7 --- /dev/null +++ b/src/xenconfig/xen_xl.c @@ -0,0 +1,515 @@ +/* + * xen_xl.c: 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 + * . + * + * Author: Kiarie Kahurani + * Author: Jim Fehlig + */ + +#include + +#include + +#include "virconf.h" +#include "virerror.h" +#include "domain_conf.h" +#include "viralloc.h" +#include "virstring.h" +#include "virstoragefile.h" +#include "xen_xl.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + +/* + * Xen provides a libxl utility library, with several useful functions, + * specifically xlu_disk_parse for parsing xl disk config strings. + * Although the libxlutil library is installed, until recently the + * corresponding header file wasn't. Use the header file if detected during + * configure, otherwise provide extern declarations for any functions used. + */ +#ifdef HAVE_LIBXLUTIL_H +# include +#else +typedef struct XLU_Config XLU_Config; + +extern XLU_Config *xlu_cfg_init(FILE *report, + const char *report_filename); + +extern void xlu_cfg_destroy(XLU_Config*); + +extern int xlu_disk_parse(XLU_Config *cfg, + int nspecs, + const char *const *specs, + libxl_device_disk *disk); +#endif + +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; +} + +/* + * For details on xl disk config syntax, see + * docs/misc/xl-disk-configuration.txt in the Xen sources. The important + * section of text is: + * + * More formally, the string is a series of comma-separated keyword/value + * pairs, flags and positional parameters. Parameters which are not bare + * keywords and which do not contain "=" symbols are assigned to the + * so-far-unspecified positional parameters, in the order below. The + * positional parameters may also be specified explicitly by name. + * + * Each parameter may be specified at most once, either as a positional + * parameter or a named parameter. Default values apply if the parameter + * is not specified, or if it is specified with an empty value (whether + * positionally or explicitly). + * + * Whitespace may appear before each parameter and will be ignored. + * + * The order of the positional parameters mentioned in the quoted text is: + * + * target,format,vdev,access + * + * The following options must be specified by key=value: + * + * devtype= + * backendtype= + * + * The following options are currently not supported: + * + * backend= + * script=