diff mbox series

[31/36] qdev: Stop using error_set_from_qdev_prop_error() for UUID property

Message ID 20201029220246.472693-32-ehabkost@redhat.com (mailing list archive)
State New, archived
Headers show
Series Make qdev static property API usable by any QOM type | expand

Commit Message

Eduardo Habkost Oct. 29, 2020, 10:02 p.m. UTC
Just setting a reasonable error string using error_setg() is
simpler and makes error messages clearer.

Before:

  $ qemu-system-x86_64 -device vmgenid,guid=x
  qemu-system-x86_64: -device vmgenid,guid=x: Property 'vmgenid.guid' doesn't take value 'x'

After:

  $ qemu-system-x86_64 -device vmgenid,guid=x
  qemu-system-x86_64: -device vmgenid,guid=x: invalid UUID: 'x'

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.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marc-André Lureau Oct. 30, 2020, 5:06 p.m. UTC | #1
On Fri, Oct 30, 2020 at 2:22 AM Eduardo Habkost <ehabkost@redhat.com> wrote:

> Just setting a reasonable error string using error_setg() is
> simpler and makes error messages clearer.
>
> Before:
>
>   $ qemu-system-x86_64 -device vmgenid,guid=x
>   qemu-system-x86_64: -device vmgenid,guid=x: Property 'vmgenid.guid'
> doesn't take value 'x'
>
> After:
>
>   $ qemu-system-x86_64 -device vmgenid,guid=x
>   qemu-system-x86_64: -device vmgenid,guid=x: invalid UUID: 'x'
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>

It looks like we agree that error_set_from_qdev_prop_error() should
eventually be replaced :)

Reviewed-by: Marc-André Lureau <marcandre.lureau@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.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 59d65a7362..5b9907e8ba 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -509,7 +509,7 @@ static void set_uuid(Object *obj, Visitor *v, const
> char *name, void *opaque,
>      if (!strcmp(str, UUID_VALUE_AUTO)) {
>          qemu_uuid_generate(uuid);
>      } else if (qemu_uuid_parse(str, uuid) < 0) {
> -        error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
> +        error_setg(errp, "invalid UUID: '%s'", str);
>      }
>      g_free(str);
>  }
> --
> 2.28.0
>
>
>
diff mbox series

Patch

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 59d65a7362..5b9907e8ba 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -509,7 +509,7 @@  static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque,
     if (!strcmp(str, UUID_VALUE_AUTO)) {
         qemu_uuid_generate(uuid);
     } else if (qemu_uuid_parse(str, uuid) < 0) {
-        error_set_from_qdev_prop_error(errp, EINVAL, obj, prop, str);
+        error_setg(errp, "invalid UUID: '%s'", str);
     }
     g_free(str);
 }