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.
This commit is contained in:
Richard W.M. Jones 2007-07-06 15:11:22 +00:00
parent ea6279cb91
commit 4ea0ef797f
13 changed files with 246 additions and 150 deletions

View File

@ -1,3 +1,18 @@
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.
Fri Jul 6 17:06:52 CEST 2007 Daniel Veillard <veillard@redhat.com> Fri Jul 6 17:06:52 CEST 2007 Daniel Veillard <veillard@redhat.com>
* src/virsh.c: fix an error in the default help string, bug #247197 * src/virsh.c: fix an error in the default help string, bug #247197

View File

@ -35,35 +35,23 @@ static int xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
static char *xenProxyGetCapabilities(virConnectPtr conn); static char *xenProxyGetCapabilities(virConnectPtr conn);
static int xenProxyListDomains(virConnectPtr conn, int *ids, int maxids); static int xenProxyListDomains(virConnectPtr conn, int *ids, int maxids);
static int xenProxyNumOfDomains(virConnectPtr conn); static int xenProxyNumOfDomains(virConnectPtr conn);
static virDomainPtr xenProxyLookupByID(virConnectPtr conn, int id);
static virDomainPtr xenProxyLookupByUUID(virConnectPtr conn,
const unsigned char *uuid);
static virDomainPtr xenProxyDomainLookupByName(virConnectPtr conn,
const char *domname);
static unsigned long xenProxyDomainGetMaxMemory(virDomainPtr domain); static unsigned long xenProxyDomainGetMaxMemory(virDomainPtr domain);
static int xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info); static int xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
static char *xenProxyDomainDumpXML(virDomainPtr domain, int flags); static char *xenProxyDomainDumpXML(virDomainPtr domain, int flags);
static char *xenProxyDomainGetOSType(virDomainPtr domain); static char *xenProxyDomainGetOSType(virDomainPtr domain);
virDriver xenProxyDriver = { struct xenUnifiedDriver xenProxyDriver = {
-1,
"XenProxy",
0,
xenProxyOpen, /* open */ xenProxyOpen, /* open */
xenProxyClose, /* close */ xenProxyClose, /* close */
NULL, /* type */ NULL, /* type */
xenProxyGetVersion, /* version */ xenProxyGetVersion, /* version */
NULL, /* hostname */ NULL, /* hostname */
NULL, /* URI */ NULL, /* URI */
NULL, /* getMaxVcpus */
xenProxyNodeGetInfo, /* nodeGetInfo */ xenProxyNodeGetInfo, /* nodeGetInfo */
xenProxyGetCapabilities, /* getCapabilities */ xenProxyGetCapabilities, /* getCapabilities */
xenProxyListDomains, /* listDomains */ xenProxyListDomains, /* listDomains */
xenProxyNumOfDomains, /* numOfDomains */ xenProxyNumOfDomains, /* numOfDomains */
NULL, /* domainCreateLinux */ NULL, /* domainCreateLinux */
xenProxyLookupByID, /* domainLookupByID */
xenProxyLookupByUUID, /* domainLookupByUUID */
xenProxyDomainLookupByName, /* domainLookupByName */
NULL, /* domainSuspend */ NULL, /* domainSuspend */
NULL, /* domainResume */ NULL, /* domainResume */
NULL, /* domainShutdown */ NULL, /* domainShutdown */
@ -799,7 +787,7 @@ xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
* *
* Returns a new domain object or NULL in case of failure * Returns a new domain object or NULL in case of failure
*/ */
static virDomainPtr virDomainPtr
xenProxyLookupByID(virConnectPtr conn, int id) xenProxyLookupByID(virConnectPtr conn, int id)
{ {
virProxyPacket req; virProxyPacket req;
@ -845,7 +833,7 @@ xenProxyLookupByID(virConnectPtr conn, int id)
* *
* Returns a new domain object or NULL in case of failure * Returns a new domain object or NULL in case of failure
*/ */
static virDomainPtr virDomainPtr
xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid) xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{ {
virProxyFullPacket req; virProxyFullPacket req;
@ -879,7 +867,7 @@ xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
} }
/** /**
* xenProxyDomainLookupByName: * xenProxyLookupByName:
* @conn: A xend instance * @conn: A xend instance
* @name: The name of the domain * @name: The name of the domain
* *
@ -887,8 +875,8 @@ xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
* *
* Returns a new domain object or NULL in case of failure * Returns a new domain object or NULL in case of failure
*/ */
static virDomainPtr virDomainPtr
xenProxyDomainLookupByName(virConnectPtr conn, const char *name) xenProxyLookupByName(virConnectPtr conn, const char *name)
{ {
virProxyFullPacket req; virProxyFullPacket req;
int ret, len; int ret, len;

View File

@ -86,8 +86,15 @@ struct _virProxyFullPacket {
typedef struct _virProxyFullPacket virProxyFullPacket; typedef struct _virProxyFullPacket virProxyFullPacket;
typedef virProxyFullPacket *virProxyFullPacketPtr; typedef virProxyFullPacket *virProxyFullPacketPtr;
extern virDriver xenProxyDriver; /* xen_unified makes direct calls or indirect calls through here. */
int xenProxyInit (void); extern struct xenUnifiedDriver xenProxyDriver;
extern int xenProxyInit (void);
extern virDomainPtr xenProxyLookupByID(virConnectPtr conn, int id);
extern virDomainPtr xenProxyLookupByUUID(virConnectPtr conn,
const unsigned char *uuid);
extern virDomainPtr xenProxyLookupByName(virConnectPtr conn,
const char *domname);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -587,27 +587,18 @@ static unsigned long xenHypervisorGetMaxMemory(virDomainPtr domain);
#endif #endif
#ifndef PROXY #ifndef PROXY
virDriver xenHypervisorDriver = { struct xenUnifiedDriver xenHypervisorDriver = {
-1,
"Xen",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
(DOM0_INTERFACE_VERSION & 0xFFFF),
xenHypervisorOpen, /* open */ xenHypervisorOpen, /* open */
xenHypervisorClose, /* close */ xenHypervisorClose, /* close */
xenHypervisorGetType, /* type */ xenHypervisorGetType, /* type */
xenHypervisorGetVersion, /* version */ xenHypervisorGetVersion, /* version */
NULL, /* hostname */ NULL, /* hostname */
NULL, /* URI */ NULL, /* URI */
xenHypervisorGetMaxVcpus, /* getMaxVcpus */
NULL, /* nodeGetInfo */ NULL, /* nodeGetInfo */
xenHypervisorGetCapabilities, /* getCapabilities */ xenHypervisorGetCapabilities, /* getCapabilities */
xenHypervisorListDomains, /* listDomains */ xenHypervisorListDomains, /* listDomains */
xenHypervisorNumOfDomains, /* numOfDomains */ xenHypervisorNumOfDomains, /* numOfDomains */
NULL, /* domainCreateLinux */ NULL, /* domainCreateLinux */
NULL, /* domainLookupByID */
NULL, /* domainLookupByUUID */
NULL, /* domainLookupByName */
xenHypervisorPauseDomain, /* domainSuspend */ xenHypervisorPauseDomain, /* domainSuspend */
xenHypervisorResumeDomain, /* domainResume */ xenHypervisorResumeDomain, /* domainResume */
NULL, /* domainShutdown */ NULL, /* domainShutdown */

View File

@ -15,7 +15,7 @@
extern "C" { extern "C" {
#endif #endif
extern virDriver xenHypervisorDriver; extern struct xenUnifiedDriver xenHypervisorDriver;
int xenHypervisorInit (void); int xenHypervisorInit (void);
/* The following calls are made directly by the Xen proxy: */ /* The following calls are made directly by the Xen proxy: */

View File

@ -17,12 +17,6 @@
* xend_internal, xs_internal and xm_internal). Historically * xend_internal, xs_internal and xm_internal). Historically
* the body of libvirt.c handled the five Xen drivers, * the body of libvirt.c handled the five Xen drivers,
* and contained Xen-specific code. * and contained Xen-specific code.
*
* The interface between Xen drivers and xen_unified is
* the same as for "ordinary" libvirt drivers (ie. virDriverPtr),
* however this is just for convenience and may be changed
* in future. Libvirt.c should no longer call directly
* to the five underlying Xen drivers.
*/ */
#include <stdint.h> #include <stdint.h>
@ -44,15 +38,13 @@
#include "xm_internal.h" #include "xm_internal.h"
/* The five Xen drivers below us. */ /* The five Xen drivers below us. */
static virDriverPtr drivers[XEN_UNIFIED_NR_DRIVERS] = { static struct xenUnifiedDriver *drivers[XEN_UNIFIED_NR_DRIVERS] = {
&xenHypervisorDriver, [XEN_UNIFIED_HYPERVISOR_OFFSET] = &xenHypervisorDriver,
&xenProxyDriver, [XEN_UNIFIED_PROXY_OFFSET] = &xenProxyDriver,
&xenDaemonDriver, [XEN_UNIFIED_XEND_OFFSET] = &xenDaemonDriver,
&xenStoreDriver, [XEN_UNIFIED_XS_OFFSET] = &xenStoreDriver,
&xenXMDriver [XEN_UNIFIED_XM_OFFSET] = &xenXMDriver,
}; };
static const int hypervisor_offset = 0;
static const int proxy_offset = 1;
/** /**
* xenUnifiedError: * xenUnifiedError:
@ -153,7 +145,7 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
continue; continue;
/* Ignore proxy for root */ /* Ignore proxy for root */
if (i == proxy_offset && getuid() == 0) if (i == XEN_UNIFIED_PROXY_OFFSET && getuid() == 0)
continue; continue;
if (drivers[i]->open && if (drivers[i]->open &&
@ -162,7 +154,8 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
/* If as root, then all drivers must succeed. /* If as root, then all drivers must succeed.
If non-root, then only proxy must succeed */ If non-root, then only proxy must succeed */
if (!priv->opened[i] && (getuid() == 0 || i == proxy_offset)) { if (!priv->opened[i] &&
(getuid() == 0 || i == XEN_UNIFIED_PROXY_OFFSET)) {
for (j = 0; j < i; ++j) for (j = 0; j < i; ++j)
if (priv->opened[j]) drivers[j]->close (conn); if (priv->opened[j]) drivers[j]->close (conn);
free (priv->name); free (priv->name);
@ -269,16 +262,18 @@ static int
xenUnifiedGetMaxVcpus (virConnectPtr conn, const char *type) xenUnifiedGetMaxVcpus (virConnectPtr conn, const char *type)
{ {
GET_PRIVATE(conn); GET_PRIVATE(conn);
int i;
if (!type)
type = "Xen";
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (priv->opened[i] && strcmp (drivers[i]->name, type) == 0)
return drivers[i]->getMaxVcpus (conn, type);
if (type && STRCASENEQ (type, "Xen")) {
xenUnifiedError (conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return -1; return -1;
}
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET])
return xenHypervisorGetMaxVcpus (conn, type);
else {
xenUnifiedError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
return -1;
}
} }
static int static int
@ -359,19 +354,37 @@ xenUnifiedDomainCreateLinux (virConnectPtr conn,
return NULL; return NULL;
} }
/* Assumption made in underlying drivers:
* If the domain is "not found" and there is no other error, then
* the Lookup* functions return a NULL but do not set virterror.
*/
static virDomainPtr static virDomainPtr
xenUnifiedDomainLookupByID (virConnectPtr conn, int id) xenUnifiedDomainLookupByID (virConnectPtr conn, int id)
{ {
GET_PRIVATE(conn); GET_PRIVATE(conn);
int i;
virDomainPtr ret; virDomainPtr ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) /* Reset any connection-level errors in virterror first, in case
if (priv->opened[i] && drivers[i]->domainLookupByID) { * there is one hanging around from a previous call.
ret = drivers[i]->domainLookupByID (conn, id); */
if (ret) return ret; virConnResetLastError (conn);
/* Try proxy. */
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
ret = xenProxyLookupByID (conn, id);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
} }
/* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByID (conn, id);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Not found. */
xenUnifiedError (conn, VIR_ERR_NO_DOMAIN, __FUNCTION__);
return NULL; return NULL;
} }
@ -380,15 +393,36 @@ xenUnifiedDomainLookupByUUID (virConnectPtr conn,
const unsigned char *uuid) const unsigned char *uuid)
{ {
GET_PRIVATE(conn); GET_PRIVATE(conn);
int i;
virDomainPtr ret; virDomainPtr ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) /* Reset any connection-level errors in virterror first, in case
if (priv->opened[i] && drivers[i]->domainLookupByUUID) { * there is one hanging around from a previous call.
ret = drivers[i]->domainLookupByUUID (conn, uuid); */
if (ret) return ret; virConnResetLastError (conn);
/* Try proxy. */
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
ret = xenProxyLookupByUUID (conn, uuid);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
} }
/* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByUUID (conn, uuid);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Try XM for inactive domains. */
if (priv->opened[XEN_UNIFIED_XM_OFFSET]) {
ret = xenXMDomainLookupByUUID (conn, uuid);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Not found. */
xenUnifiedError (conn, VIR_ERR_NO_DOMAIN, __FUNCTION__);
return NULL; return NULL;
} }
@ -397,15 +431,43 @@ xenUnifiedDomainLookupByName (virConnectPtr conn,
const char *name) const char *name)
{ {
GET_PRIVATE(conn); GET_PRIVATE(conn);
int i;
virDomainPtr ret; virDomainPtr ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) /* Reset any connection-level errors in virterror first, in case
if (priv->opened[i] && drivers[i]->domainLookupByName) { * there is one hanging around from a previous call.
ret = drivers[i]->domainLookupByName (conn, name); */
if (ret) return ret; virConnResetLastError (conn);
/* Try proxy. */
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
ret = xenProxyLookupByName (conn, name);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
} }
/* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByName (conn, name);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Try xenstore for inactive domains. */
if (priv->opened[XEN_UNIFIED_XS_OFFSET]) {
ret = xenStoreLookupByName (conn, name);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Try XM for inactive domains. */
if (priv->opened[XEN_UNIFIED_XM_OFFSET]) {
ret = xenXMDomainLookupByName (conn, name);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Not found. */
xenUnifiedError (conn, VIR_ERR_NO_DOMAIN, __FUNCTION__);
return NULL; return NULL;
} }
@ -419,15 +481,15 @@ xenUnifiedDomainSuspend (virDomainPtr dom)
* as a last resort. * as a last resort.
*/ */
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != hypervisor_offset && if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] && priv->opened[i] &&
drivers[i]->domainSuspend && drivers[i]->domainSuspend &&
drivers[i]->domainSuspend (dom) == 0) drivers[i]->domainSuspend (dom) == 0)
return 0; return 0;
if (priv->opened[hypervisor_offset] && if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
drivers[hypervisor_offset]->domainSuspend && drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainSuspend &&
drivers[hypervisor_offset]->domainSuspend (dom) == 0) drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainSuspend (dom) == 0)
return 0; return 0;
return -1; return -1;
@ -443,15 +505,15 @@ xenUnifiedDomainResume (virDomainPtr dom)
* as a last resort. * as a last resort.
*/ */
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != hypervisor_offset && if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] && priv->opened[i] &&
drivers[i]->domainResume && drivers[i]->domainResume &&
drivers[i]->domainResume (dom) == 0) drivers[i]->domainResume (dom) == 0)
return 0; return 0;
if (priv->opened[hypervisor_offset] && if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
drivers[hypervisor_offset]->domainResume && drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainResume &&
drivers[hypervisor_offset]->domainResume (dom) == 0) drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainResume (dom) == 0)
return 0; return 0;
return -1; return -1;
@ -497,15 +559,15 @@ xenUnifiedDomainDestroy (virDomainPtr dom)
* as a last resort. * as a last resort.
*/ */
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != hypervisor_offset && if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] && priv->opened[i] &&
drivers[i]->domainDestroy && drivers[i]->domainDestroy &&
drivers[i]->domainDestroy (dom) == 0) drivers[i]->domainDestroy (dom) == 0)
return 0; return 0;
if (priv->opened[i] && if (priv->opened[i] &&
drivers[hypervisor_offset]->domainDestroy && drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroy &&
drivers[hypervisor_offset]->domainDestroy (dom) == 0) drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroy (dom) == 0)
return 0; return 0;
return -1; return -1;
@ -643,15 +705,15 @@ xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
* as a last resort. * as a last resort.
*/ */
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != hypervisor_offset && if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] && priv->opened[i] &&
drivers[i]->domainSetVcpus && drivers[i]->domainSetVcpus &&
drivers[i]->domainSetVcpus (dom, nvcpus) == 0) drivers[i]->domainSetVcpus (dom, nvcpus) == 0)
return 0; return 0;
if (priv->opened[hypervisor_offset] && if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
drivers[hypervisor_offset]->domainSetVcpus && drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainSetVcpus &&
drivers[hypervisor_offset]->domainSetVcpus (dom, nvcpus) == 0) drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainSetVcpus (dom, nvcpus) == 0)
return 0; return 0;
return -1; return -1;

