From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M2hBu-0002TB-Dg for qemu-devel@nongnu.org; Sat, 09 May 2009 03:41:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M2hBp-0002Sv-EB for qemu-devel@nongnu.org; Sat, 09 May 2009 03:41:49 -0400 Received: from [199.232.76.173] (port=42267 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M2hBp-0002Ss-4m for qemu-devel@nongnu.org; Sat, 09 May 2009 03:41:45 -0400 Received: from mx20.gnu.org ([199.232.41.8]:8403) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M2hBo-0004JK-9o for qemu-devel@nongnu.org; Sat, 09 May 2009 03:41:44 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M2hBk-0005kR-U1 for qemu-devel@nongnu.org; Sat, 09 May 2009 03:41:42 -0400 Message-ID: <4A0533AA.30505@web.de> Date: Sat, 09 May 2009 09:41:30 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <20090508103416.6080.44298.stgit@mchn012c.ww002.siemens.net> <4A045CEE.5040603@codemonkey.ws> <4A04657F.7040603@siemens.com> In-Reply-To: <4A04657F.7040603@siemens.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig3BAE6DCB31855346A3698650" Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH 08/11 v2] slirp: Move smb, redir, tftp and bootp parameters and -net channel List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig3BAE6DCB31855346A3698650 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Jan Kiszka wrote: > Anthony Liguori wrote: >> Jan Kiszka wrote: >>> This series starts with four networking-related fixes and then focuse= s >>> on a grand refactoring of the slirp user space IP stack configuration= =2E >>> >>> The major contribution is that the virtual IP addresses used by slirp= >>> can now be (almost) freely configured. This enables sophisticated >>> virtual network setups, specifically with guests that depends on >>> specific addresses. >>> >>> Find this series also at git://git.kiszka.org/qemu.git queues/net >>> >>> Jan Kiszka (11): >>> net: Don't deliver to disabled interfaces in qemu_sendv_packet >>> net: Fix and improved ordered packet delivery >>> slirp: Avoid zombie processes after fork_exec >>> net: Real fix for check_params users >>> net: Improve parameter error reporting >>> slirp: Reorder initialization >>> Introduce get_next_param_value >>> slirp: Move smb, redir, tftp and bootp parameters and -net chan= nel >>> slirp: Rework internal configuration >>> slirp: Rework external configuration interface >>> slirp: Bind support for host forwarding rules >>> =20 >> With this series applied, I get: >> >> CC slirp/cksum.o >> In file included from /home/anthony/git/qemu/slirp/slirp.h:216, >> from /home/anthony/git/qemu/slirp/cksum.c:34: >> /home/anthony/git/qemu/slirp/main.h:51: error: =E2=80=98PATH_MAX=E2=80= =99 undeclared >> here (not in a function) >> make: *** [slirp/cksum.o] Error 1 >=20 > Hmpf. >=20 > As I can't reproduce here: Does this add-on patch make it build? >=20 > diff --git a/slirp/main.h b/slirp/main.h > index 537c145..44f649a 100644 > --- a/slirp/main.h > +++ b/slirp/main.h > @@ -9,6 +9,8 @@ > #include > #endif > =20 > +#include > + This should have been "limits", of course. Here is an updated patch 8: ---------> So far a couple of slirp-related parameters were expressed via stand-alone command line options. This it inconsistent and unintuitive. Moreover, it prevents both dynamically reconfigured (host_net_add/ delete) and multi-instance slirp. This patch refactors the configuration by turning -smb, -redir, -tftp and -bootp as well as -net channel into options of "-net user". The old stand-alone command line options are still processed, but no longer advertised. This allows smooth migration of management applications to to the new syntax and also the extension of that syntax later in this series. Signed-off-by: Jan Kiszka --- net.c | 157 +++++++++++++++++++++++++++++++---------- net.h | 3 + qemu-options.hx | 209 +++++++++++++++++++++++++++++-------------------= ------ slirp/bootp.c | 4 + slirp/libslirp.h | 5 + slirp/main.h | 4 + slirp/slirp.c | 10 ++- slirp/tftp.c | 6 +- vl.c | 6 +- 9 files changed, 256 insertions(+), 148 deletions(-) diff --git a/net.c b/net.c index b20a907..b5238e8 100644 --- a/net.c +++ b/net.c @@ -551,13 +551,18 @@ static void config_error(Monitor *mon, const char *= fmt, ...) =20 /* slirp network adapter */ =20 +#define SLIRP_CFG_REDIR 1 + struct slirp_config_str { struct slirp_config_str *next; - const char *str; + int flags; + char str[1024]; }; =20 static int slirp_inited; -static struct slirp_config_str *slirp_redirs; +static struct slirp_config_str *slirp_configs; +const char *legacy_tftp_prefix; +const char *legacy_bootp_filename; #ifndef _WIN32 static const char *slirp_smb_export; #endif @@ -565,6 +570,7 @@ static VLANClientState *slirp_vc; =20 static void slirp_smb(const char *exported_dir); static void slirp_redirection(Monitor *mon, const char *redir_str); +static void vmchannel_init(Monitor *mon, const char *config_str); =20 int slirp_can_output(void) { @@ -603,25 +609,40 @@ static void net_slirp_cleanup(VLANClientState *vc) slirp_in_use =3D 0; } =20 -static int net_slirp_init(VLANState *vlan, const char *model, const char= *name, - int restricted, const char *ip) +static int net_slirp_init(Monitor *mon, VLANState *vlan, const char *mod= el, + const char *name, int restricted, const char *= ip, + const char *tftp_export, const char *bootfile,= + const char *smb_export) { if (slirp_in_use) { /* slirp only supports a single instance so far */ return -1; } if (!slirp_inited) { + if (!tftp_export) { + tftp_export =3D legacy_tftp_prefix; + } + if (!bootfile) { + bootfile =3D legacy_bootp_filename; + } slirp_inited =3D 1; - slirp_init(restricted, ip); + slirp_init(restricted, ip, tftp_export, bootfile); =20 - while (slirp_redirs) { - struct slirp_config_str *config =3D slirp_redirs; + while (slirp_configs) { + struct slirp_config_str *config =3D slirp_configs; =20 - slirp_redirection(NULL, config->str); - slirp_redirs =3D config->next; + if (config->flags & SLIRP_CFG_REDIR) { + slirp_redirection(mon, config->str); + } else { + vmchannel_init(mon, config->str); + } + slirp_configs =3D config->next; qemu_free(config); } #ifndef _WIN32 + if (smb_export) { + slirp_smb_export =3D smb_export; + } if (slirp_smb_export) { slirp_smb(slirp_smb_export); } @@ -696,9 +717,10 @@ void net_slirp_redir(Monitor *mon, const char *redir= _str) monitor_printf(mon, "user mode network stack not in use\n");= } else { config =3D qemu_malloc(sizeof(*config)); - config->str =3D redir_str; - config->next =3D slirp_redirs; - slirp_redirs =3D config; + pstrcpy(config->str, sizeof(config->str), redir_str); + config->flags =3D SLIRP_CFG_REDIR; + config->next =3D slirp_configs; + slirp_configs =3D config; } return; } @@ -827,6 +849,36 @@ static void vmchannel_read(void *opaque, const uint8= _t *buf, int size) slirp_socket_recv(4, vmc->port, buf, size); } =20 +static void vmchannel_init(Monitor *mon, const char *config_str) +{ + struct VMChannel *vmc; + char *devname; + char name[20]; + int port; + + port =3D strtol(config_str, &devname, 10); + if (port < 1 || port > 65535 || *devname !=3D ':') { + config_error(mon, "invalid vmchannel port number\n"); + return; + } + devname++; + + vmc =3D qemu_malloc(sizeof(struct VMChannel)); + snprintf(name, sizeof(name), "vmchannel%d", port); + vmc->hd =3D qemu_chr_open(name, devname, NULL); + if (!vmc->hd) { + config_error(mon, "could not open vmchannel device '%s'\n", devn= ame); + qemu_free(vmc); + return; + } + vmc->port =3D port; + + slirp_add_exec(3, vmc->hd, 4, port); + qemu_chr_add_handlers(vmc->hd, vmchannel_can_read, vmchannel_read, + NULL, vmc); + return; +} + #endif /* CONFIG_SLIRP */ =20 #if !defined(_WIN32) @@ -1936,10 +1988,16 @@ int net_client_init(Monitor *mon, const char *dev= ice, const char *p) #ifdef CONFIG_SLIRP if (!strcmp(device, "user")) { static const char * const slirp_params[] =3D { - "vlan", "name", "hostname", "restrict", "ip", NULL + "vlan", "name", "hostname", "restrict", "ip", "tftp", "bootf= ile", + "smb", "redir", "channel", NULL }; + struct slirp_config_str *config; + char *tftp_export =3D NULL; + char *bootfile =3D NULL; + char *smb_export =3D NULL; int restricted =3D 0; char *ip =3D NULL; + const char *q; =20 if (check_params(buf, sizeof(buf), slirp_params, p) < 0) { config_error(mon, "invalid parameter '%s' in '%s'\n", buf, p= ); @@ -1955,34 +2013,59 @@ int net_client_init(Monitor *mon, const char *dev= ice, const char *p) if (get_param_value(buf, sizeof(buf), "ip", p)) { ip =3D qemu_strdup(buf); } + if (get_param_value(buf, sizeof(buf), "tftp", p)) { + tftp_export =3D qemu_strdup(buf); + } + if (get_param_value(buf, sizeof(buf), "bootfile", p)) { + bootfile =3D qemu_strdup(buf); + } + if (get_param_value(buf, sizeof(buf), "smb", p)) { + smb_export =3D qemu_strdup(buf); + } + q =3D p; + while (1) { + config =3D qemu_malloc(sizeof(*config)); + if (!get_next_param_value(config->str, sizeof(config->str), + "redir", &q)) { + break; + } + config->flags =3D SLIRP_CFG_REDIR; + config->next =3D slirp_configs; + slirp_configs =3D config; + config =3D NULL; + } + q =3D p; + while (1) { + config =3D qemu_malloc(sizeof(*config)); + if (!get_next_param_value(config->str, sizeof(config->str), + "channel", &q)) { + break; + } + config->flags =3D 0; + config->next =3D slirp_configs; + slirp_configs =3D config; + config =3D NULL; + } + qemu_free(config); vlan->nb_host_devs++; - ret =3D net_slirp_init(vlan, device, name, restricted, ip); + ret =3D net_slirp_init(mon, vlan, device, name, restricted, ip, + tftp_export, bootfile, smb_export); qemu_free(ip); + qemu_free(tftp_export); + qemu_free(bootfile); + qemu_free(smb_export); } else if (!strcmp(device, "channel")) { - long port; - char name[20], *devname; - struct VMChannel *vmc; - - port =3D strtol(p, &devname, 10); - devname++; - if (port < 1 || port > 65535) { - config_error(mon, "vmchannel wrong port number\n"); - ret =3D -1; - goto out; - } - vmc =3D malloc(sizeof(struct VMChannel)); - snprintf(name, 20, "vmchannel%ld", port); - vmc->hd =3D qemu_chr_open(name, devname, NULL); - if (!vmc->hd) { - config_error(mon, "could not open vmchannel device '%s'\n", - devname); - ret =3D -1; - goto out; + if (!slirp_inited) { + struct slirp_config_str *config; + + config =3D qemu_malloc(sizeof(*config)); + pstrcpy(config->str, sizeof(config->str), p); + config->flags =3D 0; + config->next =3D slirp_configs; + slirp_configs =3D config; + } else { + vmchannel_init(mon, p); } - vmc->port =3D port; - slirp_add_exec(3, vmc->hd, 4, port); - qemu_chr_add_handlers(vmc->hd, vmchannel_can_read, vmchannel_rea= d, - NULL, vmc); ret =3D 0; } else #endif diff --git a/net.h b/net.h index 4f8f393..980c380 100644 --- a/net.h +++ b/net.h @@ -108,6 +108,9 @@ uint16_t net_checksum_tcpudp(uint16_t length, uint16_= t proto, void net_checksum_calculate(uint8_t *data, int length); =20 /* from net.c */ +extern const char *legacy_tftp_prefix; +extern const char *legacy_bootp_filename; + int net_client_init(Monitor *mon, const char *device, const char *p); void net_client_uninit(NICInfo *nd); int net_client_parse(const char *str); diff --git a/qemu-options.hx b/qemu-options.hx index 87af798..e721f60 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -723,13 +723,27 @@ STEXI @table @option ETEXI =20 +HXCOMM Legacy slirp options (now moved to -net user): +#ifdef CONFIG_SLIRP +DEF("tftp", HAS_ARG, QEMU_OPTION_tftp, "") +DEF("bootp", HAS_ARG, QEMU_OPTION_bootp, "") +DEF("redir", HAS_ARG, QEMU_OPTION_redir, "") +#ifndef _WIN32 +DEF("smb", HAS_ARG, QEMU_OPTION_smb, "") +#endif +#endif + DEF("net", HAS_ARG, QEMU_OPTION_net, \ "-net nic[,vlan=3Dn][,macaddr=3Daddr][,model=3Dtype][,name=3Dstr]\n"= " create a new Network Interface Card and connect it = to VLAN 'n'\n" #ifdef CONFIG_SLIRP - "-net user[,vlan=3Dn][,name=3Dstr][,hostname=3Dhost]\n" - " connect the user mode network stack to VLAN 'n' and= send\n" - " hostname 'host' to DHCP clients\n" + "-net user[,vlan=3Dn][,name=3Dstr][ip=3Dnetaddr][,restrict=3Dy|n][,h= ostname=3Dhost]\n" + " [,tftp=3Ddir][,bootfile=3Df][,redir=3Drule][,channel=3Drul= e]" +#ifndef _WIN32 + "[,smb= =3Ddir]\n" +#endif + " connect the user mode network stack to VLAN 'n', co= nfigure its\n" + " DHCP server and enabled optional services\n" #endif #ifdef _WIN32 "-net tap[,vlan=3Dn][,name=3Dstr],ifname=3Dname\n" @@ -772,13 +786,102 @@ Valid values for @var{type} are Not all devices are supported on all targets. Use -net nic,model=3D? for a list of available devices for your target. =20 -@item -net user[,vlan=3D@var{n}][,hostname=3D@var{name}][,name=3D@var{na= me}] +@item -net user[,@var{option}][,@var{option}][,...] Use the user mode network stack which requires no administrator -privilege to run. @option{hostname=3Dname} can be used to specify the c= lient -hostname reported by the builtin DHCP server. +privilege to run. Valid options are: + +@table @code +@item vlan=3D@var{n} +Connect user mode stack to VLAN @var{n} (@var{n} =3D 0 is the default). + +@item name=3D@var{name} +Assign symbolic name for use in monitor commands. + +@item ip=3D@var{netaddr} +Set IP network address the guest will see (default: 10.0.2.x). + +@item restrict=3Dy|yes|n|no +If this options is enabled, the guest will be isolated, i.e. it will not= be +able to contact the host and no guest IP packets will be routed over the= host +to the outside. This option does not affect explicitly set forwarding ru= le. + +@item hostname=3D@var{name} +Specifies the client hostname reported by the builtin DHCP server. + +@item tftp=3D@var{dir} +When using the user mode network stack, activate a built-in TFTP +server. The files in @var{dir} will be exposed as the root of a TFTP ser= ver. +The TFTP client on the guest must be configured in binary mode (use the = command +@code{bin} of the Unix TFTP client). The host IP address on the guest is= +10.0.2.2 by default. + +@item bootfile=3D@var{file} +When using the user mode network stack, broadcast @var{file} as the BOOT= P +filename. In conjunction with @option{tftp}, this can be used to network= boot +a guest from a local directory. + +Example (using pxelinux): +@example +qemu -hda linux.img -boot n -net user,tftp=3D/path/to/tftp/files,bootfil= e=3D/pxelinux.0 +@end example + +@item smb=3D@var{dir} +When using the user mode network stack, activate a built-in SMB +server so that Windows OSes can access to the host files in @file{@var{d= ir}} +transparently. + +In the guest Windows OS, the line: +@example +10.0.2.4 smbserver +@end example +must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me) +or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000). + +Then @file{@var{dir}} can be accessed in @file{\\smbserver\qemu}. + +Note that a SAMBA server must be installed on the host OS in +@file{/usr/sbin/smbd}. QEMU was tested successfully with smbd versions f= rom +Red Hat 9, Fedora Core 3 and OpenSUSE 11.x. + +@item redir=3D[tcp|udp]:@var{host-port}:[@var{guest-host}]:@var{guest-po= rt} +Redirect incoming TCP or UDP connections to the host port @var{host-port= } to +the guest @var{guest-host} on guest port @var{guest-port}. If @var{guest= -host} +is not specified, its value is 10.0.2.15 (default address given by the b= uilt-in +DHCP server). If no connection type is specified, TCP is used. This opti= on can +be given multiple times. + +For example, to redirect host X11 connection from screen 1 to guest +screen 0, use the following: + +@example +# on the host +qemu -net user,redir=3Dtcp:6001::6000 [...] +# this host xterm should open in the guest X11 server +xterm -display :1 +@end example + +To redirect telnet connections from host port 5555 to telnet port on +the guest, use the following: + +@example +# on the host +qemu -net user,redir=3Dtcp:5555::23 [...] +telnet localhost 5555 +@end example + +Then when you use on the host @code{telnet localhost 5555}, you +connect to the guest telnet server. =20 -@item -net channel,@var{port}:@var{dev} -Forward @option{user} TCP connection to port @var{port} to character dev= ice @var{dev} +@item channel=3D@var{port}:@var{dev} +Forward guest TCP connections to port @var{port} on the host to characte= r +device @var{dev}. This option can be given multiple times. + +@end table + +Note: Legacy stand-alone options -tftp, -bootp, -smb and -redir are stil= l +processed and applied to -net user. Mixing them with the new configurati= on +syntax gives undefined results. Their use for new applications is discou= raged +as they will be removed from future versions. =20 @item -net tap[,vlan=3D@var{n}][,name=3D@var{name}][,fd=3D@var{h}][,ifna= me=3D@var{name}][,script=3D@var{file}][,downscript=3D@var{dfile}] Connect the host TAP network interface @var{name} to VLAN @var{n}, use @@ -884,96 +987,6 @@ libpcap, so it can be analyzed with tools such as tc= pdump or Wireshark. Indicate that no network devices should be configured. It is used to override the default configuration (@option{-net nic -net user}) which is activated if no @option{-net} options are provided. -ETEXI - -#ifdef CONFIG_SLIRP -DEF("tftp", HAS_ARG, QEMU_OPTION_tftp, \ - "-tftp dir allow tftp access to files in dir [-net user]\n") -#endif -STEXI -@item -tftp @var{dir} -When using the user mode network stack, activate a built-in TFTP -server. The files in @var{dir} will be exposed as the root of a TFTP ser= ver. -The TFTP client on the guest must be configured in binary mode (use the = command -@code{bin} of the Unix TFTP client). The host IP address on the guest is= as -usual 10.0.2.2. -ETEXI - -#ifdef CONFIG_SLIRP -DEF("bootp", HAS_ARG, QEMU_OPTION_bootp, \ - "-bootp file advertise file in BOOTP replies\n") -#endif -STEXI -@item -bootp @var{file} -When using the user mode network stack, broadcast @var{file} as the BOOT= P -filename. In conjunction with @option{-tftp}, this can be used to netwo= rk boot -a guest from a local directory. - -Example (using pxelinux): -@example -qemu -hda linux.img -boot n -tftp /path/to/tftp/files -bootp /pxelinux.0= -@end example -ETEXI - -#ifndef _WIN32 -DEF("smb", HAS_ARG, QEMU_OPTION_smb, \ - "-smb dir allow SMB access to files in 'dir' [-net use= r]\n") -#endif -STEXI -@item -smb @var{dir} -When using the user mode network stack, activate a built-in SMB -server so that Windows OSes can access to the host files in @file{@var{d= ir}} -transparently. - -In the guest Windows OS, the line: -@example -10.0.2.4 smbserver -@end example -must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me) -or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000). - -Then @file{@var{dir}} can be accessed in @file{\\smbserver\qemu}. - -Note that a SAMBA server must be installed on the host OS in -@file{/usr/sbin/smbd}. QEMU was tested successfully with smbd version -2.2.7a from the Red Hat 9 and version 3.0.10-1.fc3 from Fedora Core 3. -ETEXI - -#ifdef CONFIG_SLIRP -DEF("redir", HAS_ARG, QEMU_OPTION_redir, \ - "-redir [tcp|udp]:host-port:[guest-host]:guest-port\n" \ - " redirect TCP or UDP connections from host to guest = [-net user]\n") -#endif -STEXI -@item -redir [tcp|udp]:@var{host-port}:[@var{guest-host}]:@var{guest-por= t} - -When using the user mode network stack, redirect incoming TCP or UDP -connections to the host port @var{host-port} to the guest -@var{guest-host} on guest port @var{guest-port}. If @var{guest-host} -is not specified, its value is 10.0.2.15 (default address given by the -built-in DHCP server). If no connection type is specified, TCP is used. - -For example, to redirect host X11 connection from screen 1 to guest -screen 0, use the following: - -@example -# on the host -qemu -redir tcp:6001::6000 [...] -# this host xterm should open in the guest X11 server -xterm -display :1 -@end example - -To redirect telnet connections from host port 5555 to telnet port on -the guest, use the following: - -@example -# on the host -qemu -redir tcp:5555::23 [...] -telnet localhost 5555 -@end example - -Then when you use on the host @code{telnet localhost 5555}, you -connect to the guest telnet server. =20 @end table ETEXI diff --git a/slirp/bootp.c b/slirp/bootp.c index 8a97660..3f4d079 100644 --- a/slirp/bootp.c +++ b/slirp/bootp.c @@ -38,7 +38,7 @@ typedef struct { =20 static BOOTPClient bootp_clients[NB_ADDR]; =20 -const char *bootp_filename; +char bootp_filename[PATH_MAX] =3D ""; =20 static const uint8_t rfc1533_cookie[] =3D { RFC1533_COOKIE }; =20 @@ -249,7 +249,7 @@ static void bootp_reply(const struct bootp_t *bp) *q++ =3D DHCPACK; } =20 - if (bootp_filename) + if (bootp_filename[0] !=3D 0) snprintf((char *)rbp->bp_file, sizeof(rbp->bp_file), "%s", bootp_filename); =20 diff --git a/slirp/libslirp.h b/slirp/libslirp.h index c0781c3..c5b1bb9 100644 --- a/slirp/libslirp.h +++ b/slirp/libslirp.h @@ -5,7 +5,8 @@ extern "C" { #endif =20 -void slirp_init(int restricted, const char *special_ip); +void slirp_init(int restricted, const char *special_ip, const char *tftp= _path, + const char *bootfile); =20 void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds);= @@ -23,9 +24,7 @@ int slirp_redir(int is_udp, int host_port, int slirp_add_exec(int do_pty, const void *args, int addr_low_byte, int guest_port); =20 -extern const char *tftp_prefix; extern char slirp_hostname[33]; -extern const char *bootp_filename; =20 void slirp_stats(void); void slirp_socket_recv(int addr_low_byte, int guest_port, const uint8_t = *buf, diff --git a/slirp/main.h b/slirp/main.h index ed51385..9e84569 100644 --- a/slirp/main.h +++ b/slirp/main.h @@ -9,6 +9,8 @@ #include #endif =20 +#include + #define TOWRITEMAX 512 =20 extern struct timeval tt; @@ -46,6 +48,8 @@ extern int tcp_keepintvl; extern uint8_t client_ethaddr[6]; extern const char *slirp_special_ip; extern int slirp_restrict; +extern char tftp_prefix[PATH_MAX]; +extern char bootp_filename[PATH_MAX]; =20 #define PROTO_SLIP 0x1 #ifdef USE_PPP diff --git a/slirp/slirp.c b/slirp/slirp.c index 73b3704..0fe0286 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -171,7 +171,8 @@ static void slirp_cleanup(void) static void slirp_state_save(QEMUFile *f, void *opaque); static int slirp_state_load(QEMUFile *f, void *opaque, int version_id); =20 -void slirp_init(int restricted, const char *special_ip) +void slirp_init(int restricted, const char *special_ip, const char *tftp= _path, + const char *bootfile) { // debug_init("/tmp/slirp.log", DEBUG_DEFAULT); =20 @@ -202,7 +203,12 @@ void slirp_init(int restricted, const char *special_= ip) =20 if (special_ip) slirp_special_ip =3D special_ip; - + if (tftp_path) { + pstrcpy(tftp_prefix, sizeof(tftp_prefix), tftp_path); + } + if (bootfile) { + pstrcpy(bootp_filename, sizeof(bootp_filename), bootfile); + } inet_aton(slirp_special_ip, &special_addr); alias_addr.s_addr =3D special_addr.s_addr | htonl(CTL_ALIAS); getouraddr(); diff --git a/slirp/tftp.c b/slirp/tftp.c index 4ad5504..e525c6b 100644 --- a/slirp/tftp.c +++ b/slirp/tftp.c @@ -37,7 +37,7 @@ struct tftp_session { =20 static struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX]; =20 -const char *tftp_prefix; +char tftp_prefix[PATH_MAX] =3D ""; =20 static void tftp_session_update(struct tftp_session *spt) { @@ -335,7 +335,7 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pk= tlen) =20 /* only allow exported prefixes */ =20 - if (!tftp_prefix) { + if (tftp_prefix[0] =3D=3D 0) { tftp_send_error(spt, 2, "Access violation", tp); return; } @@ -370,7 +370,7 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pk= tlen) int tsize =3D atoi(value); struct stat stat_p; =20 - if (tsize =3D=3D 0 && tftp_prefix) { + if (tsize =3D=3D 0 && tftp_prefix[0] !=3D 0) { char buffer[1024]; int len; =20 diff --git a/vl.c b/vl.c index 6ab798d..728e6f2 100644 --- a/vl.c +++ b/vl.c @@ -5146,14 +5146,14 @@ int main(int argc, char **argv, char **envp) break; #ifdef CONFIG_SLIRP case QEMU_OPTION_tftp: - tftp_prefix =3D optarg; + legacy_tftp_prefix =3D optarg; break; case QEMU_OPTION_bootp: - bootp_filename =3D optarg; + legacy_bootp_filename =3D optarg; break; #ifndef _WIN32 case QEMU_OPTION_smb: - net_slirp_smb(optarg); + net_slirp_smb(optarg); break; #endif case QEMU_OPTION_redir: --------------enig3BAE6DCB31855346A3698650 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.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkoFM7AACgkQniDOoMHTA+m3FgCfaCUQq7/aJsrAFBTHqwsKUn/k bGsAn3pdJElmXr41xmbp7M08SkHtNQNj =Z7Vp -----END PGP SIGNATURE----- --------------enig3BAE6DCB31855346A3698650--