From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: [PATCH V5 31/32] libxl: update domain configuration when updating memory targets Date: Tue, 13 May 2014 22:54:13 +0100 Message-ID: <1400018054-26038-32-git-send-email-wei.liu2@citrix.com> References: <1400018054-26038-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1400018054-26038-1-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Wei Liu , ian.jackson@eu.citrix.com, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org Signed-off-by: Wei Liu --- tools/libxl/libxl.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index b578a5c..f93096b 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -3529,6 +3529,25 @@ out: /******************************************************************************/ +/* Macro to load / store domain configuration. They must use in pair. + * Load macro defines d_config that can be used by other code. Store + * macro will dispose d_config. + */ +#define LOAD_DOMAIN_CONFIG(domid) \ + libxl_domain_config d_config; \ + libxl_domain_config_init(&d_config); \ + rc = libxl_load_domain_configuration(CTX, (domid), &d_config); \ + if (rc) \ + goto out; \ + +#define STORE_DOMAIN_CONFIG(domid) \ + rc = libxl_store_domain_configuration(CTX, (domid), &d_config); \ + if (rc) { \ + libxl_domain_config_dispose(&d_config); \ + goto out; \ + } \ + libxl_domain_config_dispose(&d_config); \ + /* Macro for defining device remove/destroy functions in a compact way */ /* The following functions are defined: * libxl_device_disk_remove @@ -4005,6 +4024,14 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb) goto out; } + { + LOAD_DOMAIN_CONFIG(domid); + + d_config.b_info.max_memkb = max_memkb; + + STORE_DOMAIN_CONFIG(domid); + } + rc = 0; out: GC_FREE; @@ -4241,6 +4268,15 @@ out: if (errno == EAGAIN) goto retry_transaction; + /* Currently Dom0 information is not yet managed by libxl */ + if (!rc && domid) { + LOAD_DOMAIN_CONFIG(domid); + + d_config.b_info.target_memkb = new_target_memkb; + + STORE_DOMAIN_CONFIG(domid); + } + out_no_transaction: GC_FREE; return rc; -- 1.7.10.4