]> xenbits.xensource.com Git - libvirt.git/commitdiff
* src/hash.c, src/internal.h: Switch the uuid parameter in virGetDomain
authorDaniel Veillard <veillard@redhat.com>
Mon, 29 May 2006 18:03:27 +0000 (18:03 +0000)
committerDaniel Veillard <veillard@redhat.com>
Mon, 29 May 2006 18:03:27 +0000 (18:03 +0000)
  to be of type 'unsigned char' since its a raw UUID we're passing in,
  not a printable one.
* src/libvirt.c: Remove bogus "unsigned char" -> "char" type casts. Hook
  up the "domainLookupByID", "domainLookupByUUID", "domainLookupByName"
  and "domainGetInfo" driver backend functions.
Daniel

ChangeLog
src/hash.c
src/internal.h
src/libvirt.c

index dc12123977928198231b5fa4c550889b45a9ae51..4e874cde9b63e18e6c4acd6e503f1f93ec8a7012 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Fri May 26 11:59:20 EDT 2006 Daniel P. Berrange <berrange@redhat.com>
+
+       * src/hash.c, src/internal.h: Switch the uuid parameter in virGetDomain
+         to be of type 'unsigned char' since its a raw UUID we're passing in,
+         not a printable one.
+       * src/libvirt.c: Remove bogus "unsigned char" -> "char" type casts. Hook
+         up the "domainLookupByID", "domainLookupByUUID", "domainLookupByName"
+         and "domainGetInfo" driver backend functions.
+
 Mon May 29 17:02:26 CEST 2006 Karel Zak <kzak@redhat.com> 
 
        * src/libvirt_sym.version: added in missing symbols referenced by python
index 897c5856024af9f848872715ab193697afc6ebf2..4ffb7454db8d7435458a1186a3ba51f787485686 100644 (file)
@@ -602,7 +602,7 @@ virFreeConnect(virConnectPtr conn) {
  * Returns a pointer to the domain, or NULL in case of failure
  */
 virDomainPtr
-virGetDomain(virConnectPtr conn, const char *name, const char *uuid) {
+virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
     virDomainPtr ret = NULL;
 
     if ((!VIR_IS_CONNECT(conn)) || ((name == NULL) && (uuid == NULL)) ||
index 9ac0d99a3e42c905528d7a9c64209c0b1f2a658b..669831c792ffb428bf1b30c06e3b213d447a9ff5 100644 (file)
@@ -182,7 +182,7 @@ virConnectPtr       virGetConnect   (void);
 int            virFreeConnect  (virConnectPtr conn);
 virDomainPtr   virGetDomain    (virConnectPtr conn,
                                 const char *name,
-                                const char *uuid);
+                                const unsigned char *uuid);
 int            virFreeDomain   (virConnectPtr conn,
                                 virDomainPtr domain);
 virDomainPtr   virGetDomainByID(virConnectPtr conn,
index a77f1a14164273beca41899378fd40706283857c..aba1ba7095e56b918637f436a230fbadde3decb9 100644 (file)
@@ -30,7 +30,6 @@
 #include "xs_internal.h"
 #include "xml.h"
 
-
 /*
  * TODO:
  * - use lock to protect against concurrent accesses ?
@@ -293,6 +292,7 @@ virConnectOpenReadOnly(const char *name)
                                        VIR_DRV_OPEN_QUIET | VIR_DRV_OPEN_RO);
            if (res == 0)
                ret->drivers[ret->nb_drivers++] = virDriverTab[i];
+
        }
     }
     if (ret->nb_drivers == 0) {
@@ -600,6 +600,7 @@ virDomainLookupByID(virConnectPtr conn, int id)
     virDomainPtr ret;
     char *name = NULL;
     unsigned char uuid[16];
+    int i;
 
     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
@@ -610,6 +611,16 @@ virDomainLookupByID(virConnectPtr conn, int id)
         return (NULL);
     }
 
+    /* Go though the driver registered entry points */
+    for (i = 0;i < conn->nb_drivers;i++) {
+       if ((conn->drivers[i] != NULL) &&
+           (conn->drivers[i]->domainLookupByID != NULL)) {
+           ret = conn->drivers[i]->domainLookupByID(conn, id);
+           if (ret)
+               return(ret);
+       }
+    }
+
     /* retrieve home path of the domain */
     if (conn->xshandle != NULL) {
         path = xs_get_domain_path(conn->xshandle, (unsigned int) id);
@@ -633,7 +644,7 @@ virDomainLookupByID(virConnectPtr conn, int id)
     if (name == NULL)
         goto error;
 
-    ret = virGetDomain(conn, name, (const char *)&uuid[0]);
+    ret = virGetDomain(conn, name, uuid);
     if (ret == NULL) {
         virLibConnError(conn, VIR_ERR_NO_MEMORY, "Allocating domain");
         goto error;
@@ -670,6 +681,7 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     char **tmp;
     unsigned char ident[16];
     int id = -1;
+    int i;
 
     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
@@ -679,6 +691,17 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
         virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
         return (NULL);
     }
+
+    /* Go though the driver registered entry points */
+    for (i = 0;i < conn->nb_drivers;i++) {
+       if ((conn->drivers[i] != NULL) &&
+           (conn->drivers[i]->domainLookupByUUID != NULL)) {
+           ret = conn->drivers[i]->domainLookupByUUID(conn, uuid);
+           if (ret)
+               return(ret);
+       }
+    }
+
     names = xenDaemonListDomains(conn);
     tmp = names;
 
@@ -701,7 +724,7 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
     if (name == NULL)
         return (NULL);
 
-    ret = virGetDomain(conn, name, (const char *)&uuid[0]);
+    ret = virGetDomain(conn, name, uuid);
     if (ret == NULL) {
         if (name != NULL)
             free(name);
@@ -774,6 +797,7 @@ virDomainPtr
 virDomainLookupByName(virConnectPtr conn, const char *name)
 {
     virDomainPtr ret = NULL;
+    int i;
 
     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
@@ -784,6 +808,16 @@ virDomainLookupByName(virConnectPtr conn, const char *name)
         return (NULL);
     }
 
+    /* Go though the driver registered entry points */
+    for (i = 0;i < conn->nb_drivers;i++) {
+       if ((conn->drivers[i] != NULL) &&
+           (conn->drivers[i]->domainLookupByName != NULL)) {
+           ret = conn->drivers[i]->domainLookupByName(conn, name);
+           if (ret)
+               return(ret);
+       }
+    }
+
     /* try first though Xend */
     ret = xenDaemonDomainLookupByName(conn, name);
     if (ret != NULL) {
@@ -1400,6 +1434,7 @@ int
 virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
 {
     int ret;
+    int i;
 
     if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
         virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
@@ -1412,6 +1447,14 @@ virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
 
     memset(info, 0, sizeof(virDomainInfo));
 
+    for (i = 0;i < domain->conn->nb_drivers;i++) {
+       if ((domain->conn->drivers[i] != NULL) &&
+           (domain->conn->drivers[i]->domainGetInfo != NULL)) {
+           if (domain->conn->drivers[i]->domainGetInfo(domain, info) == 0)
+               return 0;
+       }
+    }
+
     /*
      * if we have direct access though the hypervisor do a direct call
      */