From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSu2W-00047q-FM for qemu-devel@nongnu.org; Mon, 08 Feb 2016 17:12:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSu2T-0005GW-6b for qemu-devel@nongnu.org; Mon, 08 Feb 2016 17:12:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSu2S-0005GS-VC for qemu-devel@nongnu.org; Mon, 08 Feb 2016 17:12:09 -0500 References: <84232dbd5f99c4d811f64a2451df894220efe6a2.1454927009.git.samuel.thibault@ens-lyon.org> From: Eric Blake Message-ID: <56B912B5.3040107@redhat.com> Date: Mon, 8 Feb 2016 15:12:05 -0700 MIME-Version: 1.0 In-Reply-To: <84232dbd5f99c4d811f64a2451df894220efe6a2.1454927009.git.samuel.thibault@ens-lyon.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aa9CjD2O172mf89WNFSUoEPclvn4anErW" Subject: Re: [Qemu-devel] [PATCHv7 9/9] qapi-schema, qemu-options & slirp: Adding Qemu options for IPv6 addresses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Samuel Thibault , qemu-devel@nongnu.org Cc: Thomas Huth , zhanghailiang , Li Zhijian , Stefan Hajnoczi , Jason Wang , Dave Gilbert , Vasiliy Tolstov , Huangpeng , Yann Bordenave , Gonglei , Jan Kiszka , Yang Hongyang , Guillaume Subiron This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --aa9CjD2O172mf89WNFSUoEPclvn4anErW Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/08/2016 03:28 AM, Samuel Thibault wrote: > From: Yann Bordenave >=20 > 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 i= n > argument to the qemu command. > Defaults parameters are respectively fec0::2, fec0::, /64 and fec0::3. >=20 > Signed-off-by: Yann Bordenave > Signed-off-by: Samuel Thibault > --- > net/net.c | 31 +++++++++++++++++++++++++++++++ > net/slirp.c | 50 ++++++++++++++++++++++++++++++++++++++++++++----= -- > qapi-schema.json | 40 ++++++++++++++++++++++++++-------------- > qemu-options.hx | 18 ++++++++++++++++-- > slirp/libslirp.h | 8 +++++--- > slirp/slirp.c | 16 +++++++++------- > 6 files changed, 131 insertions(+), 32 deletions(-) >=20 > diff --git a/net/net.c b/net/net.c > index c5e414f..0ececcb 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -1060,6 +1060,37 @@ int net_client_init(QemuOpts *opts, int is_netde= v, Error **errp) > int ret =3D -1; > =20 > { > + /* Parse convenience option format ip6-net=3Dfec0::0[/64] */ > + const char *ip6_net =3D qemu_opt_get(opts, "ip6-net"); > + > + if (ip6_net) { > + char buf[strlen(ip6_net)+1]; Spaces around binary '+' > + > + 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. */ > + int len; > + char *end; > + > + qemu_opt_set(opts, "ip6-prefix", buf, &error_abort); > + len =3D strtol(ip6_net, &end, 10); > + > + if (*end !=3D '\0') { > + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, > + "ip6-prefix", "a number"); > + } else { > + qemu_opt_set_number(opts, "ip6-prefixlen", len, > + &error_abort); > + } Incorrect use of strtol() (you failed to check for overflow, which requires priming errno to 0). I recommend using qemu_strtol() instead, as it does the grunt work for you and is harder to use incorrectly. > +++ b/qapi-schema.json > @@ -2399,6 +2399,14 @@ > # @dnssearch: #optional list of DNS suffixes to search, passed as DHCP= option > # to the guest > # > +# @ip6-prefix: #optional IPv6 network prefix (since 2.6) > +# > +# @ip6-prefixlen: #optional IPv6 network prefix length (since 2.6) Would be worth mentioning the default values. > +# > +# @ip6-host: #optional guest-visible IPv6 address of the host (since 2= =2E6) > +# > +# @ip6-dns: #optional guest-visible IPv6 address of the virtual namese= rver (since 2.6) > +# > # @smb: #optional root directory of the built-in SMB server > # > # @smbserver: #optional IP address of the built-in SMB server --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --aa9CjD2O172mf89WNFSUoEPclvn4anErW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWuRK1AAoJEKeha0olJ0NqGGoH/jcqAS/uYaznDe9opJUJcj9F aatYx6sHruk54GuLTS/bapmr6JxNZdduzVNY53kmN7wvo/7GGqVaRFDPD0dsFzsh KmK86geRBbx1RGUd6ia6Lx8sOWVIgGqS15khfgQDaQHFRMQ115xHiyjL3ZiesvvQ 2+6U45sipn7kJlx9pTtl3+X9g0vSLpDTVHDJPGDjEoi40tcbRvFuh6vB4OvEex0f KPWoLRV8OO+uKSiYhT3S8vA0JgKqrQR2dSucVEXxPNOKveNQaGxMb92xO4oI/yZw f/DcwvjgCrP1RExj8wVLWnu2mQ9tmkaBparaDE0oKv5XowrMJRRz912FDNwVwTE= =JKFt -----END PGP SIGNATURE----- --aa9CjD2O172mf89WNFSUoEPclvn4anErW--