From: "Jan Beulich" Subject: Re: [PATCH] libxl: fix "xl mem-set" regression from 0c029c4da2 Date: Wed, 22 Apr 2015 15:44:31 +0100 Message-ID: <5537CFEF0200007800074C2A@mail.emea.novell.com> References: <5537A9E80200007800074B19@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YkvtB-0005rC-6s for xen-devel@lists.xenproject.org; Wed, 22 Apr 2015 14:44:33 +0000 In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: Ian Campbell , Ian Jackson , Wei Liu , xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 22.04.15 at 15:57, wrote: > From the description of the problem above, we have two issues: > > 1) we don't detect that maxmem is already UINT_MAX*4, so we shouldn't try > to increase it > > 2) unsigned int / uint64_t mismatch > > > 1) is pretty easy and might just come down to one more if statement in > libxl_set_memory_target. Something like: > > > #define MAXMEM_MAX_KB ((uint64_t)UINT32_MAX * 4) > if ((new_target_memkb - current_target_memkb) > 0 && > (ptr.max_memkb - new_target_memkb + current_target_memkb) < ptr.max_memkb) > { > /* avoid overflow */ > rc = xc_domain_setmaxmem(ctx->xch, domid, MAXMEM_MAX_KB); > } else { > rc = xc_domain_setmaxmem(ctx->xch, domid, memorykb); > } Which would build into the tool stack an assumption that the hypervisor representation is a 32-bit value worth of pages. Not really desirable imo. If anything we'd need to do actual overflow checking (and saturation, similar to what the hypervisor patch does) here too. > 2) is difficult as we have unsigned int in many many places. Not only > we need to fix the libxc interface, but as far as I can tell we also > need to fix at least libxl_set_memory_target, > libxl__fill_dom0_memory_info, libxl__get_memory_target, all the callers. > This is the minimum set of changes I think are required: I'll leave that to the tool stack maintainers to decide upon. All I really need immediately is that "xl mem-set" works again. Jan