Re: [Xen-devel] [PATCH v2 3/6] tools/libxl: move domain resume code into libxl_dom_suspend.c

2015-06-16 Thread Ian Campbell
On Wed, 2015-06-03 at 16:01 +0800, Yang Hongyang wrote:
 move domain resume code into libxl_dom_suspend.c.

Even though it has resume in the name, I'm not sure that
libxl__domain_s3_resume is a good candidate for moving to the suspend
code, it's called only from libxl_send_trigger and IIRC we don't really
implement s3, just a fake version where the domain is paused/unpaused
(rather the destroyed and resumed, say.

Having moved libxl__domain_resume and libxl__domain_resume_device_model
into the same file I think the latter could become static. (If you do
that in this patch please say something along the lines of pure code
motion except for making libxl__domain_resume_device_model static in
the commit message)



___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 3/6] tools/libxl: move domain resume code into libxl_dom_suspend.c

2015-06-16 Thread Yang Hongyang



On 06/16/2015 09:04 PM, Ian Campbell wrote:

On Wed, 2015-06-03 at 16:01 +0800, Yang Hongyang wrote:

move domain resume code into libxl_dom_suspend.c.


Even though it has resume in the name, I'm not sure that
libxl__domain_s3_resume is a good candidate for moving to the suspend
code, it's called only from libxl_send_trigger and IIRC we don't really
implement s3, just a fake version where the domain is paused/unpaused
(rather the destroyed and resumed, say.

Having moved libxl__domain_resume and libxl__domain_resume_device_model
into the same file I think the latter could become static. (If you do
that in this patch please say something along the lines of pure code
motion except for making libxl__domain_resume_device_model static in
the commit message)


ok, will fix this in the next version, thank you for the review!




.



--
Thanks,
Yang.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 3/6] tools/libxl: move domain resume code into libxl_dom_suspend.c

2015-06-03 Thread Yang Hongyang
move domain resume code into libxl_dom_suspend.c.

Signed-off-by: Yang Hongyang yan...@cn.fujitsu.com
CC: Ian Campbell ian.campb...@citrix.com
CC: Ian Jackson ian.jack...@eu.citrix.com
CC: Wei Liu wei.l...@citrix.com
CC: Andrew Cooper andrew.coop...@citrix.com
---
 tools/libxl/libxl.c | 59 -
 tools/libxl/libxl_dom.c | 20 --
 tools/libxl/libxl_dom_suspend.c | 82 +
 tools/libxl/libxl_internal.h|  1 +
 4 files changed, 83 insertions(+), 79 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 5a70062..77c6a36 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -510,39 +510,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)
 {
@@ -5948,32 +5915,6 @@ int libxl_domain_sched_params_get(libxl_ctx *ctx, 
uint32_t domid,
 return ret;
 }
 
-static int libxl__domain_s3_resume(libxl__gc *gc, int domid)
-{
-int rc = 0;
-
-switch (libxl__domain_type(gc, domid)) {
-case LIBXL_DOMAIN_TYPE_HVM:
-switch (libxl__device_model_version_running(gc, domid)) {
-case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL:
-rc = xc_hvm_param_set(CTX-xch, domid, HVM_PARAM_ACPI_S_STATE, 0);
-break;
-case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-rc = libxl__qmp_system_wakeup(gc, domid);
-break;
-default:
-rc = ERROR_INVAL;
-break;
-}
-break;
-default:
-rc = ERROR_INVAL;
-break;
-}
-
-return rc;
-}
-
 int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
libxl_trigger trigger, uint32_t vcpuid)
 {
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 9444329..701e9f7 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -1319,26 +1319,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 ef8d60b..8b9dd6c 100644
--- a/tools/libxl/libxl_dom_suspend.c
+++ b/tools/libxl/libxl_dom_suspend.c
@@ -372,6 +372,88 @@ static void domain_suspend_callback_common_done(libxl__egc 
*egc,
 {
 libxl__xc_domain_saverestore_async_callback_done(egc, dss-shs, ok);
 }
+
+/* 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_s3_resume(libxl__gc *gc, int domid)
+{
+int rc = 0;
+
+switch (libxl__domain_type(gc, domid)) {
+case LIBXL_DOMAIN_TYPE_HVM:
+switch