Message ID | 20190509130345.227526-2-sgarzare@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Clean ups in net/net.c | expand |
Stefano Garzarella <sgarzare@redhat.com> writes: > If 'ipv6-prefixlen' is not a number, the current behaviour > produces an assertion failure: > $ qemu-system-x86_64 -net user,ipv6-net=feca::0/a > qemu-system-x86_64: qemu/util/qemu-option.c:1175: qemu_opts_foreach: > Assertion `!errp || !*errp' failed. > Aborted (core dumped) > > This patch fixes it, jumping to the end of the function when > 'ipv6-prefixlen' is not a number, and printing the more friendly > message: > $ qemu-system-x86_64 -net user,ipv6-net=feca::0/a > qemu-system-x86_64: Parameter 'ipv6-prefixlen' expects a number > > Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff --git a/net/net.c b/net/net.c index f3a3c5444c..d5071e49e2 100644 --- a/net/net.c +++ b/net/net.c @@ -1134,11 +1134,11 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) if (err) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, - "ipv6-prefix", "a number"); - } else { - qemu_opt_set_number(opts, "ipv6-prefixlen", len, - &error_abort); + "ipv6-prefixlen", "a number"); + goto out; } + + qemu_opt_set_number(opts, "ipv6-prefixlen", len, &error_abort); } qemu_opt_unset(opts, "ipv6-net"); } @@ -1160,6 +1160,7 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp) qapi_free_NetLegacy(object); } +out: error_propagate(errp, err); visit_free(v); return ret;
If 'ipv6-prefixlen' is not a number, the current behaviour produces an assertion failure: $ qemu-system-x86_64 -net user,ipv6-net=feca::0/a qemu-system-x86_64: qemu/util/qemu-option.c:1175: qemu_opts_foreach: Assertion `!errp || !*errp' failed. Aborted (core dumped) This patch fixes it, jumping to the end of the function when 'ipv6-prefixlen' is not a number, and printing the more friendly message: $ qemu-system-x86_64 -net user,ipv6-net=feca::0/a qemu-system-x86_64: Parameter 'ipv6-prefixlen' expects a number Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> --- net/net.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)