]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
Add shell of lu_reserve_pages()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 29 Jan 2020 15:52:06 +0000 (15:52 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 29 Jan 2020 16:17:55 +0000 (16:17 +0000)
This currently only iterates over the records and prints the version of
Xen that we're live updating from.

In the fullness of time, it will also reserve the pages passed over as
M2P as well as the pages belonging to preserved domains.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
xen/arch/x86/setup.c
xen/common/lu/Makefile
xen/common/lu/restore.c [new file with mode: 0644]
xen/include/xen/lu.h

index eea670e03b2ed78991a1abc0ce3bc1c364eb2021..f789713b1b0ef62a4768c945b8a755bb3122e237 100644 (file)
@@ -1603,6 +1603,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     if ( lu_breadcrumb_phys )
     {
         lu_stream_map(&lu_stream, lu_mfnlist_phys, lu_nr_pages);
+
+        lu_reserve_pages(&lu_stream);
     }
 
     if ( lu_bootmem_start )
index 7b7d975f653e722fa4665bf73d8ad6fb2bd567aa..592c72e1ecfe29a42413ecec1018a3d71de3e796 100644 (file)
@@ -1 +1 @@
-obj-y += stream.o save.o
+obj-y += stream.o save.o restore.o
diff --git a/xen/common/lu/restore.c b/xen/common/lu/restore.c
new file mode 100644 (file)
index 0000000..f52bb66
--- /dev/null
@@ -0,0 +1,34 @@
+#include <xen/types.h>
+#include <xen/vmap.h>
+#include <xen/lu.h>
+#include <xen/sched.h>
+#include <xen/lu.h>
+
+#include <public/migration_stream.h>
+
+void lu_reserve_pages(struct lu_stream *stream)
+{
+    struct mr_rhdr *hdr;
+
+    while ( (hdr = lu_next_record(stream)) && hdr->type != REC_TYPE_END )
+    {
+        if ( hdr->type == REC_TYPE_LU_VERSION &&
+             hdr->length == sizeof(struct mr_lu_version) )
+        {
+            struct mr_lu_version *vers = LU_REC_DATA(hdr);
+
+            printk("Live update from Xen %d.%d\n",
+                   vers->xen_major, vers->xen_minor);
+        }
+    }
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index c02268e4145123ec570f906a8a2dc334c47f1f6a..588f2dd137aa17afc4709b0da55bbe9f7b019f6a 100644 (file)
@@ -5,6 +5,8 @@
 #include <xen/types.h>
 #include <xen/mm.h>
 
+#include <public/migration_stream.h>
+
 #define LIVE_UPDATE_MAGIC        (0x4c69766555706461UL & PAGE_MASK)
 
 struct lu_stream {
@@ -28,6 +30,22 @@ struct kexec_image;
 int lu_save_all(struct kexec_image *image);
 
 void lu_stream_map(struct lu_stream *stream, unsigned long mfns_phys, int nr_pages);
+void lu_reserve_pages(struct lu_stream *stream);
+
+/* Pointer to the data immediately following a record header */
+#define LU_REC_DATA(hdr) ((void *)&(hdr)[1])
+
+static inline struct mr_rhdr *lu_next_record(struct lu_stream *stream)
+{
+    struct mr_rhdr *hdr = (struct mr_rhdr *)(stream->data + stream->last_hdr);
+
+    if (stream->len < stream->last_hdr + sizeof(*hdr) ||
+        stream->len < stream->last_hdr + sizeof(*hdr) + hdr->length)
+        return NULL;
+
+    stream->last_hdr += sizeof(*hdr) + ROUNDUP(hdr->length, 1<<REC_ALIGN_ORDER);
+    return hdr;
+}
 
 #endif /* __XEN_LU_H__ */