Zhang, Yang Z
2012-Jul-24 08:22 UTC
[PATCH] libxl: fix bug the number of running vcpu inconsistent with config file
The following patch will fix the bug 1825. http://bugzilla.xen.org/bugzilla/show_bug.cgi?id=1825 When using memcpy to update vcpu_online, the high bits of vcpu_online may unmodified if the size of avail_vcpus less than vcpu_online. So we need to clear it before the memory copying. Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> diff -r 4a28c496acbf tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Mon Jul 23 17:58:33 2012 +0100 +++ b/tools/libxl/libxl_dom.c Tue Jul 24 15:41:33 2012 +0800 @@ -357,6 +357,7 @@ static int hvm_build_set_params(xc_inter va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET); va_hvm->apic_mode = libxl_defbool_val(info->u.hvm.apic); va_hvm->nr_vcpus = info->max_vcpus; + memset(va_hvm->vcpu_online, 0, sizeof(va_hvm->vcpu_online)); memcpy(va_hvm->vcpu_online, info->avail_vcpus.map, info->avail_vcpus.size); for (i = 0, sum = 0; i < va_hvm->length; i++) sum += ((uint8_t *) va_hvm)[i]; Best regards, Yang
Ian Campbell
2012-Jul-24 09:04 UTC
Re: [PATCH] libxl: fix bug the number of running vcpu inconsistent with config file
On Tue, 2012-07-24 at 09:22 +0100, Zhang, Yang Z wrote:> The following patch will fix the bug 1825. http://bugzilla.xen.org/bugzilla/show_bug.cgi?id=1825 > > When using memcpy to update vcpu_online, the high bits of vcpu_online > may unmodified if the size of avail_vcpus less than vcpu_online. So we > need to clear it before the memory copying. > > Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>We probably ought to zero the whole struct but this change is correct in its own right: Acked-by: Ian Campbell <ian.campbelL@citrix.com> Thanks!> > diff -r 4a28c496acbf tools/libxl/libxl_dom.c > --- a/tools/libxl/libxl_dom.c Mon Jul 23 17:58:33 2012 +0100 > +++ b/tools/libxl/libxl_dom.c Tue Jul 24 15:41:33 2012 +0800 > @@ -357,6 +357,7 @@ static int hvm_build_set_params(xc_inter > va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET); > va_hvm->apic_mode = libxl_defbool_val(info->u.hvm.apic); > va_hvm->nr_vcpus = info->max_vcpus; > + memset(va_hvm->vcpu_online, 0, sizeof(va_hvm->vcpu_online)); > memcpy(va_hvm->vcpu_online, info->avail_vcpus.map, info->avail_vcpus.size); > for (i = 0, sum = 0; i < va_hvm->length; i++) > sum += ((uint8_t *) va_hvm)[i]; > > Best regards, > Yang
Ian Campbell
2012-Jul-24 09:30 UTC
Re: [PATCH] libxl: fix bug the number of running vcpu inconsistent with config file
On Tue, 2012-07-24 at 10:04 +0100, Ian Campbell wrote:> On Tue, 2012-07-24 at 09:22 +0100, Zhang, Yang Z wrote: > > The following patch will fix the bug 1825. http://bugzilla.xen.org/bugzilla/show_bug.cgi?id=1825 > > > > When using memcpy to update vcpu_online, the high bits of vcpu_online > > may unmodified if the size of avail_vcpus less than vcpu_online. So we > > need to clear it before the memory copying. > > > > Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> > > We probably ought to zero the whole struct but this change is correct in > its own right: > > Acked-by: Ian Campbell <ian.campbelL@citrix.com>And now applied, thanks. Ian.