qemu-patch-raspberry4/include
Laurent Vivier 894022e616 net: check if the file descriptor is valid before using it
qemu_set_nonblock() checks that the file descriptor can be used and, if
not, crashes QEMU. An assert() is used for that. The use of assert() is
used to detect programming error and the coredump will allow to debug
the problem.

But in the case of the tap device, this assert() can be triggered by
a misconfiguration by the user. At startup, it's not a real problem, but it
can also happen during the hot-plug of a new device, and here it's a
problem because we can crash a perfectly healthy system.

For instance:
 # ip link add link virbr0 name macvtap0 type macvtap mode bridge
 # ip link set macvtap0 up
 # TAP=/dev/tap$(ip -o link show macvtap0 | cut -d: -f1)
 # qemu-system-x86_64 -machine q35 -device pcie-root-port,id=pcie-root-port-0 -monitor stdio 9<> $TAP
 (qemu) netdev_add type=tap,id=hostnet0,vhost=on,fd=9
 (qemu) device_add driver=virtio-net-pci,netdev=hostnet0,id=net0,bus=pcie-root-port-0
 (qemu) device_del net0
 (qemu) netdev_del hostnet0
 (qemu) netdev_add type=tap,id=hostnet1,vhost=on,fd=9
 qemu-system-x86_64: .../util/oslib-posix.c:247: qemu_set_nonblock: Assertion `f != -1' failed.
 Aborted (core dumped)

To avoid that, add a function, qemu_try_set_nonblock(), that allows to report the
problem without crashing.

In the same way, we also update the function for vhostfd in net_init_tap_one() and
for fd in net_init_socket() (both descriptors are provided by the user and can
be wrong).

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
2020-07-15 21:00:13 +08:00
..
authz Include generated QAPI headers less 2019-08-16 13:31:51 +02:00
block block: Add support to warn on backing file change without format 2020-07-14 15:18:59 +02:00
chardev chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h" 2020-07-13 11:59:47 +04:00
crypto firmware (and crypto) patches 2020-07-09 20:01:43 +01:00
disas target/avr: Register AVR support with the rest of QEMU 2020-07-11 11:02:05 +02:00
exec virtio,acpi: features, fixes, cleanups. 2020-07-07 17:37:44 +01:00
fpu softfloat,m68k: disable floatx80_invalid_encoding() for m68k 2020-07-06 21:41:52 +02:00
hw hw/char: Convert the Ibex UART to use the registerfields API 2020-07-13 17:25:37 -07:00
io io/task: Move 'qom/object.h' header to source 2020-06-10 12:09:37 -04:00
libdecnumber include: Make headers more self-contained 2019-08-16 13:31:51 +02:00
migration migration/colo: Use ram_block_discard_disable() 2020-07-02 05:54:59 -04:00
monitor hmp: Implement qom-get HMP command 2020-06-01 18:44:27 +01:00
net vhost-vdpa: introduce vhost-vdpa net client 2020-07-07 07:59:51 -04:00
qapi scripts: Coccinelle script to use ERRP_GUARD() 2020-07-10 15:18:09 +02:00
qemu net: check if the file descriptor is valid before using it 2020-07-15 21:00:13 +08:00
qom qom: Introduce object_property_try_add_child() 2020-07-10 18:02:16 -04:00
scsi scsi: explicitly list guest-recoverable sense codes 2019-07-15 11:20:42 +02:00
standard-headers Linux headers: update 2020-06-18 12:13:36 +02:00
sysemu 8bit AVR port from Michael Rolnik. 2020-07-11 19:27:59 +01:00
tcg tcg: call qemu_spin_destroy for tb->jmp_lock 2020-06-16 14:49:05 +01:00
ui Remove the CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE switch 2020-07-13 11:40:52 +02:00
user linux-user: Include trace-root.h in syscall-trace.h 2020-01-15 15:13:09 -10:00
elf.h hw/avr: Add support for loading ELF/raw binaries 2020-07-11 11:02:05 +02:00
glib-compat.h glib: bump min required glib library version to 2.48 2019-08-22 10:46:34 +01:00
qemu-common.h Update copyright date for user-facing copyright strings 2020-03-22 11:16:21 +00:00
qemu-io.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
trace-tcg.h trace: get rid of generated-events.h/generated-events.c 2016-10-12 09:54:52 +02:00