sdk/emulator/qemu.git
15 years agoqemu/apic: minimal MSI/MSI-X implementation for PC
Michael S. Tsirkin [Sun, 21 Jun 2009 16:50:03 +0000 (19:50 +0300)]
qemu/apic: minimal MSI/MSI-X implementation for PC

Implement MSI support in APIC. Note that MSI and MMIO APIC registers
are at the same memory location, but actually not on the global bus: MSI
is on PCI bus, APIC is connected directly to the CPU. We map them on the
global bus at the same address which happens to work because MSI
registers are reserved in APIC MMIO and vice versa.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: MSI-X support functions
Michael S. Tsirkin [Sun, 21 Jun 2009 16:49:54 +0000 (19:49 +0300)]
qemu/pci: MSI-X support functions

Add functions implementing MSI-X support. First user will be virtio-pci.
Note that platform must set a flag to declare MSI supported: this
is a safety measure to avoid breaking platforms which should support
MSI-X but currently lack this in the interrupt controller emulation.
For PC this will be set by APIC.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: check constant registers on load
Michael S. Tsirkin [Sun, 21 Jun 2009 16:49:40 +0000 (19:49 +0300)]
qemu/pci: check constant registers on load

Add "cmask" table of constant register masks: if a bit is not writeable
and is set in cmask table, this bit is checked on load.  An attempt to
load an image that would change such a register causes load to fail.
Use this table to make sure that load does not modify registers that
guest can not change (directly or indirectly).

Note: we can't just assume that read-only registers never change,
because the guest could change a register indirectly.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: add routines to manage PCI capabilities
Michael S. Tsirkin [Sun, 21 Jun 2009 16:45:40 +0000 (19:45 +0300)]
qemu/pci: add routines to manage PCI capabilities

Add routines to manage PCI capability list. First user will be MSI-X.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: helper routines for pci access
Michael S. Tsirkin [Sun, 21 Jun 2009 16:45:30 +0000 (19:45 +0300)]
qemu/pci: helper routines for pci access

Add inline routines for convenient access to pci devices
with correct (little) endianness. Will be used by MSI-X support.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqemu/pci: make default_write_config use mask table
Michael S. Tsirkin [Sun, 21 Jun 2009 16:45:18 +0000 (19:45 +0300)]
qemu/pci: make default_write_config use mask table

Change much of hw/pci to use symbolic constants and a table-driven
design: add a mask table with writable bits set and readonly bits unset.
Detect change by comparing original and new registers.

This makes it easy to support capabilities where read-only/writeable
bit layout differs between devices, depending on capabilities present.

As a result, writing a single byte in BAR registers now works as
it should. Writing to upper limit registers in the bridge
also works as it should. Code is also shorter.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoadd sparc64-softmmu to default configure targets list
Igor V. Kovalenko [Tue, 23 Jun 2009 18:04:16 +0000 (18:04 +0000)]
add sparc64-softmmu to default configure targets list

Add sparc64 to default list of softmmu targets
Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
15 years agosparc64 follow pci_nic_init change
Igor V. Kovalenko [Tue, 23 Jun 2009 18:04:08 +0000 (18:04 +0000)]
sparc64 follow pci_nic_init change

sun4u.c: correct pci_nic_init arguments following
commit 5607c38820366954c38dd702e979499486057481

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
15 years agomicroblaze: Support the latest mmu-kernel stat64 ABI.
Edgar E. Iglesias [Tue, 23 Jun 2009 17:19:33 +0000 (19:19 +0200)]
microblaze: Support the latest mmu-kernel stat64 ABI.

Microblaze recently changed their ABI. The new is not backwards compatible
and there doesn't seem to be a way to distinguish old/new binaries.
Let's support the latest ABI for now and hope someone figures out a way to
hande both ABI's later.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
15 years agotarget-ppc: permit linux-user to read PVR
Nathan Froyd [Fri, 5 Jun 2009 01:45:03 +0000 (18:45 -0700)]
target-ppc: permit linux-user to read PVR

Access to the PVR SPR is normally forbidden from userspace apps.  The
Linux kernel, however, fixes up reads in the appropriate trap handler.
To permit applications that read PVR to run on QEMU, then, we need to
implement the same handling of PVR reads.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: malc <av1474@comtv.ru>
15 years agocris: Remove unused internal flag.
Edgar E. Iglesias [Tue, 23 Jun 2009 08:27:00 +0000 (10:27 +0200)]
cris: Remove unused internal flag.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
15 years agoWin32: Reduce section alignment for Windows.
Stefan Weil [Thu, 18 Jun 2009 21:04:48 +0000 (23:04 +0200)]
Win32: Reduce section alignment for Windows.

