qemu.git
11 years agouhci: keep uhci state pointer in async packet struct.
Gerd Hoffmann [Wed, 15 Dec 2010 09:26:15 +0000 (10:26 +0100)] 
uhci: keep uhci state pointer in async packet struct.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
11 years agouhci: switch to QTAILQ
Gerd Hoffmann [Tue, 14 Dec 2010 17:19:47 +0000 (18:19 +0100)] 
uhci: switch to QTAILQ

11 years agousb: control buffer fixes
Hans de Goede [Wed, 2 Feb 2011 16:46:00 +0000 (17:46 +0100)] 
usb: control buffer fixes

Windows allows control transfers to pass up to 4k of data, so raise our
control buffer size to 4k. For control out transfers the usb core code copies
the control request data to a buffer before calling the device's handle_control
callback. Add a check for overflowing the buffer before copying the data.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agousb-linux: Add support for buffering iso out usb packets
Hans de Goede [Fri, 26 Nov 2010 18:11:03 +0000 (19:11 +0100)] 
usb-linux: Add support for buffering iso out usb packets

Extend the iso buffering code to also buffer iso out packets, this
fixes for example using usb speakers with usb redirection.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agousb-linux: We only need to keep track of 15 endpoints
Hans de Goede [Fri, 26 Nov 2010 14:02:16 +0000 (15:02 +0100)] 
usb-linux: We only need to keep track of 15 endpoints

Currently we reserve room for endpoint data for 16 endpoints, but given
that we only use endpoint data for endpoints 1-15, and always index the
array with the endpoint-number - 1, 15 is enough.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agousb-linux: Refuse iso packets when max packet size is 0 (alt setting 0)
Hans de Goede [Fri, 26 Nov 2010 13:59:35 +0000 (14:59 +0100)] 
usb-linux: Refuse iso packets when max packet size is 0 (alt setting 0)

Refuse iso usb packets when then max packet size for the endpoint is 0,
this avoids an abort in usb_host_alloc_iso() caused by trying to qemu_malloc
a 0 bytes large buffer.

11 years agousb-linux: Refuse packets for endpoints which are not in the usb descriptor
Hans de Goede [Fri, 26 Nov 2010 13:56:17 +0000 (14:56 +0100)] 
usb-linux: Refuse packets for endpoints which are not in the usb descriptor

If an endpoint is not in the usb descriptor we've no idea what kind of
endpoint it is and thus how to handle it, refuse packages in this case.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agousb-linux: Add support for buffering iso usb packets
Hans de Goede [Fri, 26 Nov 2010 10:41:08 +0000 (11:41 +0100)] 
usb-linux: Add support for buffering iso usb packets

Currently we are submitting iso packets to the host one at a time, as we
receive them from the emulated host controller. This has 2 problems:
1) If we were fast enough to submit every packet in time for the next host host
controller usb frame, we would be generating 1000 hardware interrupts per
second on the host
2) We are not fast enough to submit every packet in time for the next host host
controller usb frame, causing us to not submit iso urbs in some usb frames
which causes devices with an endpoint with an interval of 1 ms (so every
frame) to loose data. This causes for example ubs-1.1 webcams to not work
properly (usb-2.0 is not supported at all atm).

This patch fixes both problems by changing the iso packet pass through handling
to buffer packets. This version only does so for iso input packets (webcams,
audio in) I'm working on a second patch extending this to iso output packets
(audio out).

This patch makes use of the linux batching of iso packets in one urb.
When an iso in packet gets received from the emulated host controller,
it immediately submits 3 urbs with 32 iso in packets each. This causes
the host to only get an hw interrupt every 32 packets dropping the
interrupt rate to 32 interrupts per second and gives it a queue of urbs
to work from once the first 32 iso in packets have been received to make sure
no packets are dropped.

Besides submitting a whole bunch or urbs as soon as the first urb is
received, effectively creating a buffer inside the kernel, this patch also
gets rid of the asynchroneous completion for iso in urbs. Instead they are
only marked as complete in the fd write callback (which usbfs uses to signal
complete urbs). These complete packets then get consumed by returning them
synchroneously to the emulated host controller when it submits an iso in
packet for the ep in question. When no complete packets are ready (which
happens when the stream is starting) a 0 length packet gets returned to
the emulated host controller.

With this patch I've several usb-1.1 webcams working well with usb pass
through, where as without this patch none of them work.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agousb-linux: Get the alt. setting from sysfs rather then asking the dev
Hans de Goede [Wed, 24 Nov 2010 11:57:59 +0000 (12:57 +0100)] 
usb-linux: Get the alt. setting from sysfs rather then asking the dev

At least one device I have lies when receiving a USB_REQ_GET_INTERFACE,
always returning 0 even if the alternate setting is different. This is
likely caused because in practice this control message is never used as
the operating system's usb stack knows which alternate setting it has
told the device to get into, and thus this ctrl message does not get
tested by device manufacturers.

When usb_fs_type == USB_FS_SYS, the active alt. setting can be read directly
from sysfs, which allows using this device through qemu's usb redirection.
More in general it seems a good idea to not send needless control msg's to
devices, esp. as the code in question is called every time a set_interface
is done. Which happens multiple times during virtual machine startup, and
when device drivers are activating the usb device.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agousb-linux: introduce a usb_linux_alt_setting function
Hans de Goede [Wed, 24 Nov 2010 11:50:00 +0000 (12:50 +0100)] 
usb-linux: introduce a usb_linux_alt_setting function

The next patch in this series introduces multiple ways to get the
alt setting dependent upon usb_fs_type, it is cleaner to put this
into its own function.

Note that this patch also changes the assumed alt setting in case
of an error getting the alt setting to be 0 (a sane default) rather
then the interface numberwhich makes no sense.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
11 years agoNBD: Avoid leaking a couple of strings when the NBD device is closed
Nick Thomas [Thu, 28 Apr 2011 15:20:01 +0000 (16:20 +0100)] 
NBD: Avoid leaking a couple of strings when the NBD device is closed

Signed-off-by: Nick Thomas <nick@bytemark.co.uk>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-progress.c: printf isn't signal safe
Jes Sorensen [Thu, 28 Apr 2011 11:58:30 +0000 (13:58 +0200)] 
qemu-progress.c: printf isn't signal safe

Change the signal handling to indicate a signal is pending, rather
then printing directly from the signal handler.

In addition make the signal prints go to stderr, rather than stdout.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoide/atapi: fix set but unused
Alon Levy [Thu, 28 Apr 2011 13:34:39 +0000 (16:34 +0300)] 
ide/atapi: fix set but unused

Signed-off-by: Alon Levy <alevy@redhat.com>
Acked-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoatapi: Explain why we need a 'media not present' state
Amit Shah [Thu, 28 Apr 2011 14:34:41 +0000 (20:04 +0530)] 
atapi: Explain why we need a 'media not present' state

After the re-org of the atapi code, it might not be intuitive for a
reader of the code to understand why we're inserting a 'media not
present' state between cd changes.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoatapi: Move comment to proper place
Amit Shah [Thu, 28 Apr 2011 14:34:40 +0000 (20:04 +0530)] 
atapi: Move comment to proper place

Move misplaced comment for media_is_dvd()

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-img resize: Fix option parsing
Kevin Wolf [Fri, 29 Apr 2011 08:58:12 +0000 (10:58 +0200)] 
qemu-img resize: Fix option parsing

For shrinking images, you're supposed to use a negative size. However, the
leading minus makes getopt think that it's an option and so you get the help
text if you don't use -- like in 'qemu-img resize test.img -- -1G'.

This patch handles the size first and removes it from the argument list so that
getopt won't even try to interpret it and you don't need -- any more.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agolm32: add Milkymist Minimac2 support
Michael Walle [Tue, 12 Apr 2011 22:29:36 +0000 (00:29 +0200)] 
lm32: add Milkymist Minimac2 support

This patch adds support for Milkymist's minimal Ethernet MAC v2. It
superseds minimac1.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
11 years agomilkymist-sysctl: fix timers
Michael Walle [Tue, 12 Apr 2011 22:29:35 +0000 (00:29 +0200)] 
milkymist-sysctl: fix timers

Prevent timers from firing right after starting.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
11 years agomilkymist-vgafb: fix console resizing
Michael Walle [Tue, 12 Apr 2011 22:29:34 +0000 (00:29 +0200)] 
milkymist-vgafb: fix console resizing

After enabling the framebuffer, ensure that the console is resized.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
11 years agolm32: fix exception handling
Michael Walle [Tue, 12 Apr 2011 22:29:33 +0000 (00:29 +0200)] 
lm32: fix exception handling

Global interrupt enable bit is already saved within the exception handler
helper routine. Thus remove extra code in translation routines.

Additionally, debug exceptions has always DEBA as base address.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
11 years agokvm: use qemu_free consistently
Paolo Bonzini [Mon, 2 May 2011 07:54:04 +0000 (09:54 +0200)] 
kvm: use qemu_free consistently

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agofix crash in migration, 32-bit userspace on 64-bit host
Michael Tokarev [Tue, 26 Apr 2011 16:13:49 +0000 (20:13 +0400)] 
fix crash in migration, 32-bit userspace on 64-bit host

This change fixes a long-standing immediate crash (memory corruption
and abort in glibc malloc code) in migration on 32bits.

The bug is present since this commit:

  commit 692d9aca97b865b0f7903565274a52606910f129
  Author: Bruce Rogers <brogers@novell.com>
  Date:   Wed Sep 23 16:13:18 2009 -0600

    qemu-kvm: allocate correct size for dirty bitmap

    The dirty bitmap copied out to userspace is stored in a long array,
    and gets copied out to userspace accordingly.  This patch accounts
    for that correctly.  Currently I'm seeing kvm crashing due to writing
    beyond the end of the alloc'd dirty bitmap memory, because the buffer
    has the wrong size.

Signed-off-by: Bruce Rogers
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
 --- a/qemu-kvm.c
 +++ b/qemu-kvm.c
 @@ int kvm_get_dirty_pages_range(kvm_context_t kvm, unsigned long phys_addr,
 -            buf = qemu_malloc((slots[i].len / 4096 + 7) / 8 + 2);
 +            buf = qemu_malloc(BITMAP_SIZE(slots[i].len));
             r = kvm_get_map(kvm, KVM_GET_DIRTY_LOG, i, buf);

BITMAP_SIZE is now open-coded in that function, like this:

 size = ALIGN(((mem->memory_size) >> TARGET_PAGE_BITS), HOST_LONG_BITS) / 8;

The problem is that HOST_LONG_BITS in 32bit userspace is 32
but it's 64 in 64bit kernel.  So userspace aligns this to
32, and kernel to 64, but since no length is passed from
userspace to kernel on ioctl, kernel uses its size calculation
and copies 4 extra bytes to userspace, corrupting memory.

Here's how it looks like during migrate execution:

our=20, kern=24
our=4, kern=8
...
our=4, kern=8
our=4064, kern=4064
our=512, kern=512
our=4, kern=8
our=20, kern=24
our=4, kern=8
...
our=4, kern=8
our=4064, kern=4064
*** glibc detected *** ./x86_64-softmmu/qemu-system-x86_64: realloc(): invalid next size: 0x08f20528 ***

(our is userspace size above, kern is the size as calculated
by the kernel).

Fix this by always aligning to 64 in a hope that no platform will
have sizeof(long)>8 any time soon, and add a comment describing it
all.  It's a small price to pay for bad kernel design.

Alternatively it's possible to fix that in the kernel by using
different size calculation depending on the current process.
But this becomes quite ugly.

Special thanks goes to Stefan Hajnoczi for spotting the fundamental
cause of the issue, and to Alexander Graf for his support in #qemu.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
CC: Bruce Rogers <brogers@novell.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
11 years agokvm: Install specialized interrupt handler
Jan Kiszka [Tue, 12 Apr 2011 23:32:56 +0000 (01:32 +0200)] 
kvm: Install specialized interrupt handler

KVM only requires to set the raised IRQ in CPUState and to kick the
receiving vcpu if it is remote. Installing a specialized handler allows
potential future changes to the TCG code path without risking KVM side
effects.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoRedirect cpu_interrupt to callback handler
Jan Kiszka [Tue, 12 Apr 2011 23:32:56 +0000 (01:32 +0200)] 
Redirect cpu_interrupt to callback handler

This allows to override the interrupt handling of QEMU in system mode.
KVM will make use of it to set a specialized handler.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agoBreak up user and system cpu_interrupt implementations
Jan Kiszka [Tue, 12 Apr 2011 23:32:56 +0000 (01:32 +0200)] 
Break up user and system cpu_interrupt implementations

Both have only two lines in common, and we will convert the system
service into a callback which is of no use for user mode operation.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agokvm: create kvmclock when one of the flags are present
Glauber Costa [Thu, 17 Mar 2011 22:42:07 +0000 (19:42 -0300)] 
kvm: create kvmclock when one of the flags are present

kvmclock presence can be signalled by two different flags. So for
device creation, we have to test for both.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
11 years agokvm: add kvmclock to its second bit
Glauber Costa [Thu, 17 Mar 2011 22:42:06 +0000 (19:42 -0300)] 
kvm: add kvmclock to its second bit

We have two bits that can represent kvmclock in cpuid.
They signal the guest which msr set to use. When we tweak flags
involving this value - specially when we use "-", we have to act on both.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
11 years agox86: Allow multiple cpu feature matches of lookup_feature
Jan Kiszka [Tue, 19 Apr 2011 11:06:06 +0000 (13:06 +0200)] 
x86: Allow multiple cpu feature matches of lookup_feature

kvmclock is represented by two feature bits. Therefore, lookup_feature
needs to continue its search even after the first match. Enhance it
accordingly and switch to a bool return type at this chance.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
11 years agokvm: use kernel-provided para_features instead of statically coming up with new capab...
Glauber Costa [Thu, 17 Mar 2011 22:42:05 +0000 (19:42 -0300)] 
kvm: use kernel-provided para_features instead of statically coming up with new capabilities

Use the features provided by KVM_GET_SUPPORTED_CPUID directly to
mask out features from guest-visible cpuid.

The old get_para_features() mechanism is kept for older kernels that do not implement it.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
11 years agoDon't zero out buffer in sched_getaffinity
Mike McCormack [Mon, 18 Apr 2011 05:43:36 +0000 (14:43 +0900)] 
Don't zero out buffer in sched_getaffinity

The kernel doesn't fill the buffer provided to sched_getaffinity
with zero bytes, so neither should QEMU.

Signed-off-by: Mike McCormack <mj.mccormack@samsung.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
11 years agoFix buffer overrun in sched_getaffinity
Mike McCormack [Tue, 12 Apr 2011 02:41:00 +0000 (11:41 +0900)] 
Fix buffer overrun in sched_getaffinity

Zeroing of the cpu array should start from &cpus[kernel_ret]
not &cpus[num_zeros_to_fill].

This fixes a crash in EFL's edje_cc running under qemu-arm.

Signed-off-by: Mike McCormack <mj.mccormack@samsung.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
11 years agolinux-user: Fix compilation for "old" linux versions
Stefan Weil [Wed, 27 Apr 2011 08:44:38 +0000 (10:44 +0200)] 
linux-user: Fix compilation for "old" linux versions

Debian Lenny and other installations with older linux versions
failed to compile linux-user because some CLONE_xxx macros are
undefined.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
11 years agoMerge branch 'patches' of git://qemu.weilnetz.de/git/qemu
Blue Swirl [Fri, 29 Apr 2011 20:01:51 +0000 (20:01 +0000)] 
Merge branch 'patches' of git://qemu.weilnetz.de/git/qemu

* 'patches' of git://qemu.weilnetz.de/git/qemu:
  qemu-timer: Fix timers for w32
  qemu-timer: Avoid type casts
  qemu-timer: Remove unneeded include statement (w32)
  qemu-timer: Add and use new function qemu_timer_expired_ns

11 years agovirtfs: fix build due from rename
Anthony Liguori [Thu, 28 Apr 2011 17:40:54 +0000 (12:40 -0500)] 
virtfs: fix build due from rename

The latest virtfs pull broke the cris-softmmu target.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
11 years agoMerge remote-tracking branch 'amitshah/for-anthony' into staging
Anthony Liguori [Thu, 28 Apr 2011 13:37:54 +0000 (08:37 -0500)] 
Merge remote-tracking branch 'amitshah/for-anthony' into staging

11 years agoMerge remote-tracking branch 'jvrao/for-anthony' into staging
Anthony Liguori [Thu, 28 Apr 2011 13:25:45 +0000 (08:25 -0500)] 
Merge remote-tracking branch 'jvrao/for-anthony' into staging

11 years agovirtio-serial: Fix endianness bug in the config space
Alexey Kardashevskiy [Tue, 19 Apr 2011 02:03:46 +0000 (12:03 +1000)] 
virtio-serial: Fix endianness bug in the config space

The virtio serial specification requres that the values in the config
space are encoded in native endian of the guest.

The qemu virtio-serial code did not do conversion to the guest endian
format what caused problems when host and guest use different format.

This patch corrects the qemu side, correctly doing host-native <->
guest-native conversions when accessing the config space. This won't
break any setups that aren't already broken, and fixes the case
of different host and guest endianness.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
11 years agochar: Detect chardev release by NULL handlers as well as NULL opaque
Amit Shah [Mon, 25 Apr 2011 09:48:22 +0000 (15:18 +0530)] 
char: Detect chardev release by NULL handlers as well as NULL opaque

Juan says he prefers these extra checks to ensure a user of a chardev is
releasing it.

Requested-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
11 years agochar: Allow devices to use a single multiplexed chardev.
Kusanagi Kouichi [Tue, 26 Apr 2011 10:19:26 +0000 (19:19 +0900)] 
char: Allow devices to use a single multiplexed chardev.

This fixes regression caused by commit
2d6c1ef40f3678ab47a4d14fb5dadaa486bfcda6
("char: Prevent multiple devices opening same chardev"):

-nodefaults -nographic -chardev stdio,id=stdio,mux=on,signal=off \
 -mon stdio -device virtio-serial-pci \
 -device virtconsole,chardev=stdio -device isa-serial,chardev=stdio

fails with:

qemu-system-x86_64: -device isa-serial,chardev=stdio: Property 'isa-serial.chardev' can't take value 'stdio', it's in use

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
11 years agospice-chardev: listen to frontend guest open / close
Hans de Goede [Thu, 24 Mar 2011 10:12:04 +0000 (11:12 +0100)] 
spice-chardev: listen to frontend guest open / close

Note the vmc_register_interface() in spice_chr_write is left in place
in case someone uses spice-chardev with a frontend which does not have
guest open / close notification.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
11 years agovirtio-console: notify backend of guest open / close
Hans de Goede [Thu, 24 Mar 2011 10:12:03 +0000 (11:12 +0100)] 
virtio-console: notify backend of guest open / close

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
11 years agochardev: Allow frontends to notify backends of guest open / close
Hans de Goede [Thu, 24 Mar 2011 10:12:02 +0000 (11:12 +0100)] 
chardev: Allow frontends to notify backends of guest open / close

Some frontends know when the guest has opened the "channel" and is actively
listening to it, for example virtio-serial. This patch adds 2 new qemu-chardev
functions which can be used by frontends to signal guest open / close, and
allows interested backends to listen to this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
11 years agotarget-arm: Don't update base register on abort in Thumb T1 LDM
Peter Maydell [Tue, 26 Apr 2011 17:17:20 +0000 (18:17 +0100)] 
target-arm: Don't update base register on abort in Thumb T1 LDM

Make sure the base register isn't updated if it is in the load list
for a Thumb LDM (T1 encoding) which aborts partway through the load.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-arm: fix LDMIA bug on page boundary
YuYeon Oh [Mon, 25 Apr 2011 01:23:58 +0000 (01:23 +0000)] 
target-arm: fix LDMIA bug on page boundary
target-arm: fix LDMIA bug on page boundary

When consecutive memory locations are on page boundary, a base register may be
loaded before page fault occurs. After page fault handling, it losts the memory
location information. To solve this problem, loading a base register has to put back.

Signed-off-by: Yuyeon Oh <yuyeon.oh@samsung.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoioapic: Do not set irr for masked edge IRQs
Jan Kiszka [Sat, 9 Apr 2011 11:18:59 +0000 (13:18 +0200)] 
ioapic: Do not set irr for masked edge IRQs

So far we set IRR for edge IRQs even if the pin is masked. If the guest
later on unmasks and switches the pin to level-triggered mode, irr will
remain set, causing an IRQ storm. The point is that setting IRR is not
correct in this case according to the spec, and avoiding this resolves
the issue.

Reported-and-tested-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agovl.c: Replace -virtfs string manipulation with QemuOpts
Stefan Hajnoczi [Wed, 16 Mar 2011 08:31:43 +0000 (08:31 +0000)] 
vl.c: Replace -virtfs string manipulation with QemuOpts

The -virtfs option creates an fsdev representing the pass-through file
system and a guest-visible virtio-9p-pci device that can access this
file system.  This patch replaces the string manipulation used to build
and reparse option lists with direct QemuOpts calls.  Removing the
string manipulation code makes it easier to maintain and less error
prone.

An error message is also updated to use "mount_tag" instead of
"mnt_tag".

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
11 years agov9fs_walk: As per 9p2000 RFC, MAXWELEM >= nwnames >= 0.
Harsh Prateek Bora [Thu, 14 Apr 2011 09:24:40 +0000 (14:54 +0530)] 
v9fs_walk: As per 9p2000 RFC, MAXWELEM >= nwnames >= 0.

The nwnames field in TWALK message is assumed to be >=0 and <= MAXWELEM
which is defined as macro P9_MAXWELEM (16) in virtio-9p.h as per 9p2000
RFC. Appropriate changes are required in V9fsWalkState and v9fs_walk.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
11 years agohw/virtio-9p-local.c: Remove unnecessary null char in symlink file
Harsh Prateek Bora [Wed, 2 Feb 2011 04:50:33 +0000 (10:20 +0530)] 
hw/virtio-9p-local.c: Remove unnecessary null char in symlink file

This patch removes the addition of null char in symlink file
which is being appended to file in case of mapped security model.
Without this patch, the extra null char causes LTP testcase lstat03
to fail and hence this fix is required.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
11 years agovirtio-9p: Bugfix to send correct iounit
M. Mohan Kumar [Tue, 1 Feb 2011 08:51:41 +0000 (14:21 +0530)] 
virtio-9p: Bugfix to send correct iounit

LCREATE function packs address of iounit in the pdu, fix that to send
actual iounit itself.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
11 years agovirtio-9p: removexattr on default acl should return 0
Aneesh Kumar K.V [Wed, 27 Apr 2011 06:56:43 +0000 (12:26 +0530)] 
virtio-9p: removexattr on default acl should return 0

If we don't have default acl, removexattr on default acl
should return 0

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
11 years agovirtio-9p: Print the pdu details on return
Aneesh Kumar K.V [Wed, 27 Apr 2011 06:55:46 +0000 (12:25 +0530)] 
virtio-9p: Print the pdu details on return

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
11 years agovirtio-9p: move 9p files around
Aneesh Kumar K.V [Fri, 28 Jan 2011 12:39:08 +0000 (18:09 +0530)] 
virtio-9p: move 9p files around

Now that we start adding more files related to 9pfs
it make sense to move them to a separate directory

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
11 years agopflash: Restore & fix lazy ROMD switching
Jan Kiszka [Sun, 10 Apr 2011 10:53:39 +0000 (12:53 +0200)] 
pflash: Restore & fix lazy ROMD switching

Commit 5145b3d1cc revealed a bug in the lazy ROMD switch-back logic, but
resolved it by breaking that feature. This approach addresses the issue
by switching back to ROMD after a certain amount of read accesses
without further unlock sequences.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agodarwin-user: Remove unneeded null pointer check
Stefan Weil [Sun, 3 Apr 2011 16:22:45 +0000 (18:22 +0200)] 
darwin-user: Remove unneeded null pointer check

cppcheck reports this error:

commpage.c:223: error: Possible null pointer dereference:
value - otherwise it is redundant to check if value is null at line 214

The null pointer check in line 214 is indeed not needed.
If value were null, the code would crash in line 223.
See do_compare_and_swap64 were for a reference.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoMerge branch 'for-anthony' of git://repo.or.cz/qemu/kevin
Aurelien Jarno [Wed, 27 Apr 2011 14:26:18 +0000 (16:26 +0200)] 
Merge branch 'for-anthony' of git://repo.or.cz/qemu/kevin

* 'for-anthony' of git://repo.or.cz/qemu/kevin:
  Remove obsolete 'enabled' variable from progress state
  Add dd-style SIGUSR1 progress reporting
  qed: Fix consistency check on 32-bit hosts
  ide/atapi: Introduce CHECK_READY flag for commands
  ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors
  ide/atapi: Use table instead of switch for commands
  ide/atapi: Factor commands out
  ide: Split atapi.c out
  Improve accuracy of block migration bandwidth calculation
  atapi: Add 'medium ready' to 'medium not ready' transition on cd change
  qemu-img: allow rebase to a NULL backing file when unsafe

11 years agortl8139: Fix compilation for w32/w64
Stefan Weil [Tue, 26 Apr 2011 08:17:48 +0000 (10:17 +0200)] 
rtl8139: Fix compilation for w32/w64

Compilation for Windows needs a different declaration for the
printf format attribute, so use the macro which was defined for
this purpose.

Cc: Benjamin Poirier <benjamin.poirier@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoRemove obsolete 'enabled' variable from progress state
Jes Sorensen [Wed, 27 Apr 2011 12:31:51 +0000 (14:31 +0200)] 
Remove obsolete 'enabled' variable from progress state

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoAdd dd-style SIGUSR1 progress reporting
Jes Sorensen [Wed, 27 Apr 2011 12:31:50 +0000 (14:31 +0200)] 
Add dd-style SIGUSR1 progress reporting

This introduces support for dd-style progress reporting on POSIX
systems, if the user hasn't specified -p to report progress. If sent a
SIGUSR1, qemu-img will report current progress for commands that
support progress reporting.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqed: Fix consistency check on 32-bit hosts
Stefan Hajnoczi [Sun, 24 Apr 2011 17:38:58 +0000 (18:38 +0100)] 
qed: Fix consistency check on 32-bit hosts

The qed_bytes_to_clusters() function is normally used with size_t
lengths.  Consistency check used it with file size length and therefore
failed on 32-bit hosts when the image file is 4 GB or more.

Make qed_bytes_to_clusters() explicitly 64-bit and update consistency
check to keep 64-bit cluster counts.

Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoide/atapi: Introduce CHECK_READY flag for commands
Kevin Wolf [Tue, 19 Apr 2011 11:15:52 +0000 (13:15 +0200)] 
ide/atapi: Introduce CHECK_READY flag for commands

Some commands are supposed to report a Not Ready Condition (i.e. they require
a medium to be present in order to execute successfully). Instead of
duplicating the check in each command implementation, let's add a flag and
check it before calling the command.

This patch only converts existing checks, it does not introduce new checks for
any of the other commands that can/should report a Not Ready Condition.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors
Kevin Wolf [Tue, 19 Apr 2011 11:13:44 +0000 (13:13 +0200)] 
ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors

The disk size can only change when the medium is changed, and the change
callback takes care of updating s->nb_sectors in this case.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoide/atapi: Use table instead of switch for commands
Kevin Wolf [Mon, 18 Apr 2011 15:55:08 +0000 (17:55 +0200)] 
ide/atapi: Use table instead of switch for commands

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoide/atapi: Factor commands out
Kevin Wolf [Mon, 18 Apr 2011 15:55:08 +0000 (17:55 +0200)] 
ide/atapi: Factor commands out

In preparation for a table of function pointers, factor each command out from
ide_atapi_cmd() into its own function.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoide: Split atapi.c out
Kevin Wolf [Mon, 18 Apr 2011 14:45:49 +0000 (16:45 +0200)] 
ide: Split atapi.c out

Besides moving code, this patch only fixes some whitespace issues in the moved
code and makes all functions in atapi.c static which can be static.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoImprove accuracy of block migration bandwidth calculation
Avishay Traeger [Sun, 3 Apr 2011 08:31:45 +0000 (11:31 +0300)] 
Improve accuracy of block migration bandwidth calculation

block_mig_state.total_time is currently the sum of the read request
latencies.  This is not very accurate because block migration uses aio and
so several requests can be submitted at once.  Bandwidth should be computed
with wall-clock time, not by adding the latencies.  In this case,
"total_time" has a higher value than it should, and so the computed
bandwidth is lower than it is in reality.  This means that migration can
take longer than it needs to.
However, we don't want to use pure wall-clock time here.  We are computing
bandwidth in the asynchronous phase, where the migration repeatedly wakes
up and sends some aio requests.  The computed bandwidth will be used for
synchronous transfer.

Signed-off-by: Avishay Traeger <avishay@il.ibm.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoatapi: Add 'medium ready' to 'medium not ready' transition on cd change
Amit Shah [Mon, 18 Apr 2011 11:45:46 +0000 (17:15 +0530)] 
atapi: Add 'medium ready' to 'medium not ready' transition on cd change

MMC-5 Table F.1 lists errors that can be thrown for the TEST_UNIT_READY
command.  Going from medium not ready to medium ready states is
communicated by throwing an error.

This adds the missing 'tray opened' event that we fail to report to
guests.  After doing this, older Linux guests properly revalidate a disc
on the change command.  HSM violation errors, which caused Linux guests
to do a soft-reset of the link, also go away:

ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6
sr 1:0:0:0: CDB: Test Unit Ready: 00 00 00 00 00 00
ata2.00: cmd a0/00:00:00:00:00/00:00:00:00:00/a0 tag 0
         res 01/60:00:00:00:00/00:00:00:00:00/a0 Emask 0x3 (HSM violation)
ata2.00: status: { ERR }
ata2: soft resetting link
ata2.00: configured for MWDMA2
ata2: EH complete

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Tested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoqemu-timer: Fix timers for w32
Stefan Weil [Tue, 5 Apr 2011 16:34:21 +0000 (18:34 +0200)] 
qemu-timer: Fix timers for w32

Commit 68c23e5520e8286d79d96ab47c0ea722ceb75041 removed the
multimedia timer, but this timer is needed for certain
Linux kernels. Otherwise Linux boot stops with this error:

    MP-BIOS bug: 8254 timer not connected to IO-APIC

So the multimedia timer is added again here.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
11 years agoqemu-timer: Avoid type casts
Stefan Weil [Sun, 10 Apr 2011 18:15:09 +0000 (20:15 +0200)] 
qemu-timer: Avoid type casts

The type casts are no longer needed after some small changes
in struct qemu_alarm_timer. This also improves readability
of the code.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
11 years agoqemu-timer: Remove unneeded include statement (w32)
Stefan Weil [Wed, 6 Apr 2011 20:22:48 +0000 (22:22 +0200)] 
qemu-timer: Remove unneeded include statement (w32)

mmsystem.h is not needed in qemu-timer.h, so remove it.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
11 years agoqemu-timer: Add and use new function qemu_timer_expired_ns
Stefan Weil [Thu, 24 Mar 2011 20:31:24 +0000 (21:31 +0100)] 
qemu-timer: Add and use new function qemu_timer_expired_ns

This simply moves code which is used three times
into a new function thus improving readability.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
11 years agoqemu-img: allow rebase to a NULL backing file when unsafe
Anthony Liguori [Wed, 13 Apr 2011 14:51:47 +0000 (15:51 +0100)] 
qemu-img: allow rebase to a NULL backing file when unsafe

QEMU can drop a backing file so that an image file no longer depends on
the backing file, but this feature has not been exposed in qemu-img.
This is useful in an image streaming usecase or when an image file has
been fully allocated and no reads can hit the backing file anymore.

Since the dropping the backing file can make the image unusable, only
allow this when the unsafe flag has been set.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
11 years agoconfigure: reenable opengl by default
Michael Walle [Mon, 25 Apr 2011 22:09:01 +0000 (00:09 +0200)] 
configure: reenable opengl by default

Because the opengl library is only linked to for the lm32 target, we can
now safely enable opengl by default again.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoconfigure: support target dependent linking
Michael Walle [Mon, 25 Apr 2011 22:24:07 +0000 (00:24 +0200)] 
configure: support target dependent linking

This patch is the first attempt to make configure more intelligent with
regard to how it links to libraries. It divides the softmmu libraries into
two lists, a general one and a list which depends on the target
architecture.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoMerge branch 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu
Aurelien Jarno [Tue, 26 Apr 2011 21:23:02 +0000 (23:23 +0200)] 
Merge branch 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu

* 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu:
  linux-user: untie syscalls from UID16
  linux-user: add s390x to llseek list
  linux-user: add ioctl(SIOCGIWNAME, ...) support.
  linux-user: convert ioctl(SIOCGIFCONF, ...) result.
  linux-user: improve traces
  [v2] linux-user: bigger default stack

11 years agoconfigure: Make epoll_create1 test work around SPARC glibc bug
Peter Maydell [Tue, 26 Apr 2011 15:56:40 +0000 (16:56 +0100)] 
configure: Make epoll_create1 test work around SPARC glibc bug

Work around a SPARC glibc bug which caused the epoll_create1 configure
test to wrongly claim that the function was present. Some versions of
SPARC glibc provided the function in the library but didn't declare
it in the include file; the result is that gcc warns about an implicit
declaration but a link succeeds. So we reference the function as a
value rather than a function call to induce a compile time error
if the declaration was not present.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
11 years agoMerge remote-tracking branch 'stefanha/tracing' into staging
Anthony Liguori [Tue, 26 Apr 2011 13:07:49 +0000 (08:07 -0500)] 
Merge remote-tracking branch 'stefanha/tracing' into staging

11 years agovl: trivial spelling fix
Brad Hards [Sat, 23 Apr 2011 11:50:06 +0000 (21:50 +1000)] 
vl: trivial spelling fix

Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
11 years agotrace: [trace-events] fix print formats in some events
Lluís [Wed, 6 Apr 2011 18:34:11 +0000 (20:34 +0200)] 
trace: [trace-events] fix print formats in some events

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
11 years agotrace: [ust] fix generation of 'trace.c' on events without args
Lluís [Wed, 6 Apr 2011 18:34:03 +0000 (20:34 +0200)] 
trace: [ust] fix generation of 'trace.c' on events without args

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
11 years agodocs/tracing.txt: minor documentation fixes
Lluís [Wed, 6 Apr 2011 18:33:56 +0000 (20:33 +0200)] 
docs/tracing.txt: minor documentation fixes

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
11 years agodocs: Trace events must not expect pointer dereferencing
Stefan Hajnoczi [Thu, 14 Apr 2011 17:24:50 +0000 (18:24 +0100)] 
docs: Trace events must not expect pointer dereferencing

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
11 years agotrace: Remove %s in grlib trace events
Stefan Hajnoczi [Thu, 14 Apr 2011 17:11:00 +0000 (18:11 +0100)] 
trace: Remove %s in grlib trace events

Trace events cannot use %s in their format strings because trace
backends vary in how they can deference pointers (if at all).  Recording
const char * values is not meaningful if their contents are not recorded
too.

Change grlib trace events that rely on strings so that they communicate
similar information without using strings.

A follow-up patch explains this limitation and updates docs/tracing.txt.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
11 years agotracetool: allow ) in trace output string
Paolo Bonzini [Fri, 15 Apr 2011 13:23:59 +0000 (15:23 +0200)] 
tracetool: allow ) in trace output string

