6ae9ed
From 5304cda0dc6e8f370a1f80050e03fdc4d6479d06 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <5304cda0dc6e8f370a1f80050e03fdc4d6479d06@dist-git>
6ae9ed
From: Peter Krempa <pkrempa@redhat.com>
6ae9ed
Date: Wed, 24 Aug 2016 16:10:45 -0400
6ae9ed
Subject: [PATCH] conf: Don't report errors from virDomainDefGetVcpu
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
6ae9ed
6ae9ed
Most callers make sure that it's never called with an out of range vCPU.
6ae9ed
Every other caller reports a different error explicitly. Drop the error
6ae9ed
reporting and clean up some dead code paths.
6ae9ed
6ae9ed
(cherry picked from commit 9cc931f0bbfc4529b3d07b4226af7b218624858d)
6ae9ed
---
6ae9ed
 src/conf/domain_conf.c |  6 +-----
6ae9ed
 src/qemu/qemu_driver.c | 10 ++--------
6ae9ed
 2 files changed, 3 insertions(+), 13 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
6ae9ed
index a923b60..7a12462 100644
6ae9ed
--- a/src/conf/domain_conf.c
6ae9ed
+++ b/src/conf/domain_conf.c
6ae9ed
@@ -1433,12 +1433,8 @@ virDomainVcpuDefPtr
6ae9ed
 virDomainDefGetVcpu(virDomainDefPtr def,
6ae9ed
                     unsigned int vcpu)
6ae9ed
 {
6ae9ed
-    if (vcpu >= def->maxvcpus) {
6ae9ed
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
6ae9ed
-                       _("vCPU '%u' is not present in domain definition"),
6ae9ed
-                       vcpu);
6ae9ed
+    if (vcpu >= def->maxvcpus)
6ae9ed
         return NULL;
6ae9ed
-    }
6ae9ed
 
6ae9ed
     return &def->vcpus[vcpu];
6ae9ed
 }
6ae9ed
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
6ae9ed
index b4ab095..71f2fb6 100644
6ae9ed
--- a/src/qemu/qemu_driver.c
6ae9ed
+++ b/src/qemu/qemu_driver.c
6ae9ed
@@ -4620,14 +4620,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
6ae9ed
                          unsigned int vcpu)
6ae9ed
 {
6ae9ed
     qemuDomainObjPrivatePtr priv = vm->privateData;
6ae9ed
-    virDomainVcpuDefPtr vcpuinfo;
6ae9ed
+    virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
6ae9ed
     int ret = -1;
6ae9ed
     int rc;
6ae9ed
     int oldvcpus = virDomainDefGetVcpus(vm->def);
6ae9ed
 
6ae9ed
-    if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu)))
6ae9ed
-        return -1;
6ae9ed
-
6ae9ed
     if (vcpuinfo->online) {
6ae9ed
         virReportError(VIR_ERR_INVALID_ARG,
6ae9ed
                        _("vCPU '%u' is already online"), vcpu);
6ae9ed
@@ -4672,14 +4669,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
6ae9ed
                          unsigned int vcpu)
6ae9ed
 {
6ae9ed
     qemuDomainObjPrivatePtr priv = vm->privateData;
6ae9ed
-    virDomainVcpuDefPtr vcpuinfo;
6ae9ed
+    virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu);
6ae9ed
     int ret = -1;
6ae9ed
     int rc;
6ae9ed
     int oldvcpus = virDomainDefGetVcpus(vm->def);
6ae9ed
 
6ae9ed
-    if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu)))
6ae9ed
-        return -1;
6ae9ed
-
6ae9ed
     if (!vcpuinfo->online) {
6ae9ed
         virReportError(VIR_ERR_INVALID_ARG,
6ae9ed
                        _("vCPU '%u' is already offline"), vcpu);
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed