From 88e6f39ae624bfe53dfebc9770db7d87eff94f6b Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Mon, 29 May 2006 18:03:27 +0000 Subject: [PATCH] * 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. Daniel --- ChangeLog | 9 +++++++++ src/hash.c | 2 +- src/internal.h | 2 +- src/libvirt.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc12123977..4e874cde9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri May 26 11:59:20 EDT 2006 Daniel P. Berrange + + * 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 * src/libvirt_sym.version: added in missing symbols referenced by python diff --git a/src/hash.c b/src/hash.c index 897c585602..4ffb7454db 100644 --- a/src/hash.c +++ b/src/hash.c @@ -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 --git a/src/internal.h b/src/internal.h index 9ac0d99a3e..669831c792 100644 --- a/src/internal.h +++ b/src/internal.h @@ -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, diff --git a/src/libvirt.c b/src/libvirt.c index a77f1a1416..aba1ba7095 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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 */ -- GitLab