|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1 of 2] libxl: Remus - suspend/postflush/commit callbacks
# HG changeset patch
# User Shriram Rajagopalan <rshriram@xxxxxxxxx>
# Date 1327972786 28800
# Node ID 0129989da2cda789f86f2bc83d9c642a0bcebe60
# Parent ffc99e708e90eb140b0a6f2e7087d567e71e9d0f
libxl: Remus - suspend/postflush/commit callbacks
* Add libxl callback functions for Remus checkpoint suspend, postflush
(aka resume) and checkpoint commit callbacks.
* suspend callback is a stub that just bounces off
libxl__domain_suspend_common_callback - which suspends the domain and
saves the devices model state to a file.
* resume callback currently just resumes the domain (and the device model).
* commit callback just writes out the saved device model state to the
network and sleeps for the checkpoint interval.
* 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@xxxxxxxxx>
diff -r ffc99e708e90 -r 0129989da2cd tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Mon Jan 30 16:59:01 2012 -0800
+++ b/tools/libxl/libxl.c Mon Jan 30 17:19:46 2012 -0800
@@ -480,7 +480,9 @@ int libxl_domain_suspend(libxl_ctx *ctx,
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);
GC_FREE;
diff -r ffc99e708e90 -r 0129989da2cd tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Mon Jan 30 16:59:01 2012 -0800
+++ b/tools/libxl/libxl_dom.c Mon Jan 30 17:19:46 2012 -0800
@@ -404,6 +404,8 @@ struct suspendinfo {
int hvm;
unsigned int flags;
int guest_responded;
+ int save_fd; /* Migration stream fd (for Remus) */
+ int interval; /* checkpoint interval (for Remus) */
};
static int libxl__domain_suspend_common_switch_qemu_logdirty(int domid,
unsigned int enable, void *data)
@@ -609,9 +611,43 @@ static int libxl__domain_suspend_common_
return 1;
}
+static int libxl__remus_domain_suspend_callback(void *data)
+{
+ /* TODO: Issue disk and network checkpoint reqs. */
+ return libxl__domain_suspend_common_callback(data);
+}
+
+static int libxl__remus_domain_resume_callback(void *data)
+{
+ struct suspendinfo *si = data;
+ libxl_ctx *ctx = libxl__gc_owner(si->gc);
+
+ /* Resumes the domain and the device model */
+ if (libxl_domain_resume(ctx, si->domid, /* Fast Suspend */1))
+ return 0;
+
+ /* TODO: Deal with disk. Start a new network output buffer */
+ return 1;
+}
+
+static int libxl__remus_domain_checkpoint_callback(void *data)
+{
+ struct suspendinfo *si = data;
+
+ /* This would go into tailbuf. */
+ if (si->hvm &&
+ libxl__domain_save_device_model(si->gc, si->domid, si->save_fd))
+ return 0;
+
+ /* TODO: Wait for disk and memory ack, release network buffer */
+ 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;
@@ -642,10 +678,20 @@ int libxl__domain_suspend_common(libxl__
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;
@@ -669,7 +715,27 @@ int libxl__domain_suspend_common(libxl__
}
memset(&callbacks, 0, sizeof(callbacks));
- callbacks.suspend = libxl__domain_suspend_common_callback;
+ if (r_info != NULL) {
+ /* save_callbacks:
+ * suspend - called after expiration of checkpoint interval,
+ * to *suspend* the domain.
+ *
+ * postcopy - called after the domain's dirty pages have been
+ * copied into an output buffer. We *resume* the domain
+ * & the device model, return to the caller. Caller then
+ * flushes the output buffer, while the domain continues to
run.
+ *
+ * checkpoint - called after the memory checkpoint has been flushed out
+ * into the network. Send the saved device state, *wait*
+ * for checkpoint ack and *release* the network buffer
(TBD).
+ * Then *sleep* for the checkpoint interval.
+ */
+ 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 ffc99e708e90 -r 0129989da2cd tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Mon Jan 30 16:59:01 2012 -0800
+++ b/tools/libxl/libxl_internal.h Mon Jan 30 17:19:46 2012 -0800
@@ -275,7 +275,8 @@ _hidden int libxl__domain_restore_common
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_suspend_device_model(libxl__gc *gc, uint32_t domid);
_hidden int libxl__domain_resume_device_model(libxl__gc *gc, uint32_t domid);
diff -r ffc99e708e90 -r 0129989da2cd tools/libxl/libxl_types.idl
--- a/tools/libxl/libxl_types.idl Mon Jan 30 16:59:01 2012 -0800
+++ b/tools/libxl/libxl_types.idl Mon Jan 30 17:19:46 2012 -0800
@@ -397,3 +397,9 @@ libxl_sched_sedf = Struct("sched_sedf",
("extratime", integer),
("weight", integer),
], dispose_fn=None)
+
+libxl_domain_remus_info = Struct("domain_remus_info",[
+ ("interval", integer),
+ ("blackhole", bool),
+ ("compression", bool),
+ ])
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |