[libvirt] [PATCH 1/4] qemu: make qemuDomainHelperGetVcpus silent

Francesco Romani fromani at redhat.com
Fri Sep 19 09:44:20 UTC 2014


The commit 74c066df4d8 introduced an helper to factor a code path
which is shared between the existing API and the new bulk stats API.
In the bulk stats path errors must be silenced unless critical
(e.g. memory allocation failure).

To address this need, this patch adds an argument to disable error reporting.
---
 src/qemu/qemu_driver.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f28082f..dc8d6c3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1381,8 +1381,10 @@ qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,
 
 
 static int
-qemuDomainHelperGetVcpus(virDomainObjPtr vm, virVcpuInfoPtr info, int maxinfo,
-                         unsigned char *cpumaps, int maplen)
+qemuDomainHelperGetVcpus(virDomainObjPtr vm,
+                         virVcpuInfoPtr info, int maxinfo,
+                         unsigned char *cpumaps, int maplen,
+                         bool report)
 {
     int maxcpu, hostcpus;
     size_t i, v;
@@ -1412,8 +1414,10 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm, virVcpuInfoPtr info, int maxinfo,
                                        NULL,
                                        vm->pid,
                                        priv->vcpupids[i]) < 0) {
-                    virReportSystemError(errno, "%s",
-                                         _("cannot get vCPU placement & pCPU time"));
+                    if (report)
+                        virReportSystemError(errno, "%s",
+                                             _("cannot get vCPU placement "
+                                               "& pCPU time"));
                     return -1;
                 }
             }
@@ -1440,8 +1444,9 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm, virVcpuInfoPtr info, int maxinfo,
                     virBitmapFree(map);
                 }
             } else {
-                virReportError(VIR_ERR_OPERATION_INVALID,
-                               "%s", _("cpu affinity is not available"));
+                if (report)
+                    virReportError(VIR_ERR_OPERATION_INVALID,
+                                   "%s", _("cpu affinity is not available"));
                 return -1;
             }
         }
@@ -5044,7 +5049,7 @@ qemuDomainGetVcpus(virDomainPtr dom,
         goto cleanup;
     }
 
-    ret = qemuDomainHelperGetVcpus(vm, info, maxinfo, cpumaps, maplen);
+    ret = qemuDomainHelperGetVcpus(vm, info, maxinfo, cpumaps, maplen, true);
 
  cleanup:
     if (vm)
@@ -17530,8 +17535,7 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
         return -1;
 
     if (qemuDomainHelperGetVcpus(dom, cpuinfo, dom->def->vcpus,
-                                 NULL, 0) < 0) {
-        virResetLastError();
+                                 NULL, 0, false) < 0) {
         ret = 0; /* it's ok to be silent and go ahead */
         goto cleanup;
     }
-- 
1.9.3




More information about the libvir-list mailing list