xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Shriram Rajagopalan <rshriram@cs.ubc.ca>
To: xen-devel@lists.xen.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 1 of 7 V4] [PATCH] libxl: make libxl__domain_suspend_callback	be asynchronous
Date: Thu, 14 Nov 2013 21:47:46 -0800	[thread overview]
Message-ID: <3143bed377a08bb9e87c.1384494466@athos.nss.cs.ubc.ca> (raw)
In-Reply-To: <patchbomb.1384494465@athos.nss.cs.ubc.ca>

# HG changeset patch
# User Ian Jackson <ian.jackson@eu.citrix.com>
# Date 1384374958 28800
# Node ID 3143bed377a08bb9e87c7636e004dc371bb20338
# Parent  b90864157a670771462fb05918b0829889dde86c
[PATCH] libxl: make libxl__domain_suspend_callback be asynchronous

Date: Mon, 4 Nov 2013 16:27:53 +0000
Mark the suspend callback as asynchronous in the helper stub generator
(libxl_save_msgs_gen.pl).  Remus is going to want to provide an
asynchronous version of this function.

libxl__domain_suspend_common_callback, the common synchronous core,
which used to be provided directly as the callback function for the
helper machinery, becomes libxl__domain_suspend_callback_common.  It
can now take a typesafe parameter.

For now, provide two very similar asynchronous wrappers for it.  Each
is a simple function which contains only boilerplate, calls the common
synchronous core, and returns the asynchronous response.

Essentially, we have just moved (in the case of suspend callbacks) the
call site of libxl__srm_callout_callback_complete.  It was in the
switch statement in the autogenerated _libxl_save_msgs_callout.c, and
is now in the handwritten libxl_dom.c.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Cc: Ian Campbell <ian.campbell@citrix.com>
---
 tools/libxl/libxl_dom.c            |   25 +++++++++++++++++++------
 tools/libxl/libxl_internal.h       |    2 +-
 tools/libxl/libxl_save_msgs_gen.pl |    2 +-
 3 files changed, 21 insertions(+), 8 deletions(-)

diff -r b90864157a67 -r 3143bed377a0 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c	Wed Nov 13 12:34:19 2013 -0800
+++ b/tools/libxl/libxl_dom.c	Wed Nov 13 12:35:58 2013 -0800
@@ -1003,10 +1003,8 @@ int libxl__domain_resume_device_model(li
     return 0;
 }
 
