From: Ian Jackson Subject: Re: [PATCH for-4.6 5/8] tools/libxl: Save and restore EMULATOR_XENSTORE_DATA content Date: Fri, 31 Jul 2015 17:34:46 +0100 Message-ID: <21947.41894.424801.254883@mariner.uk.xensource.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> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <55BA6037.4050906@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 Cc: Wei Liu , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org 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. > > I don't understand why you don't copy the whole subdirectory. This > > needs to be explained. > > I am replicating the behaviour of the old libxl__toolstack_save(), not > redesigning the logic from scratch. (In an ideal world, all this cruft > would be limited to qemu alone, which is the sole producer and consumer, > rather than split across qemu, xenstore and libxl, but that boat has > long since sailed.) I guess during the freeze, that is a good explanation. > > If you do want to copy only some of the keys, this thing where you do > > tiny bits of the work, each time three times, is a very strange > > structure. But this comment stands. > >> + size_t sz = strlen(s) + 1; \ > >> + ptr = realloc(buf, len + sz); \ > >> + if (!ptr) { rc = ERROR_NOMEM; goto out; } \ > > > > Please use the gc. I guess you are going to tell me that you can't > > use the gc because of the remus memory leak problem. Do I need to go > > and retrofit the per-iteration sub-ao myself ? > > Again, because that what older toolstack_save() did, but without the > buggy use of "ptr = realloc(ptr, ...". Well, I'm too late now to insist on the sub-ao, because I'm going away for a week and a bit starting Monday. So I guess I will have to live with the non-use of the gc. Ian.