|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v7 4/6] libs/guest: move batch_pfns into a separate structure
On Thu, 9 Jul 2026 at 08:44, Frediano Ziglio <freddy77@xxxxxxxxx> wrote:
>
> From: Edwin Török <edwin.torok@xxxxxxxxxx>
>
> Prepare for following change.
>
> Signed-off-by: Frediano Ziglio <frediano.ziglio@xxxxxxxxxx>
> ---
> Changes since v6:
> - split from "libs/guest: allocate various migration arrays just once".
> ---
> tools/libs/guest/xg_sr_common.h | 5 ++++-
> tools/libs/guest/xg_sr_save.c | 31 +++++++++++++++++--------------
> 2 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/tools/libs/guest/xg_sr_common.h b/tools/libs/guest/xg_sr_common.h
> index f1573aefcb..7574c9f5b6 100644
> --- a/tools/libs/guest/xg_sr_common.h
> +++ b/tools/libs/guest/xg_sr_common.h
> @@ -239,11 +239,14 @@ struct xc_sr_context
>
> struct precopy_stats stats;
>
> - xen_pfn_t *batch_pfns;
> unsigned int nr_batch_pfns;
> unsigned long *deferred_pages;
> unsigned long nr_deferred_pages;
> xc_hypercall_buffer_t dirty_bitmap_hbuf;
> + struct xc_sr_context_save_buffers
> + {
> + xen_pfn_t batch_pfns[MAX_BATCH_SIZE];
> + } *buffers;
> } save;
>
> struct /* Restore data. */
> diff --git a/tools/libs/guest/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c
> index 84fdbe4140..8956f4260d 100644
> --- a/tools/libs/guest/xg_sr_save.c
> +++ b/tools/libs/guest/xg_sr_save.c
> @@ -75,7 +75,7 @@ static int write_checkpoint_record(struct xc_sr_context
> *ctx)
>
> /*
> * Writes a batch of memory as a PAGE_DATA record into the stream. The batch
> - * is constructed in ctx->save.batch_pfns.
> + * is constructed in ctx->save.buffers->batch_pfns.
> *
> * This function:
> * - gets the types for each pfn in the batch.
> @@ -95,6 +95,7 @@ static int write_batch(struct xc_sr_context *ctx)
> void *page, *orig_page;
> uint64_t *rec_pfns = NULL;
> struct iovec *iov = NULL; int iovcnt = 0;
> + xen_pfn_t *batch_pfns;
What about a direct
xen_pfn_t *const batch_pfns = ctx->save.buffers->batch_pfns;
here ?
> struct {
> struct xc_sr_rhdr rec;
> struct xc_sr_rec_page_data_header page_data;
> @@ -110,6 +111,10 @@ static int write_batch(struct xc_sr_context *ctx)
> };
>
> assert(nr_pfns != 0);
> + assert(nr_pfns <= MAX_BATCH_SIZE);
> + assert(ctx->save.buffers);
> +
> + batch_pfns = ctx->save.buffers->batch_pfns;
>
> /* Mfns of the batch pfns. */
> mfns = malloc(nr_pfns * sizeof(*mfns));
> @@ -141,13 +146,12 @@ static int write_batch(struct xc_sr_context *ctx)
...
Frediano
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |