Return EOPNOTSUPP instead of ENOSYS for *xattr* syscalls
In current code, we're sending ENOSYS to target when a syscall for the
xattrs is done. This makes applications like ls complain loudly about
that and breaks scripts parsing the output. Moreover, iirc, implemented
features of filesystems are are sending EOPNOTSUPP (I've not checked so
I may be a little bit wrong on that...).
So, I'm proposing to return -EOPNOTSUPP and make ls happy
When converting the termios structure between host and target in
target_to_host_termios and host_to_target_termios, the c_cc[] array is
never initialised.
Calling memset() before using it allows to run successfully "stty echo /
stty -echo" on arm-linux-user target (host being x86 and mips).
Mika Westerberg [Tue, 7 Apr 2009 13:57:29 +0000 (16:57 +0300)]
linux-user: strace now handles guest strings correctly [v2]
- to not to break strace with GUEST_BASE is set:
- Strace now can load and print guest strings correctly.
- Added printing support for commonly used flags in some syscalls
(e.g open, creat, mmap etc.)
v2:
- fix strace.c build on etch
- add futex print to strace
Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Mika Westerberg [Tue, 7 Apr 2009 06:57:11 +0000 (09:57 +0300)]
linux-user: implemented ELF coredump support for ARM target
When target process is killed with signal (such signal that
should dump core) a coredump file is created. This file is
similar than coredump generated by Linux (there are few exceptions
though).
Riku Voipio: added support for rlimit
Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
No regressions were observed on either 64bit or 32bit
IA hosts.
Patch based on original patches by:
Kirill A. Shutemov <kirill@shutemov.name>
- Implement shm* syscalls
- Fix and cleanup IPCOP_shm* ipc calls handling
Depends on "export mmap_find_vma for shmat" patch.
Various whitespace uglifications applied to minimize
patch size.
Rename raw_ioctl and raw_aio_ioctl to hdev_ioctl and hdev_aio_ioctl as they
are only used for the host device. Also only add them to the method table
for the cases where we need them (generic hdev if linux and linux CDROM)
instead of declaring stubs and always add them.
Add a bdrv_probe_device method to all BlockDriver instances implementing
host devices to move matching of host device types into the actual drivers.
For now we keep exacly the old matching behaviour based on the devices names,
although we really should have better detetion methods based on device
information in the future.
Instead of declaring one BlockDriver for all host devices declared one
for each type: a generic one for normal disk devices, a Linux floppy
driver and a CDROM driver for Linux and FreeBSD. This gets rid of a lot
of messy ifdefs and switching based on the type in the various removal
device methods.
block.c grows a new method to find the correct host device driver based
on OS-sepcific criteria, which will later into the actual drivers in a
later patch in this series.
raw_open and hdev_open contain the same basic logic. Add a new
raw_open_common helper containing the guts of the open routine
and call it from raw_open and hdev_open.
We use the new open_flags field in BDRVRawState to allow passing
additional open flags to raw_open_common from both.
Both the Linux floppy and the FreeBSD CDROM host device need to store
the open flags so that they can re-open the device later. Store the
open flags unconditionally to remove the ifdef mess and simply the
calling conventions for the later patches in the series.
Andrea Arcangeli [Mon, 15 Jun 2009 11:52:27 +0000 (13:52 +0200)]
fix qemu_aio_flush
qemu_aio_wait by invoking the bh or one of the aio completion
callbacks, could end up submitting new pending aio, breaking the
invariant that qemu_aio_flush returns only when no pending aio is
outstanding (possibly a problem for migration as such).
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Kevin Wolf <kwolf@redhat.com>
Gleb Natapov [Mon, 8 Jun 2009 12:56:04 +0000 (15:56 +0300)]
Add rtc reset function.
On reset:
Periodic Interrupt Enable (PIE) bit is cleared to zero
Alarm Interrupt Enable (AIE) bit is cleared to zero
Update ended Interrupt Flag (UF) bit is cleared to zero
Interrupt Request status Flag (IRQF) bit is cleared to zero
Periodic Interrupt Flag (PF) bit is cleared to zero
Alarm Interrupt Flag (AF) bit is cleared to zero
Square Wave output Enable (SQWE) zero
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Uri Lublin [Mon, 8 Jun 2009 11:28:01 +0000 (14:28 +0300)]
migrate_fd_close: delete associated io-handler before closing the fd
It may happen that the io-handler is still registered. That causes
select() to return with EBADF, not calling handlers for other fds.
The io-handler would be registered when (on the source) the whole state
was written but not yet flushed. For example when using QEMUFileBuffered,
(tcp-migration) there may be data left in a buffer waiting to be transferred.
In such a case buffered_close() calls buffered_flush() which calls
migrate_fd_put_buffer, which may, upon EAGAIN, register migrate_fd_put_notify
as a handler.
Signed-off-by: Uri Lublin <uril@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Gleb Natapov [Wed, 10 Jun 2009 12:40:48 +0000 (15:40 +0300)]
Don't use cpu_index as apic_id.
(patch is on top of "Apic creation should not depend on pci" series)
Currently cpu_index is used as cpu apic id on x86. This is incorrect
since apic ids not have to be continuous (they can also encode cpu
hierarchy information). This patch uses cpuid_apic_id for initial apic id
value. For now cpuid_apic_id is set to be equal to cpu_index so behaviour
is fully backward compatible, but it allows us to add qemu option to
provide other values for cpu apic id.
Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Gerd Hoffmann [Thu, 11 Jun 2009 09:32:51 +0000 (11:32 +0200)]
xen nic: check tx queue after connect.
Needed for savevm/loadvm + migration: In that case the queue might
already have packets on (re-)connect. The guest wouldn't notify us
because notifications are only sent when stuffing a packet into an
empty queue.
Blue Swirl [Sat, 13 Jun 2009 08:44:31 +0000 (08:44 +0000)]
Fix mingw32 build warnings
Work around buffer and ioctlsocket argument type signedness problems
Suppress a prototype which is unused on mingw32
Expand a macro to avoid warnings from some GCC versions
Anthony Liguori [Wed, 10 Jun 2009 23:05:55 +0000 (18:05 -0500)]
Merge branch 'net-queue'
* net-queue: (28 commits)
virtio-net: Increase filter and control limits
virtio-net: Add new RX filter controls
virtio-net: MAC filter optimization
virtio-net: Fix MAC filter overflow handling
virtio-net: reorganize receive_filter()
virtio-net: Use a byte to store RX mode flags
virtio-net: Add version_id 7 placeholder for vnet header support
virtio-net: implement rx packet queueing
net: make use of async packet sending API in tap client
net: add qemu_send_packet_async()
net: split out packet queueing and flushing into separate functions
net: return status from qemu_deliver_packet()
net: add return value to packet receive handler
net: pass VLANClientState* as first arg to receive handlers
net: re-name vc->fd_read() to vc->receive()
net: add fd_readv() handler to qemu_new_vlan_client() args
net: only read from tapfd when we can send
net: vlan clients with no fd_can_read() can always receive
net: move the tap buffer into TAPState
net: factor tap_read_packet() out of tap_send()
...
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Luiz Capitulino [Tue, 9 Jun 2009 21:24:57 +0000 (18:24 -0300)]
Fix "defined but not used" warning
The function qemu_calculate_timeout() is only used when CONFIG_IOTHREAD
is not defined. When CONFIG_IOTHREAD is defined, we have the following
warning:
vl.c:4389: warning: ‘qemu_calculate_timeout’ defined but not used
This change fixes that by moving the #ifdef/#endif from main_loop()
into qemu_calculate_timeout(). This encapsulates the logic and allow
us to use qemu_calculate_timeout() when CONFIG_IOTHREAD is defined
or not (suggested by Glauber Costa).
Alex Williamson [Fri, 5 Jun 2009 20:47:23 +0000 (14:47 -0600)]
virtio-net: Increase filter and control limits
Increase the size of the perfect filter table and control queue depth.
This should give us more headroom in the MAC filter and is known to be
needed by at least one guest user. Increasing the control queue depth
allows a guest to feed several commands back to back if they so desire
rather than using the send and wait approach Linux uses.
Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Alex Williamson [Fri, 5 Jun 2009 20:47:13 +0000 (14:47 -0600)]
virtio-net: MAC filter optimization
The MAC filter table is received from the guest as two separate
buffers, one with unicast entries, the other with multicast
entries. If we track the index dividing the two sets, we can
avoid searching the part of the table with the wrong type of
entries.
We could store this index as part of the save image, but its
trivially easy to discover it on load.
Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Alex Williamson [Fri, 5 Jun 2009 20:47:08 +0000 (14:47 -0600)]
virtio-net: Fix MAC filter overflow handling
Overloading the promisc and allmulti flags for indicating filter
table overflow makes it difficult to track the actual requested
operating mode. Split these out into separate flags.
Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Alex Williamson [Fri, 5 Jun 2009 20:47:02 +0000 (14:47 -0600)]
virtio-net: reorganize receive_filter()
Reorganize receive_filter to better handle the split between
unicast and multicast filtering. This allows us to skip the
broadcast check on unicast packets and leads to more opportunities
for optimization.
Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Mark McLoughlin [Wed, 29 Apr 2009 12:40:02 +0000 (13:40 +0100)]
virtio-net: implement rx packet queueing
If we don't have room to receive a packet, we return zero
from virtio_net_receive() and call qemu_flush_queued_packets()
as soon as space becomes available.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Mark McLoughlin [Wed, 29 Apr 2009 11:15:26 +0000 (12:15 +0100)]
net: add qemu_send_packet_async()
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>
Jan Kiszka [Fri, 8 May 2009 10:34:18 +0000 (12:34 +0200)]
slirp: Reorder initialization
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>
Jan Kiszka [Fri, 8 May 2009 10:34:18 +0000 (12:34 +0200)]
net: Improve parameter error reporting
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>
Jan Kiszka [Fri, 8 May 2009 10:34:17 +0000 (12:34 +0200)]
net: Real fix for check_params users
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>
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>
Jan Kiszka [Fri, 8 May 2009 10:34:17 +0000 (12:34 +0200)]
slirp: Avoid zombie processes after fork_exec
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>