From: Ian Campbell Subject: Re: [PATCH V5 28/32] libxl: store up-to-date domain configuration as we create domain Date: Tue, 20 May 2014 15:12:18 +0100 Message-ID: <1400595138.6946.76.camel@kazak.uk.xensource.com> References: <1400018054-26038-1-git-send-email-wei.liu2@citrix.com> <1400018054-26038-29-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-29-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: > This patch utilizes "libxl-json" format and helper functions introduced > in previous patch to store up-to-do domain configuration when creating a > domain. > > Signed-off-by: Wei Liu This seems to end up saving the domain config 2 or even 3 times. I think we need an explanation as to why that is. Also we need to know what the invariants are, what must (not) change either before or after each sequencing point, what must be in each update etc. Can you not save the raw version at the start (before anything has touched it) and then do the domid, uuid, mac, vtpm etc all at the end in domcreate_complete? (Don't you do the uuid twice? The comments mention it twice) > +static void update_domain_config(libxl_ctx *ctx, Internal functions should take a libxl__gc not a ctx. > @@ -1366,6 +1400,25 @@ static void domcreate_complete(libxl__egc *egc, > if (!rc && d_config->b_info.exec_ssidref) > rc = xc_flask_relabel_domain(CTX->xch, dcs->guest_domid, d_config->b_info.exec_ssidref); > > + if (!rc) { > + libxl_domain_config d_config_saved; > + > + libxl_domain_config_init(&d_config_saved); > + rc = libxl_load_domain_configuration(CTX, dcs->guest_domid, > + &d_config_saved); > + if (rc) { > + LOG(ERROR, "cannot load domain configuration: %d", rc); > + goto out; > + } > + update_domain_config(CTX, &d_config_saved, d_config); > + rc = libxl_store_domain_configuration(CTX, dcs->guest_domid, > + &d_config_saved); > + if (rc) > + LOG(ERROR, "cannot store domain configuration: %d", rc); > + libxl_domain_config_dispose(&d_config_saved); Unless you are sure this is the only place this will be needed A helper of the form libxl__domain_config_update(gc, &update_domain_config, data) might be useful. i.e. read, call a callback, write. data is a void * passed to the update_domain_config callback. Ian.