On Fri, Oct 09, 2009 at 10:35:48AM +0100, Daniel P. Berrange wrote: > From: Jonas Eriksson <jonas.j.eriksson@xxxxxxxxxxxx> > > The xenUnifiedNumOfDomains and xenUnifiedListDomains methods work > together as a pair, so it is critical they both apply the same > logic. With the current mis-matched logic it is possible to sometimes > get into a state when you miss certain active guests. > > * src/xen/xen_driver.c: Change xenUnifiedNumOfDomains ordering to > match xenUnifiedListDomains. > --- > src/xen/proxy_internal.c | 3 +-- > src/xen/proxy_internal.h | 1 + > src/xen/xen_driver.c | 30 ++++++++++++++++++++++++------ > src/xen/xend_internal.c | 2 +- > src/xen/xend_internal.h | 1 + > 5 files changed, 28 insertions(+), 9 deletions(-) > > diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c > index f9d2fad..22ff172 100644 > --- a/src/xen/proxy_internal.c > +++ b/src/xen/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); > @@ -607,7 +606,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/xen/proxy_internal.h b/src/xen/proxy_internal.h > index 185fa67..19df751 100644 > --- a/src/xen/proxy_internal.h > +++ b/src/xen/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/xen_driver.c b/src/xen/xen_driver.c > index 76b896a..fc8bbe6 100644 > --- a/src/xen/xen_driver.c > +++ b/src/xen/xen_driver.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/xen/xend_internal.c b/src/xen/xend_internal.c > index 49bdba9..f362ae6 100644 > --- a/src/xen/xend_internal.c > +++ b/src/xen/xend_internal.c > @@ -3685,7 +3685,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/xen/xend_internal.h b/src/xen/xend_internal.h > index 9d2571b..8b00737 100644 > --- a/src/xen/xend_internal.h > +++ b/src/xen/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_ */ ACK ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@xxxxxxxxxxxx | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list