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. --- src/conf/domain_conf.c | 6 +----- src/qemu/qemu_driver.c | 10 ++-------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b660a8b..a3aa83e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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]; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 724e8ac..b993995 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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); -- 2.9.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list