From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH for-4.6 5/8] tools/libxl: Save and restore EMULATOR_XENSTORE_DATA content Date: Fri, 31 Jul 2015 17:56:30 +0100 Message-ID: <1438361790.30740.85.camel@citrix.com> References: <1438119883-8083-1-git-send-email-andrew.cooper3@citrix.com> <1438119883-8083-6-git-send-email-andrew.cooper3@citrix.com> <21944.48593.122598.951173@mariner.uk.xensource.com> <55BA6037.4050906@citrix.com> <21947.41894.424801.254883@mariner.uk.xensource.com> <55BBA47F.5060003@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <55BBA47F.5060003@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: Andrew Cooper , Ian Jackson Cc: Wei Liu , Xen-devel List-Id: xen-devel@lists.xenproject.org On Fri, 2015-07-31 at 17:38 +0100, Andrew Cooper wrote: > On 31/07/15 17:34, Ian Jackson wrote: > > Andrew Cooper writes ("Re: [PATCH for-4.6 5/8] tools/libxl: Save and > > restore EMULATOR_XENSTORE_DATA content"): > > > On 29/07/15 12:49, Ian Jackson wrote: > > > > > + rel_start = strlen(xs_path) - 7; > > > > This is horrible. > > > What do you recommend instead? > > I don't see why it is necessary to do something like rel_start at all. > > > > This whole patch could probably be made much simpler with something > > like > > > > static const char *const physmap_entries[] = { > > "start_addr", "size", "name", NULL > > }; > > > > and then loop over it a few times. > > But the rel_path has nothing to do with which subkeys get chosen. > > It is to strip out the current domains information from > /local/domain/$dm_domid/device-model/$domid/. > > This is because both of the domid in the path will be different on the > other side of migration. This is why EMULATOR_XENSTORE_DATA is > purposefully specified relative to the above path, rather than as > absolute paths. I think an approach where "/local/domain/$dm_domid/device-model/$domid/" was in a local const char *root and then smth like: foreach foo(start_addr, size, name) foo = gcstrcat("/physmap/", foo); path = gcstrcat(root, foo) fooval = read(path) output(foo, fooval) With the proper GC helpers etc of course. Would be fine, no? The rel_path thing is only there because you are trying to keep "foo" and "root" in the same string I think. Ian.