[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-3.0-testing] Support extended-info in saved guest images generated by latest -unstable tools.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID e8a45450a48dd588b8c0ba06a85dd3f5f5157f8e
# Parent  32123a23a609440ee5c8ab7541f4c635f4b61dec
Support extended-info in saved guest images generated by latest -unstable tools.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/libxc/xc_linux_restore.c |   39 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 36 insertions(+), 3 deletions(-)

diff -r 32123a23a609 -r e8a45450a48d tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    Fri Jun 02 19:16:34 2006 +0100
+++ b/tools/libxc/xc_linux_restore.c    Mon Jun 05 10:44:07 2006 +0100
@@ -169,14 +169,47 @@ int xc_linux_restore(int xc_handle, int 
         return 1;
     }
 
-
-    /* Read the saved P2M frame list */
     if(!(p2m_frame_list = malloc(P2M_FL_SIZE))) { 
         ERR("Couldn't allocate p2m_frame_list array");
         goto out;
     }
     
-    if (!read_exact(io_fd, p2m_frame_list, P2M_FL_SIZE)) { 
+    /* Read first entry of P2M list, or extended-info signature (~0UL). */
+    if (!read_exact(io_fd, p2m_frame_list, sizeof(long))) {
+        ERR("read extended-info signature failed");
+        goto out;
+    }
+
+    if (p2m_frame_list[0] == ~0UL) {
+        uint32_t tot_bytes;
+
+        /* Next 4 bytes: total size of following extended info. */
+        if (!read_exact(io_fd, &tot_bytes, sizeof(tot_bytes))) {
+            ERR("read extended-info size failed");
+            goto out;
+        }
+
+        /* remaining bytes of extended info: read and discard. */
+        while (tot_bytes) {
+            unsigned long sz = tot_bytes;
+            if ( sz > P2M_FL_SIZE )
+                sz = P2M_FL_SIZE;
+            if (!read_exact(io_fd, p2m_frame_list, sz)) {
+                ERR("read-and-discard extended-info bytes failed");
+                goto out;
+            }
+            tot_bytes -= sz;
+        }
+
+        /* Now read the real first entry of P2M list. */
+        if (!read_exact(io_fd, p2m_frame_list, sizeof(long))) {
+            ERR("read first entry of p2m_frame_list failed");
+            goto out;
+        }
+    }
+
+    /* First entry is already read into the p2m array. */
+    if (!read_exact(io_fd, &p2m_frame_list[1], P2M_FL_SIZE - sizeof(long))) { 
         ERR("read p2m_frame_list failed");
         goto out;
     }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.