@@ -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);
}
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(-)