|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/3] libxc: add a callback to xc_domain_restore
Introduce a callback argument to xc_domain_restore, so that the caller
can restore the Qemu state file by itself.
If the callback is NULL, libxc will take care of dumping the qemu
state file as usual.
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
tools/libxc/xc_domain_restore.c | 19 ++++++++++++++-----
tools/libxc/xenguest.h | 17 ++++++++++++++---
tools/libxl/libxl_dom.c | 2 +-
tools/xcutils/xc_restore.c | 3 ++-
4 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c
index 14451d1..fdc3483 100644
--- a/tools/libxc/xc_domain_restore.c
+++ b/tools/libxc/xc_domain_restore.c
@@ -1248,7 +1248,8 @@ static int apply_batch(xc_interface *xch, uint32_t dom,
struct restore_ctx *ctx,
int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
unsigned int store_evtchn, unsigned long *store_mfn,
unsigned int console_evtchn, unsigned long *console_mfn,
- unsigned int hvm, unsigned int pae, int superpages)
+ unsigned int hvm, unsigned int pae, int superpages,
+ struct restore_callbacks* callbacks)
{
DECLARE_DOMCTL;
int rc = 1, frc, i, j, n, m, pae_extended_cr3 = 0, ext_vcpucontext = 0;
@@ -1976,10 +1977,18 @@ int xc_domain_restore(xc_interface *xch, int io_fd,
uint32_t dom,
goto out;
finish_hvm:
- /* Dump the QEMU state to a state file for QEMU to load */
- if ( dump_qemu(xch, dom, &tailbuf.u.hvm) ) {
- PERROR("Error dumping QEMU state to file");
- goto out;
+ if (callbacks == NULL || callbacks->extract_qemu_savestate == NULL) {
+ /* Dump the QEMU state to a state file for QEMU to load */
+ if ( dump_qemu(xch, dom, &tailbuf.u.hvm) ) {
+ PERROR("Error dumping QEMU state to file");
+ goto out;
+ }
+ } else {
+ if ( callbacks->extract_qemu_savestate(tailbuf.u.hvm.qemubuf,
+ tailbuf.u.hvm.qemubufsize, callbacks->data) ) {
+ PERROR("Error calling extract_qemu_savestate");
+ goto out;
+ }
}
/* These comms pages need to be zeroed at the start of day */
diff --git a/tools/libxc/xenguest.h b/tools/libxc/xenguest.h
index 4475ee9..9447412 100644
--- a/tools/libxc/xenguest.h
+++ b/tools/libxc/xenguest.h
@@ -61,6 +61,15 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t
dom, uint32_t max_iter
struct save_callbacks* callbacks, int hvm);
+/* callbacks provided by xc_domain_restore */
+struct restore_callbacks {
+ /* callback to extract the qemu save state */
+ int (*extract_qemu_savestate)(uint8_t *buf, uint32_t size, void* data);
+
+ /* to be provided as the last argument to each callback function */
+ void* data;
+};
+
/**
* This function will restore a saved domain.
*
@@ -72,15 +81,17 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t
dom, uint32_t max_iter
* @parm hvm non-zero if this is a HVM restore
* @parm pae non-zero if this HVM domain has PAE support enabled
* @parm superpages non-zero to allocate guest memory with superpages
+ * @parm callbacks non-NULL to receive a callback to extract the qemu state
* @return 0 on success, -1 on failure
*/
int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
unsigned int store_evtchn, unsigned long *store_mfn,
unsigned int console_evtchn, unsigned long *console_mfn,
- unsigned int hvm, unsigned int pae, int superpages);
+ unsigned int hvm, unsigned int pae, int superpages,
+ struct restore_callbacks *callbacks);
/**
- * xc_domain_restore writes a file to disk that contains the device
- * model saved state.
+ * If callbacks is NULL, xc_domain_restore writes a file to disk that
+ * contains the device model saved state.
* The pathname of this file is XC_DEVICE_MODEL_RESTORE_FILE; The domid
* of the new domain is automatically appended to the filename,
* separated by a ".".
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index c898d89..fd2b051 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -373,7 +373,7 @@ int libxl__domain_restore_common(libxl__gc *gc, uint32_t
domid,
rc = xc_domain_restore(ctx->xch, fd, domid,
state->store_port, &state->store_mfn,
state->console_port, &state->console_mfn,
- hvm, pae, superpages);
+ hvm, pae, superpages, NULL);
if ( rc ) {
LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "restoring domain");
return ERROR_FAIL;
diff --git a/tools/xcutils/xc_restore.c b/tools/xcutils/xc_restore.c
index 985cbec..eb1d31c 100644
--- a/tools/xcutils/xc_restore.c
+++ b/tools/xcutils/xc_restore.c
@@ -46,7 +46,8 @@ main(int argc, char **argv)
superpages = !!hvm;
ret = xc_domain_restore(xch, io_fd, domid, store_evtchn, &store_mfn,
- console_evtchn, &console_mfn, hvm, pae,
superpages);
+ console_evtchn, &console_mfn, hvm, pae, superpages,
+ NULL);
if ( ret == 0 )
{
--
1.7.2.5
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |