From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 05/29] libxl: suspend: Return correct error from callbacks Date: Tue, 10 Feb 2015 20:09:52 +0000 Message-ID: <1423599016-32639-6-git-send-email-ian.jackson@eu.citrix.com> References: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1423599016-32639-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: Ian Jackson , Euan Harris List-Id: xen-devel@lists.xenproject.org If a suspend callback fails, it has a libxl error code in its hand. However we must return to libxc the values that libxc expects. So we stash the libxl error code in dss->rc and fish it out again after libxc returns from the suspend call. While we're here, abolish the now-redundant `ok' variable in remus_devices_postsuspend_cb. The overall functional change is that libxl_domain_save now completes with the correct error code as determined when the underlying failure happened. (Usually this is, still, ERROR_FAIL.) Signed-off-by: Ian Jackson --- v2: Add cleanup in remus_devices_postsuspend_cb. --- tools/libxl/libxl_dom.c | 22 ++++++++++++++++------ tools/libxl/libxl_internal.h | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 9971cdc..90877d6 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1041,6 +1041,7 @@ static void domain_suspend_switch_qemu_xen_logdirty libxl__xc_domain_saverestore_async_callback_done(egc, shs, 0); } else { LOG(ERROR,"logdirty switch failed (rc=%d), aborting suspend",rc); + dss->rc = rc; libxl__xc_domain_saverestore_async_callback_done(egc, shs, -1); } } @@ -1063,6 +1064,7 @@ void libxl__domain_suspend_common_switch_qemu_logdirty default: LOG(ERROR,"logdirty switch failed" ", no valid device model version found, aborting suspend"); + dss->rc = ERROR_FAIL; libxl__xc_domain_saverestore_async_callback_done(egc, shs, -1); } } @@ -1144,6 +1146,7 @@ static void switch_logdirty_done(libxl__egc *egc, int broke; if (rc) { broke = -1; + dss->rc = rc; } else { broke = 0; } @@ -1587,6 +1590,7 @@ static void libxl__domain_suspend_callback(void *data) static void domain_suspend_callback_common_done(libxl__egc *egc, libxl__domain_suspend_state *dss, int rc) { + dss->rc = rc; libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, !rc); } @@ -1622,6 +1626,7 @@ static void remus_domain_suspend_callback_common_done(libxl__egc *egc, return; out: + dss->rc = rc; libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, !rc); } @@ -1629,16 +1634,17 @@ static void remus_devices_postsuspend_cb(libxl__egc *egc, libxl__remus_devices_state *rds, int rc) { - int ok = 0; libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds); if (rc) goto out; - ok = 1; + rc = 0; out: - libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, ok); + if (rc) + dss->rc = rc; + libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, !rc); } static void libxl__remus_domain_resume_callback(void *data) @@ -1657,7 +1663,6 @@ static void remus_devices_preresume_cb(libxl__egc *egc, libxl__remus_devices_state *rds, int rc) { - int ok = 0; libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds); STATE_AO_GC(dss->ao); @@ -1669,10 +1674,12 @@ static void remus_devices_preresume_cb(libxl__egc *egc, if (rc) goto out; - ok = 1; + rc = 0; out: - libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, ok); + if (rc) + dss->rc = rc; + libxl__xc_domain_saverestore_async_callback_done(egc, &dss->shs, !rc); } /*----- remus asynchronous checkpoint callback -----*/ @@ -1790,6 +1797,7 @@ void libxl__domain_suspend(libxl__egc *egc, libxl__domain_suspend_state *dss) libxl__srm_save_autogen_callbacks *const callbacks = &dss->shs.callbacks.save.a; + dss->rc = 0; logdirty_init(&dss->logdirty); libxl__xswait_init(&dss->pvcontrol); libxl__ev_evtchn_init(&dss->guest_evtchn); @@ -1877,6 +1885,8 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void, "domain did not respond to suspend request"); if ( !dss->guest_responded ) rc = ERROR_GUEST_TIMEDOUT; + else if (dss->rc) + rc = dss->rc; else rc = ERROR_FAIL; goto out; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 99db92a..2862c69 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -2800,6 +2800,7 @@ struct libxl__domain_suspend_state { int debug; const libxl_domain_remus_info *remus; /* private */ + int rc; libxl__ev_evtchn guest_evtchn; int guest_evtchn_lockfd; int hvm; -- 1.7.10.4