mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
libxc/restore: introduce process_record()
Move record handle codes into a function process_record(). It will be used multiple times by Remus. No functional change. Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com> CC: Ian Campbell <Ian.Campbell@citrix.com> CC: Ian Jackson <Ian.Jackson@eu.citrix.com> CC: Wei Liu <wei.liu2@citrix.com> CC: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
This commit is contained in:
1 parent
1238640c9e
commit
9ab42c93ae
1 file changed
+43
-34
+43
-34
@@ -468,6 +468,48 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec)
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int process_record(struct xc_sr_context *ctx, struct xc_sr_record *rec)
|
||||
{
|
||||
xc_interface *xch = ctx->xch;
|
||||
int rc = 0;
|
||||
|
||||
switch ( rec->type )
|
||||
{
|
||||
case REC_TYPE_END:
|
||||
break;
|
||||
|
||||
case REC_TYPE_PAGE_DATA:
|
||||
rc = handle_page_data(ctx, rec);
|
||||
break;
|
||||
|
||||
case REC_TYPE_VERIFY:
|
||||
DPRINTF("Verify mode enabled");
|
||||
ctx->restore.verify = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
rc = ctx->restore.ops.process_record(ctx, rec);
|
||||
break;
|
||||
}
|
||||
|
||||
free(rec->data);
|
||||
|
||||
if ( rc == RECORD_NOT_PROCESSED )
|
||||
{
|
||||
if ( rec->type & REC_TYPE_OPTIONAL )
|
||||
DPRINTF("Ignoring optional record %#x (%s)",
|
||||
rec->type, rec_type_to_str(rec->type));
|
||||
else
|
||||
{
|
||||
ERROR("Mandatory record %#x (%s) not handled",
|
||||
rec->type, rec_type_to_str(rec->type));
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore a domain.
|
||||
*/
|
||||
@@ -498,40 +540,7 @@ static int restore(struct xc_sr_context *ctx)
|
||||
if ( rc )
|
||||
goto err;
|
||||
|
||||
switch ( rec.type )
|
||||
{
|
||||
case REC_TYPE_END:
|
||||
break;
|
||||
|
||||
case REC_TYPE_PAGE_DATA:
|
||||
rc = handle_page_data(ctx, &rec);
|
||||
break;
|
||||
|
||||
case REC_TYPE_VERIFY:
|
||||
DPRINTF("Verify mode enabled");
|
||||
ctx->restore.verify = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
rc = ctx->restore.ops.process_record(ctx, &rec);
|
||||
break;
|
||||
}
|
||||
|
||||
free(rec.data);
|
||||
|
||||
if ( rc == RECORD_NOT_PROCESSED )
|
||||
{
|
||||
if ( rec.type & REC_TYPE_OPTIONAL )
|
||||
DPRINTF("Ignoring optional record %#x (%s)",
|
||||
rec.type, rec_type_to_str(rec.type));
|
||||
else
|
||||
{
|
||||
ERROR("Mandatory record %#x (%s) not handled",
|
||||
rec.type, rec_type_to_str(rec.type));
|
||||
rc = -1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = process_record(ctx, &rec);
|
||||
if ( rc )
|
||||
goto err;
|
||||
|
||||
|
||||