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

View File

@ -86,8 +86,15 @@ struct _virProxyFullPacket {
typedef struct _virProxyFullPacket virProxyFullPacket;
typedef virProxyFullPacket *virProxyFullPacketPtr;
extern virDriver xenProxyDriver;
int xenProxyInit (void);
/* xen_unified makes direct calls or indirect calls through here. */
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
}

View File

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

View File

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

View File

@ -17,12 +17,6 @@
* xend_internal, xs_internal and xm_internal). Historically
* the body of libvirt.c handled the five Xen drivers,
* 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>
@ -44,15 +38,13 @@
#include "xm_internal.h"
/* The five Xen drivers below us. */
static virDriverPtr drivers[XEN_UNIFIED_NR_DRIVERS] = {
&xenHypervisorDriver,
&xenProxyDriver,
&xenDaemonDriver,
&xenStoreDriver,
&xenXMDriver
static struct xenUnifiedDriver *drivers[XEN_UNIFIED_NR_DRIVERS] = {
[XEN_UNIFIED_HYPERVISOR_OFFSET] = &xenHypervisorDriver,
[XEN_UNIFIED_PROXY_OFFSET] = &xenProxyDriver,
[XEN_UNIFIED_XEND_OFFSET] = &xenDaemonDriver,
[XEN_UNIFIED_XS_OFFSET] = &xenStoreDriver,
[XEN_UNIFIED_XM_OFFSET] = &xenXMDriver,
};
static const int hypervisor_offset = 0;
static const int proxy_offset = 1;
/**
* xenUnifiedError:
@ -153,7 +145,7 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
continue;
/* Ignore proxy for root */
if (i == proxy_offset && getuid() == 0)
if (i == XEN_UNIFIED_PROXY_OFFSET && getuid() == 0)
continue;
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 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)
if (priv->opened[j]) drivers[j]->close (conn);
free (priv->name);
@ -269,16 +262,18 @@ static int
xenUnifiedGetMaxVcpus (virConnectPtr conn, const char *type)
{
GET_PRIVATE(conn);
int i;
if (!type)
type = "Xen";
if (type && STRCASENEQ (type, "Xen")) {
xenUnifiedError (conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
return -1;
}
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);
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
@ -359,19 +354,37 @@ xenUnifiedDomainCreateLinux (virConnectPtr conn,
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
xenUnifiedDomainLookupByID (virConnectPtr conn, int id)
{
GET_PRIVATE(conn);
int i;
virDomainPtr ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (priv->opened[i] && drivers[i]->domainLookupByID) {
ret = drivers[i]->domainLookupByID (conn, id);
if (ret) return ret;
}
/* Reset any connection-level errors in virterror first, in case
* there is one hanging around from a previous call.
*/
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;
}
@ -380,15 +393,36 @@ xenUnifiedDomainLookupByUUID (virConnectPtr conn,
const unsigned char *uuid)
{
GET_PRIVATE(conn);
int i;
virDomainPtr ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (priv->opened[i] && drivers[i]->domainLookupByUUID) {
ret = drivers[i]->domainLookupByUUID (conn, uuid);
if (ret) return ret;
}
/* Reset any connection-level errors in virterror first, in case
* there is one hanging around from a previous call.
*/
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;
}
@ -397,15 +431,43 @@ xenUnifiedDomainLookupByName (virConnectPtr conn,
const char *name)
{
GET_PRIVATE(conn);
int i;
virDomainPtr ret;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (priv->opened[i] && drivers[i]->domainLookupByName) {
ret = drivers[i]->domainLookupByName (conn, name);
if (ret) return ret;
}
/* Reset any connection-level errors in virterror first, in case
* there is one hanging around from a previous call.
*/
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;
}
@ -419,15 +481,15 @@ xenUnifiedDomainSuspend (virDomainPtr dom)
* as a last resort.
*/
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != hypervisor_offset &&
if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] &&
drivers[i]->domainSuspend &&
drivers[i]->domainSuspend (dom) == 0)
return 0;
if (priv->opened[hypervisor_offset] &&
drivers[hypervisor_offset]->domainSuspend &&
drivers[hypervisor_offset]->domainSuspend (dom) == 0)
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainSuspend &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainSuspend (dom) == 0)
return 0;
return -1;
@ -443,15 +505,15 @@ xenUnifiedDomainResume (virDomainPtr dom)
* as a last resort.
*/
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != hypervisor_offset &&
if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] &&
drivers[i]->domainResume &&
drivers[i]->domainResume (dom) == 0)
return 0;
if (priv->opened[hypervisor_offset] &&
drivers[hypervisor_offset]->domainResume &&
drivers[hypervisor_offset]->domainResume (dom) == 0)
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainResume &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainResume (dom) == 0)
return 0;
return -1;
@ -497,15 +559,15 @@ xenUnifiedDomainDestroy (virDomainPtr dom)
* as a last resort.
*/
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != hypervisor_offset &&
if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] &&
drivers[i]->domainDestroy &&
drivers[i]->domainDestroy (dom) == 0)
return 0;
if (priv->opened[i] &&
drivers[hypervisor_offset]->domainDestroy &&
drivers[hypervisor_offset]->domainDestroy (dom) == 0)
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroy &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroy (dom) == 0)
return 0;
return -1;
@ -643,15 +705,15 @@ xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
* as a last resort.
*/
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
if (i != hypervisor_offset &&
if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
priv->opened[i] &&
drivers[i]->domainSetVcpus &&
drivers[i]->domainSetVcpus (dom, nvcpus) == 0)
return 0;
if (priv->opened[hypervisor_offset] &&
drivers[hypervisor_offset]->domainSetVcpus &&
drivers[hypervisor_offset]->domainSetVcpus (dom, nvcpus) == 0)
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainSetVcpus &&
drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainSetVcpus (dom, nvcpus) == 0)
return 0;
return -1;

