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". 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]
This commit is contained in:
parent
3f7febc937
commit
ff92444884
@ -339,7 +339,7 @@ static void cryptodev_vhost_user_set_chardev(Object *obj,
|
|||||||
CRYPTODEV_BACKEND_VHOST_USER(obj);
|
CRYPTODEV_BACKEND_VHOST_USER(obj);
|
||||||
|
|
||||||
if (s->opened) {
|
if (s->opened) {
|
||||||
error_setg(errp, QERR_PERMISSION_DENIED);
|
error_setg(errp, "Property 'chardev' can no longer be set");
|
||||||
} else {
|
} else {
|
||||||
g_free(s->chr_name);
|
g_free(s->chr_name);
|
||||||
s->chr_name = g_strdup(value);
|
s->chr_name = g_strdup(value);
|
||||||
|
@ -116,7 +116,7 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
|
|||||||
RngEgd *s = RNG_EGD(b);
|
RngEgd *s = RNG_EGD(b);
|
||||||
|
|
||||||
if (b->opened) {
|
if (b->opened) {
|
||||||
error_setg(errp, QERR_PERMISSION_DENIED);
|
error_setg(errp, "Property 'chardev' can no longer be set");
|
||||||
} else {
|
} else {
|
||||||
g_free(s->chr_name);
|
g_free(s->chr_name);
|
||||||
s->chr_name = g_strdup(value);
|
s->chr_name = g_strdup(value);
|
||||||
|
@ -96,7 +96,7 @@ static void rng_random_set_filename(Object *obj, const char *filename,
|
|||||||
RngRandom *s = RNG_RANDOM(obj);
|
RngRandom *s = RNG_RANDOM(obj);
|
||||||
|
|
||||||
if (b->opened) {
|
if (b->opened) {
|
||||||
error_setg(errp, QERR_PERMISSION_DENIED);
|
error_setg(errp, "Property 'filename' can no longer be set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ static void set_chardev(Object *obj, const char *value, Error **errp)
|
|||||||
Chardev *chr;
|
Chardev *chr;
|
||||||
|
|
||||||
if (b->completed) {
|
if (b->completed) {
|
||||||
error_setg(errp, QERR_PERMISSION_DENIED);
|
error_setg(errp, "Property 'chardev' can no longer be set");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user