diff options
author | Tim Deegan <Tim.Deegan@xensource.com> | 2007-01-31 12:23:35 +0000 |
---|---|---|
committer | Tim Deegan <Tim.Deegan@xensource.com> | 2007-01-31 12:23:35 +0000 |
commit | 3f44314932402b0361a245c86597889a7a402054 (patch) | |
tree | 72dad433a18082ed7dc986d3b8d6ed0ea22e1458 | |
parent | 7100d7a911cae241282f10fd8880c341a73a5620 (diff) | |
download | xen-3f44314932402b0361a245c86597889a7a402054.tar.gz xen-3f44314932402b0361a245c86597889a7a402054.tar.bz2 xen-3f44314932402b0361a245c86597889a7a402054.zip |
[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>
-rw-r--r-- | tools/libxc/xc_hvm_restore.c | 26 | ||||
-rw-r--r-- | tools/libxc/xc_hvm_save.c | 6 |
2 files changed, 23 insertions, 9 deletions
diff --git a/tools/libxc/xc_hvm_restore.c b/tools/libxc/xc_hvm_restore.c index 7092d5cea8..b2b9999fea 100644 --- a/tools/libxc/xc_hvm_restore.c +++ b/tools/libxc/xc_hvm_restore.c @@ -98,6 +98,8 @@ int xc_hvm_restore(int xc_handle, int io_fd, /* Types of the pfns in the current region */ unsigned long region_pfn_type[MAX_BATCH_SIZE]; + struct xen_add_to_physmap xatp; + /* hvm guest mem size (Mb) */ memsize = (unsigned long long)*store_mfn; v_end = memsize << 20; @@ -134,15 +136,6 @@ int xc_hvm_restore(int xc_handle, int io_fd, goto out; } - /* Get the domain's shared-info frame. */ - domctl.cmd = XEN_DOMCTL_getdomaininfo; - domctl.domain = (domid_t)dom; - if (xc_domctl(xc_handle, &domctl) < 0) { - ERROR("Could not get information on new domain"); - goto out; - } - shared_info_frame = domctl.u.getdomaininfo.shared_info_frame; - if(xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_pfn)) != 0) { errno = ENOMEM; goto out; @@ -346,6 +339,21 @@ int xc_hvm_restore(int xc_handle, int io_fd, } } + /* Shared-info pfn */ + if (!read_exact(io_fd, &(shared_info_frame), sizeof(uint32_t)) ) { + ERROR("reading the shared-info pfn failed!\n"); + goto out; + } + /* Map the shared-info frame where it was before */ + xatp.domid = dom; + xatp.space = XENMAPSPACE_shared_info; + xatp.idx = 0; + xatp.gpfn = shared_info_frame; + if ( (rc = xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp)) != 0 ) { + ERROR("setting the shared-info pfn failed!\n"); + goto out; + } + rc = 0; goto out; diff --git a/tools/libxc/xc_hvm_save.c b/tools/libxc/xc_hvm_save.c index aa6ad5a930..3d08a509d9 100644 --- a/tools/libxc/xc_hvm_save.c +++ b/tools/libxc/xc_hvm_save.c @@ -702,6 +702,12 @@ int xc_hvm_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, goto out; } } + + /* Shared-info pfn */ + if (!write_exact(io_fd, &(shared_info_frame), sizeof(uint32_t)) ) { + ERROR("write shared-info pfn failed!\n"); + goto out; + } /* Success! */ rc = 0; |