]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuAgentGetOSInfo: 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 qemuAgentGetOSInfo 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 ffdc94e62fd6a7790936870c95951908ff9b8b19..88847a5ae170fbbf60908afa862288595c3036cc 100644 (file)
@@ -2404,27 +2404,28 @@ qemuAgentGetUsers(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
 qemuAgentGetOSInfo(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;
+    int rc;
 
     if (!(cmd = qemuAgentMakeCommand("guest-get-osinfo", 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 3702abf59321d9f674b0fe2144dd12a04481303b..9cade9ca4c498aefaecaac7dd53acb31cf0a04a0 100644 (file)
@@ -157,7 +157,8 @@ int qemuAgentGetUsers(qemuAgentPtr mon,
 int qemuAgentGetOSInfo(qemuAgentPtr mon,
                        virTypedParameterPtr *params,
                        int *nparams,
-                       int *maxparams);
+                       int *maxparams,
+                       bool report_unsupported);
 
 int qemuAgentGetTimezone(qemuAgentPtr mon,
                          virTypedParameterPtr *params,
index 5ca50c4b2ff42276ed873ec23e78870fa13b3753..adf9b9054c8bbb41af538442d7ef66cd74728f9e 100644 (file)
@@ -23021,7 +23021,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
             goto exitagent;
     }
     if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS) {
-        rc = qemuAgentGetOSInfo(agent, params, nparams, &maxparams);
+        rc = qemuAgentGetOSInfo(agent, params, nparams, &maxparams, true);
         if (rc < 0 && !(rc == -2 && types == 0))
             goto exitagent;
     }
index dee9068ce5755e4405093b187cbcbc482c7b3248..57d0f857cc88c2e6015c79b0e45616eeb9708150 100644 (file)
@@ -1139,7 +1139,7 @@ testQemuAgentOSInfo(const void *data)
 
     /* get osinfo */
     if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test),
-                           &params, &nparams, &maxparams) < 0)
+                           &params, &nparams, &maxparams, true) < 0)
         goto cleanup;
 
     if (nparams != 8) {
@@ -1184,7 +1184,7 @@ testQemuAgentOSInfo(const void *data)
 
     /* get users with domain */
     if (qemuAgentGetOSInfo(qemuMonitorTestGetAgent(test),
-                           &params, &nparams, &maxparams) < 0)
+                           &params, &nparams, &maxparams, true) < 0)
         goto cleanup;
 
     if (nparams != 10) {