Maximum alignment for Win32 is 16, so don't try
to set it to 32. Otherwise the compiler complains:

exec.c:102: warning: alignment of 'code_gen_prologue'
is greater than maximum object file alignment.  Using 16

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoWin: Install keymaps for Windows, too (needed for VNC).
Stefan Weil [Thu, 18 Jun 2009 21:04:15 +0000 (23:04 +0200)]
Win: Install keymaps for Windows, too (needed for VNC).

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoWin32: Fix compilation with SDL.
Stefan Weil [Thu, 18 Jun 2009 18:11:03 +0000 (20:11 +0200)]
Win32: Fix compilation with SDL.

`sdl-config --cflags` defines main = SDL_main
on some platforms. One of these platforms is
Windows with mingw32.

For those platforms, the solution already developed
for __APPLE__ is now applied.

A compiler warning (missing return value) is fixed, too.

Maybe __APPLE__ no longer needs a separate check.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agovirtio-net: implement async packet sending
Mark McLoughlin [Thu, 18 Jun 2009 17:21:36 +0000 (18:21 +0100)]
virtio-net: implement async packet sending

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agonet: add packet length to NetPacketSent callback
Mark McLoughlin [Thu, 18 Jun 2009 17:21:35 +0000 (18:21 +0100)]
net: add packet length to NetPacketSent callback

virtio-net needs this - for the same purpose that it currently uses the
return value from qemu_sendv_packet().

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agonet: add '-net tap,sndbuf=nbytes'
Mark McLoughlin [Thu, 18 Jun 2009 17:21:34 +0000 (18:21 +0100)]
net: add '-net tap,sndbuf=nbytes'

2.6.30 adds a new TUNSETSNDBUF ioctl() which allows a send buffer limit
for the tap device to be specified. When this limit is reached, a tap
write() will return EAGAIN and poll() will indicate the fd isn't
writable.

This allows people to tune their setups so as to avoid e.g. UDP packet
loss when the sending application in the guest out-runs the NIC in the
host.

There is no obviously sensible default setting - a suitable value
depends mostly on the capabilities of the physical NIC through which the
packets are being sent.

Also, note that when using a bridge with netfilter enabled, we currently
never get EAGAIN because netfilter causes the packet to be immediately
orphaned. Set /proc/sys/net/bridge/bridge nf-call-iptables to zero to
disable this behaviour.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agonet: return TAPState from net_tap_init()
Mark McLoughlin [Thu, 18 Jun 2009 17:21:33 +0000 (18:21 +0100)]
net: return TAPState from net_tap_init()

net_tap_fd_init() already returns TAPState, so this is a sensible
cleanup in its own right.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agonet: handle EAGAIN from tapfd write()
Mark McLoughlin [Thu, 18 Jun 2009 17:21:32 +0000 (18:21 +0100)]
net: handle EAGAIN from tapfd write()

If a write() on tapfd returns EAGAIN, return zero so that the packet
gets queued (in the case of async send) and enable polling tapfd for
writing.

When tapfd becomes writable, disable write polling and flush any queued
packets.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agonet: add tap_read_poll() helper
Mark McLoughlin [Thu, 18 Jun 2009 17:21:31 +0000 (18:21 +0100)]
net: add tap_read_poll() helper

Add a helper to enable/disable the read polling on tapfd.

We need this, because we want to start write polling on the tapfd too
and enable/disable both types of polling independently.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agonet: purge queued packets in tap_cleanup()
Mark McLoughlin [Thu, 18 Jun 2009 17:21:30 +0000 (18:21 +0100)]
net: purge queued packets in tap_cleanup()

If tap has any packets queued at host_net_remove time, it needs to purge
them in order to prevent a sent callback being invoked for it.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agonet: add qemu_purge_queued_packets()
Mark McLoughlin [Thu, 18 Jun 2009 17:21:29 +0000 (18:21 +0100)]
net: add qemu_purge_queued_packets()

If net client sends packets asynchronously, it needs to purge its queued
packets in cleanup() so as to prevent sent callbacks being invoked with
a freed client.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoFix build on Mac OS X
Anthony Liguori [Thu, 18 Jun 2009 18:31:51 +0000 (13:31 -0500)]
Fix build on Mac OS X

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoDon't register cpu reset handler for cpu with APIC.
Gleb Natapov [Thu, 18 Jun 2009 13:29:18 +0000 (16:29 +0300)]
Don't register cpu reset handler for cpu with APIC.

APIC reset handler already resets cpu, no need to reset it twice.
Also register cpu_reset handler directly to make it impossible to
add additional code to main_cpu_reset() by mistake.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoSupport addr=... in option argument of -drive if=virtio
Markus Armbruster [Thu, 18 Jun 2009 13:14:10 +0000 (15:14 +0200)]
Support addr=... in option argument of -drive if=virtio

