[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libxl: libxl_domain_need_memory shouldn't modify b_info
commit b173750d2bc2c9b57fda9750309824296bdea932 Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Mon Jul 11 12:03:51 2016 +0100 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Tue Jul 12 12:49:41 2016 +0100 libxl: libxl_domain_need_memory shouldn't modify b_info This function is used to return the memory needed for a guest. It's not in a position to modify the b_info passed in (note the _setdefault function). Constify the passed in b_info, use a copy to do the calculation. Mark the change in API in libxl.h. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libxl/libxl.c | 8 +++++++- tools/libxl/libxl.h | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 0c34d6b..51d202f 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -5121,12 +5121,17 @@ int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid, return rc; } -int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info, +int libxl_domain_need_memory(libxl_ctx *ctx, + const libxl_domain_build_info *b_info_in, uint32_t *need_memkb) { GC_INIT(ctx); + libxl_domain_build_info b_info[1]; int rc; + libxl_domain_build_info_init(b_info); + libxl_domain_build_info_copy(ctx, b_info, b_info_in); + rc = libxl__domain_build_info_setdefault(gc, b_info); if (rc) goto out; @@ -5149,6 +5154,7 @@ int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info, rc = 0; out: GC_FREE; + libxl_domain_build_info_dispose(b_info); return rc; } diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index f2843fd..48a43ce 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -74,6 +74,13 @@ */ #define LIBXL_HAVE_CONST_COPY_AND_LENGTH_FUNCTIONS 1 +/* LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO + * + * If this is defined, libxl_domain_need_memory no longer modifies + * the b_info paseed in. + */ +#define LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO 1 + /* LIBXL_HAVE_VNUMA * * If this is defined the type libxl_vnode_info exists, and a @@ -1383,7 +1390,8 @@ int libxl_get_memory_target(libxl_ctx *ctx, uint32_t domid, uint32_t *out_target * existing programs which use them in roughly the same way as libxl. */ /* how much free memory in the system a domain needs to be built */ -int libxl_domain_need_memory(libxl_ctx *ctx, libxl_domain_build_info *b_info, +int libxl_domain_need_memory(libxl_ctx *ctx, + const libxl_domain_build_info *b_info_in, uint32_t *need_memkb); /* how much free memory is available in the system */ int libxl_get_free_memory(libxl_ctx *ctx, uint32_t *memkb); -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |