mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuAgentSSHGetAuthorizedKeys: Convert last use ofvirJSONValueObjectGetStringArray
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>
This commit is contained in:
parent
5baeebef0f
commit
dc5b8dbe66
@ -2413,6 +2413,7 @@ qemuAgentSSHGetAuthorizedKeys(qemuAgent *agent,
|
|||||||
g_autoptr(virJSONValue) cmd = NULL;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
g_autoptr(virJSONValue) reply = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
virJSONValue *data = NULL;
|
virJSONValue *data = NULL;
|
||||||
|
virJSONValue *arr = NULL;
|
||||||
|
|
||||||
if (!(cmd = qemuAgentMakeCommand("guest-ssh-get-authorized-keys",
|
if (!(cmd = qemuAgentMakeCommand("guest-ssh-get-authorized-keys",
|
||||||
"s:username", user,
|
"s:username", user,
|
||||||
@ -2422,13 +2423,14 @@ qemuAgentSSHGetAuthorizedKeys(qemuAgent *agent,
|
|||||||
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
|
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
|
if (!(data = virJSONValueObjectGetObject(reply, "return")) ||
|
||||||
|
!(arr = virJSONValueObjectGetArray(data, "keys"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("qemu agent didn't return an array of keys"));
|
_("qemu agent didn't return an array of keys"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*keys = virJSONValueObjectGetStringArray(data, "keys")))
|
if (!(*keys = virJSONValueArrayToStringList(arr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return g_strv_length(*keys);
|
return g_strv_length(*keys);
|
||||||
|
Loading…
Reference in New Issue
Block a user