View File

@ -19,8 +19,67 @@ extern "C" {
extern int xenUnifiedRegister (void); extern int xenUnifiedRegister (void);
#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
#define XEN_UNIFIED_NR_DRIVERS 5 #define XEN_UNIFIED_NR_DRIVERS 5
/* _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 {
virDrvOpen open;
virDrvClose close;
virDrvGetType type;
virDrvGetVersion version;
virDrvGetHostname getHostname;
virDrvGetURI getURI;
virDrvNodeGetInfo nodeGetInfo;
virDrvGetCapabilities getCapabilities;
virDrvListDomains listDomains;
virDrvNumOfDomains numOfDomains;
virDrvDomainCreateLinux domainCreateLinux;
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;
virDrvDomainDumpXML domainDumpXML;
virDrvListDefinedDomains listDefinedDomains;
virDrvNumOfDefinedDomains numOfDefinedDomains;
virDrvDomainCreate domainCreate;
virDrvDomainDefineXML domainDefineXML;
virDrvDomainUndefine domainUndefine;
virDrvDomainAttachDevice domainAttachDevice;
virDrvDomainDetachDevice domainDetachDevice;
virDrvDomainGetAutostart domainGetAutostart;
virDrvDomainSetAutostart domainSetAutostart;
virDrvDomainGetSchedulerType domainGetSchedulerType;
virDrvDomainGetSchedulerParameters domainGetSchedulerParameters;
virDrvDomainSetSchedulerParameters domainSetSchedulerParameters;
};
/* xenUnifiedPrivatePtr: /* xenUnifiedPrivatePtr:
* *
* Per-connection private data, stored in conn->privateData. All Xen * Per-connection private data, stored in conn->privateData. All Xen

View File

@ -50,9 +50,6 @@ static int xenDaemonListDomains(virConnectPtr conn, int *ids, int maxids);
static int xenDaemonNumOfDomains(virConnectPtr conn); static int xenDaemonNumOfDomains(virConnectPtr conn);
static int xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxnames); static int xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxnames);
static int xenDaemonNumOfDefinedDomains(virConnectPtr conn); static int xenDaemonNumOfDefinedDomains(virConnectPtr conn);
static virDomainPtr xenDaemonLookupByID(virConnectPtr conn, int id);
static virDomainPtr xenDaemonLookupByUUID(virConnectPtr conn,
const unsigned char *uuid);
static virDomainPtr xenDaemonCreateLinux(virConnectPtr conn, static virDomainPtr xenDaemonCreateLinux(virConnectPtr conn,
const char *xmlDesc, const char *xmlDesc,
unsigned int flags); unsigned int flags);
@ -64,27 +61,18 @@ static int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
#endif /* PROXY */ #endif /* PROXY */
#ifndef PROXY #ifndef PROXY
virDriver xenDaemonDriver = { struct xenUnifiedDriver xenDaemonDriver = {
-1,
"XenDaemon",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
(DOM0_INTERFACE_VERSION & 0xFFFF),
xenDaemonOpen, /* open */ xenDaemonOpen, /* open */
xenDaemonClose, /* close */ xenDaemonClose, /* close */
xenDaemonGetType, /* type */ xenDaemonGetType, /* type */
xenDaemonGetVersion, /* version */ xenDaemonGetVersion, /* version */
NULL, /* hostname */ NULL, /* hostname */
NULL, /* URI */ NULL, /* URI */
NULL, /* getMaxVcpus */
xenDaemonNodeGetInfo, /* nodeGetInfo */ xenDaemonNodeGetInfo, /* nodeGetInfo */
NULL, /* getCapabilities */ NULL, /* getCapabilities */
xenDaemonListDomains, /* listDomains */ xenDaemonListDomains, /* listDomains */
xenDaemonNumOfDomains, /* numOfDomains */ xenDaemonNumOfDomains, /* numOfDomains */
xenDaemonCreateLinux, /* domainCreateLinux */ xenDaemonCreateLinux, /* domainCreateLinux */
xenDaemonLookupByID, /* domainLookupByID */
xenDaemonLookupByUUID, /* domainLookupByUUID */
xenDaemonDomainLookupByName, /* domainLookupByName */
xenDaemonDomainSuspend, /* domainSuspend */ xenDaemonDomainSuspend, /* domainSuspend */
xenDaemonDomainResume, /* domainResume */ xenDaemonDomainResume, /* domainResume */
xenDaemonDomainShutdown, /* domainShutdown */ xenDaemonDomainShutdown, /* domainShutdown */
@ -2511,7 +2499,7 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
#ifndef PROXY #ifndef PROXY
/** /**
* xenDaemonDomainLookupByName: * xenDaemonLookupByName:
* @conn: A xend instance * @conn: A xend instance
* @name: The name of the domain * @name: The name of the domain
* *
@ -2522,7 +2510,7 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
* Returns domain info on success; NULL (with errno) on error * Returns domain info on success; NULL (with errno) on error
*/ */
virDomainPtr virDomainPtr
xenDaemonDomainLookupByName(virConnectPtr conn, const char *domname) xenDaemonLookupByName(virConnectPtr conn, const char *domname)
{ {
struct sexpr *root; struct sexpr *root;
virDomainPtr ret = NULL; virDomainPtr ret = NULL;
@ -2727,7 +2715,7 @@ error:
* *
* Returns a new domain object or NULL in case of failure * Returns a new domain object or NULL in case of failure
*/ */
static virDomainPtr virDomainPtr
xenDaemonLookupByID(virConnectPtr conn, int id) { xenDaemonLookupByID(virConnectPtr conn, int id) {
char *name = NULL; char *name = NULL;
unsigned char uuid[VIR_UUID_BUFLEN]; unsigned char uuid[VIR_UUID_BUFLEN];
@ -2926,7 +2914,7 @@ xenDaemonDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
* *
* Returns a new domain object or NULL in case of failure * Returns a new domain object or NULL in case of failure
*/ */
static virDomainPtr virDomainPtr
xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid) xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{ {
virDomainPtr ret; virDomainPtr ret;

View File

@ -177,9 +177,6 @@ char *xenDaemonDomainDumpXMLByName(virConnectPtr xend,
char *xend_parse_domain_sexp(virConnectPtr conn, char *root, int xendConfigVersion); char *xend_parse_domain_sexp(virConnectPtr conn, char *root, int xendConfigVersion);
extern virDriver xenDaemonDriver;
int xenDaemonInit (void);
/* refactored ones */ /* refactored ones */
int xenDaemonOpen(virConnectPtr conn, const char *name, int flags); int xenDaemonOpen(virConnectPtr conn, const char *name, int flags);
int xenDaemonClose(virConnectPtr conn); int xenDaemonClose(virConnectPtr conn);
@ -196,7 +193,6 @@ int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory); int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info); int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
char *xenDaemonDomainDumpXML(virDomainPtr domain, int flags); char *xenDaemonDomainDumpXML(virDomainPtr domain, int flags);
virDomainPtr xenDaemonDomainLookupByName(virConnectPtr conn, const char *domname);
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain); unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
char **xenDaemonListDomainsOld(virConnectPtr xend); char **xenDaemonListDomainsOld(virConnectPtr xend);
@ -216,6 +212,14 @@ int xenDaemonDomainGetVcpus (virDomainPtr domain,
unsigned char *cpumaps, unsigned char *cpumaps,
int maplen); int maplen);
/* xen_unified calls through here. */
extern struct xenUnifiedDriver xenDaemonDriver;
int xenDaemonInit (void);
virDomainPtr xenDaemonLookupByID(virConnectPtr conn, int id);
virDomainPtr xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid);
virDomainPtr xenDaemonLookupByName(virConnectPtr conn, const char *domname);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -74,27 +74,18 @@ static time_t lastRefresh = 0;
#define XEND_PCI_CONFIG_PREFIX "xend-pci-" #define XEND_PCI_CONFIG_PREFIX "xend-pci-"
#define QEMU_IF_SCRIPT "qemu-ifup" #define QEMU_IF_SCRIPT "qemu-ifup"
virDriver xenXMDriver = { struct xenUnifiedDriver xenXMDriver = {
-1,
"XenXM",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
(DOM0_INTERFACE_VERSION & 0xFFFF),
xenXMOpen, /* open */ xenXMOpen, /* open */
xenXMClose, /* close */ xenXMClose, /* close */
xenXMGetType, /* type */ xenXMGetType, /* type */
NULL, /* version */ NULL, /* version */
NULL, /* hostname */ NULL, /* hostname */
NULL, /* URI */ NULL, /* URI */
NULL, /* getMaxVcpus */
NULL, /* nodeGetInfo */ NULL, /* nodeGetInfo */
NULL, /* getCapabilities */ NULL, /* getCapabilities */
NULL, /* listDomains */ NULL, /* listDomains */
NULL, /* numOfDomains */ NULL, /* numOfDomains */
NULL, /* domainCreateLinux */ NULL, /* domainCreateLinux */
NULL, /* domainLookupByID */
xenXMDomainLookupByUUID, /* domainLookupByUUID */
xenXMDomainLookupByName, /* domainLookupByName */
NULL, /* domainSuspend */ NULL, /* domainSuspend */
NULL, /* domainResume */ NULL, /* domainResume */
NULL, /* domainShutdown */ NULL, /* domainShutdown */
@ -2286,7 +2277,7 @@ static void xenXMListIterator(const void *payload ATTRIBUTE_UNUSED, const char *
if (ctx->count == ctx->max) if (ctx->count == ctx->max)
return; return;
dom = xenDaemonDomainLookupByName(ctx->conn, name); dom = xenDaemonLookupByName(ctx->conn, name);
if (!dom) { if (!dom) {
ctx->names[ctx->count] = strdup(name); ctx->names[ctx->count] = strdup(name);
ctx->count++; ctx->count++;

View File

@ -33,7 +33,7 @@
extern "C" { extern "C" {
#endif #endif
extern virDriver xenXMDriver; extern struct xenUnifiedDriver xenXMDriver;
int xenXMInit (void); int xenXMInit (void);
int xenXMOpen(virConnectPtr conn, const char *name, int flags); int xenXMOpen(virConnectPtr conn, const char *name, int flags);

View File

@ -36,27 +36,18 @@
#ifndef PROXY #ifndef PROXY
static char *xenStoreDomainGetOSType(virDomainPtr domain); static char *xenStoreDomainGetOSType(virDomainPtr domain);
virDriver xenStoreDriver = { struct xenUnifiedDriver xenStoreDriver = {
-1,
"XenStore",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
(DOM0_INTERFACE_VERSION & 0xFFFF),
xenStoreOpen, /* open */ xenStoreOpen, /* open */
xenStoreClose, /* close */ xenStoreClose, /* close */
NULL, /* type */ NULL, /* type */
NULL, /* version */ NULL, /* version */
NULL, /* hostname */ NULL, /* hostname */
NULL, /* URI */ NULL, /* URI */
NULL, /* getMaxVcpus */
NULL, /* nodeGetInfo */ NULL, /* nodeGetInfo */
NULL, /* getCapabilities */ NULL, /* getCapabilities */
xenStoreListDomains, /* listDomains */ xenStoreListDomains, /* listDomains */
NULL, /* numOfDomains */ NULL, /* numOfDomains */
NULL, /* domainCreateLinux */ NULL, /* domainCreateLinux */
NULL, /* domainLookupByID */
NULL, /* domainLookupByUUID */
xenStoreDomainLookupByName, /* domainLookupByName */
NULL, /* domainSuspend */ NULL, /* domainSuspend */
NULL, /* domainResume */ NULL, /* domainResume */
xenStoreDomainShutdown, /* domainShutdown */ xenStoreDomainShutdown, /* domainShutdown */
@ -591,7 +582,7 @@ xenStoreListDomains(virConnectPtr conn, int *ids, int maxids)
} }
/** /**
* xenStoreDomainLookupByName: * xenStoreLookupByName:
* @conn: A xend instance * @conn: A xend instance
* @name: The name of the domain * @name: The name of the domain
* *
@ -600,7 +591,7 @@ xenStoreListDomains(virConnectPtr conn, int *ids, int maxids)
* Returns a new domain object or NULL in case of failure * Returns a new domain object or NULL in case of failure
*/ */
virDomainPtr virDomainPtr
xenStoreDomainLookupByName(virConnectPtr conn, const char *name) xenStoreLookupByName(virConnectPtr conn, const char *name)
{ {
virDomainPtr ret = NULL; virDomainPtr ret = NULL;
unsigned int num, i, len; unsigned int num, i, len;
@ -637,7 +628,7 @@ xenStoreDomainLookupByName(virConnectPtr conn, const char *name)
prop[199] = 0; prop[199] = 0;
tmp = xs_read(priv->xshandle, 0, prop, &len); tmp = xs_read(priv->xshandle, 0, prop, &len);
if (tmp != NULL) { if (tmp != NULL) {
found = !strcmp(name, tmp); found = STREQ (name, tmp);
free(tmp); free(tmp);
if (found) if (found)
break; break;

View File

@ -15,7 +15,7 @@
extern "C" { extern "C" {
#endif #endif
extern virDriver xenStoreDriver; extern struct xenUnifiedDriver xenStoreDriver;
int xenStoreInit (void); int xenStoreInit (void);
int xenStoreOpen (virConnectPtr conn, int xenStoreOpen (virConnectPtr conn,
@ -28,7 +28,7 @@ int xenStoreNumOfDomains (virConnectPtr conn);
int xenStoreListDomains (virConnectPtr conn, int xenStoreListDomains (virConnectPtr conn,
int *ids, int *ids,
int maxids); int maxids);
virDomainPtr xenStoreDomainLookupByName(virConnectPtr conn, virDomainPtr xenStoreLookupByName(virConnectPtr conn,
const char *name); const char *name);
unsigned long xenStoreGetMaxMemory (virDomainPtr domain); unsigned long xenStoreGetMaxMemory (virDomainPtr domain);
int xenStoreDomainSetMemory (virDomainPtr domain, int xenStoreDomainSetMemory (virDomainPtr domain,