-int libxl__domain_suspend_common_callback(void *user)
+int libxl__domain_suspend_callback_common(libxl__domain_suspend_state *dss)
 {
-    libxl__save_helper_state *shs = user;
-    libxl__domain_suspend_state *dss = CONTAINER_OF(shs, *dss, shs);
     STATE_AO_GC(dss->ao);
     unsigned long hvm_s_state = 0, hvm_pvdrv = 0;
     int ret;
@@ -1225,12 +1223,27 @@ int libxl__toolstack_save(uint32_t domid
     return 0;
 }
 
+static void libxl__domain_suspend_callback(void *data)
+{
+    libxl__save_helper_state *shs = data;
+    libxl__egc *egc = shs->egc;
+    libxl__domain_suspend_state *dss = CONTAINER_OF(shs, *dss, shs);
+
+    int ok = libxl__domain_suspend_callback_common(dss);
+    libxl__xc_domain_saverestore_async_callback_done(egc, shs, ok);
+}
+
 /*----- remus callbacks -----*/
 
-static int libxl__remus_domain_suspend_callback(void *data)
+static void libxl__remus_domain_suspend_callback(void *data)
 {
+    libxl__save_helper_state *shs = data;
+    libxl__egc *egc = shs->egc;
+    libxl__domain_suspend_state *dss = CONTAINER_OF(shs, *dss, shs);
+
     /* REMUS TODO: Issue disk and network checkpoint reqs. */
-    return libxl__domain_suspend_common_callback(data);
+    int ok = libxl__domain_suspend_callback_common(dss);
+    libxl__xc_domain_saverestore_async_callback_done(egc, shs, ok);
 }
 
 static int libxl__remus_domain_resume_callback(void *data)
@@ -1354,7 +1367,7 @@ void libxl__domain_suspend(libxl__egc *e
         callbacks->postcopy = libxl__remus_domain_resume_callback;
         callbacks->checkpoint = libxl__remus_domain_checkpoint_callback;
     } else
-        callbacks->suspend = libxl__domain_suspend_common_callback;
+        callbacks->suspend = libxl__domain_suspend_callback;
 
     callbacks->switch_qemu_logdirty = libxl__domain_suspend_common_switch_qemu_logdirty;
     dss->shs.callbacks.save.toolstack_save = libxl__toolstack_save;
diff -r b90864157a67 -r 3143bed377a0 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h	Wed Nov 13 12:34:19 2013 -0800
+++ b/tools/libxl/libxl_internal.h	Wed Nov 13 12:35:58 2013 -0800
@@ -2597,7 +2597,7 @@ _hidden void libxl__xc_domain_save_done(
 void libxl__xc_domain_saverestore_async_callback_done(libxl__egc *egc,
                            libxl__save_helper_state *shs, int return_value);
 
-_hidden int libxl__domain_suspend_common_callback(void *data);
+_hidden int libxl__domain_suspend_callback_common(libxl__domain_suspend_state*);
 _hidden void libxl__domain_suspend_common_switch_qemu_logdirty
                                (int domid, unsigned int enable, void *data);
 _hidden int libxl__toolstack_save(uint32_t domid, uint8_t **buf,
diff -r b90864157a67 -r 3143bed377a0 tools/libxl/libxl_save_msgs_gen.pl
--- a/tools/libxl/libxl_save_msgs_gen.pl	Wed Nov 13 12:34:19 2013 -0800
+++ b/tools/libxl/libxl_save_msgs_gen.pl	Wed Nov 13 12:35:58 2013 -0800
@@ -23,7 +23,7 @@ our @msgs = (
                                                  STRING doing_what),
                                                 'unsigned long', 'done',
                                                 'unsigned long', 'total'] ],
-    [  3, 'scxW',   "suspend", [] ],         
+    [  3, 'scxA',   "suspend", [] ],         
     [  4, 'scxW',   "postcopy", [] ],        
     [  5, 'scxA',   "checkpoint", [] ],      
     [  6, 'scxA',   "switch_qemu_logdirty",  [qw(int domid

  reply	other threads:[~2013-11-15  5:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-15  5:47 [PATCH 0 of 7 V4] Remus/Libxl: Network buffering support Shriram Rajagopalan
2013-11-15  5:47 ` Shriram Rajagopalan [this message]
2013-11-15  5:47 ` [PATCH 2 of 7 V4] remus: add libnl3 dependency to autoconf scripts Shriram Rajagopalan
2013-11-18 16:31   ` Ian Jackson
2013-11-15  5:47 ` [PATCH 3 of 7 V4] tools/hotplug: Remus network buffering setup scripts Shriram Rajagopalan
2013-11-18 16:34   ` Ian Jackson
2013-11-15  5:47 ` [PATCH 4 of 7 V4] tools/libxl: setup/teardown Remus network buffering Shriram Rajagopalan
2013-11-15  5:47 ` [PATCH 5 of 7 V4] tools/libxl: Control network buffering in remus callbacks Shriram Rajagopalan
2013-11-15  5:47 ` [PATCH 6 of 7 V4] tools/xl: Remus - Network buffering cmdline switch Shriram Rajagopalan
2013-11-15  5:47 ` [PATCH 7 of 7 V4] tools/libxl: refactor domain_suspend_callback code to be fully asynchronous Shriram Rajagopalan
2013-11-15 18:27   ` Shriram Rajagopalan
2013-11-18 17:36   ` Shriram Rajagopalan
2013-11-18 17:45     ` Ian Jackson
2013-11-18 17:55       ` Shriram Rajagopalan
2013-11-18 17:49   ` Ian Jackson
2013-11-18 17:52     ` Shriram Rajagopalan
2013-11-18 13:13 ` [PATCH 0 of 7 V4] Remus/Libxl: Network buffering support Shriram Rajagopalan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3143bed377a08bb9e87c.1384494466@athos.nss.cs.ubc.ca \
    --to=rshriram@cs.ubc.ca \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).