Be greedy in matching the trailing "\)*" pattern.  Otherwise, all the
text in the trace string up to the last closed parenthesis is taken as
part of the prototype.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
11 years agolinux-user: untie syscalls from UID16
Riku Voipio [Mon, 18 Apr 2011 12:23:06 +0000 (15:23 +0300)] 
linux-user: untie syscalls from UID16

Quite a number of uid/gid related syscalls are only defined on systems
with USE_UID16 defined. This is apperently based on the idea that these
system calls would never be called on non-UID16 systems. Make these
syscalls available for all architectures that define them.

drop alpha hack to support selected UID16 syscalls. MIPS and PowerPC
were also defined as UID16, to get uid/gid syscalls available, drop
this error as well.

Change QEMU to reflect this.

Cc: Ulrich Hecht <uli@suse.de>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
11 years agolinux-user: add s390x to llseek list
Alexander Graf [Fri, 15 Apr 2011 15:32:45 +0000 (17:32 +0200)] 
linux-user: add s390x to llseek list

We keep a list of host architectures that do llseek with the same
syscall as lseek. S390x is one of them, so let's add it to the list.

Original-patch-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
11 years agolinux-user: add ioctl(SIOCGIWNAME, ...) support.
Laurent Vivier [Tue, 29 Mar 2011 23:35:23 +0000 (01:35 +0200)] 
linux-user: add ioctl(SIOCGIWNAME, ...) support.

Allow to run properly following program from linux-user:

/* cc -o wifi wifi.c */

 #include <stdio.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <linux/wireless.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <string.h>

int main(int argc, char **argv)
{
    int ret;
    struct ifreq req;
    struct sockaddr_in *addr;
    int s;

    if (argc != 2) {
        fprintf(stderr, "Need an interface name (like wlan0)\n");
return 1;
    }

    s = socket( AF_INET, SOCK_DGRAM, 0 );
    if (s < 0) {
        perror("Cannot open socket");
        return 1;
    }
    strncpy(req.ifr_name, argv[1], sizeof(req.ifr_name));
    ret = ioctl( s, SIOCGIWNAME, &req );
    if (ret < 0) {
fprintf(stderr, "No wireless extension\n");
        return 1;
    }

    printf("%s\n", req.ifr_name);
    printf("%s\n", req.ifr_newname);
    return 0;
}

$ ./wifi eth0
No wireless extension

$ ./wifi wlan0
wlan0
IEEE 802.11bg

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
11 years agolinux-user: convert ioctl(SIOCGIFCONF, ...) result.
Laurent Vivier [Tue, 29 Mar 2011 22:12:12 +0000 (00:12 +0200)] 
linux-user: convert ioctl(SIOCGIFCONF, ...) result.

The result needs to be converted as it is stored in an array of struct
ifreq and sizeof(struct ifreq) differs according to target and host
alignment rules.

This patch allows to execute correctly the following program on arm
and m68k:

 #include <stdio.h>
 #include <sys/ioctl.h>
 #include <net/if.h>
 #include <alloca.h>
 #include <string.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>

int main(void)
{
    int s, ret;
    struct ifconf ifc;
    int i;

    memset( &ifc, 0, sizeof( struct ifconf ) );
    ifc.ifc_len = 8 * sizeof(struct ifreq);
    ifc.ifc_buf = alloca(ifc.ifc_len);

    s = socket( AF_INET, SOCK_DGRAM, 0 );
    if (s < 0) {
        perror("Cannot open socket");
        return 1;
    }
    ret = ioctl( s, SIOCGIFCONF, &ifc );
    if (s < 0) {
        perror("ioctl() failed");
        return 1;
    }

    for (i = 0; i < ifc.ifc_len / sizeof(struct ifreq) ; i ++) {
        struct sockaddr_in *s;
        s = (struct sockaddr_in*)&ifc.ifc_req[i].ifr_addr;
        printf("%s\n", ifc.ifc_req[i].ifr_name);
        printf("%s\n", inet_ntoa(s->sin_addr));
    }
}

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
11 years agolinux-user: improve traces
Laurent Vivier [Wed, 6 Apr 2011 22:25:32 +0000 (00:25 +0200)] 
linux-user: improve traces

Add trace details for getpid(), kill(), _llseek(), rt_sigaction(),
rt_sigprocmask(), clone().

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
11 years ago[v2] linux-user: bigger default stack
Riku Voipio [Fri, 4 Mar 2011 13:27:29 +0000 (15:27 +0200)] 
[v2] linux-user: bigger default stack

PTHREAD_STACK_MIN (16KB) is somewhat inadequate for a new stack for new
QEMU threads. Set new limit to 256K which should be enough, yet doesn't
increase memory pressure significantly.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
Reviewed-by: Nathan Froyd <froydnj@codesourcery.com>
11 years agodoc: fix slirp description
Brad Hards [Sun, 24 Apr 2011 07:19:56 +0000 (17:19 +1000)] 
doc: fix slirp description

net/slirp.c says:
    /* default settings according to historic slirp */
    struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
    struct in_addr mask = { .s_addr = htonl(0xffffff00) }; /* 255.255.255.0 */
    struct in_addr host = { .s_addr = htonl(0x0a000202) }; /* 10.0.2.2 */
    struct in_addr dhcp = { .s_addr = htonl(0x0a00020f) }; /* 10.0.2.15 */
    struct in_addr dns  = { .s_addr = htonl(0x0a000203) }; /* 10.0.2.3 */

Which I think is not what the documentation says.

Signed-off-by: Brad Hards <bradh@frogmouth.net>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agortl8139: add format attribute to DPRINTF
Benjamin Poirier [Wed, 20 Apr 2011 23:39:02 +0000 (19:39 -0400)] 
rtl8139: add format attribute to DPRINTF

gcc can check the format string for correctness even when debugging output is
not enabled.
Have to make sure arguments are always available. They are optimized out if
unneeded.

Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Cc: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agortl8139: use variadic macro for debug statements
Benjamin Poirier [Wed, 20 Apr 2011 23:39:01 +0000 (19:39 -0400)] 
rtl8139: use variadic macro for debug statements

Removes double (( )) to make DEBUG_PRINT compatible with real function calls.
Change the name to DPRINTF to be consistent with other DPRINTF macros
throughout qemu.
Include the "RTL8139: " prefix in the macro. This changes some debug output
slightly since the prefix wasn't present on all lines.

Part of the change was done using the "coccinelle" tool with the following
small semantic match:
    @@ expression E; @@

    - DEBUG_PRINT((E))
    + DPRINTF(E)

Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Cc: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agortl8139: use TARGET_FMT_plx in debug messages
Benjamin Poirier [Wed, 20 Apr 2011 23:39:00 +0000 (19:39 -0400)] 
rtl8139: use TARGET_FMT_plx in debug messages

Prevents a compilation failure when DEBUG_RTL8139 is defined:

CC    libhw32/rtl8139.o
cc1: warnings being treated as errors
hw/rtl8139.c: In function ‘rtl8139_cplus_transmit_one’:
hw/rtl8139.c:1960: error: format ‘%8lx’ expects type ‘long unsigned int’, but argument 5 has type ‘target_phys_addr_t’
make[1]: *** [rtl8139.o] Error 1

Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Cc: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agolinux-user/arm/nwfpe: rename REG_PC to ARM_REG_PC
Peter Maydell [Wed, 20 Apr 2011 10:19:15 +0000 (11:19 +0100)] 
linux-user/arm/nwfpe: rename REG_PC to ARM_REG_PC

The REG_PC constant used in the ARM nwfpe code is fine in the kernel
but when used in qemu can clash with a definition in the host system
include files (in particular on Ubuntu Lucid SPARC, including signal.h
will define a REG_PC). Rename the constant to avoid this issue.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-arm: Handle UNDEF cases for Neon VLD/VST multiple-structures
Peter Maydell [Mon, 18 Apr 2011 18:07:12 +0000 (19:07 +0100)] 
target-arm: Handle UNDEF cases for Neon VLD/VST multiple-structures

Correctly UNDEF for Neon VLD/VST "multiple structures" forms where the
align field is not valid.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-arm: Handle UNDEFs for Neon single element load/stores
Peter Maydell [Mon, 18 Apr 2011 18:07:11 +0000 (19:07 +0100)] 
target-arm: Handle UNDEFs for Neon single element load/stores

Handle the UNDEF and UNPREDICTABLE cases for Neon "single element to
one lane" VLD and "single element from one lane" VST.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agoMerge remote-tracking branch 'awilliam/ipxe' into staging
Anthony Liguori [Mon, 25 Apr 2011 15:26:10 +0000 (10:26 -0500)] 
Merge remote-tracking branch 'awilliam/ipxe' into staging

11 years agotarget-i386: switch to softfloat
Aurelien Jarno [Wed, 20 Apr 2011 11:04:23 +0000 (13:04 +0200)] 
target-i386: switch to softfloat

This increase the correctness (precision, NaN values, corner cases) on
non-x86 machines, and add the possibility to handle the exception
correctly.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-i386: fix constants wrt softfloat
Aurelien Jarno [Wed, 20 Apr 2011 11:04:23 +0000 (13:04 +0200)] 
target-i386: fix constants wrt softfloat

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
11 years agotarget-i386: fix helper_fprem() and helper_fprem1() wrt softfloat
Aurelien Jarno [Wed, 20 Apr 2011 11:04:23 +0000 (13:04 +0200)] 
target-i386: fix helper_fprem() and helper_fprem1() wrt softfloat

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>