conf: Don't report errors from virDomainDefGetVcpu

Most callers make sure that it's never called with an out of range vCPU.
Every other caller reports a different error explicitly. Drop the error
reporting and clean up some dead code paths.
This commit is contained in:
Peter Krempa 2016-06-30 09:26:04 +02:00
parent c7d5dd3974
commit 9cc931f0bb
2 changed files with 3 additions and 13 deletions

View File

@ -1427,12 +1427,8 @@ virDomainVcpuDefPtr
virDomainDefGetVcpu(virDomainDefPtr def,
unsigned int vcpu)
{
if (vcpu >= def->maxvcpus) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("vCPU '%u' is not present in domain definition"),
vcpu);
if (vcpu >= def->maxvcpus)
return NULL;
}
return &def->vcpus[vcpu];
}

View File

@ -4606,14 +4606,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
unsigned int vcpu)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainVcpuDefPtr vcpuinfo;
virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
int ret = -1;
int rc;
int oldvcpus = virDomainDefGetVcpus(vm->def);
if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu)))
return -1;
if (vcpuinfo->online) {
virReportError(VIR_ERR_INVALID_ARG,
_("vCPU '%u' is already online"), vcpu);
@ -4658,14 +4655,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
unsigned int vcpu)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainVcpuDefPtr vcpuinfo;
virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
int ret = -1;
int rc;
int oldvcpus = virDomainDefGetVcpus(vm->def);
if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu)))
return -1;
if (!vcpuinfo->online) {
virReportError(VIR_ERR_INVALID_ARG,
_("vCPU '%u' is already offline"), vcpu);