From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yang Hongyang Subject: [PATCH v4 --for 4.6 COLOPre 03/25] tools/libxl: move domain resume code into libxl_dom_suspend.c Date: Wed, 15 Jul 2015 15:45:29 +0800 Message-ID: <1436946351-21118-4-git-send-email-yanghy@cn.fujitsu.com> References: <1436946351-21118-1-git-send-email-yanghy@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1436946351-21118-1-git-send-email-yanghy@cn.fujitsu.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.xen.org Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, wency@cn.fujitsu.com, andrew.cooper3@citrix.com, yunhong.jiang@intel.com, eddie.dong@intel.com, guijianfeng@cn.fujitsu.com, rshriram@cs.ubc.ca, Ian Jackson List-Id: xen-devel@lists.xenproject.org move domain resume code into libxl_dom_suspend.c. pure code move. libxl__domain_resume_device_model() will be used later by COLO, so we are not making this func static. Signed-off-by: Yang Hongyang CC: Ian Jackson CC: Wei Liu Acked-by: Ian Campbell --- tools/libxl/libxl.c | 33 ------------------------- tools/libxl/libxl_dom.c | 20 --------------- tools/libxl/libxl_dom_suspend.c | 55 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 53 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index fa42c1c..69a6937 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -513,39 +513,6 @@ int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid, return rc; } -int libxl__domain_resume(libxl__gc *gc, uint32_t domid, int suspend_cancel) -{ - int rc = 0; - - if (xc_domain_resume(CTX->xch, domid, suspend_cancel)) { - LOGE(ERROR, "xc_domain_resume failed for domain %u", domid); - rc = ERROR_FAIL; - goto out; - } - - libxl_domain_type type = libxl__domain_type(gc, domid); - if (type == LIBXL_DOMAIN_TYPE_INVALID) { - rc = ERROR_FAIL; - goto out; - } - - if (type == LIBXL_DOMAIN_TYPE_HVM) { - rc = libxl__domain_resume_device_model(gc, domid); - if (rc) { - LOG(ERROR, "failed to resume device model for domain %u:%d", - domid, rc); - goto out; - } - } - - if (!xs_resume_domain(CTX->xsh, domid)) { - LOGE(ERROR, "xs_resume_domain failed for domain %u", domid); - rc = ERROR_FAIL; - } -out: - return rc; -} - int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid, int suspend_cancel, const libxl_asyncop_how *ao_how) { diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index e21e110..0788309 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1384,26 +1384,6 @@ static void switch_logdirty_done(libxl__egc *egc, /*----- callbacks, called by xc_domain_save -----*/ -int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid) -{ - - switch (libxl__device_model_version_running(gc, domid)) { - case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: { - libxl__qemu_traditional_cmd(gc, domid, "continue"); - libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL); - break; - } - case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: - if (libxl__qmp_resume(gc, domid)) - return ERROR_FAIL; - break; - default: - return ERROR_INVAL; - } - - return 0; -} - static inline char *physmap_path(libxl__gc *gc, uint32_t dm_domid, uint32_t domid, char *phys_offset, char *node) diff --git a/tools/libxl/libxl_dom_suspend.c b/tools/libxl/libxl_dom_suspend.c index 5146402..a90800d 100644 --- a/tools/libxl/libxl_dom_suspend.c +++ b/tools/libxl/libxl_dom_suspend.c @@ -371,6 +371,61 @@ static void domain_suspend_callback_common_done(libxl__egc *egc, libxl__xc_domain_saverestore_async_callback_done(egc, &dss->sws.shs, !rc); } +/*======================= Domain resume ========================*/ + +int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid) +{ + + switch (libxl__device_model_version_running(gc, domid)) { + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: { + libxl__qemu_traditional_cmd(gc, domid, "continue"); + libxl__wait_for_device_model_deprecated(gc, domid, "running", NULL, NULL, NULL); + break; + } + case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN: + if (libxl__qmp_resume(gc, domid)) + return ERROR_FAIL; + break; + default: + return ERROR_INVAL; + } + + return 0; +} + +int libxl__domain_resume(libxl__gc *gc, uint32_t domid, int suspend_cancel) +{ + int rc = 0; + + if (xc_domain_resume(CTX->xch, domid, suspend_cancel)) { + LOGE(ERROR, "xc_domain_resume failed for domain %u", domid); + rc = ERROR_FAIL; + goto out; + } + + libxl_domain_type type = libxl__domain_type(gc, domid); + if (type == LIBXL_DOMAIN_TYPE_INVALID) { + rc = ERROR_FAIL; + goto out; + } + + if (type == LIBXL_DOMAIN_TYPE_HVM) { + rc = libxl__domain_resume_device_model(gc, domid); + if (rc) { + LOG(ERROR, "failed to resume device model for domain %u:%d", + domid, rc); + goto out; + } + } + + if (!xs_resume_domain(CTX->xsh, domid)) { + LOGE(ERROR, "xs_resume_domain failed for domain %u", domid); + rc = ERROR_FAIL; + } +out: + return rc; +} + /* * Local variables: * mode: C -- 1.9.1