]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Don't report errors from virDomainDefGetVcpu
authorPeter Krempa <pkrempa@redhat.com>
Thu, 30 Jun 2016 07:26:04 +0000 (09:26 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 11 Jul 2016 07:06:09 +0000 (09:06 +0200)
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
src/qemu/qemu_driver.c

index b660a8b71f33ed5687cd2e13e03bfb56f96ceb4c..a3aa83ea3931f7047479ec5ee00370193fa666ac 100644 (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];
 }
index 724e8ac225f5166f6061e50065f4d74385f455eb..b9939952574290b96140e71998230f83b093cfbc 100644 (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);