Fix logic in qemuDomainObjPrivateXMLParseVcpu

The code in qemuDomainObjPrivateXMLParseVcpu for parsing
the 'idstr' string was comparing the overall boolean
result against 0 which was always true

qemu/qemu_domain.c: In function 'qemuDomainObjPrivateXMLParseVcpu':
qemu/qemu_domain.c:1482:59: error: comparison of constant '0' with boolean expression is always false [-Werror=bool-compare]
     if ((idstr && virStrToLong_uip(idstr, NULL, 10, &idx)) < 0 ||
                                                           ^

It was further performing two distinct error checks in
the same conditional and reporting a single error message,
which was misleading in one of the two cases.

This splits the conditional check into two parts with
distinct error messages and fixes the logic error.

Fixes the bug in

  commit 5184f398b40a5e0d7d84b86182edcb2b48ab04ba
  Author: Peter Krempa <pkrempa@redhat.com>
  Date:   Fri Jul 1 14:56:14 2016 +0200

    qemu: Store vCPU thread ids in vcpu private data objects

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2016-07-11 10:30:03 +01:00
parent 4074a82c0c
commit ed1fbd7c5b

View File

@ -1479,10 +1479,15 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node,
idstr = virXMLPropString(node, "id"); idstr = virXMLPropString(node, "id");
if ((idstr && virStrToLong_uip(idstr, NULL, 10, &idx)) < 0 || if (idstr &&
!(vcpu = virDomainDefGetVcpu(def, idx))) { (virStrToLong_uip(idstr, NULL, 10, &idx) < 0)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid vcpu index '%s'"), idstr); _("cannot parse vcpu index '%s'"), idstr);
goto cleanup;
}
if (!(vcpu = virDomainDefGetVcpu(def, idx))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid vcpu index '%u'"), idx);
goto cleanup; goto cleanup;
} }