Commit 49ec9b4054defe6bebb151399fabcfdcd35ad4aa

Authored by aliguori
1 parent a9ba3a85

Add "restrict" and "ip" option to "user" net option (Gleb Natapov)

Expose new slirp capabilities to user through a command line options.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6242 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 11 additions and 3 deletions
... ... @@ -447,6 +447,8 @@ ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov,
447 447 /* slirp network adapter */
448 448  
449 449 static int slirp_inited;
  450 +static int slirp_restrict;
  451 +static char *slirp_ip;
450 452 static VLANClientState *slirp_vc;
451 453  
452 454 int slirp_can_output(void)
... ... @@ -483,7 +485,7 @@ static int net_slirp_init(VLANState *vlan, const char *model, const char *name)
483 485 {
484 486 if (!slirp_inited) {
485 487 slirp_inited = 1;
486   - slirp_init(0, NULL);
  488 + slirp_init(slirp_restrict, slirp_ip);
487 489 }
488 490 slirp_vc = qemu_new_vlan_client(vlan, model, name,
489 491 slirp_receive, NULL, NULL);
... ... @@ -501,7 +503,7 @@ void net_slirp_redir(const char *redir_str)
501 503  
502 504 if (!slirp_inited) {
503 505 slirp_inited = 1;
504   - slirp_init(0, NULL);
  506 + slirp_init(slirp_restrict, slirp_ip);
505 507 }
506 508  
507 509 p = redir_str;
... ... @@ -587,7 +589,7 @@ void net_slirp_smb(const char *exported_dir)
587 589  
588 590 if (!slirp_inited) {
589 591 slirp_inited = 1;
590   - slirp_init(0, NULL);
  592 + slirp_init(slirp_restrict, slirp_ip);
591 593 }
592 594  
593 595 /* XXX: better tmp dir construction */
... ... @@ -1554,6 +1556,12 @@ int net_client_init(const char *device, const char *p)
1554 1556 if (get_param_value(buf, sizeof(buf), "hostname", p)) {
1555 1557 pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf);
1556 1558 }
  1559 + if (get_param_value(buf, sizeof(buf), "restrict", p)) {
  1560 + slirp_restrict = (buf[0] == 'y') ? 1 : 0;
  1561 + }
  1562 + if (get_param_value(buf, sizeof(buf), "ip", p)) {
  1563 + slirp_ip = strdup(buf);
  1564 + }
1557 1565 vlan->nb_host_devs++;
1558 1566 ret = net_slirp_init(vlan, device, name);
1559 1567 } else
... ...