@@ -235,6 +235,8 @@ struct sr_save_arrays {
struct iovec iov[MAX_BATCH_SIZE + 4];
/* write_batch */
uint64_t rec_pfns[MAX_BATCH_SIZE];
+ /* write_batch: Pointers to page data to send. Mapped gfns or local allocations. */
+ void *guest_data[MAX_BATCH_SIZE];
};
struct sr_restore_arrays {
@@ -90,7 +90,7 @@ static int write_batch(struct xc_sr_context *ctx)
xc_interface *xch = ctx->xch;
xen_pfn_t *mfns = ctx->save.m->mfns, *types = ctx->save.m->types;
void *guest_mapping = NULL;
- void **guest_data = NULL;
+ void **guest_data = ctx->save.m->guest_data;
void **local_pages = NULL;
int *errors = ctx->save.m->errors, rc = -1;
unsigned int i, p, nr_pages = 0, nr_pages_mapped = 0;
@@ -105,12 +105,10 @@ static int write_batch(struct xc_sr_context *ctx)
assert(nr_pfns != 0);
- /* 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. */
local_pages = calloc(nr_pfns, sizeof(*local_pages));
- if ( !guest_data || !local_pages )
+ if ( !local_pages )
{
ERROR("Unable to allocate arrays for a batch of %u pages",
nr_pfns);
@@ -166,7 +164,10 @@ static int write_batch(struct xc_sr_context *ctx)
for ( i = 0, p = 0; i < nr_pfns; ++i )
{
if ( page_type_has_stream_data(types[i]) == false )
+ {
+ guest_data[i] = NULL;
continue;
+ }
if ( errors[p] )
{
@@ -183,6 +184,7 @@ static int write_batch(struct xc_sr_context *ctx)
if ( rc )
{
+ guest_data[i] = NULL;
if ( rc == -1 && errno == EAGAIN )
{
set_bit(ctx->save.m->batch_pfns[i], ctx->save.deferred_pages);
@@ -256,7 +258,6 @@ static int write_batch(struct xc_sr_context *ctx)
for ( i = 0; local_pages && i < nr_pfns; ++i )
free(local_pages[i]);
free(local_pages);
- free(guest_data);
return rc;
}