From: rshriram@cs.ubc.ca
To: xen-devel@lists.xensource.com
Cc: brendan@cs.ubc.ca, ian.jackson@eu.citrix.com
Subject: [PATCH 2 of 3] tools/libxl: suspend/postflush/commit callbacks
Date: Mon, 23 Jan 2012 14:46:27 -0800 [thread overview]
Message-ID: <0446591bee86eb4e767d.1327358787@athos.nss.cs.ubc.ca> (raw)
In-Reply-To: <patchbomb.1327358785@athos.nss.cs.ubc.ca>
# HG changeset patch
# User Shriram Rajagopalan <rshriram@cs.ubc.ca>
# Date 1327358640 28800
# Node ID 0446591bee86eb4e767d75b70c885549c7a3cfef
# Parent 11fb1dfda7de4d6759dec87d80cd16cf137f7369
tools/libxl: suspend/postflush/commit callbacks
* Add libxl callbacks for Remus checkpoint suspend, postflush (aka resume)
and checkpoint commit callbacks.
* suspend callback just bounces off libxl__domain_suspend_common_callback
* resume callback directly calls xc_domain_resume instead of re-using
libxl_domain_resume (as the latter does not set the fast suspend argument
to xc_domain_resume - aka suspend_cancel support).
* commit callback just sleeps for the checkpoint interval (for the moment).
* Future patches will augument these callbacks with more functionalities like
issuing network buffer plug/unplug commands, disk checkpoint commands, etc.
Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
diff -r 11fb1dfda7de -r 0446591bee86 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Mon Jan 23 14:43:58 2012 -0800
+++ b/tools/libxl/libxl.c Mon Jan 23 14:44:00 2012 -0800
@@ -475,7 +475,9 @@
int debug = info != NULL && info->flags & XL_SUSPEND_DEBUG;
int rc = 0;
- rc = libxl__domain_suspend_common(gc, domid, fd, type, live, debug);
+ rc = libxl__domain_suspend_common(gc, domid, fd, type, live, debug,
+ /* No Remus */ NULL);
+
if (!rc && type == LIBXL_DOMAIN_TYPE_HVM)
rc = libxl__domain_save_device_model(gc, domid, fd, /* No Remus */ 0);
GC_FREE;
diff -r 11fb1dfda7de -r 0446591bee86 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Mon Jan 23 14:43:58 2012 -0800
+++ b/tools/libxl/libxl.h Mon Jan 23 14:44:00 2012 -0800
@@ -212,6 +212,12 @@
int (*suspend_callback)(void *, int);
} libxl_domain_suspend_info;
+typedef struct {
+ int interval;
+ int blackhole;
+ int compression;
+} libxl_domain_remus_info;
+
enum {
ERROR_NONSPECIFIC = -1,
ERROR_VERSION = -2,
diff -r 11fb1dfda7de -r 0446591bee86 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Mon Jan 23 14:43:58 2012 -0800
+++ b/tools/libxl/libxl_dom.c Mon Jan 23 14:44:00 2012 -0800
@@ -395,6 +395,8 @@
int hvm;
unsigned int flags;
int guest_responded;
+ int save_fd; /* Migration stream fd (for Remus) */
+ int interval; /* remus checkpoint interval */
};
static int libxl__domain_suspend_common_switch_qemu_logdirty(int domid, unsigned int enable, void *data)
@@ -581,9 +583,69 @@
return 0;
}
+static int libxl__remus_domain_suspend_callback(void *data)
+{
+ struct suspendinfo *si = data;
+
+ if (libxl__domain_suspend_common_callback(data)) {
+ if (si->hvm) {
+ if (!libxl__remus_domain_suspend_qemu(si->gc, si->domid))
+ return 1;
+ else
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+static int libxl__remus_domain_resume_callback(void *data)
+{
+ struct suspendinfo *si = data;
+ libxl_ctx *ctx = libxl__gc_owner(si->gc);
+
+ /* Assumes that SUSPEND_CANCEL is available - just like
+ * xm version of Remus. Without that, remus wont work.
+ * Since libxl_domain_resume calls xc_domain_resume with
+ * fast_suspend = 0, we cant re-use that api.
+ */
+ if (xc_domain_resume(ctx->xch, si->domid, 1)) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+ "xc_domain_resume failed for domain %u",
+ si->domid);
+ return 0;
+ }
+ if (!xs_resume_domain(ctx->xsh, si->domid)) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+ "xs_resume_domain failed for domain %u",
+ si->domid);
+ return 0;
+ }
+
+ if (si->hvm) {
+ if (libxl__remus_domain_resume_qemu(si->gc, si->domid))
+ return 0;
+ }
+ return 1;
+}
+
+/* For now, just sleep. Later, we need to release disk/netbuf */
+static int libxl__remus_domain_checkpoint_callback(void *data)
+{
+ struct suspendinfo *si = data;
+
+ if (si->hvm && libxl__domain_save_device_model(si->gc, si->domid,
+ si->save_fd, 1))
+ return 0;
+
+ usleep(si->interval * 1000);
+ return 1;
+}
+
int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd,
libxl_domain_type type,
- int live, int debug)
+ int live, int debug,
+ const libxl_domain_remus_info *r_info)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
int flags;
@@ -614,10 +676,20 @@
return ERROR_INVAL;
}
+ memset(&si, 0, sizeof(si));
flags = (live) ? XCFLAGS_LIVE : 0
| (debug) ? XCFLAGS_DEBUG : 0
| (hvm) ? XCFLAGS_HVM : 0;
+ if (r_info != NULL) {
+ si.interval = r_info->interval;
+ if (r_info->compression)
+ flags |= XCFLAGS_CHECKPOINT_COMPRESS;
+ si.save_fd = fd;
+ }
+ else
+ si.save_fd = -1;
+
si.domid = domid;
si.flags = flags;
si.hvm = hvm;
@@ -641,7 +713,13 @@
}
memset(&callbacks, 0, sizeof(callbacks));
- callbacks.suspend = libxl__domain_suspend_common_callback;
+ if (r_info != NULL) {
+ callbacks.suspend = libxl__remus_domain_suspend_callback;
+ callbacks.postcopy = libxl__remus_domain_resume_callback;
+ callbacks.checkpoint = libxl__remus_domain_checkpoint_callback;
+ } else
+ callbacks.suspend = libxl__domain_suspend_common_callback;
+
callbacks.switch_qemu_logdirty = libxl__domain_suspend_common_switch_qemu_logdirty;
callbacks.data = &si;
diff -r 11fb1dfda7de -r 0446591bee86 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Mon Jan 23 14:43:58 2012 -0800
+++ b/tools/libxl/libxl_internal.h Mon Jan 23 14:44:00 2012 -0800
@@ -272,7 +272,8 @@
int fd);
_hidden int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd,
libxl_domain_type type,
- int live, int debug);
+ int live, int debug,
+ const libxl_domain_remus_info *r_info);
_hidden const char *libxl__device_model_savefile(libxl__gc *gc, uint32_t domid);
_hidden int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int fd,
int remus);
next prev parent reply other threads:[~2012-01-23 22:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-23 22:46 [PATCH 0 of 3] Remus - libxl support rshriram
2012-01-23 22:46 ` [PATCH 1 of 3] tools/libxl: QEMU device model suspend/resume rshriram
2012-01-25 11:08 ` Ian Campbell
2012-01-25 23:07 ` Shriram Rajagopalan
2012-01-26 9:18 ` Ian Campbell
2012-01-23 22:46 ` rshriram [this message]
2012-01-25 11:22 ` [PATCH 2 of 3] tools/libxl: suspend/postflush/commit callbacks Ian Campbell
2012-01-25 23:15 ` Shriram Rajagopalan
2012-01-26 9:23 ` Ian Campbell
2012-01-23 22:46 ` [PATCH 3 of 3] tools/libxl: xl remus/remus-receive commands rshriram
2012-01-25 11:52 ` Ian Campbell
2012-01-26 0:09 ` Shriram Rajagopalan
2012-01-26 10:37 ` Ian Campbell
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=0446591bee86eb4e767d.1327358787@athos.nss.cs.ubc.ca \
--to=rshriram@cs.ubc.ca \
--cc=brendan@cs.ubc.ca \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).