From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LJr9f-0004Sp-AQ for qemu-devel@nongnu.org; Mon, 05 Jan 2009 10:14:11 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LJr9e-0004SK-EK for qemu-devel@nongnu.org; Mon, 05 Jan 2009 10:14:10 -0500 Received: from [199.232.76.173] (port=60992 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LJr9e-0004SE-90 for qemu-devel@nongnu.org; Mon, 05 Jan 2009 10:14:10 -0500 Received: from mx2.redhat.com ([66.187.237.31]:48492) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LJr9d-0004en-So for qemu-devel@nongnu.org; Mon, 05 Jan 2009 10:14:10 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n05FE9Ft011714 for ; Mon, 5 Jan 2009 10:14:09 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n05FE9oJ003161 for ; Mon, 5 Jan 2009 10:14:10 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n05FE8St025955 for ; Mon, 5 Jan 2009 10:14:09 -0500 Received: from dhcp-1-237.tlv.redhat.com (localhost [127.0.0.1]) by dhcp-1-237.tlv.redhat.com (Postfix) with ESMTP id 3D6BE18D43A for ; Mon, 5 Jan 2009 17:15:20 +0200 (IST) From: Gleb Natapov Date: Mon, 05 Jan 2009 17:15:20 +0200 Message-ID: <20090105151520.3819.93912.stgit@dhcp-1-237.tlv.redhat.com> In-Reply-To: <20090105151459.3819.79836.stgit@dhcp-1-237.tlv.redhat.com> References: <20090105151459.3819.79836.stgit@dhcp-1-237.tlv.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v2 4/5] Add "restrict" and "ip" option to "user" net option Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Expose new slirp capabilities to user through a command line options. Signed-off-by: Gleb Natapov --- net.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/net.c b/net.c index 3fa8776..6af4255 100644 --- a/net.c +++ b/net.c @@ -410,6 +410,8 @@ ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, /* slirp network adapter */ static int slirp_inited; +static int slirp_restrict; +static char *slirp_ip; static VLANClientState *slirp_vc; int slirp_can_output(void) @@ -446,7 +448,7 @@ static int net_slirp_init(VLANState *vlan) { if (!slirp_inited) { slirp_inited = 1; - slirp_init(0, NULL); + slirp_init(slirp_restrict, slirp_ip); } slirp_vc = qemu_new_vlan_client(vlan, slirp_receive, NULL, NULL); @@ -464,7 +466,7 @@ void net_slirp_redir(const char *redir_str) if (!slirp_inited) { slirp_inited = 1; - slirp_init(0, NULL); + slirp_init(slirp_restrict, slirp_ip); } p = redir_str; @@ -550,7 +552,7 @@ void net_slirp_smb(const char *exported_dir) if (!slirp_inited) { slirp_inited = 1; - slirp_init(0, NULL); + slirp_init(slirp_restrict, slirp_ip); } /* XXX: better tmp dir construction */ @@ -1487,6 +1489,12 @@ int net_client_init(const char *device, const char *p) if (get_param_value(buf, sizeof(buf), "hostname", p)) { pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); } + if (get_param_value(buf, sizeof(buf), "restrict", p)) { + slirp_restrict = (buf[0] == 'y') ? 1 : 0; + } + if (get_param_value(buf, sizeof(buf), "ip", p)) { + slirp_ip = strdup(buf); + } vlan->nb_host_devs++; ret = net_slirp_init(vlan); } else