[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl: suspend: New domain_suspend_pvcontrol_acked
commit 83c20713bd006220a6cb39af6a764a9f900de3e5 Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> AuthorDate: Thu Dec 5 18:48:21 2013 +0000 Commit: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CommitDate: Mon Mar 17 15:54:00 2014 +0000 libxl: suspend: New domain_suspend_pvcontrol_acked Factor out domain_suspend_pvcontrol_acked. This replaces a bunch of open-coded strcmp()s and makes the code clearer. It also eliminates the need to check for state==NULL each time it's read, because we can check for NULL once before the strcmp. No functional change. Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- v3: Improve comment re xswatch state ENOENT --- tools/libxl/libxl_dom.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index cef62cf..78f1de7 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1034,6 +1034,12 @@ static void domain_suspend_common_done(libxl__egc *egc, libxl__domain_suspend_state *dss, bool ok); +static bool domain_suspend_pvcontrol_acked(const char *state) { + /* any value other than "suspend", including ENOENT (i.e. !state), is OK */ + if (!state) return 1; + return strcmp(state,"suspend"); +} + /* calls dss->callback_common_done when done */ static void domain_suspend_callback_common(libxl__egc *egc, libxl__domain_suspend_state *dss) @@ -1091,11 +1097,10 @@ static void domain_suspend_callback_common(libxl__egc *egc, LOG(DEBUG, "wait for the guest to acknowledge suspend request"); watchdog = 60; - while (!strcmp(state, "suspend") && watchdog > 0) { + while (!domain_suspend_pvcontrol_acked(state) && watchdog > 0) { usleep(100000); state = libxl__domain_pvcontrol_read(gc, XBT_NULL, domid); - if (!state) state = ""; watchdog--; } @@ -1109,21 +1114,19 @@ static void domain_suspend_callback_common(libxl__egc *egc, * against the guest catching up and acknowledging the request * at the last minute. */ - if (!strcmp(state, "suspend")) { + if (!domain_suspend_pvcontrol_acked(state)) { LOG(ERROR, "guest didn't acknowledge suspend, cancelling request"); retry_transaction: t = xs_transaction_start(CTX->xsh); state = libxl__domain_pvcontrol_read(gc, t, domid); - if (!state) state = ""; - if (!strcmp(state, "suspend")) + if (!domain_suspend_pvcontrol_acked(state)) libxl__domain_pvcontrol_write(gc, t, domid, ""); if (!xs_transaction_end(CTX->xsh, t, 0)) if (errno == EAGAIN) goto retry_transaction; - } /* @@ -1131,7 +1134,7 @@ static void domain_suspend_callback_common(libxl__egc *egc, * acknowledged while we were cancelling the request in which * case we lost the race while cancelling and should continue. */ - if (!strcmp(state, "suspend")) { + if (!domain_suspend_pvcontrol_acked(state)) { LOG(ERROR, "guest didn't acknowledge suspend, request cancelled"); goto err; } -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |