Just setting a reasonable error string using error_setg() is
simpler and makes error messages clearer.
Before:
$ qemu-system-x86_64 -device AC97,audiodev=a0
qemu-system-x86_64: -device AC97,audiodev=a0: Property 'AC97.audiodev' can't find value 'a0'
After:
$ ./qemu-system-x86_64 -device AC97,audiodev=a0
qemu-system-x86_64: -device AC97,audiodev=a0: Property 'AC97.audiodev' can't take value 'a0': audiodev not found
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org
---
hw/core/qdev-properties-system.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 60be09efba..a5a1a6ffee 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -447,7 +447,6 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name,
Property *prop = opaque;
QEMUSoundCard *card = object_static_prop_ptr(obj, prop);
AudioState *state;
- int err = 0;
char *str;
if (!visit_type_str(v, name, &str, errp)) {
@@ -457,13 +456,12 @@ static void set_audiodev(Object *obj, Visitor *v, const char* name,
state = audio_state_by_name(str);
if (!state) {
- err = -ENOENT;
+ error_setg(errp, "audiodev not found");
goto out;
}
card->state = state;
out:
- error_set_from_qdev_prop_error(errp, err, obj, prop, str);
g_free(str);
}
--
2.28.0