Skip to contentSkip to conversation

Error reporting patches for 2022-10-28

GIT PULL Applied Markus Armbruster 2 participants 6 messages Oct 28, 2022 – Oct 31, 2022

lore
Share & tools
lore
#0 lore raw

The following changes since commit 344744e148e6e865f5a57e745b02a87e5ea534ad:

Merge tag 'dump-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging (2022-10-26 10:53:49 -0400)

are available in the Git repository at:

https://repo.or.cz/qemu/armbru.git tags/pull-error-2022-10-28

for you to fetch changes up to 0dddb0fc80f83d3bb469dc220ba8e2496b27a205:

qerror: QERR_PERMISSION_DENIED is no longer used, drop (2022-10-27 07:57:18 +0200)

----------------------------------------------------------------
Error reporting patches for 2022-10-28

----------------------------------------------------------------
Markus Armbruster (4):
qom: Improve error messages when property has no getter or setter
backends: Improve error messages when property can no longer be set
qtest: Improve error messages when property can not be set right now
qerror: QERR_PERMISSION_DENIED is no longer used, drop

 include/qapi/qmp/qerror.h       | 3 ---
 backends/cryptodev-vhost-user.c | 2 +-
 backends/rng-egd.c              | 2 +-
 backends/rng-random.c           | 2 +-
 backends/vhost-user.c           | 2 +-
 qom/object.c                    | 6 ++++--
 softmmu/qtest.c                 | 4 ++--
 7 files changed, 10 insertions(+), 11 deletions(-)
Signature · 1 line
2.37.3
#1 lore raw

[PULL 2/4] backends: Improve error messages when property can no longer be set

When you try to set virtio-rng property "filename" after the backend has been completed with user_creatable_complete(), the error message blames "insufficient permission":

    $ qemu-system-x86_64 -S -display none -nodefaults -monitor stdio -object rng-random,id=rng0 -device virtio-rng,id=vrng0,rng=rng0
    QEMU 7.1.50 monitor - type 'help' for more information
    (qemu) qom-set /objects/rng0 filename /dev/random
    Error: Insufficient permission to perform this operation

This implies it could work with "sufficient permission". It can't. Change the error message to:

Error: Property 'filename' can no longer be set

Same for cryptodev-vhost-user property "chardev", rng-egd property "chardev", and vhost-user-backend property "chardev".

Message-Id: <[email protected]>

[Commit message tidied up]
---
 backends/cryptodev-vhost-user.c | 2 +-
 backends/rng-egd.c              | 2 +-
 backends/rng-random.c           | 2 +-
 backends/vhost-user.c           | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
