[PATCH 12/12] qemuDomainGetGuestInfo: Suppress non-fatal errors

Peter Krempa pkrempa at redhat.com
Mon Mar 16 08:35:54 UTC 2020


Don't report cases when the guest information is not requested
explicitly and not present either.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_driver.c | 45 +++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2f043e3ad9..946fe63ea6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -22876,6 +22876,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
     int maxparams = 0;
     g_autofree char *hostname = NULL;
     unsigned int supportedTypes;
+    bool report_unsupported = types != 0;
     int rc;
     size_t nfs = 0;
     qemuAgentFSInfoPtr *agentfsinfo = NULL;
@@ -22906,37 +22907,31 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
      * categories were explicitly requested (i.e. 'types' is 0), ignore
      * 'unsupported' errors and gather as much information as we can. In all
      * other cases, abort on error. */
-    if (supportedTypes & VIR_DOMAIN_GUEST_INFO_USERS) {
-        rc = qemuAgentGetUsers(agent, params, nparams, &maxparams, true);
-        if (rc < 0 && !(rc == -2 && types == 0))
-            goto exitagent;
-    }
-    if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS) {
-        rc = qemuAgentGetOSInfo(agent, params, nparams, &maxparams, true);
-        if (rc < 0 && !(rc == -2 && types == 0))
-            goto exitagent;
-    }
-    if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE) {
-        rc = qemuAgentGetTimezone(agent, params, nparams, &maxparams, true);
-        if (rc < 0 && !(rc == -2 && types == 0))
-            goto exitagent;
-    }
-    if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) {
-        rc = qemuAgentGetHostname(agent, &hostname, true);
-        if (rc < 0 && !(rc == -2 && types == 0))
-            goto exitagent;
-    }
+    if (supportedTypes & VIR_DOMAIN_GUEST_INFO_USERS &&
+        qemuAgentGetUsers(agent, params, nparams, &maxparams, report_unsupported) == -1)
+        goto exitagent;
+
+    if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS &&
+        qemuAgentGetOSInfo(agent, params, nparams, &maxparams, report_unsupported) == -1)
+        goto exitagent;
+
+    if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE &&
+        qemuAgentGetTimezone(agent, params, nparams, &maxparams, report_unsupported) == -1)
+        goto exitagent;
+
+    if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME &&
+        qemuAgentGetHostname(agent, &hostname, report_unsupported) == -1)
+        goto exitagent;

     if (hostname &&
         virTypedParamsAddString(params, nparams, &maxparams, "hostname", hostname) < 0)
         goto exitagent;

     if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
-        rc = qemuAgentGetFSInfo(agent, &agentfsinfo, true);
-        if (rc < 0) {
-            if (!(rc == -2 && types == 0))
-                goto exitagent;
-        } else {
+        rc = qemuAgentGetFSInfo(agent, &agentfsinfo, report_unsupported);
+        if (rc == -1) {
+            goto exitagent;
+        } else if (rc >= 0) {
             nfs = rc;
         }
     }
-- 
2.24.1




More information about the libvir-list mailing list