qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: [PATCH 02/20] qdev: Stop using error_set_from_qdev_prop_error() for netdev property
Date: Fri, 30 Oct 2020 16:21:13 -0400	[thread overview]
Message-ID: <20201030202131.796967-3-ehabkost@redhat.com> (raw)
In-Reply-To: <20201030202131.796967-1-ehabkost@redhat.com>

Just setting a reasonable error string using error_setg() is
simpler and makes error messages clearer.

Before:

  $ qemu-system-x86_64 -device e1000,netdev=n0
  qemu-system-x86_64: -device e1000,netdev=n0: Property 'e1000.netdev' can't find value 'n0'
  $ qemu-system-x86_64 -netdev id=n0,type=user -device e1000,netdev=n0 -device e1000,netdev=n0
  qemu-system-x86_64: -device e1000,netdev=n0: Property 'e1000.netdev' can't take value 'n0', it's in use

After:

  $ ./qemu-system-x86_64 -device e1000,netdev=n0
  qemu-system-x86_64: -device e1000,netdev=n0: Property 'e1000.netdev' can't take value 'n0': netdev not found
  $ ./qemu-system-x86_64 -netdev id=n0,type=user -device e1000,netdev=n0 -device e1000,netdev=n0
  qemu-system-x86_64: -device e1000,netdev=n0: Property 'e1000.netdev' can't take value 'n0': netdev is in use

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 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 232ff955fa..60be09efba 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -376,7 +376,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
     NICPeers *peers_ptr = object_static_prop_ptr(obj, prop);
     NetClientState **ncs = peers_ptr->ncs;
     NetClientState *peers[MAX_QUEUE_NUM];
-    int queues, err = 0, i = 0;
+    int queues, i = 0;
     char *str;
 
     if (!visit_type_str(v, name, &str, errp)) {
@@ -387,7 +387,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
                                           NET_CLIENT_DRIVER_NIC,
                                           MAX_QUEUE_NUM);
     if (queues == 0) {
-        err = -ENOENT;
+        error_setg(errp, "netdev not found");
         goto out;
     }
 
@@ -399,7 +399,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
 
     for (i = 0; i < queues; i++) {
         if (peers[i]->peer) {
-            err = -EEXIST;
+            error_setg(errp, "netdev is in use");
             goto out;
         }
 
@@ -418,7 +418,6 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
     peers_ptr->queues = queues;
 
 out:
-    error_set_from_qdev_prop_error(errp, err, obj, prop, str);
     g_free(str);
 }
 
-- 
2.28.0



  parent reply	other threads:[~2020-10-30 20:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 20:21 [PATCH 00/20] qdev/qom: Remove explicit type names from error_setg() calls Eduardo Habkost
2020-10-30 20:21 ` [PATCH 01/20] qom: Add prefix to error message inside object_property_parse() Eduardo Habkost
2020-11-03 12:33   ` Igor Mammedov
2020-10-30 20:21 ` Eduardo Habkost [this message]
2020-10-30 20:21 ` [PATCH 03/20] qdev: Stop using error_set_from_qdev_prop_error() for audiodev property Eduardo Habkost
2020-10-30 20:21 ` [PATCH 04/20] qdev: Stop using error_set_from_qdev_prop_error() for mac property Eduardo Habkost
2020-10-30 20:21 ` [PATCH 05/20] qdev: Stop using error_set_from_qdev_prop_error() for devfn property Eduardo Habkost
2020-10-30 20:21 ` [PATCH 06/20] qdev: Stop using error_set_from_qdev_prop_error() for PCI host device property Eduardo Habkost
2020-10-30 20:21 ` [PATCH 07/20] qdev: Stop using error_set_from_qdev_prop_error() for css devno property Eduardo Habkost
2020-10-30 20:21 ` [PATCH 08/20] qdev: Delete unused error_set_from_qdev_prop_error() function Eduardo Habkost
2020-10-30 20:21 ` [PATCH 09/20] cryptodev: Remove unnecessary prefix from error message Eduardo Habkost
2020-10-30 20:21 ` [PATCH 10/20] memfd: " Eduardo Habkost
2020-11-03 12:30   ` Igor Mammedov
2020-10-30 20:21 ` [PATCH 11/20] tpm_util: " Eduardo Habkost
2020-10-30 20:21 ` [PATCH 12/20] qdev: drive: " Eduardo Habkost
2020-10-30 20:21 ` [PATCH 13/20] qdev: chardev: " Eduardo Habkost
2020-10-30 20:21 ` [PATCH 14/20] i386: " Eduardo Habkost
2020-11-03 12:34   ` Igor Mammedov
2020-10-30 20:21 ` [PATCH 15/20] qerror: Delete unused QERR_PROPERTY_VALUE_BAD macro Eduardo Habkost
2020-10-30 20:21 ` [PATCH 16/20] nvdimm: Remove unnecessary prefix from error message Eduardo Habkost
2020-11-03 12:31   ` Igor Mammedov
2020-10-30 20:21 ` [PATCH 17/20] colo-compare: " Eduardo Habkost
2020-10-30 20:21 ` [PATCH 18/20] filter-dump: " Eduardo Habkost
2020-10-30 20:21 ` [PATCH 19/20] filter-buffer: " Eduardo Habkost
2020-10-30 20:21 ` [PATCH 20/20] qom: Remove error prefix check at object_property_parse() Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201030202131.796967-3-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).