]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuAgentSSHGetAuthorizedKeys: Convert last use ofvirJSONValueObjectGetStringArray
authorPeter Krempa <pkrempa@redhat.com>
Thu, 1 Dec 2022 16:07:12 +0000 (17:07 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 2 Dec 2022 15:18:37 +0000 (16:18 +0100)
Use virJSONValueObjectGetArray + virJSONValueArrayToStringList instead
so that the ofvirJSONValueObjectGetStringArray wrapper can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_agent.c

index 70d45955b27514c5cdb65d2301927459405b77f9..fa2c0bf91537377989bca8d42571a928df3dccf1 100644 (file)
@@ -2413,6 +2413,7 @@ qemuAgentSSHGetAuthorizedKeys(qemuAgent *agent,
     g_autoptr(virJSONValue) cmd = NULL;
     g_autoptr(virJSONValue) reply = NULL;
     virJSONValue *data = NULL;
+    virJSONValue *arr = NULL;
 
     if (!(cmd = qemuAgentMakeCommand("guest-ssh-get-authorized-keys",
                                      "s:username", user,
@@ -2422,13 +2423,14 @@ qemuAgentSSHGetAuthorizedKeys(qemuAgent *agent,
     if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
         return -1;
 
-    if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
+    if (!(data = virJSONValueObjectGetObject(reply, "return")) ||
+        !(arr = virJSONValueObjectGetArray(data, "keys"))) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("qemu agent didn't return an array of keys"));
         return -1;
     }
 
-    if (!(*keys = virJSONValueObjectGetStringArray(data, "keys")))
+    if (!(*keys = virJSONValueArrayToStringList(arr)))
         return -1;
 
     return g_strv_length(*keys);