Message ID | 20210701095635.15648-34-olaf@aepfle.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | leftover from 2020 | expand |
On Thu, Jul 01, 2021 at 11:56:28AM +0200, Olaf Hering wrote: > This will help libxl_save_msgs_gen.pl to copy the struct as a region of memory. > > No change in behavior intented. > > Signed-off-by: Olaf Hering <olaf@aepfle.de> > --- > tools/include/xensaverestore.h | 7 +++---- > tools/libs/saverestore/common.h | 2 +- > tools/libs/saverestore/save.c | 6 +++--- > 3 files changed, 7 insertions(+), 8 deletions(-) > > diff --git a/tools/include/xensaverestore.h b/tools/include/xensaverestore.h > index 0410f0469e..dca0134605 100644 > --- a/tools/include/xensaverestore.h > +++ b/tools/include/xensaverestore.h > @@ -23,18 +23,17 @@ > #define XCFLAGS_DEBUG (1 << 1) > > /* For save's precopy_policy(). */ > -struct precopy_stats I don't think changing the existing API is a good idea. It's probably ok to add a typedef. But can't libxl_save_msgs_gen.pl been able to deal with thing like 'struct precopy_stats' ? It seems to be able to deal with 'unsigned long'. > -{ > +typedef struct { > unsigned int iteration; > unsigned long total_written; > long dirty_count; /* -1 if unknown */ > -}; > +} precopy_stats_t; > Thanks,
Am Thu, 1 Jul 2021 17:45:12 +0100 schrieb Anthony PERARD <anthony.perard@citrix.com>: > But can't libxl_save_msgs_gen.pl been able to deal with > thing like 'struct precopy_stats' ? It seems to be able to deal with > 'unsigned long'. Yes, this is apparently possible. I have to check why I thought it was required to turn this into a typedef. Right now I do not see the reason in the code comments. Olaf
diff --git a/tools/include/xensaverestore.h b/tools/include/xensaverestore.h index 0410f0469e..dca0134605 100644 --- a/tools/include/xensaverestore.h +++ b/tools/include/xensaverestore.h @@ -23,18 +23,17 @@ #define XCFLAGS_DEBUG (1 << 1) /* For save's precopy_policy(). */ -struct precopy_stats -{ +typedef struct { unsigned int iteration; unsigned long total_written; long dirty_count; /* -1 if unknown */ -}; +} precopy_stats_t; /* * A precopy_policy callback may not be running in the same address * space as libxc an so precopy_stats is passed by value. */ -typedef int (*precopy_policy_t)(struct precopy_stats, void *); +typedef int (*precopy_policy_t)(precopy_stats_t, void *); /* callbacks provided by xc_domain_save */ struct save_callbacks { diff --git a/tools/libs/saverestore/common.h b/tools/libs/saverestore/common.h index 3adcf2f83f..bb7e437291 100644 --- a/tools/libs/saverestore/common.h +++ b/tools/libs/saverestore/common.h @@ -283,7 +283,7 @@ struct xc_sr_context size_t pages_sent; size_t overhead_sent; - struct precopy_stats stats; + precopy_stats_t stats; unsigned int nr_batch_pfns; unsigned long *deferred_pages; diff --git a/tools/libs/saverestore/save.c b/tools/libs/saverestore/save.c index e486bce96f..537b977ba8 100644 --- a/tools/libs/saverestore/save.c +++ b/tools/libs/saverestore/save.c @@ -488,7 +488,7 @@ static int update_progress_string(struct xc_sr_context *ctx, char **str) #define SPP_MAX_ITERATIONS 5 #define SPP_TARGET_DIRTY_COUNT 50 -static int simple_precopy_policy(struct precopy_stats stats, void *user) +static int simple_precopy_policy(precopy_stats_t stats, void *user) { return ((stats.dirty_count >= 0 && stats.dirty_count < SPP_TARGET_DIRTY_COUNT) || @@ -515,13 +515,13 @@ static int send_memory_live(struct xc_sr_context *ctx) precopy_policy_t precopy_policy = ctx->save.callbacks->precopy_policy; void *data = ctx->save.callbacks->data; - struct precopy_stats *policy_stats; + precopy_stats_t *policy_stats; rc = update_progress_string(ctx, &progress_str); if ( rc ) goto out; - ctx->save.stats = (struct precopy_stats){ + ctx->save.stats = (precopy_stats_t){ .dirty_count = ctx->save.p2m_size, }; policy_stats = &ctx->save.stats;
This will help libxl_save_msgs_gen.pl to copy the struct as a region of memory. No change in behavior intented. Signed-off-by: Olaf Hering <olaf@aepfle.de> --- tools/include/xensaverestore.h | 7 +++---- tools/libs/saverestore/common.h | 2 +- tools/libs/saverestore/save.c | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-)