[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.5] libxl: keep PoD target adjustment by memory fudge after reload_domain_config()
commit df9c5c4da9407b7b6ceea02eb2c47c40239713b6 Author: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> AuthorDate: Wed Feb 3 16:53:03 2016 +0100 Commit: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CommitDate: Tue Jun 7 17:03:48 2016 +0100 libxl: keep PoD target adjustment by memory fudge after reload_domain_config() Commit 56fb5fd623 ("libxl: adjust PoD target by memory fudge, too") introduced target_memkb adjustment for HVM PoD domains on create, wherein the value it wrote to target is always 1MiB lower than the actual target_memkb. Unfortunately, on reboot, it is this value which is read *unmodified* to feed into the next domain creation; from which 1MiB is subtracted *again*. This means that any guest which reboots with memory < maxmem will have its memory target decreased by 1MiB on every boot. This patch makes it so that when reading target on reboot, we adjust the value we read *up* by 1MiB, so that the domain will be build with the appropriate amount of memory and the target will remain the same after reboot. This is still not quite a complete fix, as the 1MiB offset is only subtracted when creating or rebooting; it is not subtracted when 'xl set-memory' is called. But it will prevent any situations where memory is continually increased or decreased. A better fix will have to wait until after the release. Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Release-acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> (cherry picked from commit 7e81d992b183c47a74eea5ecd613d27950b5cdc3) (cherry picked from commit 7c5c20d129b1a333a3f85a2d04ecde48b5fd7589) --- tools/libxl/libxl.c | 8 ++++---- tools/libxl/libxl_dom.c | 10 ++-------- tools/libxl/libxl_internal.h | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index c0a80cb..0796d90 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -6739,12 +6739,12 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid, LOG(ERROR, "fail to get memory target for domain %d", domid); goto out; } - /* Target memory in xenstore is different from what user has - * asked for. The difference is video_memkb. See - * libxl_set_memory_target. + + /* libxl__get_targetmem_fudge() calculates the difference from + * what is in xenstore to what we have in the domain build info. */ d_config->b_info.target_memkb = target_memkb + - d_config->b_info.video_memkb; + libxl__get_targetmem_fudge(gc, &d_config->b_info); d_config->b_info.max_memkb = max_memkb; } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 137df83..6bef1e4 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -446,7 +446,6 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid, xs_transaction_t t; char **ents; int i, rc; - int64_t mem_target_fudge; rc = libxl_domain_sched_params_set(CTX, domid, &info->sched_params); if (rc) @@ -473,17 +472,12 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid, } } - mem_target_fudge = - (info->type == LIBXL_DOMAIN_TYPE_HVM && - info->max_memkb > info->target_memkb) - ? LIBXL_MAXMEM_CONSTANT : 0; - ents = libxl__calloc(gc, 12 + (info->max_vcpus * 2) + 2, sizeof(char *)); ents[0] = "memory/static-max"; ents[1] = GCSPRINTF("%"PRId64, info->max_memkb); ents[2] = "memory/target"; - ents[3] = GCSPRINTF("%"PRId64, info->target_memkb - info->video_memkb - - mem_target_fudge); + ents[3] = GCSPRINTF("%"PRId64, info->target_memkb - + libxl__get_targetmem_fudge(gc, info)); ents[4] = "memory/videoram"; ents[5] = GCSPRINTF("%"PRId64, info->video_memkb); ents[6] = "domid"; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 302585c..7026824 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3581,6 +3581,21 @@ static inline void libxl__update_config_vtpm(libxl__gc *gc, libxl_uuid_copy(CTX, &dst->uuid, &src->uuid); } +/* Target memory in xenstore is different from what user has + * asked for. The difference is video_memkb + (possible) fudge. + * See libxl_set_memory_target. + */ +static inline +uint64_t libxl__get_targetmem_fudge(libxl__gc *gc, + const libxl_domain_build_info *info) +{ + int64_t mem_target_fudge = (info->type == LIBXL_DOMAIN_TYPE_HVM && + info->max_memkb > info->target_memkb) + ? LIBXL_MAXMEM_CONSTANT : 0; + + return info->video_memkb + mem_target_fudge; +} + /* Macros used to compare device identifier. Returns true if the two * devices have same identifier. */ #define COMPARE_DEVID(a, b) ((a)->devid == (b)->devid) -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.5 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |