ia64/xen-unstable

changeset 15648:d9836851a2a4

[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@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Tue Jul 24 15:47:36 2007 +0100 (2007-07-24)
parents cc48264ed647
children 207582c8d88b
files tools/ioemu/target-i386-dm/helper2.c tools/ioemu/xenstore.c tools/xcutils/xc_save.c
line diff
     1.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Tue Jul 24 14:53:06 2007 +0100
     1.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Tue Jul 24 15:47:36 2007 +0100
     1.3 @@ -632,7 +632,6 @@ int main_loop(void)
     1.4              /* Wait up to 10 msec. */
     1.5              main_loop_wait(10);
     1.6  
     1.7 -        xenstore_record_dm_state("paused");
     1.8          fprintf(logfile, "device model saving state\n");
     1.9  
    1.10          /* Pull all outstanding ioreqs through the system */
    1.11 @@ -644,6 +643,8 @@ int main_loop(void)
    1.12                   "/var/lib/xen/qemu-save.%d", domid);
    1.13          do_savevm(qemu_file);
    1.14  
    1.15 +        xenstore_record_dm_state("paused");
    1.16 +
    1.17          /* Wait to be allowed to continue */
    1.18          while (suspend_requested) {
    1.19              FD_ZERO(&fds);
     2.1 --- a/tools/ioemu/xenstore.c	Tue Jul 24 14:53:06 2007 +0100
     2.2 +++ b/tools/ioemu/xenstore.c	Tue Jul 24 15:47:36 2007 +0100
     2.3 @@ -181,7 +181,8 @@ void xenstore_parse_domain_config(int do
     2.4      }
     2.5  
     2.6      /* Set a watch for log-dirty requests from the migration tools */
     2.7 -    if (pasprintf(&buf, "%s/logdirty/next-active", path) != -1) {
     2.8 +    if (pasprintf(&buf, "/local/domain/0/device-model/%u/logdirty/next-active",
     2.9 +                  domid) != -1) {
    2.10          xs_watch(xsh, buf, "logdirty");
    2.11          fprintf(logfile, "Watching %s\n", buf);
    2.12      }
    2.13 @@ -224,33 +225,26 @@ void xenstore_process_logdirty_event(voi
    2.14      unsigned int len;
    2.15      int i;
    2.16  
    2.17 -    fprintf(logfile, "Triggered log-dirty buffer switch\n");
    2.18 -
    2.19      if (!seg) {
    2.20 -        char *path, *p, *key_ascii, key_terminated[17] = {0,};
    2.21 +        char *path = NULL, *key_ascii, key_terminated[17] = {0,};
    2.22          key_t key;
    2.23          int shmid;
    2.24  
    2.25          /* Find and map the shared memory segment for log-dirty bitmaps */
    2.26 -        if (!(path = xs_get_domain_path(xsh, domid))) {            
    2.27 -            fprintf(logfile, "Log-dirty: can't get domain path in store\n");
    2.28 -            exit(1);
    2.29 -        }
    2.30 -        if (!(path = realloc(path, strlen(path) 
    2.31 -                             + strlen("/logdirty/next-active") + 1))) {
    2.32 +        if (pasprintf(&path, 
    2.33 +                      "/local/domain/0/device-model/%u/logdirty/key", 
    2.34 +                      domid) == -1) {
    2.35              fprintf(logfile, "Log-dirty: out of memory\n");
    2.36              exit(1);
    2.37          }
    2.38 -        strcat(path, "/logdirty/");
    2.39 -        p = path + strlen(path);
    2.40 -        strcpy(p, "key");
    2.41          
    2.42          key_ascii = xs_read(xsh, XBT_NULL, path, &len);
    2.43 -        if (!key_ascii) {
    2.44 +        free(path);
    2.45 +
    2.46 +        if (!key_ascii) 
    2.47              /* No key yet: wait for the next watch */
    2.48 -            free(path);
    2.49              return;
    2.50 -        }
    2.51 +
    2.52          strncpy(key_terminated, key_ascii, 16);
    2.53          free(key_ascii);
    2.54          key = (key_t) strtoull(key_terminated, NULL, 16);
    2.55 @@ -282,18 +276,21 @@ void xenstore_process_logdirty_event(voi
    2.56          }
    2.57  
    2.58          /* Remember the paths for the next-active and active entries */
    2.59 -        strcpy(p, "active");
    2.60 -        if (!(active_path = strdup(path))) {
    2.61 +        if (pasprintf(&active_path, 
    2.62 +                      "/local/domain/0/device-model/%u/logdirty/active",
    2.63 +                      domid) == -1) {
    2.64              fprintf(logfile, "Log-dirty: out of memory\n");
    2.65              exit(1);
    2.66          }
    2.67 -        strcpy(p, "next-active");
    2.68 -        if (!(next_active_path = strdup(path))) {
    2.69 +        if (pasprintf(&next_active_path, 
    2.70 +                      "/local/domain/0/device-model/%u/logdirty/next-active",
    2.71 +                      domid) == -1) {
    2.72              fprintf(logfile, "Log-dirty: out of memory\n");
    2.73              exit(1);
    2.74          }
    2.75 -        free(path);
    2.76      }
    2.77 +
    2.78 +    fprintf(logfile, "Triggered log-dirty buffer switch\n");
    2.79      
    2.80      /* Read the required active buffer from the store */
    2.81      act = xs_read(xsh, XBT_NULL, next_active_path, &len);
     3.1 --- a/tools/xcutils/xc_save.c	Tue Jul 24 14:53:06 2007 +0100
     3.2 +++ b/tools/xcutils/xc_save.c	Tue Jul 24 15:47:36 2007 +0100
     3.3 @@ -123,11 +123,13 @@ static void * init_qemu_maps(int domid, 
     3.4      /* Tell qemu about it */
     3.5      if ((xs = xs_daemon_open()) == NULL)
     3.6          errx(1, "Couldn't contact xenstore");
     3.7 -    if (!(path = xs_get_domain_path(xs, domid)))
     3.8 +    if (!(path = strdup("/local/domain/0/device-model/")))
     3.9          errx(1, "can't get domain path in store");
    3.10      if (!(path = realloc(path, strlen(path) 
    3.11 +                         + 10 
    3.12                           + strlen("/logdirty/next-active") + 1))) 
    3.13          errx(1, "no memory for constructing xenstore path");
    3.14 +    snprintf(path + strlen(path), 11, "%i", domid);
    3.15      strcat(path, "/logdirty/");
    3.16      p = path + strlen(path);
    3.17