From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH for-4.5] libxl: allow copying between bitmaps of different sizes Date: Tue, 25 Nov 2014 15:21:50 +0000 Message-ID: <1416928910.16769.0.camel@citrix.com> References: <1416928416-21329-1-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: <1416928416-21329-1-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 , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Tue, 2014-11-25 at 15:13 +0000, Wei Liu wrote: > When parsing bitmap objects JSON parser will create libxl_bitmap map of the > smallest size needed. > > This can cause problems when saved image file specifies CPU affinity. For > example, if 'vcpu_hard_affinity' in the saved image has only the first CPU > specified, just a single byte will be allocated and libxl_bitmap->size will be > set to 1. > > This will result in assertion in libxl_set_vcpuaffinity()->libxl_bitmap_copy() > since the destination bitmap is created for maximum number of CPUs. > > We could allocate that bitmap of the same size as the source, however, it is > later passed to xc_vcpu_setaffinity() which expects it to be sized to the max > number of CPUs > > To fix this issue, introduce an internal function to allowing copying between > bitmaps of different sizes. Note that this function is only used in > libxl_set_vcpuaffinity at the moment. Though NUMA placement logic invokes > libxl_bitmap_copy as well there's no need to replace those invocations. NUMA > placement logic comes into effect when no vcpu / node pinning is provided, so > it always operates on bitmap of the same sizes (that is, size of maximum > number of cpus /nodes). > > Reported-and-tested-by: Boris Ostrovsky > Signed-off-by: Wei Liu > Reviewed-by: Dario Faggioli Acked-by: Ian Campbell