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

[libvirt] [PATCH 1/2] Make sure that xenUnifiedNumOfDomains uses the same backends as xenUnifiedListDomains



src/xen_unified.c: xenUnifiedNumOfDomains used backends in same order as array
  priv->opened. Changed this to reflect the priorities used in
  xenUnifiedListDomains
---
 src/proxy_internal.c |    3 +--
 src/proxy_internal.h |    1 +
 src/xen_unified.c    |   30 ++++++++++++++++++++++++------
 src/xend_internal.c  |    2 +-
 src/xend_internal.h  |    1 +
 5 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/proxy_internal.c b/src/proxy_internal.c
index 5b92ad8..8d8877a 100644
--- a/src/proxy_internal.c
+++ b/src/proxy_internal.c
@@ -40,7 +40,6 @@ static virDrvOpenStatus xenProxyOpen(virConnectPtr conn, virConnectAuthPtr auth,
 static int xenProxyGetVersion(virConnectPtr conn, unsigned long *hvVer);
 static int xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
 static char *xenProxyGetCapabilities(virConnectPtr conn);
-static int xenProxyNumOfDomains(virConnectPtr conn);
 static unsigned long xenProxyDomainGetMaxMemory(virDomainPtr domain);
 static int xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
 static char *xenProxyDomainGetOSType(virDomainPtr domain);
@@ -604,7 +603,7 @@ xenProxyListDomains(virConnectPtr conn, int *ids, int maxids)
  *
  * Returns the number of domain found or -1 in case of error
  */
-static int
+int
 xenProxyNumOfDomains(virConnectPtr conn)
 {
     virProxyPacket req;
diff --git a/src/proxy_internal.h b/src/proxy_internal.h
index 185fa67..19df751 100644
--- a/src/proxy_internal.h
+++ b/src/proxy_internal.h
@@ -96,4 +96,5 @@ extern char *       xenProxyDomainDumpXML(virDomainPtr domain,
                                           int flags);
 extern int          xenProxyListDomains(virConnectPtr conn, int *ids,
                                         int maxids);
+extern int xenProxyNumOfDomains(virConnectPtr conn);
 #endif /* __LIBVIR_PROXY_H__ */
diff --git a/src/xen_unified.c b/src/xen_unified.c
index f2ffc25..c04ea37 100644
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -576,13 +576,31 @@ static int
 xenUnifiedNumOfDomains (virConnectPtr conn)
 {
     GET_PRIVATE(conn);
-    int i, ret;
+    int ret;
 
-    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
-        if (priv->opened[i] && drivers[i]->numOfDomains) {
-            ret = drivers[i]->numOfDomains (conn);
-            if (ret >= 0) return ret;
-        }
+    /* Try xenstore. */
+    if (priv->opened[XEN_UNIFIED_XS_OFFSET]) {
+        ret = xenStoreNumOfDomains (conn);
+        if (ret >= 0) return ret;
+    }
+
+    /* Try HV. */
+    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]) {
+        ret = xenHypervisorNumOfDomains (conn);
+        if (ret >= 0) return ret;
+    }
+
+    /* Try xend. */
+    if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
+        ret = xenDaemonNumOfDomains (conn);
+        if (ret >= 0) return ret;
+    }
+
+    /* Try proxy. */
+    if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
+        ret = xenProxyNumOfDomains (conn);
+        if (ret >= 0) return ret;
+    }
 
     return -1;
 }
diff --git a/src/xend_internal.c b/src/xend_internal.c
index e23ae2b..867f85f 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -3678,7 +3678,7 @@ error:
  *
  * Returns the number of domain found or -1 in case of error
  */
-static int
+int
 xenDaemonNumOfDomains(virConnectPtr conn)
 {
     struct sexpr *root = NULL;
diff --git a/src/xend_internal.h b/src/xend_internal.h
index 9d2571b..8b00737 100644
--- a/src/xend_internal.h
+++ b/src/xend_internal.h
@@ -187,5 +187,6 @@ int xenDaemonDomainMigratePerform (virDomainPtr domain, const char *cookie, int
 
 int xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path, unsigned long long offset, size_t size, void *buffer);
 int xenDaemonListDomains(virConnectPtr conn, int *ids, int maxids);
+int xenDaemonNumOfDomains(virConnectPtr conn);
 
 #endif /* __XEND_INTERNAL_H_ */
-- 
1.6.2


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