Make drive_init() accept addr=, put the value into struct DriveInfo.
Use it in all the places that create virtio-blk-pci devices:
pc_init1(), bamboo_init(), mpc8544ds_init().

Don't support addr= in third argument of monitor command pci_add and
second argument of drive_add, because that clashes with their first
arguments.  Admittedly unelegant.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoMake first argument of monitor command pci_add work
Markus Armbruster [Thu, 18 Jun 2009 13:14:09 +0000 (15:14 +0200)]
Make first argument of monitor command pci_add work

Simply pass the PCI address through qemu_pci_hot_add_nic() to
pci_nic_init() and through qemu_pci_hot_add_storage() to pci_create().

Before, pci_device_hot_add() passed along the PCI bus to use, and
ignored any user-specified slot.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoSupport addr=... in option argument of -net nic
Markus Armbruster [Thu, 18 Jun 2009 13:14:08 +0000 (15:14 +0200)]
Support addr=... in option argument of -net nic

Make net_client_init() accept addr=, put the value into struct
NICinfo.  Use it in pci_nic_init(), and remove arguments bus and
devfn.

Don't support addr= in third argument of monitor command pci_add,
because that clashes with its first argument.  Admittedly unelegant.

Machines "malta" and "r2d" have a default NIC with a well-known PCI
address.  Deal with that the same way as the NIC model: make
pci_nic_init() take an optional default to be used when the user
doesn't specify one.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoFix do_pci_register_device() to reject devfn already in use
Markus Armbruster [Thu, 18 Jun 2009 13:14:07 +0000 (15:14 +0200)]
Fix do_pci_register_device() to reject devfn already in use

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agovmware_vga: clean up
Isaku Yamahata [Thu, 18 Jun 2009 10:55:38 +0000 (19:55 +0900)]
vmware_vga: clean up

use NULL instead of 0 for pci_register_device() argument
for consistency. Any other caller uses NULL.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agodot gitignore: add qemu-monitor.texi
Isaku Yamahata [Thu, 18 Jun 2009 10:55:09 +0000 (19:55 +0900)]
dot gitignore: add qemu-monitor.texi

add qemu-monitor.texi to .gitignore.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agovirtio-net: enable mergeable receive buffers
Mark McLoughlin [Thu, 18 Jun 2009 10:31:07 +0000 (11:31 +0100)]
virtio-net: enable mergeable receive buffers

When virtio-net was merged in from qemu-kvm.git, the VNET_HDR related
features were dropped from the code.

However, VIRTIO_NET_F_MRG_RXBUF appears to have accidentally been
dropped too. Re-instate that now.

Reported-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoacpi.c: make qemu_system_device_hot_add piix independent.
Isaku Yamahata [Thu, 18 Jun 2009 10:57:00 +0000 (19:57 +0900)]
acpi.c: make qemu_system_device_hot_add piix independent.

introruce piix4_device_hot_add() for piix4 specific code
and make qemu_system_device_hot_add() generic.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoInstead of writing a zero page, madvise it away
Anthony Liguori [Wed, 17 Jun 2009 21:46:12 +0000 (16:46 -0500)]
Instead of writing a zero page, madvise it away

Otherwise, after migration, we end up with a much larger RSS size then we
ought to have.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoHandle init/sipi in a main cpu exec loop. (v2)
Gleb Natapov [Wed, 17 Jun 2009 20:26:59 +0000 (23:26 +0300)]
Handle init/sipi in a main cpu exec loop. (v2)

This should fix compilation problem in case of CONFIG_USER_ONLY.

Currently INIT/SIPI is handled in the context of CPU that sends IPI.
This patch changes this to handle them like all other events in a main
cpu exec loop. When KVM will gain thread per vcpu capability it will
be much more clear to handle those event by cpu thread itself and not
modify one cpu's state from the context of the other.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoAdd pci_bus_reset() function.
Gleb Natapov [Wed, 17 Jun 2009 16:32:00 +0000 (19:32 +0300)]
Add pci_bus_reset() function.

To reset internal irq handling data structures.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Yaniv Kamay <ykamay@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agovirtio: add support for indirect ring entries
Mark McLoughlin [Wed, 17 Jun 2009 10:38:28 +0000 (11:38 +0100)]
virtio: add support for indirect ring entries

Support a new feature flag for indirect ring entries. These are ring
entries which point to a table of buffer descriptors.

The idea here is to increase the ring capacity by allowing a larger
effective ring size whereby the ring size dictates the number of
requests that may be outstanding, rather than the size of those
requests.

