ia64/xen-unstable

changeset 18854:2647c63be4cf

Do not request domain shutdown if in S3 state during domain save.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 03 15:12:19 2008 +0000 (2008-12-03)
parents cb526325927c
children 00a15b45cae3
files tools/xcutils/xc_save.c
line diff
     1.1 --- a/tools/xcutils/xc_save.c	Wed Dec 03 11:44:47 2008 +0000
     1.2 +++ b/tools/xcutils/xc_save.c	Wed Dec 03 15:12:19 2008 +0000
     1.3 @@ -24,8 +24,11 @@
     1.4  #include <xenguest.h>
     1.5  
     1.6  static struct suspendinfo {
     1.7 +    int xc_fd; /* libxc handle */
     1.8      int xce; /* event channel handle */
     1.9      int suspend_evtchn;
    1.10 +    int domid;
    1.11 +    unsigned int flags;
    1.12  } si;
    1.13  
    1.14  /**
    1.15 @@ -161,6 +164,19 @@ static int evtchn_suspend(void)
    1.16  
    1.17  static int suspend(void)
    1.18  {
    1.19 +    unsigned long sx_state = 0;
    1.20 +
    1.21 +    /* Nothing to do if the guest is in an ACPI sleep state. */
    1.22 +    if (si.flags & XCFLAGS_HVM)
    1.23 +        xc_get_hvm_param(si.xc_fd, si.domid,
    1.24 +                         HVM_PARAM_ACPI_S_STATE, &sx_state);
    1.25 +    if (sx_state != 0) {
    1.26 +        /* notify xend that it can do device migration */
    1.27 +        printf("suspended\n");
    1.28 +        fflush(stdout);
    1.29 +        return 1;
    1.30 +    }
    1.31 +
    1.32      if (si.suspend_evtchn >= 0)
    1.33          return evtchn_suspend();
    1.34  
    1.35 @@ -297,32 +313,32 @@ static void *init_qemu_maps(int domid, u
    1.36  int
    1.37  main(int argc, char **argv)
    1.38  {
    1.39 -    unsigned int domid, maxit, max_f, flags; 
    1.40 -    int xc_fd, io_fd, ret;
    1.41 +    unsigned int maxit, max_f;
    1.42 +    int io_fd, ret;
    1.43  
    1.44      if (argc != 6)
    1.45          errx(1, "usage: %s iofd domid maxit maxf flags", argv[0]);
    1.46  
    1.47 -    xc_fd = xc_interface_open();
    1.48 -    if (xc_fd < 0)
    1.49 +    si.xc_fd = xc_interface_open();
    1.50 +    if (si.xc_fd < 0)
    1.51          errx(1, "failed to open control interface");
    1.52  
    1.53      io_fd = atoi(argv[1]);
    1.54 -    domid = atoi(argv[2]);
    1.55 +    si.domid = atoi(argv[2]);
    1.56      maxit = atoi(argv[3]);
    1.57      max_f = atoi(argv[4]);
    1.58 -    flags = atoi(argv[5]);
    1.59 +    si.flags = atoi(argv[5]);
    1.60  
    1.61 -    if (suspend_evtchn_init(xc_fd, domid) < 0)
    1.62 +    if (suspend_evtchn_init(si.xc_fd, si.domid) < 0)
    1.63          warnx("suspend event channel initialization failed, using slow path");
    1.64  
    1.65 -    ret = xc_domain_save(xc_fd, io_fd, domid, maxit, max_f, flags, 
    1.66 -                         &suspend, !!(flags & XCFLAGS_HVM),
    1.67 +    ret = xc_domain_save(si.xc_fd, io_fd, si.domid, maxit, max_f, si.flags, 
    1.68 +                         &suspend, !!(si.flags & XCFLAGS_HVM),
    1.69                           &init_qemu_maps, &qemu_flip_buffer);
    1.70  
    1.71      suspend_evtchn_release();
    1.72  
    1.73 -    xc_interface_close(xc_fd);
    1.74 +    xc_interface_close(si.xc_fd);
    1.75  
    1.76      return ret;
    1.77  }