If a packet is queued by qemu_send_packet(), remove I/O
handler for the tap fd until we get notification that the
packet has been sent.
A not insignificant side effect of this is we can now
drain the tap send queue in one go without fear of packets
being dropped.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Add a qemu_send_packet() variant which will queue up the packet
if it cannot be sent when all client queues are full. It later
invokes the supplied callback when the packet has been sent.
If qemu_send_packet_async() returns zero, the caller is expected
to not send any more packets until the queued packet has been
sent.
Packets are queued iff a receive() handler returns zero (indicating
queue full) and the caller has provided a sent notification callback
(indicating it will stop and start its own queue).
We need the packet sending API to support queueing because:
- a sending client should process all available packets in one go
(e.g. virtio-net emptying its tx ring)
- a receiving client may not be able to handle the packet
(e.g. -EAGAIN from write() to tapfd)
- the sending client could detect this condition in advance
(e.g. by select() for writable on tapfd)
- that's too much overhead (e.g. a select() call per packet)
- therefore the sending client must handle the condition by
dropping the packet or queueing it
- dropping packets is poor form; we should queue.
However, we don't want queueing to be completely transparent. We
want the sending client to stop sending packets as soon as a
packet is queued. This allows the sending client to be throttled
by the receiver.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
VLANClientState's fd_read() handler doesn't read from file
descriptors, it adds a buffer to the client's receive queue.
Re-name the handlers to make things a little less confusing.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
This, apparently, is the style we prefer - all VLANClientState
should be an argument to qemu_new_vlan_client().
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Reduce the number of packets dropped under heavy network
traffic by only reading a packet from the tapfd when a
client can actually handle it.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
If a vlan client has no fd_can_read(), that means it can
always receive packets. The current code assumes it can *never*
receive packets.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
KVM uses a 64k buffer for reading from tapfd (for GSO support)
and allocates the buffer with TAPState rather than on the stack.
Not allocating it on the stack probably makes sense for qemu
anyway, so merge it in advance of GSO support.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
This patch reorders the initialization of slirp itself as well as its
associated features smb and redirection. So far the first reference to
slirp triggered the initialization, independent of the actual -net user
option which may carry additional parameters. Now we save any request to
add a smb export or some redirections until the actual initialization of
the stack. This also allows to move a few parameters that were passed
via global variable into the argument list of net_slirp_init.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
As host network devices can also be instantiated via the monitor, errors
should then be reported to the related monitor instead of stderr. This
requires larger refactoring, so this patch starts small with introducing
a helper to catch both cases and convert net_client_init as well as
net_slirp_redir.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
A small bit of confusion between buffers is causing errors like:
qemu: invalid parameter '10' in 'script=/etc/qemu-ifup,fd=10'
instead of:
qemu: invalid parameter 'script' in 'script=/etc/qemu-ifup,fd=10'
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
OK, last try: 8e4416af45 broke -net socket, ffad4116b9 tried to fix it
but broke error reporting of invalid parameters. So this patch widely
reverts ffad4116b9 again and intead fixes those callers of check_params
that originally suffered from overwritten buffers by using separate
ones.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
This reverts commit 8cf07dcbe7.
This is a sorry saga.
This commit:
8e4416af45 net: Add parameter checks for VLAN clients
broken '-net socket' and this commit:
ffad4116b9 net: Fix -net socket parameter checks
fixed the problem but introduced another problem which
this commit:
8cf07dcbe7 Fix output of uninitialized strings
fixed that final problem, but causing us to lose some
error reporting information in the process.
Meanwhile Jan posted a patch to mostly re-do ffad4116b9
in a way that fixes the original issue, but without
losing the error reporting information. So, let's revert
8cf07dcbe7 and apply Jan's patch.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Slirp uses fork_exec for spawning service processes, and QEMU uses this
for running smbd. As SIGCHLD is not handled, these processes become
zombies on termination. Fix this by installing a proper signal handler,
but also make sure we disable the signal while waiting on forked network
setup/shutdown scripts.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Fix a race in qemu_send_packet when delivering deferred packets and
add proper deferring also to qemu_sendv_packet.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Users complained that it is not obvious what to do when kvm refuses to
build or run due to an unsupported host kernel, so let's improve the
hints.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
When configuring for several targets, some with KVM and some without, CONFIG_KVM was accidentally disabled for some of the targets.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Use hxtool to generate the 'command syntax' section of qemu-img's help
message, and the corresponding section of the texinfo documentation.
This has the side-effect of adding 'check' to this list of commands in
the texinfo documentation.
Signed-off-by: Stuart Brady <stuart.brady@gmail.com>
Update the documentation to reflect the introduction of format specific options
with -o. Don't advertise -e or -6 any more, they exist only for compatibility
reasons and can be replaced by the corresponding -o options.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This patch adds a small help text to each of the options in the block drivers
which can be displayed by using qemu-img create -f fmt -o ?
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Record device property types, and provide a list of properties at device
registration time.
Add a "device" property type that holds a reference to annother device.
Signed-off-by: Paul Brook <paul@codesourcery.com>
The ELF loader tracks the range of addresses used by a binary.
However this incorrectly assumes zero is not a valid address.
Signed-off-by: Paul Brook <paul@codesourcery.com>
The ARMv7-M NVIC device pokes itself into the CPU state. Now we have a
proper device model we can have the CPU/SoC code do this.
Signed-off-by: Paul Brook <paul@codesourcery.com>
When debugging multi-threaded programs, QEMU's gdb stub would report the
correct number of threads (the qfThreadInfo and qsThreadInfo packets).
However, the stub was unable to actually switch between threads (the T
packet), since it would report every thread except the first as being
dead. Furthermore, the stub relied upon cpu_index as a reliable means
of assigning IDs to the threads. This was a bad idea; if you have this
sequence of events:
initial thread created
new thread #1
new thread #2
thread #1 exits
new thread #3
thread #3 will have the same cpu_index as thread #1, which would confuse
GDB. (This problem is partly due to the remote protocol not having a
good way to send thread creation/destruction events.)
We fix this by using the host thread ID for the identifier passed to GDB
when debugging a multi-threaded userspace program. The thread ID might
wrap, but the same sort of problems with wrapping thread IDs would come
up with debugging programs natively, so this doesn't represent a
problem.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
This isn't the most ideal layout, but it makes -L /path/to/git/pc-bios Just
Work which is very convenient.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>