From: Ian Campbell Subject: Re: [PATCH V5 31/32] libxl: update domain configuration when updating memory targets Date: Tue, 20 May 2014 15:32:04 +0100 Message-ID: <1400596324.6946.92.camel@kazak.uk.xensource.com> References: <1400018054-26038-1-git-send-email-wei.liu2@citrix.com> <1400018054-26038-32-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-32-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: Wei Liu Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Tue, 2014-05-13 at 22:54 +0100, Wei Liu wrote: > 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. > + */ I was asking for a helper earlier, I suppose this could be useful there too. TBH I think a helper fn and callback arrangement would be preferable to magic macros (macros only when there is no alternative I think). I suppose that would result in a plethora of little callback helpers though. Hrm, what do you think? > +#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); \ rc = libxl_domain_config_dispose if (rc) goto out; would work here I think, since dispose doesn't clobber rc. > + > /* 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;