From: rshriram@cs.ubc.ca
To: xen-devel@lists.xensource.com
Cc: brendan@cs.ubc.ca, ian.jackson@eu.citrix.com
Subject: [PATCH 1 of 3] tools/libxl: QEMU device model suspend/resume
Date: Mon, 23 Jan 2012 14:46:26 -0800 [thread overview]
Message-ID: <11fb1dfda7de4d6759de.1327358786@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 1327358638 28800
# Node ID 11fb1dfda7de4d6759dec87d80cd16cf137f7369
# Parent 80fdf2182bc62ca358ba2f1a3513b47a4f8d9dfd
tools/libxl: QEMU device model suspend/resume
* Refactor the libxl__domain_save_device_model.
* Add support for suspend/resume QEMU device model
(both traditional xen and QMP).
Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
diff -r 80fdf2182bc6 -r 11fb1dfda7de tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Sat Jan 21 17:15:40 2012 +0000
+++ b/tools/libxl/libxl.c Mon Jan 23 14:43:58 2012 -0800
@@ -477,7 +477,7 @@
rc = libxl__domain_suspend_common(gc, domid, fd, type, live, debug);
if (!rc && type == LIBXL_DOMAIN_TYPE_HVM)
- rc = libxl__domain_save_device_model(gc, domid, fd);
+ rc = libxl__domain_save_device_model(gc, domid, fd, /* No Remus */ 0);
GC_FREE;
return rc;
}
diff -r 80fdf2182bc6 -r 11fb1dfda7de tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Sat Jan 21 17:15:40 2012 +0000
+++ b/tools/libxl/libxl_dom.c Mon Jan 23 14:43:58 2012 -0800
@@ -534,6 +534,53 @@
return 0;
}
+static int libxl__remus_domain_suspend_qemu(libxl__gc *gc, uint32_t domid)
+{
+
+ switch (libxl__device_model_version_running(gc, domid)) {
+ case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
+ char *path = NULL;
+ path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command",
+ domid);
+ libxl__xs_write(gc, XBT_NULL, path, "save");
+ libxl__wait_for_device_model(gc, domid, "paused", NULL, NULL, NULL);
+ break;
+ }
+ case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+ /* Stop QEMU */
+ if (libxl__qmp_stop(gc, domid))
+ return ERROR_FAIL;
+ break;
+ default:
+ return ERROR_INVAL;
+ }
+
+ return 0;
+}
+
+static int libxl__remus_domain_resume_qemu(libxl__gc *gc, uint32_t domid)
+{
+
+ switch (libxl__device_model_version_running(gc, domid)) {
+ case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
+ char *path = NULL;
+ path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command",
+ domid);
+ libxl__xs_write(gc, XBT_NULL, path, "continue");
+ break;
+ }
+ case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
+ /* Stop QEMU */
+ if (libxl__qmp_resume(gc, domid))
+ return ERROR_FAIL;
+ break;
+ default:
+ return ERROR_INVAL;
+ }
+
+ return 0;
+}
+
int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd,
libxl_domain_type type,
int live, int debug)
@@ -620,7 +667,7 @@
return rc;
}
-int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int fd)
+int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int fd, int remus)
{
libxl_ctx *ctx = libxl__gc_owner(gc);
int ret, fd2 = -1, c;
@@ -631,13 +678,12 @@
switch (libxl__device_model_version_running(gc, domid)) {
case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
- char *path = NULL;
- LIBXL__LOG(ctx, LIBXL__LOG_DEBUG,
- "Saving device model state to %s", filename);
- path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/command",
- domid);
- libxl__xs_write(gc, XBT_NULL, path, "save");
- libxl__wait_for_device_model(gc, domid, "paused", NULL, NULL, NULL);
+ /* For Remus,we issue suspend_qemu call separately */
+ if (!remus) {
+ c = libxl__remus_domain_suspend_qemu(gc, domid);
+ if (c)
+ return c;
+ }
break;
}
case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN:
@@ -668,8 +714,9 @@
qemu_state_len = st.st_size;
LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Qemu state is %d bytes\n", qemu_state_len);
- ret = libxl_write_exactly(ctx, fd, QEMU_SIGNATURE, strlen(QEMU_SIGNATURE),
- "saved-state file", "qemu signature");
+ ret = libxl_write_exactly(ctx, fd, remus ? REMUS_QEMU_SIGNATURE : QEMU_SIGNATURE,
+ remus ? strlen(REMUS_QEMU_SIGNATURE): strlen(QEMU_SIGNATURE),
+ "saved-state file", "qemu signature");
if (ret)
goto out;
diff -r 80fdf2182bc6 -r 11fb1dfda7de tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Sat Jan 21 17:15:40 2012 +0000
+++ b/tools/libxl/libxl_internal.h Mon Jan 23 14:43:58 2012 -0800
@@ -73,6 +73,7 @@
#define LIBXL_HVM_EXTRA_MEMORY 2048
#define LIBXL_MIN_DOM0_MEM (128*1024)
#define QEMU_SIGNATURE "DeviceModelRecord0002"
+#define REMUS_QEMU_SIGNATURE "RemusDeviceModelState"
#define STUBDOM_CONSOLE_LOGGING 0
#define STUBDOM_CONSOLE_SAVE 1
#define STUBDOM_CONSOLE_RESTORE 2
@@ -273,7 +274,8 @@
libxl_domain_type type,
int live, int debug);
_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);
+_hidden int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int fd,
+ int remus);
_hidden void libxl__userdata_destroyall(libxl__gc *gc, uint32_t domid);
_hidden int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid);
@@ -616,6 +618,10 @@
_hidden int libxl__qmp_pci_add(libxl__gc *gc, int d, libxl_device_pci *pcidev);
_hidden int libxl__qmp_pci_del(libxl__gc *gc, int domid,
libxl_device_pci *pcidev);
+/* Suspend QEMU. */
+_hidden int libxl__qmp_stop(libxl__gc *gc, int domid);
+/* Resume QEMU. */
+_hidden int libxl__qmp_resume(libxl__gc *gc, int domid);
/* Save current QEMU state into fd. */
_hidden int libxl__qmp_migrate(libxl__gc *gc, int domid, int fd);
/* close and free the QMP handler */
diff -r 80fdf2182bc6 -r 11fb1dfda7de tools/libxl/libxl_qmp.c
--- a/tools/libxl/libxl_qmp.c Sat Jan 21 17:15:40 2012 +0000
+++ b/tools/libxl/libxl_qmp.c Mon Jan 23 14:43:58 2012 -0800
@@ -878,6 +878,38 @@
return rc;
}
+int libxl__qmp_stop(libxl__gc *gc, int domid)
+{
+ libxl__qmp_handler *qmp = NULL;
+ int rc = 0;
+
+ qmp = libxl__qmp_initialize(libxl__gc_owner(gc), domid);
+ if (!qmp)
+ return ERROR_FAIL;
+
+ rc = qmp_synchronous_send(qmp, "stop", NULL,
+ NULL, NULL, qmp->timeout);
+
+ libxl__qmp_close(qmp);
+ return rc;
+}
+
+int libxl__qmp_resume(libxl__gc *gc, int domid)
+{
+ libxl__qmp_handler *qmp = NULL;
+ int rc = 0;
+
+ qmp = libxl__qmp_initialize(libxl__gc_owner(gc), domid);
+ if (!qmp)
+ return ERROR_FAIL;
+
+ rc = qmp_synchronous_send(qmp, "cont", NULL,
+ NULL, NULL, qmp->timeout);
+
+ libxl__qmp_close(qmp);
+ return rc;
+}
+
int libxl__qmp_initializations(libxl_ctx *ctx, uint32_t domid)
{
libxl__qmp_handler *qmp = NULL;
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 ` rshriram [this message]
2012-01-25 11:08 ` [PATCH 1 of 3] tools/libxl: QEMU device model suspend/resume Ian Campbell
2012-01-25 23:07 ` Shriram Rajagopalan
2012-01-26 9:18 ` Ian Campbell
2012-01-23 22:46 ` [PATCH 2 of 3] tools/libxl: suspend/postflush/commit callbacks rshriram
2012-01-25 11:22 ` 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=11fb1dfda7de4d6759de.1327358786@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).