diff options
author | Stefano Garzarella <sgarzare@redhat.com> | 2019-05-17 15:47:45 +0200 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2019-07-02 10:21:06 +0800 |
commit | 21c520d0c1ab64770f09f6fbf5952807e856e903 (patch) | |
tree | a3a9559820bca50f091c72c5a619f59b73bbf46e | |
parent | 59377b4a4b6830b71ea937aaf25bfca941cad264 (diff) | |
download | qemu-21c520d0c1ab64770f09f6fbf5952807e856e903.zip qemu-21c520d0c1ab64770f09f6fbf5952807e856e903.tar.gz qemu-21c520d0c1ab64770f09f6fbf5952807e856e903.tar.bz2 |
net: fix assertion failure when ipv6-prefixlen is not a number
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>
Signed-off-by: Jason Wang <jasowang@redhat.com>
-rw-r--r-- | net/net.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1136,11 +1136,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"); } @@ -1162,6 +1162,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; |