@@ -639,6 +639,58 @@ int libxl__domain_unpause_deprecated(libxl__gc *gc, libxl_domid domid)
return rc;
}
+static void domain_unpause_done(libxl__egc *egc,
+ libxl__dm_resume_state *,
+ int rc);
+
+void libxl__domain_unpause(libxl__egc *egc,
+ libxl__dm_resume_state *dmrs)
+{
+ STATE_AO_GC(dmrs->ao);
+ int rc = 0;
+
+ /* Convenience aliases */
+ libxl_domid domid = dmrs->domid;
+
+ 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) {
+ dmrs->dm_resumed_callback = domain_unpause_done;
+ libxl__dm_resume(egc, dmrs); /* must be last */
+ return;
+ }
+ rc = 0;
+out:
+ domain_unpause_done(egc, dmrs, rc);
+}
+
+static void domain_unpause_done(libxl__egc *egc,
+ libxl__dm_resume_state *dmrs,
+ int rc)
+{
+ EGC_GC;
+ int r;
+
+ /* Convenience aliases */
+ libxl_domid domid = dmrs->domid;
+
+ if (rc) goto out;
+
+ r = xc_domain_unpause(CTX->xch, domid);
+ if (r < 0) {
+ LOGED(ERROR, domid, "Unpausing domain");
+ rc = ERROR_FAIL;
+ goto out;
+ }
+ rc = 0;
+out:
+ dmrs->callback(egc, dmrs, rc);
+}
+
int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid,
const libxl_asyncop_how *ao_how)
{
@@ -1350,9 +1350,10 @@ struct libxl__dm_resume_state {
libxl_domid domid;
void (*callback)(libxl__egc *, libxl__dm_resume_state *, int rc);
- /* private to libxl__domain_resume */
+ /* private to libxl__domain_resume and libxl__domain_unpause */
void (*dm_resumed_callback)(libxl__egc *,
libxl__dm_resume_state *, int rc);
+ /* private to libxl__domain_resume */
bool suspend_cancel;
/* private to libxl__dm_resume */
@@ -1365,6 +1366,8 @@ _hidden void libxl__dm_resume(libxl__egc *egc,
_hidden void libxl__domain_resume(libxl__egc *egc,
libxl__dm_resume_state *dmrs,
bool suspend_cancel);
+_hidden void libxl__domain_unpause(libxl__egc *,
+ libxl__dm_resume_state *dmrs);
/* returns 0 or 1, or a libxl error code */
_hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid);
libxl__domain_unpause is a reimplementation of libxl__domain_unpause_deprecated with asynchronous operation. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- tools/libxl/libxl_domain.c | 52 ++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 5 +++- 2 files changed, 56 insertions(+), 1 deletion(-)