2007-04-04 14:19:49 +00:00
|
|
|
/*
|
|
|
|
* xen_unified.c: Unified Xen driver.
|
|
|
|
*
|
2010-10-07 14:59:27 +00:00
|
|
|
* Copyright (C) 2007, 2010 Red Hat, Inc.
|
2007-04-04 14:19:49 +00:00
|
|
|
*
|
|
|
|
* See COPYING.LIB for the License of this software
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
# include "hash.h"
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2008-11-21 12:16:08 +00:00
|
|
|
extern 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 XEN_CONFIG_FORMAT_XM "xen-xm"
|
|
|
|
# define XEN_CONFIG_FORMAT_SEXPR "xen-sxpr"
|
2009-05-21 14:14:01 +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
|
|
|
|
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
|
|
|
/* _xenUnifiedDriver:
|
|
|
|
*
|
|
|
|
* Entry points into the underlying Xen drivers. This structure
|
|
|
|
* will eventually go away and instead xen unified will make direct
|
|
|
|
* calls to the underlying Xen drivers.
|
|
|
|
*
|
|
|
|
* To reiterate - the goal is to remove elements from this structure
|
|
|
|
* until it is empty, replacing indirect calls through this
|
|
|
|
* structure with direct calls in xen_unified.c.
|
|
|
|
*/
|
|
|
|
struct xenUnifiedDriver {
|
2008-04-10 16:54:54 +00:00
|
|
|
virDrvOpen open;
|
|
|
|
virDrvClose close;
|
|
|
|
virDrvGetVersion version;
|
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
|
|
|
virDrvGetHostname getHostname;
|
2008-04-10 16:54:54 +00:00
|
|
|
virDrvNodeGetInfo nodeGetInfo;
|
|
|
|
virDrvGetCapabilities getCapabilities;
|
|
|
|
virDrvListDomains listDomains;
|
|
|
|
virDrvNumOfDomains numOfDomains;
|
2008-10-10 09:32:27 +00:00
|
|
|
virDrvDomainCreateXML domainCreateXML;
|
2008-04-10 16:54:54 +00:00
|
|
|
virDrvDomainSuspend domainSuspend;
|
|
|
|
virDrvDomainResume domainResume;
|
|
|
|
virDrvDomainShutdown domainShutdown;
|
|
|
|
virDrvDomainReboot domainReboot;
|
|
|
|
virDrvDomainDestroy domainDestroy;
|
|
|
|
virDrvDomainGetOSType domainGetOSType;
|
|
|
|
virDrvDomainGetMaxMemory domainGetMaxMemory;
|
|
|
|
virDrvDomainSetMaxMemory domainSetMaxMemory;
|
|
|
|
virDrvDomainSetMemory domainSetMemory;
|
|
|
|
virDrvDomainGetInfo domainGetInfo;
|
|
|
|
virDrvDomainSave domainSave;
|
|
|
|
virDrvDomainRestore domainRestore;
|
|
|
|
virDrvDomainCoreDump domainCoreDump;
|
|
|
|
virDrvDomainPinVcpu domainPinVcpu;
|
|
|
|
virDrvDomainGetVcpus domainGetVcpus;
|
|
|
|
virDrvListDefinedDomains listDefinedDomains;
|
|
|
|
virDrvNumOfDefinedDomains numOfDefinedDomains;
|
|
|
|
virDrvDomainCreate domainCreate;
|
|
|
|
virDrvDomainDefineXML domainDefineXML;
|
|
|
|
virDrvDomainUndefine domainUndefine;
|
2010-01-14 01:44:26 +00:00
|
|
|
virDrvDomainAttachDeviceFlags domainAttachDeviceFlags;
|
|
|
|
virDrvDomainDetachDeviceFlags domainDetachDeviceFlags;
|
2010-03-22 13:13:53 +00:00
|
|
|
virDrvDomainUpdateDeviceFlags domainUpdateDeviceFlags;
|
2008-04-10 16:54:54 +00:00
|
|
|
virDrvDomainGetAutostart domainGetAutostart;
|
|
|
|
virDrvDomainSetAutostart domainSetAutostart;
|
|
|
|
virDrvDomainGetSchedulerType domainGetSchedulerType;
|
|
|
|
virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
|
|
|
|
virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
|
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;
|
|
|
|
char filename[PATH_MAX];
|
|
|
|
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 {
|
|
|
|
unsigned int count;
|
|
|
|
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;
|
2007-04-04 14:19:49 +00:00
|
|
|
int handle; /* Xen hypervisor handle */
|
|
|
|
|
|
|
|
int xendConfigVersion; /* XenD config version */
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
/* An list of callbacks */
|
|
|
|
virDomainEventCallbackListPtr domainEventCallbacks;
|
2009-01-21 18:11:14 +00:00
|
|
|
int domainEventDispatching;
|
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;
|
|
|
|
|
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
|
|
|
|
|
|
|
int useXenConfigCache ;
|
|
|
|
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;
|
|
|
|
|
2007-10-31 09:39:13 +00:00
|
|
|
char *xenDomainUsedCpus(virDomainPtr dom);
|
2007-04-04 14:19:49 +00:00
|
|
|
|
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,
|
2008-12-04 21:09:20 +00:00
|
|
|
virDomainEventPtr event);
|
2008-11-28 12:03:20 +00:00
|
|
|
unsigned long xenUnifiedVersion(void);
|
2010-10-14 22:17:18 +00:00
|
|
|
int xenUnifiedGetMaxVcpus(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__ */
|