return rc;
}
+static int setup(struct xc_sr_context *ctx)
+{
+ xc_interface *xch = ctx->xch;
+ int rc;
+
+ rc = ctx->restore.ops.setup(ctx);
+ if ( rc )
+ goto err;
+
+ ctx->restore.max_populated_pfn = (32 * 1024 / 4) - 1;
+ ctx->restore.populated_pfns = bitmap_alloc(
+ ctx->restore.max_populated_pfn + 1);
+ if ( !ctx->restore.populated_pfns )
+ {
+ ERROR("Unable to allocate memory for populated_pfns bitmap");
+ rc = -1;
+ goto err;
+ }
+
+ err:
+ return rc;
+}
+
+static void cleanup(struct xc_sr_context *ctx)
+{
+ xc_interface *xch = ctx->xch;
+
+ free(ctx->restore.populated_pfns);
+ if ( ctx->restore.ops.cleanup(ctx) )
+ PERROR("Failed to clean up");
+}
+
#ifdef XG_LIBXL_HVM_COMPAT
extern int read_qemu(struct xc_sr_context *ctx);
#endif
IPRINTF("Restoring domain");
- rc = ctx->restore.ops.setup(ctx);
+ rc = setup(ctx);
if ( rc )
goto err;
- ctx->restore.max_populated_pfn = (32 * 1024 / 4) - 1;
- ctx->restore.populated_pfns = bitmap_alloc(
- ctx->restore.max_populated_pfn + 1);
- if ( !ctx->restore.populated_pfns )
- {
- ERROR("Unable to allocate memory for populated_pfns bitmap");
- goto err;
- }
-
do
{
rc = read_record(ctx, &rec);
PERROR("Restore failed");
done:
- free(ctx->restore.populated_pfns);
- rc = ctx->restore.ops.cleanup(ctx);
- if ( rc )
- PERROR("Failed to clean up");
+ cleanup(ctx);
if ( saved_rc )
{