ia64/xen-unstable

changeset 15094:b6f9f1148273

Fix HVM save/restore after upgrade to 0.90.

Signed-off-by: Steven Hand <steven@xensource.com>
author Steven Hand <steven@xensource.com>
date Mon May 14 15:19:46 2007 +0100 (2007-05-14)
parents 9c2a616722da
children a605044ecb33
files tools/ioemu/vl.c
line diff
     1.1 --- a/tools/ioemu/vl.c	Mon May 14 15:16:32 2007 +0100
     1.2 +++ b/tools/ioemu/vl.c	Mon May 14 15:19:46 2007 +0100
     1.3 @@ -4891,6 +4891,77 @@ static int bdrv_snapshot_find(BlockDrive
     1.4      return ret;
     1.5  }
     1.6  
     1.7 +#ifdef CONFIG_DM
     1.8 +/* We use simpler state save/load functions for Xen */
     1.9 +void do_savevm(const char *name)
    1.10 +{
    1.11 +    QEMUFile *f;
    1.12 +    int saved_vm_running, ret;
    1.13 +
    1.14 +    f = qemu_fopen(name, "wb");
    1.15 +    
    1.16 +    /* ??? Should this occur after vm_stop?  */
    1.17 +    qemu_aio_flush();
    1.18 +
    1.19 +    saved_vm_running = vm_running;
    1.20 +    vm_stop(0);
    1.21 +
    1.22 +    if (!f) {
    1.23 +        fprintf(logfile, "Failed to open savevm file '%s'\n", name);
    1.24 +        goto the_end;
    1.25 +    }
    1.26 +    
    1.27 +    ret = qemu_savevm_state(f);
    1.28 +    qemu_fclose(f);
    1.29 +
    1.30 +    if (ret < 0)
    1.31 +        fprintf(logfile, "Error %d while writing VM to savevm file '%s'\n",
    1.32 +                ret, name);
    1.33 +
    1.34 + the_end:
    1.35 +    if (saved_vm_running)
    1.36 +        vm_start();
    1.37 +
    1.38 +    return;
    1.39 +}
    1.40 +void do_loadvm(const char *name)
    1.41 +{
    1.42 +    QEMUFile *f;
    1.43 +    int saved_vm_running, ret;
    1.44 +
    1.45 +    /* Flush all IO requests so they don't interfere with the new state.  */
    1.46 +    qemu_aio_flush();
    1.47 +
    1.48 +    saved_vm_running = vm_running;
    1.49 +    vm_stop(0);
    1.50 +
    1.51 +    /* restore the VM state */
    1.52 +    f = qemu_fopen(name, "rb");
    1.53 +    if (!f) {
    1.54 +        fprintf(logfile, "Could not open VM state file\n");
    1.55 +        goto the_end;
    1.56 +    }
    1.57 +
    1.58 +    ret = qemu_loadvm_state(f);
    1.59 +    qemu_fclose(f);
    1.60 +    if (ret < 0) {
    1.61 +        fprintf(logfile, "Error %d while loading savevm file '%s'\n",
    1.62 +                ret, name);
    1.63 +        goto the_end; 
    1.64 +    }
    1.65 +
    1.66 +#if 0 
    1.67 +    /* del tmp file */
    1.68 +    if (unlink(name) == -1)
    1.69 +        fprintf(stderr, "delete tmp qemu state file failed.\n");
    1.70 +#endif
    1.71 +
    1.72 +
    1.73 + the_end:
    1.74 +    if (saved_vm_running)
    1.75 +        vm_start();
    1.76 +}
    1.77 +#else 
    1.78  void do_savevm(const char *name)
    1.79  {
    1.80      BlockDriverState *bs, *bs1;
    1.81 @@ -5064,6 +5135,7 @@ void do_loadvm(const char *name)
    1.82      if (saved_vm_running)
    1.83          vm_start();
    1.84  }
    1.85 +#endif
    1.86  
    1.87  void do_delvm(const char *name)
    1.88  {