From: Ian Jackson Date: Tue, 17 Mar 2015 15:30:57 +0000 (-0600) Subject: libxl: In domain death search, start search at first domid we want X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=56be637e71e5fe22bebb8045762a1fab3da8a184;p=xen.git libxl: In domain death search, start search at first domid we want From: Ian Jackson When domain_death_xswatch_callback needed a further call to xc_domain_getinfolist it would restart it with the last domain it found rather than the first one it wants. If it only wants one it will also only ask for one domain. The result would then be that it gets the previous domain again (ie, the previous one to the one it wants), which still doesn't reveal the answer to the question, and it would therefore loop again. It's completely unclear to me why I thought it was a good idea to start the xc_domain_getinfolist with the last domain previously found rather than the first one left un-confirmed. The code has been that way since it was introduced. Instead, start each xc_domain_getinfolist at the next domain whose status we need to check. We also need to move the test for !evg into the loop, we now need evg to compute the arguments to getinfolist. Signed-off-by: Ian Jackson Reported-by: Jim Fehlig Reviewed-by: Jim Fehlig Tested-by: Jim Fehlig Acked-by: Wei Liu Acked-by: Ian Campbell (cherry picked from commit 4783c99aab866f470bd59368cfbf5ad5f677b0ec) (cherry picked from commit 0b19348f3cd176e4badb173dd0054c49346a6ce1) (cherry picked from commit 13623d5d8e854f20b2da885f4d452dc870912205) (cherry picked from commit 0332b3f24b2c1be06a17b00786021aeea01c52f5) --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index b9fb822589..99cfc6edef 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -974,22 +974,20 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, const char *wpath, const char *epath) { EGC_GC; libxl_evgen_domain_death *evg; - uint32_t domid; int rc; CTX_LOCK; evg = LIBXL_TAILQ_FIRST(&CTX->death_list); - if (!evg) goto out; - - domid = evg->domid; for (;;) { + if (!evg) goto out; + int nentries = LIBXL_TAILQ_NEXT(evg, entry) ? 200 : 1; xc_domaininfo_t domaininfos[nentries]; const xc_domaininfo_t *got = domaininfos, *gotend; - rc = xc_domain_getinfolist(CTX->xch, domid, nentries, domaininfos); + rc = xc_domain_getinfolist(CTX->xch, evg->domid, nentries, domaininfos); if (rc == -1) { LIBXL__EVENT_DISASTER(egc, "xc_domain_getinfolist failed while" " processing @releaseDomain watch event", @@ -999,8 +997,10 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, gotend = &domaininfos[rc]; LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, "[evg=%p:%"PRIu32"]" - " from domid=%"PRIu32" nentries=%d rc=%d", - evg, evg->domid, domid, nentries, rc); + " nentries=%d rc=%d %ld..%ld", + evg, evg->domid, nentries, rc, + rc>0 ? (long)domaininfos[0].domain : 0, + rc>0 ? (long)domaininfos[rc-1].domain : 0); for (;;) { if (!evg) { @@ -1063,7 +1063,6 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, } assert(rc); /* rc==0 results in us eating all evgs and quitting */ - domid = gotend[-1].domain; } all_reported: out: