Re: [Xen-devel] [PATCH v2 2/6] tools/libxl: move domain suspend 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 suspend code into a separate file libxl_dom_suspend.c.
 export an API libxl__domain_suspend() which wrappers the static

just ..which wraps the...

 function domain_suspend_callback_common() for internal use.
 
 Note that the newly added file libxl_dom_suspend.c is used for
 suspend/resume code.
 
 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
 Acked-by: Ian Campbell ian.campb...@citrix.com
 ---
  tools/libxl/Makefile|   3 +-
  tools/libxl/libxl_dom.c | 350 +---
  tools/libxl/libxl_dom_suspend.c | 381 
 
  tools/libxl/libxl_internal.h|   6 +
  4 files changed, 393 insertions(+), 347 deletions(-)
  create mode 100644 tools/libxl/libxl_dom_suspend.c
 
 diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
 index cc9c152..3f98d62 100644
 --- a/tools/libxl/Makefile
 +++ b/tools/libxl/Makefile
 @@ -95,7 +95,8 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o 
 libxl_pci.o \
   libxl_internal.o libxl_utils.o libxl_uuid.o \
   libxl_json.o libxl_aoutils.o libxl_numa.o libxl_vnuma.o 
 \
   libxl_save_callout.o _libxl_save_msgs_callout.o \
 - libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y)
 + libxl_qmp.o libxl_event.o libxl_fork.o 
 libxl_dom_suspend.o \
 + $(LIBXL_OBJS-y)
  LIBXL_OBJS += libxl_genid.o
  LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
  
 diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
 index cce04dd..9444329 100644
 --- a/tools/libxl/libxl_dom.c
 +++ b/tools/libxl/libxl_dom.c
 @@ -1103,11 +1103,6 @@ int libxl__toolstack_restore(uint32_t domid, const 
 uint8_t *buf,
  
  /* Domain suspend (save) */
  
 -static void domain_save_done(libxl__egc *egc,
 - libxl__domain_suspend_state *dss, int rc);
 -static void domain_suspend_callback_common_done(libxl__egc *egc,
 -libxl__domain_suspend_state *dss, int ok);
 -
  /*- complicated callback, called by xc_domain_save -*/
  
  /*
 @@ -1324,35 +1319,6 @@ static void switch_logdirty_done(libxl__egc *egc,
  
  /*- callbacks, called by xc_domain_save -*/
  
 -int libxl__domain_suspend_device_model(libxl__gc *gc,
 -   libxl__domain_suspend_state *dss)
 -{
 -int ret = 0;
 -uint32_t const domid = dss-domid;
 -const char *const filename = dss-dm_savefile;
 -
 -switch (libxl__device_model_version_running(gc, domid)) {
 -case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
 -LOG(DEBUG, Saving device model state to %s, filename);
 -libxl__qemu_traditional_cmd(gc, domid, save);
 -libxl__wait_for_device_model_deprecated(gc, domid, paused, NULL, 
 NULL, NULL);
 -break;
 -}
 -case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
 -if (libxl__qmp_stop(gc, domid))
 -return ERROR_FAIL;
 -/* Save DM state into filename */
 -ret = libxl__qmp_save(gc, domid, filename);
 -if (ret)
 -unlink(filename);
 -break;
 -default:
 -return ERROR_INVAL;
 -}
 -
 -return ret;
 -}
 -
  int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid)
  {
  
 @@ -1373,301 +1339,6 @@ int libxl__domain_resume_device_model(libxl__gc *gc, 
 uint32_t domid)
  return 0;
  }
  
 -static void domain_suspend_common_wait_guest(libxl__egc *egc,
 - libxl__domain_suspend_state 
 *dss);
 -static void domain_suspend_common_guest_suspended(libxl__egc *egc,
 - libxl__domain_suspend_state *dss);
 -
 -static void domain_suspend_common_pvcontrol_suspending(libxl__egc *egc,
 -  libxl__xswait_state *xswa, int rc, const char *state);
 -static void domain_suspend_common_wait_guest_evtchn(libxl__egc *egc,
 -libxl__ev_evtchn *evev);
 -static void suspend_common_wait_guest_watch(libxl__egc *egc,
 -  libxl__ev_xswatch *xsw, const char *watch_path, const char 
 *event_path);
 -static void suspend_common_wait_guest_check(libxl__egc *egc,
 -libxl__domain_suspend_state *dss);
 -static void suspend_common_wait_guest_timeout(libxl__egc *egc,
 -  libxl__ev_time *ev, const struct timeval *requested_abs);
 -
 -static void domain_suspend_common_failed(libxl__egc *egc,
 - libxl__domain_suspend_state *dss);
 -static void domain_suspend_common_done(libxl__egc *egc,
 -   libxl__domain_suspend_state *dss,
 -   bool ok);
 -
 

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

2015-06-16 Thread Yang Hongyang



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

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

Move domain suspend code into a separate file libxl_dom_suspend.c.
export an API libxl__domain_suspend() which wrappers the static


just ..which wraps the...


will fix, thank you !




function domain_suspend_callback_common() for internal use.

Note that the newly added file libxl_dom_suspend.c is used for
suspend/resume code.

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
Acked-by: Ian Campbell ian.campb...@citrix.com
---
  tools/libxl/Makefile|   3 +-
  tools/libxl/libxl_dom.c | 350 +---
  tools/libxl/libxl_dom_suspend.c | 381 
  tools/libxl/libxl_internal.h|   6 +
  4 files changed, 393 insertions(+), 347 deletions(-)
  create mode 100644 tools/libxl/libxl_dom_suspend.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index cc9c152..3f98d62 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -95,7 +95,8 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o 
libxl_pci.o \
libxl_internal.o libxl_utils.o libxl_uuid.o \
libxl_json.o libxl_aoutils.o libxl_numa.o libxl_vnuma.o 
\
libxl_save_callout.o _libxl_save_msgs_callout.o \
-   libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y)
+   libxl_qmp.o libxl_event.o libxl_fork.o 
libxl_dom_suspend.o \
+   $(LIBXL_OBJS-y)
  LIBXL_OBJS += libxl_genid.o
  LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o

diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index cce04dd..9444329 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -1103,11 +1103,6 @@ int libxl__toolstack_restore(uint32_t domid, const 
uint8_t *buf,

  /* Domain suspend (save) */

-static void domain_save_done(libxl__egc *egc,
- libxl__domain_suspend_state *dss, int rc);
-static void domain_suspend_callback_common_done(libxl__egc *egc,
-libxl__domain_suspend_state *dss, int ok);
-
  /*- complicated callback, called by xc_domain_save -*/

  /*
@@ -1324,35 +1319,6 @@ static void switch_logdirty_done(libxl__egc *egc,

  /*- callbacks, called by xc_domain_save -*/

-int libxl__domain_suspend_device_model(libxl__gc *gc,
-   libxl__domain_suspend_state *dss)
-{
-int ret = 0;
-uint32_t const domid = dss-domid;
-const char *const filename = dss-dm_savefile;
-
-switch (libxl__device_model_version_running(gc, domid)) {
-case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
-LOG(DEBUG, Saving device model state to %s, filename);
-libxl__qemu_traditional_cmd(gc, domid, save);
-libxl__wait_for_device_model_deprecated(gc, domid, paused, NULL, 
NULL, NULL);
-break;
-}
-case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-if (libxl__qmp_stop(gc, domid))
-return ERROR_FAIL;
-/* Save DM state into filename */
-ret = libxl__qmp_save(gc, domid, filename);
-if (ret)
-unlink(filename);
-break;
-default:
-return ERROR_INVAL;
-}
-
-return ret;
-}
-
  int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid)
  {

@@ -1373,301 +1339,6 @@ int libxl__domain_resume_device_model(libxl__gc *gc, 
uint32_t domid)
  return 0;
  }

-static void domain_suspend_common_wait_guest(libxl__egc *egc,
- libxl__domain_suspend_state *dss);
-static void domain_suspend_common_guest_suspended(libxl__egc *egc,
- libxl__domain_suspend_state *dss);
-
-static void domain_suspend_common_pvcontrol_suspending(libxl__egc *egc,
-  libxl__xswait_state *xswa, int rc, const char *state);
-static void domain_suspend_common_wait_guest_evtchn(libxl__egc *egc,
-libxl__ev_evtchn *evev);
-static void suspend_common_wait_guest_watch(libxl__egc *egc,
-  libxl__ev_xswatch *xsw, const char *watch_path, const char *event_path);
-static void suspend_common_wait_guest_check(libxl__egc *egc,
-libxl__domain_suspend_state *dss);
-static void suspend_common_wait_guest_timeout(libxl__egc *egc,
-  libxl__ev_time *ev, const struct timeval *requested_abs);
-
-static void domain_suspend_common_failed(libxl__egc *egc,
- libxl__domain_suspend_state *dss);
-static void domain_suspend_common_done(libxl__egc *egc,
-   libxl__domain_suspend_state *dss,
-   bool ok);
-
-static bool 

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

2015-06-03 Thread Yang Hongyang
Move domain suspend code into a separate file libxl_dom_suspend.c.
export an API libxl__domain_suspend() which wrappers the static
function domain_suspend_callback_common() for internal use.

Note that the newly added file libxl_dom_suspend.c is used for
suspend/resume code.

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
Acked-by: Ian Campbell ian.campb...@citrix.com
---
 tools/libxl/Makefile|   3 +-
 tools/libxl/libxl_dom.c | 350 +---
 tools/libxl/libxl_dom_suspend.c | 381 
 tools/libxl/libxl_internal.h|   6 +
 4 files changed, 393 insertions(+), 347 deletions(-)
 create mode 100644 tools/libxl/libxl_dom_suspend.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index cc9c152..3f98d62 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -95,7 +95,8 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o 
libxl_pci.o \
libxl_internal.o libxl_utils.o libxl_uuid.o \
libxl_json.o libxl_aoutils.o libxl_numa.o libxl_vnuma.o 
\
libxl_save_callout.o _libxl_save_msgs_callout.o \
-   libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y)
+   libxl_qmp.o libxl_event.o libxl_fork.o 
libxl_dom_suspend.o \
+   $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index cce04dd..9444329 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -1103,11 +1103,6 @@ int libxl__toolstack_restore(uint32_t domid, const 
uint8_t *buf,
 
 /* Domain suspend (save) */
 
-static void domain_save_done(libxl__egc *egc,
- libxl__domain_suspend_state *dss, int rc);
-static void domain_suspend_callback_common_done(libxl__egc *egc,
-libxl__domain_suspend_state *dss, int ok);
-
 /*- complicated callback, called by xc_domain_save -*/
 
 /*
@@ -1324,35 +1319,6 @@ static void switch_logdirty_done(libxl__egc *egc,
 
 /*- callbacks, called by xc_domain_save -*/
 
-int libxl__domain_suspend_device_model(libxl__gc *gc,
-   libxl__domain_suspend_state *dss)
-{
-int ret = 0;
-uint32_t const domid = dss-domid;
-const char *const filename = dss-dm_savefile;
-
-switch (libxl__device_model_version_running(gc, domid)) {
-case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
-LOG(DEBUG, Saving device model state to %s, filename);
-libxl__qemu_traditional_cmd(gc, domid, save);
-libxl__wait_for_device_model_deprecated(gc, domid, paused, NULL, 
NULL, NULL);
-break;
-}
-case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
-if (libxl__qmp_stop(gc, domid))
-return ERROR_FAIL;
-/* Save DM state into filename */
-ret = libxl__qmp_save(gc, domid, filename);
-if (ret)
-unlink(filename);
-break;
-default:
-return ERROR_INVAL;
-}
-
-return ret;
-}
-
 int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid)
 {
 
@@ -1373,301 +1339,6 @@ int libxl__domain_resume_device_model(libxl__gc *gc, 
uint32_t domid)
 return 0;
 }
 
-static void domain_suspend_common_wait_guest(libxl__egc *egc,
- libxl__domain_suspend_state *dss);
-static void domain_suspend_common_guest_suspended(libxl__egc *egc,
- libxl__domain_suspend_state *dss);
-
-static void domain_suspend_common_pvcontrol_suspending(libxl__egc *egc,
-  libxl__xswait_state *xswa, int rc, const char *state);
-static void domain_suspend_common_wait_guest_evtchn(libxl__egc *egc,
-libxl__ev_evtchn *evev);
-static void suspend_common_wait_guest_watch(libxl__egc *egc,
-  libxl__ev_xswatch *xsw, const char *watch_path, const char *event_path);
-static void suspend_common_wait_guest_check(libxl__egc *egc,
-libxl__domain_suspend_state *dss);
-static void suspend_common_wait_guest_timeout(libxl__egc *egc,
-  libxl__ev_time *ev, const struct timeval *requested_abs);
-
-static void domain_suspend_common_failed(libxl__egc *egc,
- libxl__domain_suspend_state *dss);
-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