# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
# Date 1185288456 -3600
# Node ID d9836851a2a4cf6e506f6a8e162a4c90c9f87d82
# Parent cc48264ed64742a7c57704948ea04dcad438a015
[HVM] Live-migration fixups after 15639:c585f993385c
Use the same xenstore area for log-dirty commands as for save/continue,
and avoid a race condition by acking the save command after the save.
Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>
---
tools/ioemu/target-i386-dm/helper2.c | 3 +-
tools/ioemu/xenstore.c | 41 ++++++++++++++++-------------------
tools/xcutils/xc_save.c | 4 ++-
3 files changed, 24 insertions(+), 24 deletions(-)
diff -r cc48264ed647 -r d9836851a2a4 tools/ioemu/target-i386-dm/helper2.c
--- a/tools/ioemu/target-i386-dm/helper2.c Tue Jul 24 14:53:06 2007 +0100
+++ b/tools/ioemu/target-i386-dm/helper2.c Tue Jul 24 15:47:36 2007 +0100
@@ -632,7 +632,6 @@ int main_loop(void)
/* Wait up to 10 msec. */
main_loop_wait(10);
- xenstore_record_dm_state("paused");
fprintf(logfile, "device model saving state\n");
/* Pull all outstanding ioreqs through the system */
@@ -643,6 +642,8 @@ int main_loop(void)
snprintf(qemu_file, sizeof(qemu_file),
"/var/lib/xen/qemu-save.%d", domid);
do_savevm(qemu_file);
+
+ xenstore_record_dm_state("paused");
/* Wait to be allowed to continue */
while (suspend_requested) {
diff -r cc48264ed647 -r d9836851a2a4 tools/ioemu/xenstore.c
--- a/tools/ioemu/xenstore.c Tue Jul 24 14:53:06 2007 +0100
+++ b/tools/ioemu/xenstore.c Tue Jul 24 15:47:36 2007 +0100
@@ -181,7 +181,8 @@ void xenstore_parse_domain_config(int do
}
/* Set a watch for log-dirty requests from the migration tools */
- if (pasprintf(&buf, "%s/logdirty/next-active", path) != -1) {
+ if (pasprintf(&buf, "/local/domain/0/device-model/%u/logdirty/next-active",
+ domid) != -1) {
xs_watch(xsh, buf, "logdirty");
fprintf(logfile, "Watching %s\n", buf);
}
@@ -224,33 +225,26 @@ void xenstore_process_logdirty_event(voi
unsigned int len;
int i;
- fprintf(logfile, "Triggered log-dirty buffer switch\n");
-
if (!seg) {
- char *path, *p, *key_ascii, key_terminated[17] = {0,};
+ char *path = NULL, *key_ascii, key_terminated[17] = {0,};
key_t key;
int shmid;
/* Find and map the shared memory segment for log-dirty bitmaps */
- if (!(path = xs_get_domain_path(xsh, domid))) {
- fprintf(logfile, "Log-dirty: can't get domain path in store\n");
- exit(1);
- }
- if (!(path = realloc(path, strlen(path)
- + strlen("/logdirty/next-active") + 1))) {
+ if (pasprintf(&path,
+ "/local/domain/0/device-model/%u/logdirty/key",
+ domid) == -1) {
fprintf(logfile, "Log-dirty: out of memory\n");
exit(1);
}
- strcat(path, "/logdirty/");
- p = path + strlen(path);
- strcpy(p, "key");
key_ascii = xs_read(xsh, XBT_NULL, path, &len);
- if (!key_ascii) {
+ free(path);
+
+ if (!key_ascii)
/* No key yet: wait for the next watch */
- free(path);
return;
- }
+
strncpy(key_terminated, key_ascii, 16);
free(key_ascii);
key = (key_t) strtoull(key_terminated, NULL, 16);
@@ -282,18 +276,21 @@ void xenstore_process_logdirty_event(voi
}
/* Remember the paths for the next-active and active entries */
- strcpy(p, "active");
- if (!(active_path = strdup(path))) {
+ if (pasprintf(&active_path,
+ "/local/domain/0/device-model/%u/logdirty/active",
+ domid) == -1) {
fprintf(logfile, "Log-dirty: out of memory\n");
exit(1);
}
- strcpy(p, "next-active");
- if (!(next_active_path = strdup(path))) {
+ if (pasprintf(&next_active_path,
+ "/local/domain/0/device-model/%u/logdirty/next-active",
+ domid) == -1) {
fprintf(logfile, "Log-dirty: out of memory\n");
exit(1);
}
- free(path);
- }
+ }
+
+ fprintf(logfile, "Triggered log-dirty buffer switch\n");
/* Read the required active buffer from the store */
act = xs_read(xsh, XBT_NULL, next_active_path, &len);
diff -r cc48264ed647 -r d9836851a2a4 tools/xcutils/xc_save.c
--- a/tools/xcutils/xc_save.c Tue Jul 24 14:53:06 2007 +0100
+++ b/tools/xcutils/xc_save.c Tue Jul 24 15:47:36 2007 +0100
@@ -123,11 +123,13 @@ static void * init_qemu_maps(int domid,
/* Tell qemu about it */
if ((xs = xs_daemon_open()) == NULL)
errx(1, "Couldn't contact xenstore");
- if (!(path = xs_get_domain_path(xs, domid)))
+ if (!(path = strdup("/local/domain/0/device-model/")))
errx(1, "can't get domain path in store");
if (!(path = realloc(path, strlen(path)
+ + 10
+ strlen("/logdirty/next-active") + 1)))
errx(1, "no memory for constructing xenstore path");
+ snprintf(path + strlen(path), 11, "%i", domid);
strcat(path, "/logdirty/");
p = path + strlen(path);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|