2007-04-04 14:19:49 +00:00
|
|
|
/*
|
2014-03-07 13:38:51 +00:00
|
|
|
* xen_driver.h: Unified Xen driver.
|
2007-04-04 14:19:49 +00:00
|
|
|
*
|
2011-06-22 20:31:45 +00:00
|
|
|
* Copyright (C) 2007, 2010-2011 Red Hat, Inc.
|
2007-04-04 14:19:49 +00:00
|
|
|
*
|
2012-07-27 09:39:53 +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-27 09:39:53 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2007-04-04 14:19:49 +00:00
|
|
|
*
|
|
|
|
* Richard W.M. Jones <rjones@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_XEN_UNIFIED_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_XEN_UNIFIED_H__
|
|
|
|
|
|
|
|
# include "internal.h"
|
|
|
|
# include "capabilities.h"
|
|
|
|
# include "driver.h"
|
|
|
|
# include "domain_conf.h"
|
|
|
|
# include "xs_internal.h"
|
|
|
|
# if WITH_XEN_INOTIFY
|
|
|
|
# include "xen_inotify.h"
|
|
|
|
# endif
|
|
|
|
# include "domain_event.h"
|
2012-01-25 16:13:59 +00:00
|
|
|
# include "virhash.h"
|
2010-03-09 18:22:22 +00:00
|
|
|
|
|
|
|
# ifndef HAVE_WINSOCK2_H
|
|
|
|
# include <sys/un.h>
|
|
|
|
# include <netinet/in.h>
|
|
|
|
# else
|
|
|
|
# include <winsock2.h>
|
|
|
|
# endif
|
Wed Dec 5 13:48:00 UTC 2007 Richard W.M. Jones <rjones@redhat.com>
* python/libvir.c, python/libvirt_wrap.h, qemud/qemud.c,
qemud/remote.c, src/internal.h, src/openvz_conf.c,
src/openvz_driver.c, src/proxy_internal.h, src/qemu_conf.c,
src/qemu_driver.c, src/remote_internal.h, src/test.h, src/util.c,
src/xen_unified.c, src/xen_unified.h, tests/nodeinfotest.c,
tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c, tests/reconnect.c,
tests/sexpr2xmltest.c, tests/virshtest.c, tests/xencapstest.c,
tests/xmconfigtest.c, tests/xml2sexprtest.c:
Change #include <> to #include "" for local includes.
Removed many includes from src/internal.h and put them in
the C files which actually use them.
Removed <ansidecl.h> - unused.
Added a comment around __func__.
Removed a clashing redefinition of VERSION symbol.
All limits (PATH_MAX etc) now done in src/internal.h, so we
don't need to include those headers in other files.
2007-12-05 13:56:22 +00:00
|
|
|
|
2010-11-01 20:02:55 +00:00
|
|
|
# include <xen/xen.h>
|
|
|
|
|
2010-10-29 16:51:01 +00:00
|
|
|
/* xen-unstable changeset 19788 removed MAX_VIRT_CPUS from public
|
|
|
|
* headers. Its semantic was retained with XEN_LEGACY_MAX_VCPUS.
|
|
|
|
* Ensure MAX_VIRT_CPUS is defined accordingly.
|
|
|
|
*/
|
|
|
|
# if !defined(MAX_VIRT_CPUS) && defined(XEN_LEGACY_MAX_VCPUS)
|
|
|
|
# define MAX_VIRT_CPUS XEN_LEGACY_MAX_VCPUS
|
|
|
|
# endif
|
|
|
|
|
2016-05-10 11:37:32 +00:00
|
|
|
int xenRegister (void);
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# define XEN_UNIFIED_HYPERVISOR_OFFSET 0
|
2010-11-08 16:32:02 +00:00
|
|
|
# define XEN_UNIFIED_XEND_OFFSET 1
|
|
|
|
# define XEN_UNIFIED_XS_OFFSET 2
|
|
|
|
# define XEN_UNIFIED_XM_OFFSET 3
|
2008-11-25 10:44:52 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# if WITH_XEN_INOTIFY
|
2010-11-08 16:32:02 +00:00
|
|
|
# define XEN_UNIFIED_INOTIFY_OFFSET 4
|
2010-03-09 18:22:22 +00:00
|
|
|
# define XEN_UNIFIED_NR_DRIVERS 5
|
2010-11-08 16:32:02 +00:00
|
|
|
# else
|
|
|
|
# define XEN_UNIFIED_NR_DRIVERS 4
|
2010-03-09 18:22:22 +00:00
|
|
|
# endif
|
2007-04-30 16:57:15 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
|
2008-11-04 23:22:06 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# define XEND_DOMAINS_DIR "/var/lib/xend/domains"
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
|
2011-05-18 08:52:57 +00:00
|
|
|
# define XEN_SCHED_SEDF_NPARAM 6
|
|
|
|
# define XEN_SCHED_CRED_NPARAM 2
|
|
|
|
|
xen: reject unknown flags
Also fix a logic bug in xenXMDomain{Attach,Detach}DeviceFlags,
where (flags & VIR_DOMAIN_DEVICE_MODIFY_CURRENT) is always false.
* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare, xenDaemonDomainSetVcpusFlags,
xenDaemonDomainGetVcpusFlags, xenDaemonAttachDeviceFlags,
xenDaemonDetachDeviceFlags): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState, xenXMDomainSetVcpusFlags)
(xenXMDomainGetVcpusFlags): Reject unknown flags.
(xenXMDomainAttachDeviceFlags, xenXMDomainDetachDeviceFlags):
Likewise, and avoid always-false conditional.
* src/xen/xen_driver.h (XEN_MIGRATION_FLAGS): New define.
2011-07-06 23:15:33 +00:00
|
|
|
/* The set of migration flags explicitly supported by xen. */
|
|
|
|
# define XEN_MIGRATION_FLAGS \
|
|
|
|
(VIR_MIGRATE_LIVE | \
|
|
|
|
VIR_MIGRATE_UNDEFINE_SOURCE | \
|
|
|
|
VIR_MIGRATE_PAUSED | \
|
|
|
|
VIR_MIGRATE_PERSIST_DEST)
|
|
|
|
|
Fri Jul 6 16:08:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/proxy_internal.c, src/proxy_internal.h,
src.xen_internal.c, src/xen_internal.h,
src/xen_unified.c, src/xen_unified.h,
src/xend_internal.c, src/xend_internal.h,
src/xm_internal.c, src/xm_internal.h,
src/xs_internal.c, src/xs_internal.h: The interface
between xen_unified.c and its underlying driver now uses
a custom structure (struct xenUnifiedDriver) instead
of reusing virDriver.
* src/xen_unified.c: virDomainLookup* functions in Xen
now throw VIR_ERR_NO_DOMAIN if the domain does not exist.
* src/xs_internal.c: Fix indentation.
2007-07-06 15:11:22 +00:00
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
typedef struct xenXMConfCache *xenXMConfCachePtr;
|
|
|
|
typedef struct xenXMConfCache {
|
|
|
|
time_t refreshedAt;
|
2011-06-22 20:31:45 +00:00
|
|
|
char *filename;
|
2008-11-25 10:44:52 +00:00
|
|
|
virDomainDefPtr def;
|
|
|
|
} xenXMConfCache;
|
|
|
|
|
|
|
|
/* xenUnifiedDomainInfoPtr:
|
|
|
|
* The minimal state we have about active domains
|
|
|
|
* This is the minmal info necessary to still get a
|
|
|
|
* virDomainPtr when the domain goes away
|
|
|
|
*/
|
|
|
|
struct _xenUnifiedDomainInfo {
|
|
|
|
int id;
|
|
|
|
char *name;
|
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
|
|
|
};
|
|
|
|
typedef struct _xenUnifiedDomainInfo xenUnifiedDomainInfo;
|
|
|
|
typedef xenUnifiedDomainInfo *xenUnifiedDomainInfoPtr;
|
|
|
|
|
|
|
|
struct _xenUnifiedDomainInfoList {
|
2014-03-07 08:33:31 +00:00
|
|
|
size_t count;
|
2008-11-25 10:44:52 +00:00
|
|
|
xenUnifiedDomainInfoPtr *doms;
|
|
|
|
};
|
|
|
|
typedef struct _xenUnifiedDomainInfoList xenUnifiedDomainInfoList;
|
|
|
|
typedef xenUnifiedDomainInfoList *xenUnifiedDomainInfoListPtr;
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
/* xenUnifiedPrivatePtr:
|
|
|
|
*
|
|
|
|
* Per-connection private data, stored in conn->privateData. All Xen
|
|
|
|
* low-level drivers access parts of this structure.
|
|
|
|
*/
|
|
|
|
struct _xenUnifiedPrivate {
|
2009-01-21 18:11:14 +00:00
|
|
|
virMutex lock;
|
|
|
|
|
|
|
|
/* These initial vars are initialized in Open method
|
|
|
|
* and readonly thereafter, so can be used without
|
|
|
|
* holding the lock
|
|
|
|
*/
|
2008-07-25 13:17:27 +00:00
|
|
|
virCapsPtr caps;
|
2013-03-31 18:03:42 +00:00
|
|
|
virDomainXMLOptionPtr xmlopt;
|
2007-04-04 14:19:49 +00:00
|
|
|
int handle; /* Xen hypervisor handle */
|
|
|
|
|
|
|
|
/* connection to xend */
|
2009-01-22 19:41:48 +00:00
|
|
|
struct sockaddr_storage addr;
|
|
|
|
socklen_t addrlen;
|
|
|
|
int addrfamily;
|
|
|
|
int addrprotocol;
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2007-04-30 16:57:15 +00:00
|
|
|
/* Keep track of the drivers which opened. We keep a yes/no flag
|
|
|
|
* here for each driver, corresponding to the array drivers in
|
|
|
|
* xen_unified.c.
|
|
|
|
*/
|
|
|
|
int opened[XEN_UNIFIED_NR_DRIVERS];
|
2008-11-25 10:44:52 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Everything from this point onwards must be protected
|
|
|
|
* by the lock when used
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct xs_handle *xshandle; /* handle to talk to the xenstore */
|
|
|
|
|
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
/* A list of xenstore watches */
|
|
|
|
xenStoreWatchListPtr xsWatchList;
|
|
|
|
int xsWatch;
|
2009-01-20 17:19:23 +00:00
|
|
|
/* A list of active domain name/uuids */
|
|
|
|
xenUnifiedDomainInfoListPtr activeDomainList;
|
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
/* NUMA topology info cache */
|
|
|
|
int nbNodeCells;
|
|
|
|
int nbNodeCpus;
|
2008-11-25 10:44:52 +00:00
|
|
|
|
2013-11-21 10:43:10 +00:00
|
|
|
virObjectEventStatePtr domainEvents;
|
2008-11-25 10:44:52 +00:00
|
|
|
|
2009-01-20 17:34:56 +00:00
|
|
|
/* Location of config files, either /etc
|
|
|
|
* or /var/lib/xen */
|
|
|
|
const char *configDir;
|
2012-12-04 10:00:02 +00:00
|
|
|
/* Location of managed save dir, default /var/lib/libvirt/xen/save */
|
|
|
|
char *saveDir;
|
2009-01-20 17:34:56 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# if WITH_XEN_INOTIFY
|
2008-11-25 10:44:52 +00:00
|
|
|
/* The inotify fd */
|
|
|
|
int inotifyFD;
|
|
|
|
int inotifyWatch;
|
2009-01-20 17:19:23 +00:00
|
|
|
|
2013-05-21 07:21:21 +00:00
|
|
|
int useXenConfigCache;
|
2009-01-20 17:19:23 +00:00
|
|
|
xenUnifiedDomainInfoListPtr configInfoList;
|
2010-03-09 18:22:22 +00:00
|
|
|
# endif
|
2009-01-20 17:34:56 +00:00
|
|
|
|
|
|
|
/* For the 'xm' driver */
|
|
|
|
/* Primary config file name -> virDomainDef map */
|
|
|
|
virHashTablePtr configCache;
|
|
|
|
/* Domain name to config file name */
|
|
|
|
virHashTablePtr nameConfigMap;
|
|
|
|
/* So we don't refresh too often */
|
|
|
|
time_t lastRefresh;
|
2007-04-04 14:19:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr;
|
|
|
|
|
2013-08-06 11:28:58 +00:00
|
|
|
char *xenDomainUsedCpus(virDomainPtr dom, virDomainDefPtr def);
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2013-03-13 20:39:34 +00:00
|
|
|
virDomainXMLOptionPtr xenDomainXMLConfInit(void);
|
|
|
|
|
2008-11-25 10:44:52 +00:00
|
|
|
void xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr info);
|
|
|
|
int xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr info,
|
|
|
|
int id, char *name,
|
|
|
|
unsigned char *uuid);
|
|
|
|
int xenUnifiedRemoveDomainInfo(xenUnifiedDomainInfoListPtr info,
|
|
|
|
int id, char *name,
|
|
|
|
unsigned char *uuid);
|
|
|
|
void xenUnifiedDomainEventDispatch (xenUnifiedPrivatePtr priv,
|
2013-11-22 14:38:05 +00:00
|
|
|
virObjectEventPtr event);
|
2008-11-28 12:03:20 +00:00
|
|
|
unsigned long xenUnifiedVersion(void);
|
2013-04-23 12:50:18 +00:00
|
|
|
int xenUnifiedConnectGetMaxVcpus(virConnectPtr conn, const char *type);
|
2008-11-28 12:03:20 +00:00
|
|
|
|
2009-01-21 18:11:14 +00:00
|
|
|
void xenUnifiedLock(xenUnifiedPrivatePtr priv);
|
|
|
|
void xenUnifiedUnlock(xenUnifiedPrivatePtr priv);
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
#endif /* __VIR_XEN_UNIFIED_H__ */
|