View File

@ -19,8 +19,67 @@ extern "C" {
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
/* _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:
*
* 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 xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxnames);
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,
const char *xmlDesc,
unsigned int flags);
@ -64,27 +61,18 @@ static int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
#endif /* PROXY */
#ifndef PROXY
virDriver xenDaemonDriver = {
-1,
"XenDaemon",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
(DOM0_INTERFACE_VERSION & 0xFFFF),
struct xenUnifiedDriver xenDaemonDriver = {
xenDaemonOpen, /* open */
xenDaemonClose, /* close */
xenDaemonGetType, /* type */
xenDaemonGetVersion, /* version */
NULL, /* hostname */
NULL, /* URI */
NULL, /* getMaxVcpus */
xenDaemonNodeGetInfo, /* nodeGetInfo */
NULL, /* getCapabilities */
xenDaemonListDomains, /* listDomains */
xenDaemonNumOfDomains, /* numOfDomains */
xenDaemonCreateLinux, /* domainCreateLinux */
xenDaemonLookupByID, /* domainLookupByID */
xenDaemonLookupByUUID, /* domainLookupByUUID */
xenDaemonDomainLookupByName, /* domainLookupByName */
xenDaemonDomainSuspend, /* domainSuspend */
xenDaemonDomainResume, /* domainResume */
xenDaemonDomainShutdown, /* domainShutdown */
@ -2511,7 +2499,7 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
#ifndef PROXY
/**
* xenDaemonDomainLookupByName:
* xenDaemonLookupByName:
* @conn: A xend instance
* @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
*/
virDomainPtr
xenDaemonDomainLookupByName(virConnectPtr conn, const char *domname)
xenDaemonLookupByName(virConnectPtr conn, const char *domname)
{
struct sexpr *root;
virDomainPtr ret = NULL;
@ -2727,7 +2715,7 @@ error:
*
* Returns a new domain object or NULL in case of failure
*/
static virDomainPtr
virDomainPtr
xenDaemonLookupByID(virConnectPtr conn, int id) {
char *name = NULL;
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
*/
static virDomainPtr
virDomainPtr
xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
virDomainPtr ret;

View File

@ -177,9 +177,6 @@ char *xenDaemonDomainDumpXMLByName(virConnectPtr xend,
char *xend_parse_domain_sexp(virConnectPtr conn, char *root, int xendConfigVersion);
extern virDriver xenDaemonDriver;
int xenDaemonInit (void);
/* refactored ones */
int xenDaemonOpen(virConnectPtr conn, const char *name, int flags);
int xenDaemonClose(virConnectPtr conn);
@ -196,7 +193,6 @@ int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
int xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
int xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
char *xenDaemonDomainDumpXML(virDomainPtr domain, int flags);
virDomainPtr xenDaemonDomainLookupByName(virConnectPtr conn, const char *domname);
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
char **xenDaemonListDomainsOld(virConnectPtr xend);
@ -216,6 +212,14 @@ int xenDaemonDomainGetVcpus (virDomainPtr domain,
unsigned char *cpumaps,
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
}
#endif

View File

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

View File

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

View File

@ -36,27 +36,18 @@
#ifndef PROXY
static char *xenStoreDomainGetOSType(virDomainPtr domain);
virDriver xenStoreDriver = {
-1,
"XenStore",
(DOM0_INTERFACE_VERSION >> 24) * 1000000 +
((DOM0_INTERFACE_VERSION >> 16) & 0xFF) * 1000 +
(DOM0_INTERFACE_VERSION & 0xFFFF),
struct xenUnifiedDriver xenStoreDriver = {
xenStoreOpen, /* open */
xenStoreClose, /* close */
NULL, /* type */
NULL, /* version */
NULL, /* hostname */
NULL, /* URI */
NULL, /* getMaxVcpus */
NULL, /* nodeGetInfo */
NULL, /* getCapabilities */
xenStoreListDomains, /* listDomains */
NULL, /* numOfDomains */
NULL, /* domainCreateLinux */
NULL, /* domainLookupByID */
NULL, /* domainLookupByUUID */
xenStoreDomainLookupByName, /* domainLookupByName */
NULL, /* domainSuspend */
NULL, /* domainResume */
xenStoreDomainShutdown, /* domainShutdown */
@ -591,7 +582,7 @@ xenStoreListDomains(virConnectPtr conn, int *ids, int maxids)
}
/**
* xenStoreDomainLookupByName:
* xenStoreLookupByName:
* @conn: A xend instance
* @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
*/
virDomainPtr
xenStoreDomainLookupByName(virConnectPtr conn, const char *name)
xenStoreLookupByName(virConnectPtr conn, const char *name)
{
virDomainPtr ret = NULL;
unsigned int num, i, len;
@ -625,23 +616,23 @@ xenStoreDomainLookupByName(virConnectPtr conn, const char *name)
goto done;
for (i = 0; i < num; i++) {
id = strtol(idlist[i], &endptr, 10);
if ((endptr == idlist[i]) || (*endptr != 0)) {
goto done;
}
id = strtol(idlist[i], &endptr, 10);
if ((endptr == idlist[i]) || (*endptr != 0)) {
goto done;
}
#if 0
if (virConnectCheckStoreID(conn, (int) id) < 0)
continue;
if (virConnectCheckStoreID(conn, (int) id) < 0)
continue;
#endif
snprintf(prop, 199, "/local/domain/%s/name", idlist[i]);
prop[199] = 0;
tmp = xs_read(priv->xshandle, 0, prop, &len);
if (tmp != NULL) {
found = !strcmp(name, tmp);
free(tmp);
if (found)
break;
}
snprintf(prop, 199, "/local/domain/%s/name", idlist[i]);
prop[199] = 0;
tmp = xs_read(priv->xshandle, 0, prop, &len);
if (tmp != NULL) {
found = STREQ (name, tmp);
free(tmp);
if (found)
break;
}
}
path = xs_get_domain_path(priv->xshandle, (unsigned int) id);

View File

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