From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
"Olaf Hering" <olaf@aepfle.de>, "Juergen Gross" <jgross@suse.com>,
"Ian Jackson" <iwj@xenproject.org>, "Wei Liu" <wl@xen.org>
Subject: [PATCH 5/5] tools/migration: unify type checking for data pfns in migration stream
Date: Mon, 5 Jul 2021 20:10:27 +0100 [thread overview]
Message-ID: <20210705191027.15107-6-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20210705191027.15107-1-andrew.cooper3@citrix.com>
From: Olaf Hering <olaf@aepfle.de>
Introduce a helper which decides if a given pfn type has data
in the migration stream.
No change in behaviour intended, except for invalid page types which now
have a safer default.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
tools/libs/guest/xg_sr_common.h | 27 +++++++++++++++++++++++++++
tools/libs/guest/xg_sr_restore.c | 29 +++--------------------------
tools/libs/guest/xg_sr_save.c | 14 ++------------
3 files changed, 32 insertions(+), 38 deletions(-)
diff --git a/tools/libs/guest/xg_sr_common.h b/tools/libs/guest/xg_sr_common.h
index 7f4b0439f6bd..36d45ef56fb8 100644
--- a/tools/libs/guest/xg_sr_common.h
+++ b/tools/libs/guest/xg_sr_common.h
@@ -513,6 +513,33 @@ static inline bool page_type_to_populate(uint32_t type)
}
}
+static inline bool page_type_has_stream_data(uint32_t type)
+{
+ switch ( type )
+ {
+ case XEN_DOMCTL_PFINFO_NOTAB:
+
+ case XEN_DOMCTL_PFINFO_L1TAB:
+ case XEN_DOMCTL_PFINFO_L1TAB | XEN_DOMCTL_PFINFO_LPINTAB:
+
+ case XEN_DOMCTL_PFINFO_L2TAB:
+ case XEN_DOMCTL_PFINFO_L2TAB | XEN_DOMCTL_PFINFO_LPINTAB:
+
+ case XEN_DOMCTL_PFINFO_L3TAB:
+ case XEN_DOMCTL_PFINFO_L3TAB | XEN_DOMCTL_PFINFO_LPINTAB:
+
+ case XEN_DOMCTL_PFINFO_L4TAB:
+ case XEN_DOMCTL_PFINFO_L4TAB | XEN_DOMCTL_PFINFO_LPINTAB:
+ return true;
+
+ case XEN_DOMCTL_PFINFO_XTAB:
+ case XEN_DOMCTL_PFINFO_BROKEN:
+ case XEN_DOMCTL_PFINFO_XALLOC:
+ default:
+ return false;
+ }
+}
+
#endif
/*
* Local variables:
diff --git a/tools/libs/guest/xg_sr_restore.c b/tools/libs/guest/xg_sr_restore.c
index 3d63442d4537..aa4113d7f679 100644
--- a/tools/libs/guest/xg_sr_restore.c
+++ b/tools/libs/guest/xg_sr_restore.c
@@ -231,25 +231,8 @@ static int process_page_data(struct xc_sr_context *ctx, unsigned int count,
{
ctx->restore.ops.set_page_type(ctx, pfns[i], types[i]);
- switch ( types[i] )
- {
- case XEN_DOMCTL_PFINFO_NOTAB:
-
- case XEN_DOMCTL_PFINFO_L1TAB:
- case XEN_DOMCTL_PFINFO_L1TAB | XEN_DOMCTL_PFINFO_LPINTAB:
-
- case XEN_DOMCTL_PFINFO_L2TAB:
- case XEN_DOMCTL_PFINFO_L2TAB | XEN_DOMCTL_PFINFO_LPINTAB:
-
- case XEN_DOMCTL_PFINFO_L3TAB:
- case XEN_DOMCTL_PFINFO_L3TAB | XEN_DOMCTL_PFINFO_LPINTAB:
-
- case XEN_DOMCTL_PFINFO_L4TAB:
- case XEN_DOMCTL_PFINFO_L4TAB | XEN_DOMCTL_PFINFO_LPINTAB:
-
+ if ( page_type_has_stream_data(types[i]) )
mfns[nr_pages++] = ctx->restore.ops.pfn_to_gfn(ctx, pfns[i]);
- break;
- }
}
/* Nothing to do? */
@@ -269,14 +252,8 @@ static int process_page_data(struct xc_sr_context *ctx, unsigned int count,
for ( i = 0, j = 0; i < count; ++i )
{
- switch ( types[i] )
- {
- case XEN_DOMCTL_PFINFO_XTAB:
- case XEN_DOMCTL_PFINFO_BROKEN:
- case XEN_DOMCTL_PFINFO_XALLOC:
- /* No page data to deal with. */
+ if ( !page_type_has_stream_data(types[i]) )
continue;
- }
if ( map_errs[j] )
{
@@ -411,7 +388,7 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec)
goto err;
}
- if ( type < XEN_DOMCTL_PFINFO_BROKEN )
+ if ( page_type_has_stream_data(type) )
/* NOTAB and all L1 through L4 tables (including pinned) should
* have a page worth of data in the record. */
pages_of_data++;
diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c
index c84a073e86f4..3fce41b6cfff 100644
--- a/tools/libs/guest/xg_sr_save.c
+++ b/tools/libs/guest/xg_sr_save.c
@@ -153,13 +153,8 @@ static int write_batch(struct xc_sr_context *ctx)
goto err;
}
- switch ( types[i] )
- {
- case XEN_DOMCTL_PFINFO_BROKEN:
- case XEN_DOMCTL_PFINFO_XALLOC:
- case XEN_DOMCTL_PFINFO_XTAB:
+ if ( !page_type_has_stream_data(types[i]) )
continue;
- }
mfns[nr_pages++] = mfns[i];
}
@@ -177,13 +172,8 @@ static int write_batch(struct xc_sr_context *ctx)
for ( i = 0, p = 0; i < nr_pfns; ++i )
{
- switch ( types[i] )
- {
- case XEN_DOMCTL_PFINFO_BROKEN:
- case XEN_DOMCTL_PFINFO_XALLOC:
- case XEN_DOMCTL_PFINFO_XTAB:
+ if ( !page_type_has_stream_data(types[i]) )
continue;
- }
if ( errors[p] )
{
--
2.11.0
next prev parent reply other threads:[~2021-07-05 19:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-05 19:10 [PATCH 0/5] tools/migration: Py3 fixes, and page type helpers Andrew Cooper
2021-07-05 19:10 ` [PATCH 1/5] tools/python: handle libxl__physmap_info.name properly in convert-legacy-stream Andrew Cooper
2021-07-05 19:49 ` Marek Marczykowski-Górecki
2021-07-05 19:10 ` [PATCH 2/5] tools/python: fix Python3.4 TypeError in format string Andrew Cooper
2021-07-05 19:51 ` Marek Marczykowski-Górecki
2021-07-05 19:10 ` [PATCH 3/5] tools/migration: unify known page type checking Andrew Cooper
2021-07-05 19:10 ` [PATCH 4/5] tools/migration: unify type checking for data pfns in the VM Andrew Cooper
2021-07-05 19:10 ` Andrew Cooper [this message]
2021-07-06 4:57 ` [PATCH 5/5] tools/migration: unify type checking for data pfns in migration stream Juergen Gross
2021-07-06 7:11 ` [PATCH 0/5] tools/migration: Py3 fixes, and page type helpers Olaf Hering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210705191027.15107-6-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=iwj@xenproject.org \
--cc=jgross@suse.com \
--cc=marmarek@invisiblethingslab.com \
--cc=olaf@aepfle.de \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).