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

[Xen-devel] [RFC PATCH v3 19/22] Add shell of lu_reserve_pages()



From: David Woodhouse <dwmw@xxxxxxxxxxxx>

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@xxxxxxxxxxxx>
---
 xen/arch/x86/setup.c    |  2 ++
 xen/common/lu/Makefile  |  2 +-
 xen/common/lu/restore.c | 34 ++++++++++++++++++++++++++++++++++
 xen/include/xen/lu.h    | 18 ++++++++++++++++++
 4 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 xen/common/lu/restore.c

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index eea670e03b..f789713b1b 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -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 )
diff --git a/xen/common/lu/Makefile b/xen/common/lu/Makefile
index 7b7d975f65..592c72e1ec 100644
--- a/xen/common/lu/Makefile
+++ b/xen/common/lu/Makefile
@@ -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
index 0000000000..f52bb660d2
--- /dev/null
+++ b/xen/common/lu/restore.c
@@ -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:
+ */
diff --git a/xen/include/xen/lu.h b/xen/include/xen/lu.h
index c02268e414..588f2dd137 100644
--- a/xen/include/xen/lu.h
+++ b/xen/include/xen/lu.h
@@ -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__ */
 
-- 
2.21.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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