2013-09-04 05:43:00 +00:00
|
|
|
/*
|
|
|
|
* libxl_conf.h: libxl configuration management
|
|
|
|
*
|
2014-02-01 01:09:53 +00:00
|
|
|
* Copyright (C) 2011-2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
2013-09-04 05:43:00 +00:00
|
|
|
* Copyright (C) 2011 Univention GmbH.
|
2011-02-10 22:42:34 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2011-03-29 12:24:05 +00:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Jim Fehlig <jfehlig@novell.com>
|
2011-05-30 09:53:02 +00:00
|
|
|
* Markus Groß <gross@univention.de>
|
2011-02-10 22:42:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBXL_CONF_H
|
|
|
|
# define LIBXL_CONF_H
|
|
|
|
|
|
|
|
# include <libxl.h>
|
|
|
|
|
|
|
|
# include "internal.h"
|
2013-12-13 16:16:50 +00:00
|
|
|
# include "libvirt_internal.h"
|
2015-07-17 09:11:23 +00:00
|
|
|
# include "virdomainobjlist.h"
|
2011-03-29 12:18:24 +00:00
|
|
|
# include "domain_event.h"
|
2011-02-10 22:42:34 +00:00
|
|
|
# include "capabilities.h"
|
|
|
|
# include "configmake.h"
|
2013-01-11 12:09:53 +00:00
|
|
|
# include "virportallocator.h"
|
2013-01-21 17:09:05 +00:00
|
|
|
# include "virobject.h"
|
2013-07-26 03:30:50 +00:00
|
|
|
# include "virchrdev.h"
|
2014-03-06 09:46:11 +00:00
|
|
|
# include "virhostdev.h"
|
2015-04-14 20:38:46 +00:00
|
|
|
# include "locking/lock_manager.h"
|
2016-05-18 14:24:37 +00:00
|
|
|
# include "virfirmware.h"
|
2016-03-04 18:35:20 +00:00
|
|
|
# include "libxl_capabilities.h"
|
2011-02-10 22:42:34 +00:00
|
|
|
|
2014-03-06 09:46:11 +00:00
|
|
|
# define LIBXL_DRIVER_NAME "xenlight"
|
2011-02-10 22:42:34 +00:00
|
|
|
# define LIBXL_VNC_PORT_MIN 5900
|
|
|
|
# define LIBXL_VNC_PORT_MAX 65535
|
|
|
|
|
2014-05-08 21:56:51 +00:00
|
|
|
# define LIBXL_MIGRATION_PORT_MIN 49152
|
|
|
|
# define LIBXL_MIGRATION_PORT_MAX 49216
|
|
|
|
|
2013-09-09 15:15:15 +00:00
|
|
|
# define LIBXL_CONFIG_BASE_DIR SYSCONFDIR "/libvirt"
|
2011-02-10 22:42:34 +00:00
|
|
|
# define LIBXL_CONFIG_DIR SYSCONFDIR "/libvirt/libxl"
|
|
|
|
# define LIBXL_AUTOSTART_DIR LIBXL_CONFIG_DIR "/autostart"
|
|
|
|
# define LIBXL_STATE_DIR LOCALSTATEDIR "/run/libvirt/libxl"
|
|
|
|
# define LIBXL_LOG_DIR LOCALSTATEDIR "/log/libvirt/libxl"
|
|
|
|
# define LIBXL_LIB_DIR LOCALSTATEDIR "/lib/libvirt/libxl"
|
|
|
|
# define LIBXL_SAVE_DIR LIBXL_LIB_DIR "/save"
|
2014-02-19 23:09:36 +00:00
|
|
|
# define LIBXL_DUMP_DIR LIBXL_LIB_DIR "/dump"
|
2014-11-21 14:32:53 +00:00
|
|
|
# define LIBXL_BOOTLOADER_PATH "pygrub"
|
2011-02-10 22:42:34 +00:00
|
|
|
|
2015-03-17 20:10:28 +00:00
|
|
|
|
2011-02-10 22:42:34 +00:00
|
|
|
typedef struct _libxlDriverPrivate libxlDriverPrivate;
|
|
|
|
typedef libxlDriverPrivate *libxlDriverPrivatePtr;
|
2013-08-30 20:52:14 +00:00
|
|
|
|
|
|
|
typedef struct _libxlDriverConfig libxlDriverConfig;
|
|
|
|
typedef libxlDriverConfig *libxlDriverConfigPtr;
|
|
|
|
|
|
|
|
struct _libxlDriverConfig {
|
|
|
|
virObject parent;
|
|
|
|
|
2013-08-30 20:32:10 +00:00
|
|
|
const libxl_version_info *verInfo;
|
2011-02-10 22:42:34 +00:00
|
|
|
unsigned int version;
|
|
|
|
|
2013-08-09 23:41:46 +00:00
|
|
|
/* log stream for driver-wide libxl ctx */
|
|
|
|
FILE *logger_file;
|
|
|
|
xentoollog_logger *logger;
|
2011-02-10 22:42:34 +00:00
|
|
|
/* libxl ctx for driver wide ops; getVersion, getNodeInfo, ... */
|
2012-11-26 16:28:56 +00:00
|
|
|
libxl_ctx *ctx;
|
2011-02-10 22:42:34 +00:00
|
|
|
|
2013-06-19 02:46:26 +00:00
|
|
|
/* Controls automatic ballooning of domain0. If true, attempt to get
|
|
|
|
* memory for new domains from domain0. */
|
|
|
|
bool autoballoon;
|
|
|
|
|
2015-04-14 20:38:46 +00:00
|
|
|
char *lockManagerName;
|
|
|
|
|
2016-02-05 20:45:03 +00:00
|
|
|
int keepAliveInterval;
|
|
|
|
unsigned int keepAliveCount;
|
|
|
|
|
2013-08-30 20:52:14 +00:00
|
|
|
/* Once created, caps are immutable */
|
|
|
|
virCapsPtr caps;
|
|
|
|
|
2013-09-09 15:15:15 +00:00
|
|
|
char *configBaseDir;
|
2013-08-30 20:52:14 +00:00
|
|
|
char *configDir;
|
|
|
|
char *autostartDir;
|
|
|
|
char *logDir;
|
|
|
|
char *stateDir;
|
|
|
|
char *libDir;
|
|
|
|
char *saveDir;
|
2014-02-19 23:09:36 +00:00
|
|
|
char *autoDumpDir;
|
2016-05-18 14:24:37 +00:00
|
|
|
|
|
|
|
virFirmwarePtr *firmwares;
|
|
|
|
size_t nfirmwares;
|
2013-08-30 20:52:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct _libxlDriverPrivate {
|
|
|
|
virMutex lock;
|
|
|
|
|
2014-03-06 09:46:11 +00:00
|
|
|
virHostdevManagerPtr hostdevMgr;
|
2013-08-30 20:52:14 +00:00
|
|
|
/* Require lock to get reference on 'config',
|
|
|
|
* then lockless thereafter */
|
|
|
|
libxlDriverConfigPtr config;
|
|
|
|
|
2013-08-30 20:55:52 +00:00
|
|
|
/* Atomic inc/dec only */
|
2013-08-30 20:54:50 +00:00
|
|
|
unsigned int nactive;
|
2013-08-30 20:52:14 +00:00
|
|
|
|
2013-08-30 20:55:52 +00:00
|
|
|
/* Immutable pointers. Caller must provide locking */
|
2012-10-31 19:03:55 +00:00
|
|
|
virStateInhibitCallback inhibitCallback;
|
|
|
|
void *inhibitOpaque;
|
|
|
|
|
2013-08-30 20:55:52 +00:00
|
|
|
/* Immutable pointer, self-locking APIs */
|
2013-01-11 16:04:47 +00:00
|
|
|
virDomainObjListPtr domains;
|
2011-02-10 22:42:34 +00:00
|
|
|
|
2013-08-30 20:55:52 +00:00
|
|
|
/* Immutable pointer, immutable object */
|
2013-08-30 20:52:14 +00:00
|
|
|
virDomainXMLOptionPtr xmlopt;
|
|
|
|
|
2013-08-30 20:55:52 +00:00
|
|
|
/* Immutable pointer, self-locking APIs */
|
2013-11-21 10:43:10 +00:00
|
|
|
virObjectEventStatePtr domainEventState;
|
2011-03-29 12:18:24 +00:00
|
|
|
|
2013-08-30 20:55:52 +00:00
|
|
|
/* Immutable pointer, self-locking APIs */
|
2015-04-28 00:53:04 +00:00
|
|
|
virPortAllocatorPtr reservedGraphicsPorts;
|
2013-08-30 20:52:14 +00:00
|
|
|
|
2014-05-08 21:56:51 +00:00
|
|
|
/* Immutable pointer, self-locking APIs */
|
|
|
|
virPortAllocatorPtr migrationPorts;
|
|
|
|
|
2013-08-30 20:55:52 +00:00
|
|
|
/* Immutable pointer, lockless APIs*/
|
2013-08-30 20:52:14 +00:00
|
|
|
virSysinfoDefPtr hostsysinfo;
|
2015-04-14 20:38:46 +00:00
|
|
|
|
|
|
|
/* Immutable pointer. lockless access */
|
|
|
|
virLockManagerPluginPtr lockManager;
|
2011-02-10 22:42:34 +00:00
|
|
|
};
|
|
|
|
|
2011-05-30 09:53:02 +00:00
|
|
|
# define LIBXL_SAVE_MAGIC "libvirt-xml\n \0 \r"
|
libxl: support Xen migration stream V2 in save/restore
Xen 4.6 introduced a new migration stream commonly referred to as
"migration V2". Xen 4.6 and newer always produce this new stream,
whereas Xen 4.5 and older always produce the legacy stream.
Support for migration stream V2 can be detected at build time with
LIBXL_HAVE_SRM_V2 from libxl.h. The legacy and V2 streams are not
compatible, but a V2 host can accept and convert a legacy stream.
Commit e7440656 changed the libxl driver to use the lowest libxl
API version possible (version 0x040200) to ensure the driver
builds against older Xen releases. The old 4.2 restore API does
not support specifying a stream version and assumes a legacy
stream, even if the incoming stream is migration V2. Thinking it
has been given a legacy stream, libxl will fail to convert an
incoming stream that is already V2, which causes the entire
restore operation to fail. Xen's libvirt-related OSSTest has been
failing since commit e7440656 landed in libvirt.git master. One
of the more recent failures can be seen here
http://lists.xenproject.org/archives/html/xen-devel/2016-05/msg00071.html
This patch changes the call to libxl_domain_create_restore() to
include the stream version if LIBXL_HAVE_SRM_V2 is defined. The
version field of the libxlSavefileHeader struct is also updated
to '2' when LIBXL_HAVE_SRM_V2 is defined, ensuring the stream
version in the header matches the actual stream version produced
by Xen. Along with bumping the libxl API requirement to 0x040400,
this patch fixes save/restore on a migration V2 Xen host.
Oddly, migration has never used the libxlSavefileHeader. It
handles passing configuration in the Begin and Prepare phases,
and then calls libxl directly to transfer domain state/memory
in the Perform phase. A subsequent patch will add stream
version handling in the Begin and Prepare phase handshaking,
which will fix the migration related OSSTest failures.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-05-02 18:00:39 +00:00
|
|
|
# ifdef LIBXL_HAVE_SRM_V2
|
|
|
|
# define LIBXL_SAVE_VERSION 2
|
|
|
|
# else
|
|
|
|
# define LIBXL_SAVE_VERSION 1
|
|
|
|
# endif
|
2011-05-30 09:53:02 +00:00
|
|
|
|
|
|
|
typedef struct _libxlSavefileHeader libxlSavefileHeader;
|
|
|
|
typedef libxlSavefileHeader *libxlSavefileHeaderPtr;
|
|
|
|
struct _libxlSavefileHeader {
|
|
|
|
char magic[sizeof(LIBXL_SAVE_MAGIC)-1];
|
|
|
|
uint32_t version;
|
|
|
|
uint32_t xmlLen;
|
|
|
|
/* 24 bytes used, pad up to 64 bytes */
|
|
|
|
uint32_t unused[10];
|
|
|
|
};
|
2011-02-10 22:42:34 +00:00
|
|
|
|
2013-08-30 20:52:14 +00:00
|
|
|
libxlDriverConfigPtr
|
|
|
|
libxlDriverConfigNew(void);
|
|
|
|
|
|
|
|
libxlDriverConfigPtr
|
|
|
|
libxlDriverConfigGet(libxlDriverPrivatePtr driver);
|
2013-08-30 17:11:08 +00:00
|
|
|
|
2014-02-26 20:44:09 +00:00
|
|
|
int
|
|
|
|
libxlDriverNodeGetInfo(libxlDriverPrivatePtr driver,
|
|
|
|
virNodeInfoPtr info);
|
|
|
|
|
2013-09-09 15:15:15 +00:00
|
|
|
int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg,
|
|
|
|
const char *filename);
|
|
|
|
|
2011-05-26 15:09:01 +00:00
|
|
|
int
|
2012-11-26 16:28:56 +00:00
|
|
|
libxlMakeDisk(virDomainDiskDefPtr l_dev, libxl_device_disk *x_dev);
|
2011-05-26 15:09:01 +00:00
|
|
|
int
|
2014-01-06 18:37:20 +00:00
|
|
|
libxlMakeNic(virDomainDefPtr def,
|
|
|
|
virDomainNetDefPtr l_nic,
|
|
|
|
libxl_device_nic *x_nic);
|
2011-05-26 15:09:01 +00:00
|
|
|
int
|
2014-05-30 13:48:56 +00:00
|
|
|
libxlMakeVfb(virPortAllocatorPtr graphicsports,
|
2011-05-30 09:53:00 +00:00
|
|
|
virDomainGraphicsDefPtr l_vfb, libxl_device_vfb *x_vfb);
|
2011-05-26 15:09:01 +00:00
|
|
|
|
2014-03-06 09:46:11 +00:00
|
|
|
int
|
2014-03-13 11:59:32 +00:00
|
|
|
libxlMakePCI(virDomainHostdevDefPtr hostdev, libxl_device_pci *pcidev);
|
2014-03-06 09:46:11 +00:00
|
|
|
|
2016-05-19 08:14:33 +00:00
|
|
|
# ifdef LIBXL_HAVE_PVUSB
|
|
|
|
int
|
|
|
|
libxlMakeUSB(virDomainHostdevDefPtr hostdev, libxl_device_usbdev *usbdev);
|
|
|
|
# endif
|
|
|
|
|
2014-05-30 14:53:12 +00:00
|
|
|
virDomainXMLOptionPtr
|
|
|
|
libxlCreateXMLConf(void);
|
|
|
|
|
2011-02-10 22:42:34 +00:00
|
|
|
int
|
2014-05-30 13:48:56 +00:00
|
|
|
libxlBuildDomainConfig(virPortAllocatorPtr graphicsports,
|
2014-05-30 13:46:35 +00:00
|
|
|
virDomainDefPtr def,
|
|
|
|
libxl_ctx *ctx,
|
|
|
|
libxl_domain_config *d_config);
|
2011-02-10 22:42:34 +00:00
|
|
|
|
2013-08-30 20:56:40 +00:00
|
|
|
static inline void
|
|
|
|
libxlDriverLock(libxlDriverPrivatePtr driver)
|
|
|
|
{
|
|
|
|
virMutexLock(&driver->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
libxlDriverUnlock(libxlDriverPrivatePtr driver)
|
|
|
|
{
|
|
|
|
virMutexUnlock(&driver->lock);
|
|
|
|
}
|
|
|
|
|
2011-02-10 22:42:34 +00:00
|
|
|
#endif /* LIBXL_CONF_H */
|