From: Peter Krempa Date: Wed, 14 Sep 2016 04:50:00 +0000 (+0200) Subject: qemu: process: Don't use shifted indexes for vcpu order verification X-Git-Tag: v2.3.0-rc2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8924f1b25646e939997dc42589604cc2230b4646;p=thirdparty%2Flibvirt.git qemu: process: Don't use shifted indexes for vcpu order verification Allocate a one larger bitmap rather than shifting the indexes back to zero. --- diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e4f27eaf5e..3b6e07811d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4788,7 +4788,7 @@ qemuProcessValidateHotpluggableVcpus(virDomainDefPtr def) virBitmapPtr ordermap = NULL; int ret = -1; - if (!(ordermap = virBitmapNew(maxvcpus))) + if (!(ordermap = virBitmapNew(maxvcpus + 1))) goto cleanup; /* validate: @@ -4805,13 +4805,13 @@ qemuProcessValidateHotpluggableVcpus(virDomainDefPtr def) continue; if (vcpu->order != 0) { - if (virBitmapIsBitSet(ordermap, vcpu->order - 1)) { + if (virBitmapIsBitSet(ordermap, vcpu->order)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("duplicate vcpu order '%u'"), vcpu->order); goto cleanup; } - ignore_value(virBitmapSetBit(ordermap, vcpu->order - 1)); + ignore_value(virBitmapSetBit(ordermap, vcpu->order)); }