[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] Connect up more internal driver methods



The attached patch connects up more of the internal driver methods, as
the final step preparing for a minimally operational test driver.

      * 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.

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
# HG changeset patch
# User "Daniel P. Berrange <berrange redhat com>"
# Node ID 5ec05a73e1fb1eeda431c0ddc7bd6ae1ce44812b
# Parent  e6fc9607648cbe0b150bbaf9f7e9a07e8dd263e3
Hooked up more driver methods. Fix type for uuid parameter in virGetDomain

diff -r e6fc9607648c -r 5ec05a73e1fb ChangeLog
--- a/ChangeLog	Fri May 26 12:02:10 2006 -0400
+++ b/ChangeLog	Fri May 26 12:03:10 2006 -0400
@@ -1,3 +1,12 @@ Fri May 26 11:40:20 EDT 2006 Daniel P. B
+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.
+
 Fri May 26 11:40:20 EDT 2006 Daniel P. Berrange <berrange redhat com>
 
 	* src/virsh.c: added 'domuuid' command to display printable UUID
diff -r e6fc9607648c -r 5ec05a73e1fb src/hash.c
--- a/src/hash.c	Fri May 26 12:02:10 2006 -0400
+++ b/src/hash.c	Fri May 26 12:03:10 2006 -0400
@@ -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)) ||
diff -r e6fc9607648c -r 5ec05a73e1fb src/internal.h
--- a/src/internal.h	Fri May 26 12:02:10 2006 -0400
+++ b/src/internal.h	Fri May 26 12:03:10 2006 -0400
@@ -182,7 +182,7 @@ int		virFreeConnect	(virConnectPtr conn)
 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,
diff -r e6fc9607648c -r 5ec05a73e1fb src/libvirt.c
--- a/src/libvirt.c	Fri May 26 12:02:10 2006 -0400
+++ b/src/libvirt.c	Fri May 26 12:03:10 2006 -0400
@@ -29,7 +29,6 @@
 #include "xend_internal.h"
 #include "xs_internal.h"
 #include "xml.h"
-
 
 /*
  * TODO:
@@ -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, 
     virDomainPtr ret;
     char *name = NULL;
     unsigned char uuid[16];
+    int i;
 
     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
@@ -608,6 +609,16 @@ virDomainLookupByID(virConnectPtr conn, 
     if (id < 0) {
         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]->domainLookupByID != NULL)) {
+	    ret = conn->drivers[i]->domainLookupByID(conn, id);
+	    if (ret)
+	        return(ret);
+	}
     }
 
     /* retrieve home path of the domain */
@@ -633,7 +644,7 @@ virDomainLookupByID(virConnectPtr conn, 
     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
     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
         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
     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 @@ virDomainLookupByName(virConnectPtr conn
 virDomainLookupByName(virConnectPtr conn, const char *name)
 {
     virDomainPtr ret = NULL;
+    int i;
 
     if (!VIR_IS_CONNECT(conn)) {
         virLibConnError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
@@ -782,6 +806,16 @@ virDomainLookupByName(virConnectPtr conn
     if (name == NULL) {
         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]->domainLookupByName != NULL)) {
+	    ret = conn->drivers[i]->domainLookupByName(conn, name);
+	    if (ret)
+	        return(ret);
+	}
     }
 
     /* try first though Xend */
@@ -1400,6 +1434,7 @@ virDomainGetInfo(virDomainPtr domain, vi
 virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
 {
     int ret;
+    int i;
 
     if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
         virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
@@ -1411,6 +1446,14 @@ virDomainGetInfo(virDomainPtr domain, vi
     }
 
     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

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]