qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/4] Error reporting patches for 2022-10-28
@ 2022-10-28  6:08 Markus Armbruster
  2022-10-28  6:08 ` [PULL 1/4] qom: Improve error messages when property has no getter or setter Markus Armbruster
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Markus Armbruster @ 2022-10-28  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha

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(-)

-- 
2.37.3



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PULL 1/4] qom: Improve error messages when property has no getter or setter
  2022-10-28  6:08 [PULL 0/4] Error reporting patches for 2022-10-28 Markus Armbruster
@ 2022-10-28  6:08 ` Markus Armbruster
  2022-10-28  6:08 ` [PULL 2/4] backends: Improve error messages when property can no longer be set Markus Armbruster
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2022-10-28  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, David Hildenbrand

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.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20221012153801.2604340-2-armbru@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 qom/object.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index d34608558e..e5cef30f6d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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);
-- 
2.37.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PULL 2/4] backends: Improve error messages when property can no longer be set
  2022-10-28  6:08 [PULL 0/4] Error reporting patches for 2022-10-28 Markus Armbruster
  2022-10-28  6:08 ` [PULL 1/4] qom: Improve error messages when property has no getter or setter Markus Armbruster
@ 2022-10-28  6:08 ` Markus Armbruster
  2022-10-28  6:08 ` [PULL 3/4] qtest: Improve error messages when property can not be set right now Markus Armbruster
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2022-10-28  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, Michael S . Tsirkin

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".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20221012153801.2604340-3-armbru@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
[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(-)

diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-user.c
index 5443a59153..f9c5867e38 100644
--- a/backends/cryptodev-vhost-user.c
+++ b/backends/cryptodev-vhost-user.c
@@ -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);
diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 4de142b9dc..684c3cf3d6 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -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);
diff --git a/backends/rng-random.c b/backends/rng-random.c
index 7add272edd..80eb5be138 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -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;
     }
 
diff --git a/backends/vhost-user.c b/backends/vhost-user.c
index 10b39992d2..5dedb2d987 100644
--- a/backends/vhost-user.c
+++ b/backends/vhost-user.c
@@ -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;
     }
 
-- 
2.37.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PULL 3/4] qtest: Improve error messages when property can not be set right now
  2022-10-28  6:08 [PULL 0/4] Error reporting patches for 2022-10-28 Markus Armbruster
  2022-10-28  6:08 ` [PULL 1/4] qom: Improve error messages when property has no getter or setter Markus Armbruster
  2022-10-28  6:08 ` [PULL 2/4] backends: Improve error messages when property can no longer be set Markus Armbruster
@ 2022-10-28  6:08 ` Markus Armbruster
  2022-10-28  6:08 ` [PULL 4/4] qerror: QERR_PERMISSION_DENIED is no longer used, drop Markus Armbruster
  2022-10-31 10:14 ` [PULL 0/4] Error reporting patches for 2022-10-28 Stefan Hajnoczi
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2022-10-28  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha

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".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20221012153801.2604340-4-armbru@redhat.com>
---
 softmmu/qtest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index f8acef2628..afea7693d0 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -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;
     }
 
-- 
2.37.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PULL 4/4] qerror: QERR_PERMISSION_DENIED is no longer used, drop
  2022-10-28  6:08 [PULL 0/4] Error reporting patches for 2022-10-28 Markus Armbruster
                   ` (2 preceding siblings ...)
  2022-10-28  6:08 ` [PULL 3/4] qtest: Improve error messages when property can not be set right now Markus Armbruster
@ 2022-10-28  6:08 ` Markus Armbruster
  2022-10-31 10:14 ` [PULL 0/4] Error reporting patches for 2022-10-28 Stefan Hajnoczi
  4 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2022-10-28  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20221012153801.2604340-5-armbru@redhat.com>
---
 include/qapi/qmp/qerror.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index 596fce0c54..87ca83b155 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -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'"
 
-- 
2.37.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PULL 0/4] Error reporting patches for 2022-10-28
  2022-10-28  6:08 [PULL 0/4] Error reporting patches for 2022-10-28 Markus Armbruster
                   ` (3 preceding siblings ...)
  2022-10-28  6:08 ` [PULL 4/4] qerror: QERR_PERMISSION_DENIED is no longer used, drop Markus Armbruster
@ 2022-10-31 10:14 ` Stefan Hajnoczi
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2022-10-31 10:14 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, stefanha

[-- Attachment #1: Type: text/plain, Size: 115 bytes --]

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/7.2 for any user-visible changes.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-10-31 13:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-28  6:08 [PULL 0/4] Error reporting patches for 2022-10-28 Markus Armbruster
2022-10-28  6:08 ` [PULL 1/4] qom: Improve error messages when property has no getter or setter Markus Armbruster
2022-10-28  6:08 ` [PULL 2/4] backends: Improve error messages when property can no longer be set Markus Armbruster
2022-10-28  6:08 ` [PULL 3/4] qtest: Improve error messages when property can not be set right now Markus Armbruster
2022-10-28  6:08 ` [PULL 4/4] qerror: QERR_PERMISSION_DENIED is no longer used, drop Markus Armbruster
2022-10-31 10:14 ` [PULL 0/4] Error reporting patches for 2022-10-28 Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).