From: Yang Hongyang Date: Thu, 14 May 2015 08:55:15 +0000 (+0800) Subject: libxc/restore: introduce process_record() X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3239 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9ab42c93ae865e73d694abec7e07286ddbdf0eef;p=xen.git 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 CC: Ian Campbell CC: Ian Jackson CC: Wei Liu CC: Andrew Cooper Reviewed-by: Andrew Cooper Acked-by: Ian Campbell --- diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index 0bf4bae1c2..53bd6741b0 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -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;