Go to file
Stefan Hajnoczi 8917c3bdba slirp: switch to GPollFD
Slirp uses rfds/wfds/xfds more extensively than other QEMU components.

The rarely-used out-of-band TCP data feature is used.  That means we
need the full table of select(2) to g_poll(3) events:

  rfds -> G_IO_IN | G_IO_HUP | G_IO_ERR
  wfds -> G_IO_OUT | G_IO_ERR
  xfds -> G_IO_PRI

I came up with this table by looking at Linux fs/select.c which maps
select(2) to poll(2) internally.

Another detail to watch out for are the global variables that reference
rfds/wfds/xfds during slirp_select_poll().  sofcantrcvmore() and
sofcantsendmore() use these globals to clear fd_set bits.  When
sofcantrcvmore() is called, the wfds bit is cleared so that the write
handler will no longer be run for this iteration of the event loop.

This actually seems buggy to me since TCP connections can be half-closed
and we'd still want to handle data in half-duplex fashion.  I think the
real intention is to avoid running the read/write handler when the
socket has been fully closed.  This is indicated with the SS_NOFDREF
state bit so we now check for it before invoking the TCP write handler.
Note that UDP/ICMP code paths don't care because they are
connectionless.

Note that slirp/ has a lot of tabs and sometimes mixed tabs with spaces.
I followed the style of the surrounding code.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-id: 1361356113-11049-6-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-21 16:17:31 -06:00
audio audio: Replace non-portable asprintf in debug code by g_strdup_printf 2013-01-16 12:03:26 -06:00
backends Make all static TypeInfos const 2013-01-10 15:11:53 -06:00
block block/curl: only restrict protocols with libcurl>=7.19.4 2013-02-13 11:57:35 -06:00
bsd-user qemu-log: Rename the public-facing cpu_set_log function to qemu_set_log 2013-02-16 10:44:44 +00:00
default-configs make usb devices configurable 2013-02-19 12:28:48 +01:00
disas build: remove universal-obj-y 2013-01-26 13:15:35 +00:00
docs trace: Fix location of simpletrace.py in docs 2013-02-05 21:52:55 +01:00
fpu softfloat: Handle float_muladd_negate_c when product is zero 2013-01-26 13:22:09 +00:00
fsdev virtfs-proxy-helper: Fix unchecked strdup() by conv. to g_strdup() 2013-01-30 11:14:46 +01:00
gdb-xml
hw Merge remote-tracking branch 'kraxel/usb.78' into staging 2013-02-21 09:39:17 -06:00
include Remove forward declaration of non-existant variable 2013-02-21 10:33:39 +01:00
ldscripts build: create ldscripts/ 2012-12-19 08:29:06 +01:00
libcacard libcacard: Fix unchecked strdup() by converting to g_strdup() 2013-01-30 11:14:46 +01:00
linux-headers Update Linux kernel headers 2013-01-18 19:06:57 +01:00
linux-user cpu: Move running field to CPUState 2013-02-16 14:51:00 +01:00
net net: Avoid NULL function pointer dereference on cleanup 2013-02-13 11:57:25 -06:00
pc-bios Revert "Update OpenBIOS images" 2013-02-14 08:58:30 -06:00
pixman@97336fad32 qapi: move include files to include/qobject/ 2012-12-19 08:31:31 +01:00
qapi qapi: Fix unchecked strdup() by converting to g_strdup() 2013-01-30 11:14:46 +01:00
qga qemu-ga: Fix unchecked strdup() by converting to g_strdup() 2013-01-30 11:14:46 +01:00
QMP qmp: add pull_event function 2012-10-24 10:26:22 +02:00
qobject build: move qobject files to qobject/ and libqemuutil.a 2013-01-12 18:42:50 +01:00
qom cpu: Move current_tb field to CPUState 2013-02-16 14:51:00 +01:00
roms Revert "Update OpenBIOS images" 2013-02-14 08:58:30 -06:00
scripts fix scripts/make_device_config.sh 2013-02-19 11:53:49 +01:00
slirp slirp: switch to GPollFD 2013-02-21 16:17:31 -06:00
stubs slirp: switch to GPollFD 2013-02-21 16:17:31 -06:00
sysconfigs/target Eliminate cpus-x86_64.conf file 2012-09-21 15:12:58 +02:00
target-alpha cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-arm cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-cris cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-i386 target-i386: Split command line parsing out of cpu_x86_register() 2013-02-16 14:51:01 +01:00
target-lm32 target-lm32: Drop unused cpu_lm32_close() prototype 2013-02-16 14:51:00 +01:00
target-m68k cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-microblaze cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-mips cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-openrisc cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-ppc cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-s390x target-s390x: Drop unused cpu_s390x_close() prototype 2013-02-16 14:51:00 +01:00
target-sh4 cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-sparc Merge remote-tracking branch 'afaerber/qom-cpu' into staging 2013-02-18 08:37:29 -06:00
target-unicore32 cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
target-xtensa cpu: Add CPUArchState pointer to CPUState 2013-02-16 14:51:00 +01:00
tcg tcg/ppc: Fix build of tcg_qemu_tb_exec() 2013-02-17 14:27:36 +00:00
tests Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2013-02-21 09:38:27 -06:00
trace trace: deal with deprecated glib thread functions 2013-02-12 16:26:44 -06:00
ui vnc-tls: Fix compilation with newer versions of GNU-TLS 2013-02-18 08:40:20 -06:00
util host-utils: Improve mulu64 and muls64 2013-02-17 14:28:58 +00:00
.exrc qemu: add .exrc 2012-09-07 09:02:44 +03:00
.gitignore .gitignore: Ignore optionrom/*.asm 2013-02-21 10:38:07 +01:00
.gitmodules pixman: add submodule 2012-11-01 13:10:06 +01:00
.mailmap Add a .mailmap to map pre-git-conversion authors to friendly names 2011-12-12 17:06:21 -06:00
aio-posix.c aio: Fix return value of aio_poll() 2013-01-17 10:51:42 +01:00
aio-win32.c aio: Fix return value of aio_poll() 2013-01-17 10:51:42 +01:00
arch_init.c Allow XBZRLE decoding without enabling the capability 2013-02-01 08:32:21 +01:00
async.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
balloon.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
block-migration.c block-migration: fix pending() and iterate() return values 2013-02-12 16:26:44 -06:00
block.c block: Fix is_allocated_above with resized files 2013-02-01 14:58:28 +01:00
blockdev-nbd.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
blockdev.c Merge remote-tracking branch 'kwolf/for-anthony' into staging 2013-01-28 14:46:45 -06:00
blockjob.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
bt-host.c softmmu: move remaining include files to include/ subdirectories 2012-12-19 08:32:46 +01:00
bt-vhci.c softmmu: move remaining include files to include/ subdirectories 2012-12-19 08:32:46 +01:00
Changelog fix some common typos 2012-05-14 07:27:24 +02:00
cmd.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
cmd.h Delete useless 'extern' qualifiers for functions 2011-01-23 16:21:20 +00:00
CODING_STYLE Replace Qemu by QEMU in internal documentation 2012-04-07 13:58:25 +00:00
configure usb-host: move legacy cmd line bits 2013-02-19 12:30:05 +01:00
COPYING
COPYING.LIB
coroutine-gthread.c block: move include files to include/block/ 2012-12-19 08:31:31 +01:00
coroutine-sigaltstack.c block: move include files to include/block/ 2012-12-19 08:31:31 +01:00
coroutine-ucontext.c gcc: rename CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET to CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE 2013-01-12 12:42:53 +00:00
coroutine-win32.c block: move include files to include/block/ 2012-12-19 08:31:31 +01:00
cpu-exec.c cpu: Move current_tb field to CPUState 2013-02-16 14:51:00 +01:00
cpus.c cpus.c: Drop unnecessary set_cpu_log() 2013-02-16 10:45:19 +00:00
cputlb.c cpu: Move current_tb field to CPUState 2013-02-16 14:51:00 +01:00
device_tree.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
disas.c monitor: move include files to include/monitor/ 2012-12-19 08:31:32 +01:00
dma-helpers.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
dump-stub.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
dump.c cpu: Move host_tid field to CPUState 2013-02-16 14:50:59 +01:00
exec.c cputlb: Pass CPUState to cpu_unlink_tb() 2013-02-16 14:51:00 +01:00
gdbstub.c cpu: Move host_tid field to CPUState 2013-02-16 14:50:59 +01:00
HACKING HACKING: List areas where we may rely on impdef C behaviour 2012-12-08 14:27:40 +00:00
hmp-commands.hx hmp: Disable chardev-add and chardev-remove 2013-02-06 16:35:43 -06:00
hmp.c error: Strip trailing '\n' from error string arguments (again) 2013-02-11 08:13:19 -06:00
hmp.h qemu-char: Saner naming of memchar stuff & doc fixes 2013-02-06 16:35:19 -06:00
iohandler.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
ioport.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
kvm-all.c cpu: Move exit_request field to CPUState 2013-02-16 14:51:00 +01:00
kvm-stub.c kvm: Pass CPUState to kvm_on_sigbus_vcpu() 2013-01-28 16:57:56 +01:00
LICENSE LICENSE: There is no libqemu.a anymore 2011-12-09 11:25:22 +00:00
main-loop.c slirp: switch to GPollFD 2013-02-21 16:17:31 -06:00
MAINTAINERS prep: Move PReP machine to hw/ppc/ 2013-01-30 10:42:29 +01:00
Makefile build: remove *.lo, *.a, *.la files from all subdirectories on make clean 2013-01-26 13:30:00 +00:00
Makefile.objs qtest: Add MMIO support 2013-02-18 08:39:10 -06:00
Makefile.target qtest: Add MMIO support 2013-02-18 08:39:10 -06:00
memory_mapping-stub.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
memory_mapping.c exec: change RAM list to a TAILQ 2012-12-20 23:08:47 +01:00
memory.c memory: Use non-bitops ctzl 2013-02-16 11:12:13 +00:00
migration-exec.c migration: make writes blocking 2012-12-20 23:09:25 +01:00
migration-fd.c migration: make writes blocking 2012-12-20 23:09:25 +01:00
migration-tcp.c migration: make writes blocking 2012-12-20 23:09:25 +01:00
migration-unix.c migration: make writes blocking 2012-12-20 23:09:25 +01:00
migration.c migration: restrict scope of incoming fd read handler 2013-02-11 13:22:52 -06:00
monitor.c qemu-log: Rename CPULogItem, cpu_log_items to QEMULogItem, qemu_log_items 2013-02-16 10:45:46 +00:00
nbd.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
os-posix.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
os-win32.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
page_cache.c migration: move include files to include/migration/ 2012-12-19 08:31:32 +01:00
qapi-schema-test.json qapi: add struct-errors test case to test-qmp-output-visitor 2012-03-27 09:11:00 -03:00
qapi-schema.json qapi: Flatten away ChardevPort 2013-02-13 11:57:32 -06:00
qdict-test-data.txt
qemu-bridge-helper.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
qemu-char.c qapi: Flatten away ChardevPort 2013-02-13 11:57:32 -06:00
qemu-coroutine-io.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
qemu-coroutine-lock.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
qemu-coroutine-sleep.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
qemu-coroutine.c block: move include files to include/block/ 2012-12-19 08:31:31 +01:00
qemu-doc.texi Documentation: Update image format information 2012-11-30 11:33:24 +01:00
qemu-img-cmds.hx qemu-img: document 'info --backing-chain' 2012-10-24 10:26:19 +02:00
qemu-img.c qemu-img: report size overflow error message 2013-01-02 16:08:56 +01:00
qemu-img.texi Documentation: Update image format information 2012-11-30 11:33:24 +01:00
qemu-io.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
qemu-log.c qemu-log: Rename CPULogItem, cpu_log_items to QEMULogItem, qemu_log_items 2013-02-16 10:45:46 +00:00
qemu-nbd.c block: move include files to include/block/ 2012-12-19 08:31:31 +01:00
qemu-nbd.texi qemu-nbd: document --cache and --aio options 2013-02-08 11:14:19 -06:00
qemu-options-wrapper.h vl.c: In qemu -h output, only print options for the arch we are running as 2011-12-19 10:27:33 -06:00
qemu-options.h vl.c: Move option generation logic into a wrapper file 2011-12-19 10:27:33 -06:00
qemu-options.hx doc help: Collect block device stuff under its own heading 2013-02-18 08:39:48 -06:00
qemu-seccomp.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
qemu-tech.texi qemu-tech.texi: update implemented xtensa features list 2012-11-29 13:00:52 -06:00
qemu-timer.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
qemu.sasl
qmp-commands.hx qemu-char: Saner naming of memchar stuff & doc fixes 2013-02-06 16:35:19 -06:00
qmp.c softmmu: move remaining include files to include/ subdirectories 2012-12-19 08:32:46 +01:00
qtest.c qtest: Add MMIO support 2013-02-18 08:39:10 -06:00
readline.c readline: Fix unchecked strdup() by converting to g_strdup() 2013-01-30 11:14:46 +01:00
README Update README 2011-12-11 17:50:43 -06:00
rules.mak rules/mak: make clean should blow away timestamp files 2013-01-30 01:31:08 +02:00
savevm.c migration: make qemu_ftell() public and support writable files 2013-02-12 16:26:44 -06:00
spice-qemu-char.c Merge remote-tracking branch 'bonzini/header-dirs' into staging 2012-12-19 17:15:39 -06:00
tcg-runtime.c
tci.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
thread-pool.c misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
thunk.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00
TODO
trace-events usb-xhci: usb3 streams 2013-02-19 13:17:48 +01:00
translate-all.c cputlb: Pass CPUState to cpu_unlink_tb() 2013-02-16 14:51:00 +01:00
translate-all.h cputlb: Pass CPUState to cpu_unlink_tb() 2013-02-16 14:51:00 +01:00
user-exec.c Merge remote-tracking branch 'bonzini/header-dirs' into staging 2012-12-19 17:15:39 -06:00
VERSION Open up 1.5 development tree 2013-02-15 17:40:56 -06:00
version.rc
vl.c usb-host: remove usb_host_device_close 2013-02-19 12:30:05 +01:00
xbzrle.c Move XBZRLE encoding code to a separate file to allow testing 2013-02-01 08:32:20 +01:00
xen-all.c xen: Simplify halting of first CPU 2013-01-15 04:09:14 +01:00
xen-mapcache.c softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
xen-stub.c exec: move include files to include/exec/ 2012-12-19 08:31:31 +01:00

Read the documentation in qemu-doc.html or on http://wiki.qemu.org

- QEMU team