diff options
author | Yann Bordenave <meow@meowstars.org> | 2016-03-15 10:31:22 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-03-15 10:35:25 +0100 |
commit | 7aac531ef260e3176838f8089525f3e13e40b607 (patch) | |
tree | d6f86287f03acba16bdf2407871e21d74caf5932 /net/net.c | |
parent | 05061d8548598c92bda94de0c6159732e75da719 (diff) |
qapi-schema, qemu-options & slirp: Adding Qemu options for IPv6 addresses
This patch adds parameters to manage some new options in the qemu -net
command.
Slirp IPv6 address, network prefix, and DNS IPv6 address can be given in
argument to the qemu command.
Defaults parameters are respectively fec0::2, fec0::, /64 and fec0::3.
Signed-off-by: Yann Bordenave <meow@meowstars.org>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'net/net.c')
-rw-r--r-- | net/net.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -1050,6 +1050,37 @@ int net_client_init(QemuOpts *opts, int is_netdev, Error **errp) OptsVisitor *ov = opts_visitor_new(opts); Visitor *v = opts_get_visitor(ov); + { + /* Parse convenience option format ip6-net=fec0::0[/64] */ + const char *ip6_net = qemu_opt_get(opts, "ip6-net"); + + if (ip6_net) { + char buf[strlen(ip6_net) + 1]; + + if (get_str_sep(buf, sizeof(buf), &ip6_net, '/') < 0) { + /* Default 64bit prefix length. */ + qemu_opt_set(opts, "ip6-prefix", ip6_net, &error_abort); + qemu_opt_set_number(opts, "ip6-prefixlen", 64, &error_abort); + } else { + /* User-specified prefix length. */ + unsigned long len; + int err; + + qemu_opt_set(opts, "ip6-prefix", buf, &error_abort); + err = qemu_strtoul(ip6_net, NULL, 10, &len); + + if (err) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, + "ip6-prefix", "a number"); + } else { + qemu_opt_set_number(opts, "ip6-prefixlen", len, + &error_abort); + } + } + qemu_opt_unset(opts, "ip6-net"); + } + } + if (is_netdev) { visit_type_Netdev(v, NULL, (Netdev **)&object, &err); } else { |