2007-04-04 14:19:49 +00:00
|
|
|
/*
|
|
|
|
* xen_unified.c: Unified Xen driver.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* See COPYING.LIB for the License of this software
|
|
|
|
*
|
|
|
|
* Richard W.M. Jones <rjones@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_XEN_UNIFIED_H__
|
|
|
|
#define __VIR_XEN_UNIFIED_H__
|
|
|
|
|
|
|
|
#include "internal.h"
|
2008-07-25 13:17:27 +00:00
|
|
|
#include "capabilities.h"
|
2008-11-04 23:22:06 +00:00
|
|
|
#include "driver.h"
|
2008-11-25 10:44:52 +00:00
|
|
|
#include "domain_conf.h"
|
|
|
|
#include "xs_internal.h"
|
|
|
|
#if WITH_XEN_INOTIFY
|
|
|
|
#include "xen_inotify.h"
|
|
|
|
#endif
|
|
|
|
#include "domain_event.h"
|
2007-04-04 14:19:49 +00:00
|
|
|
|
2007-12-07 14:45:39 +00:00
|
|
|
#ifndef HAVE_WINSOCK2_H
|
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
|
|
|
#include <sys/un.h>
|
|
|
|
#include <netinet/in.h>
|
2007-12-07 14:45:39 +00:00
|
|
|
#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
|
|
|
|
2008-11-21 12:16:08 +00:00
|
|
|
extern int xenRegister (void);
|
2007-04-04 14:19:49 +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
|
|
|
#define XEN_UNIFIED_HYPERVISOR_OFFSET 0
|
|
|
|
#define XEN_UNIFIED_PROXY_OFFSET 1
|
|
|
|
#define XEN_UNIFIED_XEND_OFFSET 2
|
|
|
|
#define XEN_UNIFIED_XS_OFFSET 3
|
|
|
|
#define XEN_UNIFIED_XM_OFFSET 4
|
2008-11-25 10:44:52 +00:00
|
|
|
|
|
|
|
#if WITH_XEN_INOTIFY
|
|
|
|
#define XEN_UNIFIED_INOTIFY_OFFSET 5
|
|
|
|
#define XEN_UNIFIED_NR_DRIVERS 6
|
|
|
|
#else
|
2007-04-30 16:57:15 +00:00
|
|
|
#define XEN_UNIFIED_NR_DRIVERS 5
|
2008-11-25 10:44:52 +00:00
|
|
|
#endif
|
2007-04-30 16:57:15 +00:00
|
|
|
|
2008-11-04 23:22:06 +00:00
|
|
|
#define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
|
|
|
|
|
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;
|
|
|
|
virDrvGetURI getURI;
|
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;
|
|
|
|
virDrvDomainSetVcpus domainSetVcpus;
|
|
|
|
virDrvDomainPinVcpu domainPinVcpu;
|
|
|
|
virDrvDomainGetVcpus domainGetVcpus;
|
|
|
|
virDrvDomainGetMaxVcpus domainGetMaxVcpus;
|
|
|
|
virDrvListDefinedDomains listDefinedDomains;
|
|
|
|
virDrvNumOfDefinedDomains numOfDefinedDomains;
|
|
|
|
virDrvDomainCreate domainCreate;
|
|
|
|
virDrvDomainDefineXML domainDefineXML;
|
|
|
|
virDrvDomainUndefine domainUndefine;
|
|
|
|
virDrvDomainAttachDevice domainAttachDevice;
|
|
|
|
virDrvDomainDetachDevice domainDetachDevice;
|
|
|
|
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 {
|
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 */
|
|
|
|
|
|
|
|
/* XXX This code is not IPv6 aware. */
|
|
|
|
/* connection to xend */
|
|
|
|
int type; /* PF_UNIX or PF_INET */
|
|
|
|
int len; /* length of addr */
|
|
|
|
struct sockaddr *addr; /* type of address used */
|
|
|
|
struct sockaddr_un addr_un; /* the unix address */
|
|
|
|
struct sockaddr_in addr_in; /* the inet address */
|
|
|
|
|
|
|
|
struct xs_handle *xshandle; /* handle to talk to the xenstore */
|
|
|
|
|
|
|
|
int proxy; /* fd of proxy. */
|
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
|
|
|
|
|
|
|
/* A list of xenstore watches */
|
|
|
|
xenStoreWatchListPtr xsWatchList;
|
|
|
|
int xsWatch;
|
|
|
|
|
|
|
|
/* An list of callbacks */
|
|
|
|
virDomainEventCallbackListPtr domainEventCallbacks;
|
|
|
|
|
|
|
|
#if WITH_XEN_INOTIFY
|
|
|
|
/* The inotify fd */
|
|
|
|
int inotifyFD;
|
|
|
|
int inotifyWatch;
|
|
|
|
#endif
|
2007-04-04 14:19:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr;
|
|
|
|
|
2007-10-22 20:28:55 +00:00
|
|
|
|
|
|
|
int xenNbCells(virConnectPtr conn);
|
|
|
|
int xenNbCpus(virConnectPtr conn);
|
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);
|
|
|
|
|
2007-04-04 14:19:49 +00:00
|
|
|
#endif /* __VIR_XEN_UNIFIED_H__ */
|