ia64/xen-unstable

changeset 13769:54678a99e102

[HVM] Save/restore: save shared-info pfn and re-map it on restore
In the short term this allows us to save the same domain more than once.
Longer-term some more careful shared-info management will be needed.

Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Wed Jan 31 12:23:35 2007 +0000 (2007-01-31)
parents d653e4bcead0
children 7c992fd3b19b 5e66c05c67ad
files tools/libxc/xc_hvm_restore.c tools/libxc/xc_hvm_save.c
line diff
     1.1 --- a/tools/libxc/xc_hvm_restore.c	Wed Jan 31 10:44:21 2007 +0000
     1.2 +++ b/tools/libxc/xc_hvm_restore.c	Wed Jan 31 12:23:35 2007 +0000
     1.3 @@ -98,6 +98,8 @@ int xc_hvm_restore(int xc_handle, int io
     1.4      /* Types of the pfns in the current region */
     1.5      unsigned long region_pfn_type[MAX_BATCH_SIZE];
     1.6  
     1.7 +    struct xen_add_to_physmap xatp;
     1.8 +
     1.9      /* hvm guest mem size (Mb) */
    1.10      memsize = (unsigned long long)*store_mfn;
    1.11      v_end = memsize << 20;
    1.12 @@ -134,15 +136,6 @@ int xc_hvm_restore(int xc_handle, int io
    1.13          goto out;
    1.14      }
    1.15  
    1.16 -    /* Get the domain's shared-info frame. */
    1.17 -    domctl.cmd = XEN_DOMCTL_getdomaininfo;
    1.18 -    domctl.domain = (domid_t)dom;
    1.19 -    if (xc_domctl(xc_handle, &domctl) < 0) {
    1.20 -        ERROR("Could not get information on new domain");
    1.21 -        goto out;
    1.22 -    }
    1.23 -    shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
    1.24 -
    1.25      if(xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_pfn)) != 0) {
    1.26          errno = ENOMEM;
    1.27          goto out;
    1.28 @@ -346,6 +339,21 @@ int xc_hvm_restore(int xc_handle, int io
    1.29          }
    1.30      }
    1.31  
    1.32 +    /* Shared-info pfn */
    1.33 +    if (!read_exact(io_fd, &(shared_info_frame), sizeof(uint32_t)) ) {
    1.34 +        ERROR("reading the shared-info pfn failed!\n");
    1.35 +        goto out;
    1.36 +    }
    1.37 +    /* Map the shared-info frame where it was before */
    1.38 +    xatp.domid = dom;
    1.39 +    xatp.space = XENMAPSPACE_shared_info;
    1.40 +    xatp.idx   = 0;
    1.41 +    xatp.gpfn  = shared_info_frame;
    1.42 +    if ( (rc = xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp)) != 0 ) {
    1.43 +        ERROR("setting the shared-info pfn failed!\n");
    1.44 +        goto out;
    1.45 +    }
    1.46 +
    1.47      rc = 0;
    1.48      goto out;
    1.49  
     2.1 --- a/tools/libxc/xc_hvm_save.c	Wed Jan 31 10:44:21 2007 +0000
     2.2 +++ b/tools/libxc/xc_hvm_save.c	Wed Jan 31 12:23:35 2007 +0000
     2.3 @@ -702,6 +702,12 @@ int xc_hvm_save(int xc_handle, int io_fd
     2.4              goto out;
     2.5          }
     2.6      }
     2.7 +
     2.8 +    /* Shared-info pfn */
     2.9 +    if (!write_exact(io_fd, &(shared_info_frame), sizeof(uint32_t)) ) {
    2.10 +        ERROR("write shared-info pfn failed!\n");
    2.11 +        goto out;
    2.12 +    }
    2.13   
    2.14      /* Success! */
    2.15      rc = 0;