[HVM] Save/restore: save shared-info pfn and re-map it on restore
authorTim Deegan <Tim.Deegan@xensource.com>
Wed, 31 Jan 2007 12:23:35 +0000 (12:23 +0000)
committerTim Deegan <Tim.Deegan@xensource.com>
Wed, 31 Jan 2007 12:23:35 +0000 (12:23 +0000)
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>
tools/libxc/xc_hvm_restore.c
tools/libxc/xc_hvm_save.c

index 7092d5cea8ddb29fe65101b73076a70922dabe90..b2b9999feae1f88254af3333d239bf842faae828 100644 (file)
@@ -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;
 
index aa6ad5a9305d1251f145cc50f93242f2091bade3..3d08a509d9929985d2da36f99a6784abdce6a3b7 100644 (file)
@@ -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;