This should be most effective in the case of block I/O where we can
potentially benefit by concurrently dispatching a large number of
large requests. Even in the simple case of single segment block
requests, this results in a threefold increase in ring capacity.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agovirtio: make vring_desc_*() take phys addrs
Mark McLoughlin [Wed, 17 Jun 2009 10:37:32 +0000 (11:37 +0100)]
virtio: make vring_desc_*() take phys addrs

Change the vring descriptor helpers to take the physical
address of the descriptor table rather than a virtqueue.

This is needed in order to allow these helpers to be used
with an indirect descriptor table.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoAdd O_BINARY to open call in net_dump_init.
Filip Navara [Wed, 17 Jun 2009 17:48:08 +0000 (19:48 +0200)]
Add O_BINARY to open call in net_dump_init.

Fix the pcap dumps on Win32 and other systems where O_BINARY is required.

Signed-off-by: Filip Navara <filip.navara@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoMake nic option rom loading less painful.
Glauber Costa [Wed, 17 Jun 2009 13:05:30 +0000 (09:05 -0400)]
Make nic option rom loading less painful.

The code how it is today, is totally painful to read and keep.
To begin with, the code is duplicated with the option rom loading
code that linux_boot and vga are already using.

This patch introduces a "bootable" state in NICInfo structure,
that we can use to keep track of whether or not a given nic should
be bootable, avoiding the introduction of yet another global state.

With that in hands, we move the code in vl.c to hw/pc.c, and use
the already existing infra structure to load those option roms.

Error checking code suggested by Mark McLoughlin

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoDisable _FORTIFY_SOURCE to fix Ubuntu build with -Werror
Anthony Liguori [Wed, 17 Jun 2009 19:27:09 +0000 (14:27 -0500)]
Disable _FORTIFY_SOURCE to fix Ubuntu build with -Werror

This eliminates the results unused warnings.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoApply TCGV_UNUSED on variables that GCC mistakenly thinks can be used
malc [Sat, 20 Jun 2009 01:51:47 +0000 (05:51 +0400)]
Apply TCGV_UNUSED on variables that GCC mistakenly thinks can be used
uninitialized

15 years agoRestore consistent formatting of audio devices
malc [Sat, 20 Jun 2009 01:13:29 +0000 (05:13 +0400)]
Restore consistent formatting of audio devices

15 years agolinux-user: strace now handles guest stringscorrectly [v2]
Riku Voipio [Thu, 18 Jun 2009 19:51:31 +0000 (22:51 +0300)]
linux-user: strace now handles guest stringscorrectly [v2]

On Tue, Jun 16, 2009 at 08:19:23PM -0500, Anthony Liguori wrote:
> malc wrote:
>>
>> On my system the above line causes gcc to emit:
>>
>> In file included from /home/malc/x/rcs/git/qemu/linux-user/strace.c:12:
>> /usr/include/linux/futex.h:48: error: field `__user' has incomplete type
>> /usr/include/linux/futex.h:48: error: syntax error before '*' token
>> /usr/include/linux/futex.h:63: error: field `list' has incomplete type
>> /usr/include/linux/futex.h:83: error: field `__user' has incomplete type
>> /usr/include/linux/futex.h:83: error: syntax error before '*' token
>> make[1]: *** [strace.o] Error 1

> We had the same problem with usb-linux.c.  It's broken system headers,
> the __user stuff is supposed to get removed as part of the headers
> installation.

> It builds fine on my system (Fedora 10).

Howabout something like this:

commit eb8387cb0eda32a18880664eb5f0ca5c8bf05b45
Author: Riku Voipio <riku.voipio@iki.fi>
Date:   Thu Jun 18 22:44:31 2009 +0300
Subject: linux-user: include futex defines directly

Since some common distributions have broken linux/futex.h, stop
including it. Instead add the defines directly.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
15 years agofix qemu_alloc/qemu_free for audio subsystem
Jean-Christophe Dubois [Thu, 18 Jun 2009 20:50:14 +0000 (22:50 +0200)]
fix qemu_alloc/qemu_free for audio subsystem

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
15 years agoalsa: fix warning
Gerd Hoffmann [Wed, 17 Jun 2009 11:51:20 +0000 (13:51 +0200)]
alsa: fix warning

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
15 years agoxilinx-eth: Remove debug print.
Edgar E. Iglesias [Thu, 18 Jun 2009 08:28:10 +0000 (10:28 +0200)]
xilinx-eth: Remove debug print.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
15 years agoDon't set IRQs on device reset and loadvm/savevm
Blue Swirl [Wed, 17 Jun 2009 19:23:44 +0000 (19:23 +0000)]
Don't set IRQs on device reset and loadvm/savevm

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoCall piix4_reset() on system reset.
Blue Swirl [Wed, 17 Jun 2009 17:36:51 +0000 (17:36 +0000)]
Call piix4_reset() on system reset.

Also zero pci_irq_levels on reset to avoid stuck irq after reset.

Based on 15a1956af94e36105494f782a752698103addf63 by Gleb Natapov.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoDon't set IRQs on device reset and loadvm/savevm
Blue Swirl [Wed, 17 Jun 2009 17:20:01 +0000 (17:20 +0000)]
Don't set IRQs on device reset and loadvm/savevm

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoCall piix3_reset() on system reset.
Gleb Natapov [Wed, 17 Jun 2009 16:32:01 +0000 (19:32 +0300)]
Call piix3_reset() on system reset.

Also zero pci_irq_levels on reset to avoid stuck irq after reset.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Yaniv Kamay <ykamay@redhat.com>
15 years agoRegister usb-uhci reset function.
Gleb Natapov [Wed, 17 Jun 2009 16:32:02 +0000 (19:32 +0300)]
Register usb-uhci reset function.

The device is not reset on system reset currently.
Without this patch RHEL4.8 hangs after reboot if -usbdevice table
is in use.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
15 years agoRevert "Update irqs on reset and device load"
Blue Swirl [Wed, 17 Jun 2009 17:01:03 +0000 (17:01 +0000)]
Revert "Update irqs on reset and device load"

This reverts commit 3dcd219f09d6c1817bf9a132899e6b925f7a0914.

It is incorrect to call qemu_irq functions (or any other functions that
access other device state) during savevm/loadvm.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoAllow user to specify CPU model
Blue Swirl [Wed, 17 Jun 2009 15:49:37 +0000 (15:49 +0000)]
Allow user to specify CPU model

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoFix opening of read only raw images
Blue Swirl [Wed, 17 Jun 2009 15:27:44 +0000 (18:27 +0300)]
Fix opening of read only raw images

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoReplace ELF section hack with normal table
Blue Swirl [Wed, 17 Jun 2009 15:22:31 +0000 (15:22 +0000)]
Replace ELF section hack with normal table

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoConcentrate rest of table entries to top
Blue Swirl [Wed, 17 Jun 2009 15:22:24 +0000 (15:22 +0000)]
Concentrate rest of table entries to top

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoConcentrate most table entries to top
Blue Swirl [Wed, 17 Jun 2009 15:22:19 +0000 (15:22 +0000)]
Concentrate most table entries to top

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoClean up GEN_HANDLER2
Blue Swirl [Wed, 17 Jun 2009 15:22:14 +0000 (15:22 +0000)]
Clean up GEN_HANDLER2

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoClean up GEN_HANDLER
Blue Swirl [Wed, 17 Jun 2009 15:22:09 +0000 (15:22 +0000)]
Clean up GEN_HANDLER

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
15 years agoexec.c: remove unnecessary #if NB_MMU_MODES
Isaku Yamahata [Wed, 20 May 2009 02:31:43 +0000 (11:31 +0900)]
exec.c: remove unnecessary #if NB_MMU_MODES

remove unnecessary #if NB_MMU_MODES by using loop.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoFix vga_screen_dump_blank() PPM generation
Eduardo Habkost [Mon, 25 May 2009 21:20:05 +0000 (18:20 -0300)]
Fix vga_screen_dump_blank() PPM generation

vga_screen_dump_blank() was not generating a valid PPM file: the width of the
image made no sense (why it was multiplied by sizeof(uint32_t)?), and there was
only one sample per pixel, instead of three.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoPrevent CD-ROM media eject while device is locked
Mark McLoughlin [Wed, 27 May 2009 09:06:11 +0000 (10:06 +0100)]
Prevent CD-ROM media eject while device is locked

Section 10.8.25 ("START/STOP UNIT Command") of SFF-8020i states that
if the device is locked we should refuse to eject if the device is
locked.

ASC_MEDIA_REMOVAL_PREVENTED is the appropriate return in this case.

In order to stop itself from ejecting the media it is running from,
Fedora's installer (anaconda) requires the CDROMEJECT ioctl() to fail
if the drive has been previously locked.

See also https://bugzilla.redhat.com/501412

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoset migration max downtime
Glauber Costa [Thu, 28 May 2009 19:22:58 +0000 (15:22 -0400)]
set migration max downtime

provide a monitor command to allow one to set the maximum
downtime he is willing to suffer during migration, in seconds.
"ms", "us", "ns" and "s" are accepted as modifiers.

This parameter will be used by ram_save_live() code to determine
a safe moment to enter stage 3

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoadd non-arbitrary migration stop condition
Glauber Costa [Thu, 28 May 2009 19:22:57 +0000 (15:22 -0400)]
add non-arbitrary migration stop condition

Currently, we're entering migration's stage 3 when
a treshold of 10 pages remain to be transferred in the system.

This has hurt some users. However, any proposed threshold is
arbitrary by nature, and would only shift the annoyance.

The proposal of this patch is to define a max_downtime variable,
which represents the maximum downtime a migration user is willing
to suffer. Then, based on the bandwidth of last iteration, we
calculate how much data we can transfer in such a window of time.

Whenever we reach that value (or lower), we know is safe to enter
stage3.

This has largely improved the situation for me.
On localhost migrations, where one would expect things to go as
quickly as me running away from the duty of writting software for
windows, a kernel compile was enough to get the migration stuck.

It takes 20 ~ 30 iterations now.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agokvm: Fix IRQ injection into full queue
Jan Kiszka [Sat, 30 May 2009 08:01:45 +0000 (10:01 +0200)]
kvm: Fix IRQ injection into full queue

User space may only inject interrupts during kvm_arch_pre_run if
ready_for_interrupt_injection is set in kvm_run. But that field is
updated on exit from KVM_RUN, so we must ensure that we enter the
kernel after potentially queuing an interrupt, otherwise we risk to
loose one - like it happens with the current code against latest
kernel modules (since kvm-86) that started to queue only a single
interrupt.

Fix the problem by reordering kvm_cpu_exec.

Credits go to Gleb Natapov for analyzing the issue in details.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoCall qemu_bh_delete at bdrv_aio_bh_cb.
Dor Laor [Mon, 1 Jun 2009 09:07:23 +0000 (12:07 +0300)]
Call qemu_bh_delete at bdrv_aio_bh_cb.

Also replave qemu_bh_cancel with qemu_bh_delete in bdrv_aio_cancel_em.
 Otherwise the bh will live forever in the bh list.

Signed-off-by: Dor Laor <dor@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRemove dead code
Amit Shah [Wed, 3 Jun 2009 09:06:24 +0000 (14:36 +0530)]
Remove dead code

vl.c contains some dead code that initialises a 'label' string with the name
of the char device being initialised. This is unused.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoQEMU KVM: i386: Fix the cpu reset state
Nitin A Kamble [Thu, 4 Jun 2009 21:29:50 +0000 (14:29 -0700)]
QEMU KVM: i386: Fix the cpu reset state

As per the IA32 processor manual, the accessed bit is set to 1 in the
processor state after reset. qemu pc cpu_reset code was missing this
accessed bit setting.

Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoallow CPUID vendor override
Andre Przywara [Fri, 5 Jun 2009 23:03:29 +0000 (01:03 +0200)]
allow CPUID vendor override

KVM-enabled QEMU will always report the vendor ID of the physical CPU it is
running on. Allow to override this if explicitly requested on the
command line. It will not suffice to name a CPU type (like -cpu phenom),
but you have to explicitly set the vendor: -cpu phenom,vendor=AuthenticAMD

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoFix help message for new configure option --enable-debug.
Stefan Weil [Sat, 6 Jun 2009 14:51:30 +0000 (16:51 +0200)]
Fix help message for new configure option --enable-debug.

The new option is --enable-debug, not --disable-debug.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoprovide cpu_index to env mapping
Glauber Costa [Tue, 9 Jun 2009 16:15:18 +0000 (12:15 -0400)]
provide cpu_index to env mapping

There are some people interested in, given a cpu number,
pick its CPUState. KVM is an example, although not yet in tree.
This patch provides a way of doing that.

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agopci: add define for communication class devices
Amit Shah [Tue, 9 Jun 2009 16:42:46 +0000 (22:12 +0530)]
pci: add define for communication class devices

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agovnc: improve numpad support for qemu console.
Gerd Hoffmann [Thu, 11 Jun 2009 09:32:14 +0000 (11:32 +0200)]
vnc: improve numpad support for qemu console.

Reorganize qemu console emulation code.  Make it look at the numlock
state and interpret numpad keys as arrow+friends (numlock off) or
digits (numlock on).  While being at it also wind up the other numpad
keys.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agovirtio blk: fix warning.
Gerd Hoffmann [Fri, 12 Jun 2009 07:50:18 +0000 (09:50 +0200)]
virtio blk: fix warning.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agolsi53c895a: Implement write access to DMA Byte Counter
Sebastian Herbszt [Sat, 13 Jun 2009 21:03:29 +0000 (23:03 +0200)]
lsi53c895a: Implement write access to DMA Byte Counter

Adds CASE_SET_REG24 and fixes the following errors:

lsi_scsi: error: Unhandled writeb 0x24 = 0x0
lsi_scsi: error: Unhandled writeb 0x25 = 0x0

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agolsi53c895a: Implement read and write access to DMA Next Address
Sebastian Herbszt [Sat, 13 Jun 2009 21:03:27 +0000 (23:03 +0200)]
lsi53c895a: Implement read and write access to DMA Next Address

Fixes the following errors:

lsi_scsi: error: Unhandled writeb 0x28 = 0x0
lsi_scsi: error: Unhandled writeb 0x29 = 0x0
lsi_scsi: error: Unhandled writeb 0x2a = 0x0
lsi_scsi: error: Unhandled writeb 0x2b = 0x0

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agolsi53c895a: Implement Scratch Byte Register
Sebastian Herbszt [Sat, 13 Jun 2009 21:03:26 +0000 (23:03 +0200)]
lsi53c895a: Implement Scratch Byte Register

Fixes the following errors:

lsi_scsi: error: Unhandled writeb 0x3a = 0x0
lsi_scsi: error: readb 0x3a

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRename pci_register_io_region() to pci_register_bar()
Avi Kivity [Sun, 14 Jun 2009 08:38:53 +0000 (11:38 +0300)]
Rename pci_register_io_region() to pci_register_bar()

This function is used to manage a PCI BAR, so make the more generic
pci_register_io_region() available to other uses.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRearrange io_mem_init()
Avi Kivity [Sun, 14 Jun 2009 08:38:52 +0000 (11:38 +0300)]
Rearrange io_mem_init()

Move io_mem_init() downwards to avoid a forward declaration.  No code change.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoRemove io_index argument from cpu_register_io_memory()
Avi Kivity [Sun, 14 Jun 2009 08:38:51 +0000 (11:38 +0300)]
Remove io_index argument from cpu_register_io_memory()

The parameter is always zero except when registering the three internal
io regions (ROM, unassigned, notdirty).  Remove the parameter to reduce
the API's power, thus facilitating future change.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agokvm: Restrict configure check to Linux
Jan Kiszka [Sun, 14 Jun 2009 18:05:02 +0000 (20:05 +0200)]
kvm: Restrict configure check to Linux

There is no point in trying to find KVM on anything else than Linux, at
least for the moment.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agomux-term: Fix timestamp association
Jan Kiszka [Mon, 15 Jun 2009 20:25:34 +0000 (22:25 +0200)]
mux-term: Fix timestamp association

So far a new timestamp was generated *after* a full line had been
printed. Fix this.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agomux-term: Localize timestamps
Jan Kiszka [Mon, 15 Jun 2009 20:25:30 +0000 (22:25 +0200)]
mux-term: Localize timestamps

As we can have multiple multiplexed terminals, timestamp control and
tracking should better take place per MuxDriver.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoreadline: Remove unneeded qemu_mallocz() check
Luiz Capitulino [Mon, 15 Jun 2009 20:37:31 +0000 (17:37 -0300)]
readline: Remove unneeded qemu_mallocz() check

qemu_mallocz() already checks for NULL returns, readline_init() doesn't
have to do it again.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoupdate_refcount: Write complete sectors
Kevin Wolf [Tue, 16 Jun 2009 09:31:30 +0000 (11:31 +0200)]
update_refcount: Write complete sectors

When updating the refcount blocks in update_refcount(), write complete sectors
instead of updating single entries.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoalloc_cluster_link_l2: Write complete sectors
Kevin Wolf [Tue, 16 Jun 2009 09:31:29 +0000 (11:31 +0200)]
alloc_cluster_link_l2: Write complete sectors

When updating the L2 tables in alloc_cluster_link_l2(), write complete
sectors instead of updating single entries.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agol2_allocate: Write complete sectors
Kevin Wolf [Tue, 16 Jun 2009 09:31:28 +0000 (11:31 +0200)]
l2_allocate: Write complete sectors

When modifying the L1 table, l2_allocate() needs to write complete sectors
instead of single entries. The L1 table is already in memory, reading it from
disk in the block layer to align the request is wasted performance.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqcow2: Rename global functions
Kevin Wolf [Thu, 28 May 2009 14:07:07 +0000 (16:07 +0200)]
qcow2: Rename global functions

The qcow2 source is now split into several more manageable files. During the
conversion quite some functions that were static before needed to be changed to
be global to make the source compile again.

We were lucky enough not to get name conflicts with these additional global
names, but they are not nice. This patch adds a qcow2_ prefix to all of the
global functions in qcow2.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqcow2: Split out snapshot functions
Kevin Wolf [Thu, 28 May 2009 14:07:06 +0000 (16:07 +0200)]
qcow2: Split out snapshot functions

qcow2-snapshot.c contains the code related to snapshotting.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqcow2: Split out guest cluster functions
Kevin Wolf [Thu, 28 May 2009 14:07:05 +0000 (16:07 +0200)]
qcow2: Split out guest cluster functions

qcow2-cluster.c contains all functions related to the management of guest
clusters, i.e. what the guest sees on its virtual disk. This code is about
mapping these guest clusters to host clusters in the image file using the
two-level lookup tables.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqcow2: Split out refcount handling
Kevin Wolf [Thu, 28 May 2009 14:07:04 +0000 (16:07 +0200)]
qcow2: Split out refcount handling

qcow2-refcount.c contains all functions which are related to cluster
allocation and management in the image file. A large part of this is the
reference counting of these clusters.

Also a header file qcow2.h is introduced which will contain the interface of
the split qcow2 modules.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqcow2: Change default cluster size to 64k
Kevin Wolf [Tue, 16 Jun 2009 10:53:25 +0000 (12:53 +0200)]
qcow2: Change default cluster size to 64k

Larger cluster sizes mean less metadata. This has been discussion a few times,
let's do it now. This turns 64k clusters on by default for new images.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agovnc: rework VncState release workflow.
Gerd Hoffmann [Tue, 16 Jun 2009 12:19:48 +0000 (14:19 +0200)]
vnc: rework VncState release workflow.

Split socket closing and releasing of VncState into two steps.  First
close the socket and set the variable to -1 to indicate shutdown in
progress.  Do the actual release in a few places where we can be sure it
doesn't cause trouble in form of use-after-free.  Add some checks for a
valid socket handle to make sure we don't try to use the closed socket.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoraw-posix: Remove O_RDWR when attempting to open a file read-only
Avi Kivity [Tue, 16 Jun 2009 13:21:09 +0000 (16:21 +0300)]
raw-posix: Remove O_RDWR when attempting to open a file read-only

When we open a file, we first attempt to open it read-write, then fall back
to read-only.  Unfortunately we reuse the flags from the previous attempt,
so both attempts try to open the file with write permissions, and fail.

Fix by clearing the O_RDWR flag from the previous attempt.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoraw-posix: open flags use BDRV_ namespace, not posix namespace
Avi Kivity [Tue, 16 Jun 2009 13:21:08 +0000 (16:21 +0300)]
raw-posix: open flags use BDRV_ namespace, not posix namespace

The flags argument to raw_common_open() contain bits defined by the BDRV_O_*
namespace, not the posix O_* namespace.

Adjust to use the correct constants.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoqdev: Fix regression in "pci_add ... storage if=virtio, ..."
Markus Armbruster [Tue, 16 Jun 2009 14:24:44 +0000 (16:24 +0200)]
qdev: Fix regression in "pci_add ... storage if=virtio, ..."

qemu_pci_hot_add_storage() runs qdev_init() twice.  Broken in commit
07e3af9a "Virtio-blk qdev conversion".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agoMake sure to use SDL_CFLAGS everywhere we include SDL headers
Anthony Liguori [Tue, 16 Jun 2009 20:17:22 +0000 (15:17 -0500)]
Make sure to use SDL_CFLAGS everywhere we include SDL headers

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
15 years agolinux-user: remove duplicate tswap32() from do_getsockopt()
Laurent Vivier [Mon, 1 Jun 2009 21:57:48 +0000 (23:57 +0200)]
linux-user: remove duplicate tswap32() from do_getsockopt()

This issue has been detected with tests/linux-tests.c:

linux-test.c:330: getsockopt

327     len = sizeof(val);
328     chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len));
329     if (val != SOCK_STREAM)
330         error("getsockopt");

In linux-user/syscall.c:do_getsockopt(), we have:
...
        val = tswap32(val);
...
            if (put_user_u32(val, optval_addr))
...

whereas "put_user_u32" calls in the end "__put_user" which uses "tswap32".

So the "val = tswap32(val);" is useless and wrong.

This patch removes it.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
15 years agolinux-user/syscall.c: define _ATFILE_SOURCE
Eduardo Habkost [Tue, 9 Jun 2009 21:26:31 +0000 (18:26 -0300)]
linux-user/syscall.c: define _ATFILE_SOURCE

Needed to make sure the xxxat() functions are available.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
15 years agolinux-user: initialize mmap_mutex properly
Nathan Froyd [Thu, 4 Jun 2009 18:51:56 +0000 (11:51 -0700)]
linux-user: initialize mmap_mutex properly

We initialize mmap_mutex in any child threads/processes, but we need to
correctly statically initialize it for the original process.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>