Commit f17a73b3 authored by Olaf Hering's avatar Olaf Hering Committed by Andrew Cooper

tools/migration: unify type checking for data pfns in migration stream

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: default avatarOlaf Hering <olaf@aepfle.de>
Reviewed-by: default avatarAndrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
parent 5588ebcf
......@@ -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:
......
......@@ -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++;
......
......@@ -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] )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment