xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH v4 2/5] libxl: libxl_domain_need_memory shouldn't modify b_info
Date: Mon, 11 Jul 2016 16:49:34 +0100	[thread overview]
Message-ID: <1468252177-12625-3-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1468252177-12625-1-git-send-email-wei.liu2@citrix.com>

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@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>

v4: constify b_info and use LIBXL_HAVE_NEED_MEMORY_CONST_B_INFO

v3: new
---
 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);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-07-11 15:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-11 15:49 [PATCH v4 0/5] libxl: update available vcpus map in retrieved configuration Wei Liu
2016-07-11 15:49 ` [PATCH v4 1/5] libxl: constify copy and length calculation functions Wei Liu
2016-07-11 15:52   ` Ian Jackson
2016-07-11 15:49 ` Wei Liu [this message]
2016-07-11 15:52   ` [PATCH v4 2/5] libxl: libxl_domain_need_memory shouldn't modify b_info Ian Jackson
2016-07-11 15:49 ` [PATCH v4 3/5] libxl: introduce libxl__qmp_query_cpus Wei Liu
2016-07-11 15:49 ` [PATCH v4 4/5] libxl: update vcpus bitmap in retrieved guest config Wei Liu
2016-07-11 15:56   ` Ian Jackson
2016-07-11 16:24     ` Wei Liu
2016-07-11 16:38       ` Ian Jackson
2016-07-11 15:49 ` [PATCH v4 5/5] libxl: only issue cpu-add call to QEMU for not present CPU Wei Liu
2016-07-11 15:56   ` Ian Jackson
2016-07-12 13:40 ` [PATCH v4 0/5] libxl: update available vcpus map in retrieved configuration Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468252177-12625-3-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).