]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fri Jul 6 16:08:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 6 Jul 2007 15:11:22 +0000 (15:11 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 6 Jul 2007 15:11:22 +0000 (15:11 +0000)
* 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.

13 files changed:
ChangeLog
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

index b6a8d1924b99fddff12cb2646005a4d4d41da50f..48e966e1e7d9efc78e943bbf51b2d90b37bdc977 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 3d9403d229c2d889af81c85350339591eea092a2..9b2aebc3a8b198259a9b5d5864ae1c86383b261a 100644 (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;
index f857bd55205f537d079b59f54cb72aaf14f9be23..322d39cdf481c55abbe91c75d3389e673a026104 100644 (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
 }
index c410a0cc99586519f62c31b7da6f171f2c82c263..12d948bb8e51a1b2dd463465dec6625cd2d12c0e 100644 (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 */
index b77fd2752950b1af35db74c5d62a9fae1ab6fe6b..65a7ace8ec64006526d08eb54609803ab39617b1 100644 (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: */
index 1f3628dcad1b680603dccd6bb727d7620d9290fc..1a913ece31452e92805cd3945fb1d956a2e8206c 100644 (file)
  * 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>
 #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";
 
-    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
@@ -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;
index f17ec5cbd3c015649c177864aab30658a844800d..0d991bff345f54794be26a8204517f83c01961fe 100644 (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
index 03b489c54c9e231032e2311a92c5208f05e1fd61..fec45a24540915e8dbf0ef600c45f806cb436d88 100644 (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;
index 7718e695cabbd8d600400cfc50f2b3c3efb0c2e8..3facac1bb64c1ad7d2e88e1c362ab6f496f80c69 100644 (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
index b70d9e20a3bec86bf96c9058406cd0c1cc75474c..0a547b9967bbceeca75f44b8ca12ea7a6f386197 100644 (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++;
index 57fc936dcb5748969c5dfb8c4fc951ae1e174c21..4adef07a33e5348d2bc1e4ca37da36c0979f4e4a 100644 (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);
index cce182b826e113cc16c875d8cfb3d76a3f44d708..4569e54688a3c6a65807851edfcd90b1d1de724d 100644 (file)
 #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);
 
index 79e550b307e45f8288615ae433bbb351f4a616d0..a5001e5612cbd334803fddc30c30ce607358f007 100644 (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,