From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LKrbB-0005jP-Rh for qemu-devel@nongnu.org; Thu, 08 Jan 2009 04:54:45 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LKrb9-0005hr-R0 for qemu-devel@nongnu.org; Thu, 08 Jan 2009 04:54:44 -0500 Received: from [199.232.76.173] (port=36626 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LKrb9-0005hh-9b for qemu-devel@nongnu.org; Thu, 08 Jan 2009 04:54:43 -0500 Received: from mx2.redhat.com ([66.187.237.31]:36489) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LKrb8-0007a2-Lu for qemu-devel@nongnu.org; Thu, 08 Jan 2009 04:54:43 -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 n089sgdb003201 for ; Thu, 8 Jan 2009 04:54:42 -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 n089sg6x030117 for ; Thu, 8 Jan 2009 04:54:42 -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 n089sf2B011545 for ; Thu, 8 Jan 2009 04:54:41 -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 5AD9E18D43A for ; Thu, 8 Jan 2009 11:55:54 +0200 (IST) From: Gleb Natapov Date: Thu, 08 Jan 2009 11:55:54 +0200 Message-ID: <20090108095554.12548.92863.stgit@dhcp-1-237.tlv.redhat.com> In-Reply-To: <20090108095533.12548.8211.stgit@dhcp-1-237.tlv.redhat.com> References: <20090108095533.12548.8211.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 v3 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 2399557..237d3ef 100644 --- a/net.c +++ b/net.c @@ -446,6 +446,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) @@ -482,7 +484,7 @@ static int net_slirp_init(VLANState *vlan, const char *model, const char *name) { if (!slirp_inited) { slirp_inited = 1; - slirp_init(0, NULL); + slirp_init(slirp_restrict, slirp_ip); } slirp_vc = qemu_new_vlan_client(vlan, model, name, slirp_receive, NULL, NULL); @@ -500,7 +502,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; @@ -586,7 +588,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 */ @@ -1553,6 +1555,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, device, name); } else