From fe7f2462377ffff07ad778888b080ebffd440556 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 31 Jan 2020 23:43:44 +0000 Subject: [PATCH] live update: define LU_VERSION record and add it to live update stream Signed-off-by: David Woodhouse --- xen/common/lu/restore.c | 16 ++++++++++++++++ xen/common/lu/save.c | 18 ++++++++++++++++++ xen/include/public/migration_stream.h | 9 +++++++++ 3 files changed, 43 insertions(+) diff --git a/xen/common/lu/restore.c b/xen/common/lu/restore.c index a506b99643..b2ec3bb80b 100644 --- a/xen/common/lu/restore.c +++ b/xen/common/lu/restore.c @@ -4,12 +4,28 @@ #include #include +#include + void lu_reserve_pages(struct lu_stream *stream) { } struct domain *lu_restore_domains(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) ) + { + const struct mr_lu_version *vers = LU_REC_DATA(hdr); + + printk("Live update from Xen %d.%d\n", + vers->xen_major, vers->xen_minor); + } + } + panic("Implement me!\n"); } diff --git a/xen/common/lu/save.c b/xen/common/lu/save.c index dc5d1d75ee..10966e04e5 100644 --- a/xen/common/lu/save.c +++ b/xen/common/lu/save.c @@ -4,8 +4,20 @@ #include #include #include +#include #include +int lu_save_version(struct lu_stream *stream) +{ + struct mr_lu_version ver_rec; + + ver_rec.xen_major = xen_major_version(); + ver_rec.xen_minor = xen_minor_version(); + return lu_stream_append_record(stream, REC_TYPE_LU_VERSION, + &ver_rec, sizeof(ver_rec)); +} + + int lu_save_domain(struct lu_stream *stream, struct domain *d) { return 0; @@ -19,6 +31,11 @@ int lu_save_all(struct kexec_image *image) memset(&stream, 0, sizeof(stream)); + rc = lu_save_version(&stream); + + if ( rc ) + goto err_notpaused; + /* * Pause all the domains before saving the state. * @@ -64,6 +81,7 @@ err: rcu_read_unlock(&domlist_read_lock); +err_notpaused: lu_stream_free(&stream); return rc; diff --git a/xen/include/public/migration_stream.h b/xen/include/public/migration_stream.h index de5b736362..7dda153439 100644 --- a/xen/include/public/migration_stream.h +++ b/xen/include/public/migration_stream.h @@ -50,6 +50,8 @@ struct mr_rhdr #define REC_TYPE_CHECKPOINT 0x0000000eU #define REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST 0x0000000fU +#define REC_TYPE_LU_VERSION 0x40000000U + #define REC_TYPE_OPTIONAL 0x80000000U #define REC_TYPE_LIVE_UPDATE 0x40000000U @@ -112,6 +114,13 @@ struct mr_hvm_params struct mr_hvm_params_entry param[0]; }; +/* LU_VERSION */ +struct mr_lu_version +{ + uint32_t xen_major; + uint32_t xen_minor; +}; + #endif /* __XEN_MIGRATION_STREAM_H__ */ /* -- 2.39.5