]> git.proxmox.com Git - mirror_qemu.git/commitdiff
authz-list-file: Improve an error message
authorMarkus Armbruster <armbru@redhat.com>
Fri, 13 Nov 2020 06:23:58 +0000 (07:23 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 18 Nov 2020 10:51:35 +0000 (10:51 +0000)
When qauthz_list_file_load() rejects JSON values other than JSON
object with a rather confusing error message:

    $ echo 1 | qemu-system-x86_64 -nodefaults -S -display none  -object authz-list-file,id=authz0,filename=/dev/stdin
    qemu-system-x86_64: -object authz-list-file,id=authz0,filename=/dev/stdin: Invalid parameter type for 'obj', expected: dict

Improve to

    qemu-system-x86_64: -object authz-list-file,id=authz0,filename=/dev/stdin: File '/dev/stdin' must contain a JSON object

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
authz/listfile.c

index 1421e674a4665295e63349129a723cac69732078..da3a0e69a2ed472c053a2b64113405f371e1b2e1 100644 (file)
@@ -73,7 +73,8 @@ qauthz_list_file_load(QAuthZListFile *fauthz, Error **errp)
 
     pdict = qobject_to(QDict, obj);
     if (!pdict) {
-        error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "obj", "dict");
+        error_setg(errp, "File '%s' must contain a JSON object",
+                   fauthz->filename);
         goto cleanup;
     }