summaryrefslogtreecommitdiff
path: root/net/slirp.c
AgeCommit message (Collapse)AuthorFilesLines
2014-03-12slirp smb with modern win guests when samba is also running on hostMichael Tokarev1-1/+2
After numerous reports that -smb (or -netdev user,smb=foo) not working with modern windows (win7 and vista are reported as non-working), I started digging myself. And found that indeed it doesn't work, and why. The thing is that modern win tries to connect to port 445 (microsoft-ds) first, and if that fails, it falls back to old port 139 (netbios-ssn). slirp code in qemu only redirects port 139, it does not touch port 445. So the prob is that if samba is also running on the host, guest will try to communicate using port 445, and that will succed, but ofcourse guest will not talk with our samba but with samba running on the host. If samba is not running on the host, guest will fall back to port 139, and will reach the redirecting rule and qemu will spawn smbd correctly. The solution is to redirect both ports (139 and 445), and the fix is a one-liner, adding second call to slirp_add_exec() at the end of net/slirp.c:slirp_smb() function (provided below). But it looks like that is not a proper fix really, since in theory we should redirect both ports to the SAME, single samba instance, but I'm not sure this is possible with slirp. Well, even if two smbd processes will be run on the same config dir, it should not be a problem. The one-liner (not exactly 1 since it touches previous line too) is like this: Signed-off-By: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2014-03-12qemu/slirp: Fix SMB security configuration on newer samba versionsMichael Buesch1-1/+2
The smb.conf automatically generated by qemu's -smb option fails on current samba, because smbd rejects the security=share option with the following warning: > WARNING: Ignoring invalid value 'share' for parameter 'security' Which makes it fall back to security=user without guest login. This results in being unable to login to the samba server from the guest OS. This fixes it by selecting 'user' explicitly and mapping unknown users to guest logins. Signed-off-by: Michael Buesch <m@bues.ch> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2013-06-19fix -net user checks by reordering checksBas van Sisseren1-6/+6
reorder slirp config options. first check the dns-server-address, then check the first-dhcp-address. the original code was comparing the first-dhcp-address with the default dns-server-address, not the configured dns-server-address. Signed-off-by: Bas van Sisseren <bas@quarantainenet.nl> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2013-04-15sysemu: avoid proliferation of include/ subdirectoriesPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-04-04qemu-char: Call fe_claim / fe_release when not using qdev chr propertiesHans de Goede1-0/+1
chardev-frontends need to explictly check, increase and decrement the avail_connections "property" of the chardev when they are not using a qdev-chardev-property for the chardev. This fixes things like: qemu-kvm -chardev stdio,id=foo -device isa-serial,chardev=foo \ -mon chardev=foo Working, where they should fail. Most of the changes here are due to old hardware emulation code which is using serial_hds directly rather then a qdev-chardev-property. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Message-id: 1364412581-3672-3-git-send-email-hdegoede@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-17HMP: add QDict to info callback handlerWenchao Xia1-1/+1
This patch change all info call back function to take additional QDict * parameter, which allow those command take parameter. Now it is set to NULL at default case. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2012-12-19softmmu: move remaining include files to include/ subdirectoriesPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19monitor: move include files to include/monitor/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19net: reorganize headersPaolo Bonzini1-1/+1
Move public headers to include/net, and leave private headers in net/. Put the virtio headers in include/net/tap.h, removing the multiple copies that existed. Leave include/net/tap.h as the interface for NICs, and net/tap_int.h as the interface for OS-specific parts of the tap backend. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19janitor: do not include qemu-char everywherePaolo Bonzini1-0/+1
Touching char/char.h basically causes the whole of QEMU to be rebuilt. Avoid this, it is usually unnecessary. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-15slirp: Add domain-search option to slirp's DHCP serverKlaus Stengel1-3/+32
This patch will allow the user to include the domain-search option in replies from the built-in DHCP server. The domain suffixes can be specified by adding dnssearch= entries to the "-net user" parameter. [Jan: tiny style adjustments] Signed-off-by: Klaus Stengel <Klaus.Stengel@asamnet.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-10-08net: consolidate NetClientState header files into onePaolo Bonzini1-1/+2
This patch doesn't seem much useful alone, I must admit. However, it makes sense as part of the upcoming directory reorganization, where I want to have include/net/tap.h as the net<->hw interface for tap. Then having both net/tap.h and include/net/tap.h does not work. "Fixed" by moving all the init functions to a single header file net/clients.h. The patch also adopts a uniform style for including net/*.h files from net/*.c, without the net/ path. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-08-09qapi: avoid reserved keywordsBlue Swirl1-3/+3
Clang compiler complained about use of reserved word 'restrict' in SLIRP and QAPI. Prefix C keywords with "q_", adjust SLIRP accordingly. Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-08-01net: determine if packets can be sent before net queue deliver packetsZhi Yong Wu1-7/+0
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-08-01net: Rename qemu_del_vlan_client() to qemu_del_net_client()Stefan Hajnoczi1-1/+1
Another step in moving the vlan feature out of net core. Users only deal with NetClientState and therefore qemu_del_vlan_client() should be named qemu_del_net_client(). Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-08-01net: Rename VLANClientState to NetClientStateStefan Hajnoczi1-7/+7
The vlan feature is no longer part of net core. Rename VLANClientState to NetClientState because net clients are not explicitly associated with a vlan at all, instead they have a peer net client to which they are connected. This patch is a mechanical search-and-replace except for a few whitespace fixups where changing VLANClientState to NetClientState misaligned whitespace. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-08-01net: Drop vlan argument to qemu_new_net_client()Stefan Hajnoczi1-1/+1
Since hubs are now used to implement the 'vlan' feature and the vlan argument is always NULL, remove the argument entirely and update all net clients that use qemu_new_net_client(). Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-08-01net: Look up 'vlan' net clients using hubsStefan Hajnoczi1-2/+5
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-08-01net: Use hubs for the vlan featureStefan Hajnoczi1-4/+4
Stop using the special-case vlan code in net.c. Instead use the hub net client to implement the vlan feature. The next patch will remove vlan code from net.c completely. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2012-07-23remove unused QemuOpts parameter from net init functionsLaszlo Ersek1-2/+2
v1->v2: - unchanged v2->v3: - keep "qemu-option.h" included in "net/slirp.h" Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-07-23convert net_init_slirp() to NetClientOptionsLaszlo Ersek1-68/+25
Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-07-23convert net_client_init() to OptsVisitorLaszlo Ersek1-1/+2
The net_client_init() prototype is kept intact. Based on "is_netdev", the QemuOpts-rooted QemuOpt-list is parsed as a Netdev or a NetLegacy. The original meat of net_client_init() is moved to and simplified in net_client_init1(): Fields not common between -net and -netdev are clearly separated. Getting the name for the init functions is cleaner: Netdev::id is mandatory, and all init functions handle a NULL NetLegacy::name. NetLegacy::vlan explicitly depends on -net (see below). Verifying the "type=" option for -netdev can be turned into a switch. Format validation with qemu_opts_validate() can be removed because the visitor covers it. Relatedly, the "net_client_types" array is reduced to an array of init functions that can be directly indexed by opts->kind. (Help text is available in the schema JSON.) The outermost negation in the condition around qemu_find_vlan() was flattened, because it expresses the dependent code's requirements more clearly. VLAN lookup is avoided if there's no init function to pass the VLAN to. Whenever the value of type=... is needed, we substitute NetClientOptionsKind_lookup[kind]. The individual init functions are not converted yet, thus the original QemuOpts instance is passed transparently. v1->v2: - NetLegacy::name is optional. Tracked it through all init functions: they all handle a NULL name. Updated commit message accordingly. v2->v3: - NetLegacy::id is allowed and takes precedence over NetLegacy::name. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-07-23hw, net: "net_client_type" -> "NetClientOptionsKind" (qapi-generated)Laszlo Ersek1-1/+1
NET_CLIENT_TYPE_ -> NET_CLIENT_OPTIONS_KIND_ Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-07-09slirp: Improve error reporting of inaccessible smb directoriesJan Kiszka1-2/+2
Instead of guessing, print the error code returned by access. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-07-09slirp: Ensure smbd and shared directory exist when enable smbDunrong Huang1-0/+12
Users may pass the following parameters to qemu: $ qemu-kvm -net nic -net user,smb= ... $ qemu-kvm -net nic -net user,smb ... $ qemu-kvm -net nic -net user,smb=bad_directory ... In these cases, qemu started successfully while samba server failed to start. Users will confuse since samba server failed silently without any indication of what it did wrong. To avoid it, we check whether the shared directory exist and if users have permission to access this directory when QEMU's "built-in" SMB server is enabled. Signed-off-by: Dunrong Huang <riegamaths@gmail.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-07-09slirp: add 'cmd:' target for guestfwdAlexander Graf1-17/+27
When using guestfwd=, Qemu only connects the virtual server's TCP port to a single chardev. This is useless in most cases, as we usually want to have more than a single connection from the guest to the outside world. This patch adds a new cmd: target to guestfwd= that allows for execution of a command on every TCP connection. This leverages the same code as the -smb parameter, just that here the command is user defined. Reported-by: Sascha Wilde <wilde@intevation.de> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-07-09slirp: Enforce host-side user of smb shareJan Kiszka1-2/+12
Windows 7 (and possibly other versions) cannot connect to the samba share if the exported host directory is not world-readable. This can be resolved by forcing the username used for access checks to the one under which QEMU and smbd are running. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-06-04net: purge the monitor object from all init functionsLuiz Capitulino1-4/+1
The only backend that really uses it is the socket one, which calls monitor_get_fd(). But it can use 'cur_mon' instead. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-By: Laszlo Ersek <lersek@redhat.com>
2012-05-01Declare state directory in smb.confNikolaus Rath1-0/+2
The smb.conf generated by the userspace networking does not include a state directory directive. Samba therefore falls back to the default value. Since the user generally does not have write access to this path, smbd immediately crashes. The "state directory" option was added in Samba 3.4.0 (commit http://gitweb.samba.org/?p=samba.git;a=commit;h=7b02e05eb64f3ffd7aa1cf027d10a7343c0da757). This patch adds the missing option. Signed-off-by: Nikolaus Rath <Nikolaus@rath.org> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2012-05-01slirp: don't use "smb ports = 0" optionNikolaus Rath1-1/+0
The "smb ports = 0" option causes recent samba versions to crash. It was introduced in commit 157777ef3e with log message "Samba 3 support". However, a value of 0 has never been officially supported by smb and is also not necessary: if stdin is a socket, smb does not try to listen on any ports and uses just stdin. This is necessary to support inetd based operation (otherwise smbd would always fail when called from inetd, because inetd already listens on the SMB port). Since samba has supported inetd operation since pre-3.x, it should be safe to rely on this feature. I have tested it with Samba 3.6.4 -- communication works fine, and smbd is not listening on any ports. I suspect the "smb ports = 0" hack may have been introduced when someone tested the qemu generated samba config from the command line with "smbd -i" and found it to fail (because then stdin isn't a socket). Signed-off-by: Nikolaus Rath <Nikolaus@rath.org> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2011-12-19slirp: Fix typo in net_slirp_hostfwd_removeGeoffrey Thomas1-1/+1
Report an error when err is nonzero, not when it is zero. Signed-off-by: Geoffrey Thomas <geofft@ldpreload.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-11-22slirp: Clean up net_slirp_hostfwd_remove()'s use of get_str_sep()Markus Armbruster1-5/+4
get_str_sep() can fail, but net_slirp_hostfwd_remove() doesn't check. Works, because it initializes buf[] to "", which get_str_sep() doesn't touch when it fails. Coverity doesn't like it, and neither do I. Change it to work exactly like slirp_hostfwd(). Acked-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-09-03Allow overriding the location of Samba's smbd.Brad1-1/+1
Allow overriding the location of Samba's smbd. Pretty much every OS I look at has some means of changing this path (patching) so lets just make it easier for OS developers creating packages and/or end users to override the location. Signed-off-by: Brad Smith <brad@comstyle.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-22char: rename qemu_chr_open() -> qemu_chr_new()Anthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-11/+11
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-23net: Refactor net_client_typesJan Kiszka1-1/+1
Position entries of net_client_types according to the corresponding values of NET_CLIENT_TYPE_*. The array size is now defined by NET_CLIENT_TYPE_MAX. This will allow to obtain entries based on type value in later patches. At this chance rename NET_CLIENT_TYPE_SLIRP to NET_CLIENT_TYPE_USER for the sake of consistency. CC: Markus Armbruster <armbru@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-07-23slirp: Canonicalize restrict syntaxJan Kiszka1-6/+15
All other boolean arguments accept on|off - except for slirp's restrict. Fix that while still accepting the formerly allowed yes|y|no|n, but reject everything else. This avoids accidentally allowing external connections because syntax errors were so far interpreted as 'restrict=no'. CC: Gleb Natapov <gleb@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-06-08slirp: fix guestfwd idAlexander Graf1-1/+1
When using -net user,guestfwd=... Qemu immediately complains about the id being in invalid format. This is because we pass in an id that contains a colon, while the id restrictions don't allow colons. This patch changes the colon into a dot, making guestfwd work again. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-04-15Remove unused sysemu.h include directivesBlue Swirl1-1/+0
Remove unused sysemu.h include directives to speed up build with the following patches. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-03-16error: Replace qemu_error() by error_report()Markus Armbruster1-14/+14
error_report() terminates the message with a newline. Strip it it from its arguments. This fixes a few error messages lacking a newline: net_handle_fd_param()'s "No file descriptor named %s found", and tap_open()'s "vnet_hdr=1 requested, but no kernel support for IFF_VNET_HDR available" (all three versions). There's one place that passes arguments without newlines intentionally: load_vmstate(). Fix it up.
2010-03-09slirp: check system() successJuan Quintela1-1/+1
we shouldn't call W*() macros until we check that fork worked. Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19net: Fix bogus "Warning: vlan 0 with no nics" with -deviceMarkus Armbruster1-4/+0
net_check_clients() prints this when an VLAN has host devices, but no guest devices. It uses VLANState members nb_guest_devs and nb_host_devs to keep track of these devices. However, -device does not update nb_guest_devs, only net_init_nic() does that, for -net nic. Check the VLAN clients directly, and remove the counters. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-27Fix BSD buildBlue Swirl1-0/+3
<sys/wait.h> must be included in order to use WIF* macros. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-26net/slirp.c: fix warning with _FORTIFY_SOURCEKirill A. Shutemov1-1/+8
CC net/slirp.o cc1: warnings being treated as errors net/slirp.c: In function 'slirp_smb_cleanup': net/slirp.c:470: error: ignoring return value of 'system', declared with attribute warn_unused_result make: *** [net/slirp.o] Error 1 Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03net: convert slirp to NetClientInfoMark McLoughlin1-24/+37
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03net: move slirp code from net.c to net/slirp.cMark McLoughlin1-0/+752
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>