]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuAgentGetTimezone: expose 'report_unsupported' argument
authorPeter Krempa <pkrempa@redhat.com>
Mon, 16 Mar 2020 07:37:13 +0000 (08:37 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 25 Mar 2020 12:13:18 +0000 (13:13 +0100)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_agent.c
src/qemu/qemu_agent.h
src/qemu/qemu_driver.c
tests/qemuagenttest.c

index 88847a5ae170fbbf60908afa862288595c3036cc..0d87d78ee5cbaafa061a46d9e4a2502273adfbbf 100644 (file)
@@ -2458,29 +2458,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",
index 9cade9ca4c498aefaecaac7dd53acb31cf0a04a0..361a67aaee90acbe8a1d89084e1c0a63b3c93a6f 100644 (file)
@@ -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);
index adf9b9054c8bbb41af538442d7ef66cd74728f9e..d2fb8d124b6559e5378b5645a67651f388fc1309 100644 (file)
@@ -23026,7 +23026,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;
     }
index 57d0f857cc88c2e6015c79b0e45616eeb9708150..7ea330892bb278929563c367417d8ebd85b5af72 100644 (file)
@@ -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, \