[PATCH 10/12] qemuAgentGetTimezone: expose 'report_unsupported' argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use qemuAgentCommandFull so that callers of qemuAgentGetTimezone can
suppress error reports if the function is not supported by the guest
agent.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_agent.c  | 17 +++++++++--------
 src/qemu/qemu_agent.h  |  3 ++-
 src/qemu/qemu_driver.c |  2 +-
 tests/qemuagenttest.c  |  2 +-
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 77f3247602..efb6c52f96 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2465,29 +2465,30 @@ qemuAgentGetOSInfo(qemuAgentPtr agent,
 }

 /* Returns: 0 on success
- *          -2 when agent command is not supported by the agent
- *          -1 otherwise
+ *          -2 when agent command is not supported by the agent and
+ *             'report_unsupported' is false (libvirt error is not reported)
+ *          -1 otherwise (libvirt error is reported)
  */
 int
 qemuAgentGetTimezone(qemuAgentPtr agent,
                      virTypedParameterPtr *params,
                      int *nparams,
-                     int *maxparams)
+                     int *maxparams,
+                     bool report_unsupported)
 {
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValuePtr data = NULL;
     const char *name;
     int offset;
+    int rc;

     if (!(cmd = qemuAgentMakeCommand("guest-get-timezone", NULL)))
         return -1;

-    if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) {
-        if (qemuAgentErrorCommandUnsupported(reply))
-            return -2;
-        return -1;
-    }
+    if ((rc = qemuAgentCommandFull(agent, cmd, &reply, agent->timeout,
+                                   report_unsupported)) < 0)
+        return rc;

     if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 9cade9ca4c..361a67aaee 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -163,7 +163,8 @@ int qemuAgentGetOSInfo(qemuAgentPtr mon,
 int qemuAgentGetTimezone(qemuAgentPtr mon,
                          virTypedParameterPtr *params,
                          int *nparams,
-                         int *maxparams);
+                         int *maxparams,
+                         bool report_unsupported);

 void qemuAgentSetResponseTimeout(qemuAgentPtr mon,
                                  int timeout);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 17d9bbe01c..1b1fa5e209 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -22917,7 +22917,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
             goto exitagent;
     }
     if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE) {
-        rc = qemuAgentGetTimezone(agent, params, nparams, &maxparams);
+        rc = qemuAgentGetTimezone(agent, params, nparams, &maxparams, true);
         if (rc < 0 && !(rc == -2 && types == 0))
             goto exitagent;
     }
diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
index 57d0f857cc..7ea330892b 100644
--- a/tests/qemuagenttest.c
+++ b/tests/qemuagenttest.c
@@ -1244,7 +1244,7 @@ testQemuAgentTimezone(const void *data)
                                    response_) < 0) \
             goto cleanup; \
         if (qemuAgentGetTimezone(qemuMonitorTestGetAgent(test), \
-                                 &params_, &nparams_, &maxparams_) < 0) \
+                                 &params_, &nparams_, &maxparams_, true) < 0) \
             goto cleanup; \
         if (nparams_ != 2) { \
             virReportError(VIR_ERR_INTERNAL_ERROR, \
-- 
2.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux