提交 9cc931f0 编写于 作者: P Peter Krempa

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.
上级 c7d5dd39
...@@ -1427,12 +1427,8 @@ virDomainVcpuDefPtr ...@@ -1427,12 +1427,8 @@ virDomainVcpuDefPtr
virDomainDefGetVcpu(virDomainDefPtr def, virDomainDefGetVcpu(virDomainDefPtr def,
unsigned int vcpu) unsigned int vcpu)
{ {
if (vcpu >= def->maxvcpus) { if (vcpu >= def->maxvcpus)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("vCPU '%u' is not present in domain definition"),
vcpu);
return NULL; return NULL;
}
return &def->vcpus[vcpu]; return &def->vcpus[vcpu];
} }
......
...@@ -4606,14 +4606,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, ...@@ -4606,14 +4606,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
unsigned int vcpu) unsigned int vcpu)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainVcpuDefPtr vcpuinfo; virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
int ret = -1; int ret = -1;
int rc; int rc;
int oldvcpus = virDomainDefGetVcpus(vm->def); int oldvcpus = virDomainDefGetVcpus(vm->def);
if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu)))
return -1;
if (vcpuinfo->online) { if (vcpuinfo->online) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("vCPU '%u' is already online"), vcpu); _("vCPU '%u' is already online"), vcpu);
...@@ -4658,14 +4655,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, ...@@ -4658,14 +4655,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
unsigned int vcpu) unsigned int vcpu)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainVcpuDefPtr vcpuinfo; virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
int ret = -1; int ret = -1;
int rc; int rc;
int oldvcpus = virDomainDefGetVcpus(vm->def); int oldvcpus = virDomainDefGetVcpus(vm->def);
if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu)))
return -1;
if (!vcpuinfo->online) { if (!vcpuinfo->online) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,
_("vCPU '%u' is already offline"), vcpu); _("vCPU '%u' is already offline"), vcpu);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册