]> xenbits.xensource.com Git - libvirt.git/commitdiff
* src/libvirt.c src/xen_internal.c src/xend_internal.c
authorDaniel Veillard <veillard@redhat.com>
Tue, 13 Jun 2006 18:29:42 +0000 (18:29 +0000)
committerDaniel Veillard <veillard@redhat.com>
Tue, 13 Jun 2006 18:29:42 +0000 (18:29 +0000)
  src/xs_internal.c: fix the connection and GetType initialization.
Daniel

ChangeLog
src/libvirt.c
src/xen_internal.c
src/xend_internal.c
src/xs_internal.c

index 73365f95e2b4ac4cbe2188b914274c307c01c7cd..b3a3217c03f3908593ba21fdee421c853b1581d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jun 13 18:35:22 EDT 2006 Daniel Veillard <veillard@redhat.com>
+
+       * src/libvirt.c src/xen_internal.c src/xend_internal.c
+         src/xs_internal.c: fix the connection and GetType initialization.
+
 Tue Jun 13 16:37:27 EDT 2006 Daniel Veillard <veillard@redhat.com>
 
        * docs//*: rebuilt the documentation
index dd0cd4a50a95cf5c3bb1a67afe557ceb93a26a63..80a61d967c90e27b2500cbc8a8e7e066cbad83b6 100644 (file)
@@ -217,12 +217,19 @@ virGetVersion(unsigned long *libVer, const char *type,
 virConnectPtr
 virConnectOpen(const char *name)
 {
-    int i, res;
+    int i, res, for_xen = 0;
     virConnectPtr ret = NULL;
 
     if (!initialized)
         virInitialize();
 
+    if (name == NULL) {
+        name = "Xen";
+       for_xen = 1;
+    } else if (strncasecmp(name, "xen", 3)) {
+       for_xen = 1;
+    }
+
     ret = virGetConnect();
     if (ret == NULL) {
         virLibConnError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection");
@@ -236,8 +243,8 @@ virConnectOpen(const char *name)
             * For a default connect to Xen make sure we manage to contact
             * all related drivers.
             */
-           if ((res < 0) && (name == NULL) &&
-               (!strncmp(virDriverTab[i]->name, "Xen", 3)))
+           if ((res < 0) && (for_xen) &&
+               (!strncasecmp(virDriverTab[i]->name, "xen", 3)))
                goto failed;
            if (res == 0)
                ret->drivers[ret->nb_drivers++] = virDriverTab[i];
@@ -282,6 +289,9 @@ virConnectOpenReadOnly(const char *name)
     if (!initialized)
         virInitialize();
 
+    if (name == NULL)
+        name = "Xen";
+
     ret = virGetConnect();
     if (ret == NULL) {
         virLibConnError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection");
@@ -354,11 +364,20 @@ const char *
 virConnectGetType(virConnectPtr conn)
 {
     int i;
+    const char *ret;
 
     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
         return (NULL);
     }
+    for (i = 0;i < conn->nb_drivers;i++) {
+       if ((conn->drivers[i] != NULL) &&
+           (conn->drivers[i]->type != NULL)) {
+           ret = conn->drivers[i]->type(conn);
+           if (ret != NULL)
+               return(ret);
+       }
+    }
     for (i = 0;i < conn->nb_drivers;i++) {
        if ((conn->drivers[i] != NULL) &&
            (conn->drivers[i]->name != NULL)) {
index 11473fd6ee2e022e246ebca437ce6f4b4cbf1b91..6ab54779dc158c1dab692297f8cc8ee624bd6a33 100644 (file)
@@ -40,6 +40,8 @@ typedef struct hypercall_struct {
 
 #define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
 
+static const char * xenHypervisorGetType(virConnectPtr conn);
+
 static virDriver xenHypervisorDriver = {
     "Xen",
     (DOM0_INTERFACE_VERSION >> 24) * 1000000 +
@@ -48,7 +50,7 @@ static virDriver xenHypervisorDriver = {
     NULL, /* init */
     xenHypervisorOpen, /* open */
     xenHypervisorClose, /* close */
-    NULL, /* type */
+    xenHypervisorGetType, /* type */
     xenHypervisorGetVersion, /* version */
     NULL, /* nodeGetInfo */
     xenHypervisorListDomains, /* listDomains */
@@ -121,7 +123,7 @@ xenHypervisorOpen(virConnectPtr conn, const char *name, int flags)
 {
     int ret;
 
-    if ((name != NULL) && (strcmp(name, "xen")))
+    if ((name != NULL) && (strcasecmp(name, "xen")))
         return(-1);
 
     conn->handle = -1;
@@ -201,6 +203,26 @@ xenHypervisorDoOp(int handle, dom0_op_t * op)
     return (0);
 }
 
+/**
+ * xenHypervisorGetType:
+ * @conn: pointer to the Xen Hypervisor block
+ *
+ * Get the version level of the Hypervisor running.
+ *
+ * Returns -1 in case of error, 0 otherwise. if the version can't be
+ *    extracted by lack of capacities returns 0 and @hvVer is 0, otherwise
+ *    @hvVer value is major * 1,000,000 + minor * 1,000 + release
+ */
+static const char *
+xenHypervisorGetType(virConnectPtr conn)
+{
+    if (!VIR_IS_CONNECT(conn)) {
+        virXenError(VIR_ERR_INVALID_CONN, __FUNCTION__, 0);
+        return (NULL);
+    }
+    return("Xen");
+}
+
 /**
  * xenHypervisorGetVersion:
  * @conn: pointer to the connection block
index cb1ae7fde33fa7dd4270e9ef2887ce8c7f12f0ec..a682705e406286c5c059bba75791ffdedbb37713 100644 (file)
@@ -36,6 +36,7 @@
 #include "xend_internal.h"
 #include "xen_internal.h" /* for DOM0_INTERFACE_VERSION */
 
+static const char * xenDaemonGetType(virConnectPtr conn);
 static int xenDaemonNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
 static int xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer);
 
@@ -47,7 +48,7 @@ static virDriver xenDaemonDriver = {
     NULL, /* init */
     xenDaemonOpen, /* open */
     xenDaemonClose, /* close */
-    NULL, /* type */
+    xenDaemonGetType, /* type */
     xenDaemonGetVersion, /* version */
     xenDaemonNodeGetInfo, /* nodeGetInfo */
     NULL, /* listDomains */
@@ -2076,6 +2077,26 @@ xenDaemonNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) {
     return (ret);
 }
 
+/**
+ * xenDaemonGetType:
+ * @conn: pointer to the Xen Daemon block
+ *
+ * Get the version level of the Hypervisor running.
+ *
+ * Returns -1 in case of error, 0 otherwise. if the version can't be
+ *    extracted by lack of capacities returns 0 and @hvVer is 0, otherwise
+ *    @hvVer value is major * 1,000,000 + minor * 1,000 + release
+ */
+static const char *
+xenDaemonGetType(virConnectPtr conn)
+{
+    if (!VIR_IS_CONNECT(conn)) {
+        virXendError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
+        return (NULL);
+    }
+    return("XenDaemon");
+}
+
 /**
  * xenDaemonGetVersion:
  * @conn: pointer to the Xen Daemon block
index 69989e25605a275ab8ad7801136a8d3308d17b54..2c61f4af9fac16ce3fd4f8d0a2559dc0f90620b5 100644 (file)
@@ -288,7 +288,7 @@ virConnectCheckStoreID(virConnectPtr conn, int id)
 int
 xenStoreOpen(virConnectPtr conn, const char *name, int flags)
 {
-    if ((name != NULL) && (strcmp(name, "xen")))
+    if ((name != NULL) && (strcasecmp(name, "xen")))
         return(-1);
 
     if (flags & VIR_DRV_OPEN_RO)