@@ -229,6 +229,8 @@ struct sr_save_arrays {
xen_pfn_t mfns[MAX_BATCH_SIZE];
/* write_batch: Types of the batch pfns. */
xen_pfn_t types[MAX_BATCH_SIZE];
+ /* write_batch: Errors from attempting to map the gfns. */
+ int errors[MAX_BATCH_SIZE];
};
struct sr_restore_arrays {
@@ -92,7 +92,7 @@ static int write_batch(struct xc_sr_context *ctx)
void *guest_mapping = NULL;
void **guest_data = NULL;
void **local_pages = NULL;
- int *errors = NULL, rc = -1;
+ int *errors = ctx->save.m->errors, rc = -1;
unsigned int i, p, nr_pages = 0, nr_pages_mapped = 0;
unsigned int nr_pfns = ctx->save.nr_batch_pfns;
void *page, *orig_page;
@@ -105,8 +105,6 @@ static int write_batch(struct xc_sr_context *ctx)
assert(nr_pfns != 0);
- /* Errors from attempting to map the gfns. */
- errors = malloc(nr_pfns * sizeof(*errors));
/* Pointers to page data to send. Mapped gfns or local allocations. */
guest_data = calloc(nr_pfns, sizeof(*guest_data));
/* Pointers to locally allocated pages. Need freeing. */
@@ -114,7 +112,7 @@ static int write_batch(struct xc_sr_context *ctx)
/* iovec[] for writev(). */
iov = malloc((nr_pfns + 4) * sizeof(*iov));
- if ( !errors || !guest_data || !local_pages || !iov )
+ if ( !guest_data || !local_pages || !iov )
{
ERROR("Unable to allocate arrays for a batch of %u pages",
nr_pfns);
@@ -271,7 +269,6 @@ static int write_batch(struct xc_sr_context *ctx)
free(iov);
free(local_pages);
free(guest_data);
- free(errors);
return rc;
}