backends/cryptodev-vhost-user.c +1 -1
index 5443a59153..f9c5867e38 100644
@@ -339,7 +339,7 @@ static void cryptodev_vhost_user_set_chardev(Object *obj,
                       CRYPTODEV_BACKEND_VHOST_USER(obj);
 
     if (s->opened) {
-        error_setg(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, "Property 'chardev' can no longer be set");
     } else {
         g_free(s->chr_name);
         s->chr_name = g_strdup(value);
backends/rng-egd.c +1 -1
index 4de142b9dc..684c3cf3d6 100644
@@ -116,7 +116,7 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
     RngEgd *s = RNG_EGD(b);
 
     if (b->opened) {
-        error_setg(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, "Property 'chardev' can no longer be set");
     } else {
         g_free(s->chr_name);
         s->chr_name = g_strdup(value);
backends/rng-random.c +1 -1
index 7add272edd..80eb5be138 100644
@@ -96,7 +96,7 @@ static void rng_random_set_filename(Object *obj, const char *filename,
     RngRandom *s = RNG_RANDOM(obj);
 
     if (b->opened) {
-        error_setg(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, "Property 'filename' can no longer be set");
         return;
     }
 
backends/vhost-user.c +1 -1
index 10b39992d2..5dedb2d987 100644
@@ -141,7 +141,7 @@ static void set_chardev(Object *obj, const char *value, Error **errp)
     Chardev *chr;
 
     if (b->completed) {
-        error_setg(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, "Property 'chardev' can no longer be set");
         return;
     }
 
Signature · 1 line
2.37.3
#2 lore raw

[PULL 3/4] qtest: Improve error messages when property can not be set right now

In reply to Markus Armbruster

When you try to set qtest property "log" while the qtest object is active, the error message blames "insufficient permission":

    $ qemu-system-x86_64 -S -display none -nodefaults -monitor stdio -chardev socket,id=chrqt0,path=qtest.socket,server=on,wait=off -object qtest,id=qt0,chardev=chrqt0,log=/dev/null
    QEMU 7.1.50 monitor - type 'help' for more information
    (qemu) qom-set /objects/qt0 log qtest.log
    Error: Insufficient permission to perform this operation

This implies it could work with "sufficient permission". It can't. Change the error message to:

Error: Property 'log' can not be set now

Same for property "chardev".

Message-Id: <[email protected]>

---
 softmmu/qtest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
softmmu/qtest.c +2 -2
index f8acef2628..afea7693d0 100644
@@ -977,7 +977,7 @@ static void qtest_set_log(Object *obj, const char *value, Error **errp)
     QTest *q = QTEST(obj);
 
     if (qtest == q) {
-        error_setg(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, "Property 'log' can not be set now");
     } else {
         g_free(q->log);
         q->log = g_strdup(value);
@@ -997,7 +997,7 @@ static void qtest_set_chardev(Object *obj, const char *value, Error **errp)
     Chardev *chr;
 
     if (qtest == q) {
-        error_setg(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, "Property 'chardev' can not be set now");
         return;
     }
 
Signature · 1 line
2.37.3
#3 lore raw

[PULL 1/4] qom: Improve error messages when property has no getter or setter

In reply to Markus Armbruster

When you try to set a property that has no setter, the error message blames "insufficient permission":

    $ qemu-system-x86_64 -S -display none -nodefaults -monitor stdio
    QEMU 7.1.50 monitor - type 'help' for more information
    (qemu) qom-set /machine type q35
    Error: Insufficient permission to perform this operation

This implies it could work with "sufficient permission". It can't. Change the error message to:

Error: Property 'pc-i440fx-7.2-machine.type' is not writable

Do the same for getting a property that has no getter.

Message-Id: <[email protected]>

---
 qom/object.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
qom/object.c +4 -2
index d34608558e..e5cef30f6d 100644
@@ -1383,7 +1383,8 @@ bool object_property_get(Object *obj, const char *name, Visitor *v,
     }
 
     if (!prop->get) {
-        error_setg(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, "Property '%s.%s' is not readable",
+                   object_get_typename(obj), name);
         return false;
     }
     prop->get(obj, v, name, prop->opaque, &err);
@@ -1402,7 +1403,8 @@ bool object_property_set(Object *obj, const char *name, Visitor *v,
     }
 
     if (!prop->set) {
-        error_setg(errp, QERR_PERMISSION_DENIED);
+        error_setg(errp, "Property '%s.%s' is not writable",
+                   object_get_typename(obj), name);
         return false;
     }
     prop->set(obj, v, name, prop->opaque, errp);
Signature · 1 line
2.37.3
#4 lore raw

[PULL 4/4] qerror: QERR_PERMISSION_DENIED is no longer used, drop

In reply to Markus Armbruster

Message-Id: <[email protected]>

---
 include/qapi/qmp/qerror.h | 3 ---
 1 file changed, 3 deletions(-)
include/qapi/qmp/qerror.h +0 -3
index 596fce0c54..87ca83b155 100644
@@ -50,9 +50,6 @@
 #define QERR_MISSING_PARAMETER \
     "Parameter '%s' is missing"
 
-#define QERR_PERMISSION_DENIED \
-    "Insufficient permission to perform this operation"
-
 #define QERR_PROPERTY_VALUE_BAD \
     "Property '%s.%s' doesn't take value '%s'"
 
Signature · 1 line
2.37.3