Commit Graph

9731 Commits

Author SHA1 Message Date
Luiz Capitulino 357b6156f9 QError: Add QERR_DEVICE_NOT_FOUND
New class for device not found errors.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:20 -06:00
Luiz Capitulino 8204a9180c monitor: QError support
This commit adds QError support in the Monitor.

A QError member is added to the Monitor struct. This new member
stores error information and is also used to check if an error
has occurred when the called handler returns.

Additionally, a new macro called qemu_error_new() is introduced.
It builds on top of the QemuErrorSink API and should be used in
place of qemu_error().

When all conversion to qemu_error_new() is done, qemu_error() can
be turned private.

Basically, Monitor's error flow is something like this:

1. An error occurs in the handler, it calls qemu_error_new()
2. qemu_error_new() builds a new QError object and stores it in
   the Monitor struct
3. The handler returns
4. Top level Monitor code checks the Monitor struct and calls
   qerror_print() to print the error

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:20 -06:00
Luiz Capitulino 9f9daf9a63 Introduce QError
QError is a high-level data type which represents an exception
in QEMU, it stores the following error information:

- class          Error class name (eg. "ServiceUnavailable")
- description    A detailed error description, which can contain
                 references to run-time error data
- filename       The file name of where the error occurred
- line number    The exact line number of the error
- function       The function name of where the error occurred
- run-time data  Any run-time error data

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:20 -06:00
Luiz Capitulino 64084a03c3 utests: Add qstring_from_substr() unit-test
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:19 -06:00
Luiz Capitulino f08932c880 utests: Add qstring_append_chr() unit-test
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:19 -06:00
Luiz Capitulino 4b5c5766d0 QString: Introduce qstring_from_substr()
Note that we can now write qstring_from_str() as a wrapper.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:19 -06:00
Luiz Capitulino 764c1caeb3 QString: Introduce qstring_append_int()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:19 -06:00
Luiz Capitulino 6fe9565c5b QString: Introduce qstring_append_chr()
It appends a C char to a QString.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:19 -06:00
Luiz Capitulino 8ff5a7d346 QJSON: Introduce qobject_from_jsonv()
It accepts a va_list and will be used by QError. Also simplifies
the code a little, as the other qobject_from_() functions can
use it.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 09:41:18 -06:00
Juha Riihimäki b3a219883e fix I2C slave addressing
With the recent device handling changes the I2C slave addressing code
was broken. With current code, if a slave with the correct address is

not found on the bus the last scanned slave on the bus will be
addressed. This is wrong. Please find attached a patch to fix it.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Acked-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-02 17:26:19 +01:00
Gerd Hoffmann 51954d565f Fix qdev property type definition for isa serial/parallel devices
Use the correct qdev property type for these devices.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:50 -06:00
Jean-Christophe DUBOIS 2bc6f59b23 Fix qemu_malloc/qemu_free use in rtl8139.c
rtl8139.c is using malloc()/free() instead of qemu_malloc()/qemu_free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:43 -06:00
Jean-Christophe DUBOIS 834fac78d4 Fix free use in xen_backend.c
xen_backend.c is using qemu_free() instead of free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:43 -06:00
Jean-Christophe DUBOIS e3c916e680 Fix qemu_free use in scsi-generic.c
scsi-generic.c is using free() instead of qemu_free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:43 -06:00
Jean-Christophe DUBOIS 6f0953b1a4 Fix qemu_free use in nseries.c
nseries.c is using free() instead of qemu_free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:42 -06:00
Jean-Christophe DUBOIS 2db69b2372 Fix qemu_free use in bt-l2cap.c
bt-l2cap.c is using free() instead of qemu_free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:42 -06:00
Jean-Christophe DUBOIS 5f6eab3f10 Fix qemu_free use in nand.c
nand.c is using free() instead of qemu_free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:42 -06:00
Jean-Christophe DUBOIS 49cd8046dd Fix qemu_free use in baum.c
baum.c is using free() instead of qemu_free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:42 -06:00
Jean-Christophe DUBOIS b2538b4b1f Fix qemu_free use in acpi.c
acpi.c is using free() instead of qemu_free().
Fix it.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:42 -06:00
Michael S. Tsirkin d6318738c3 pci: move apb specific stuff to apb_pci.c
pci code had a TODO to move apb specific
pci bridge initialization to apb_pci.
Implement this and remove the TODO.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:42 -06:00
Michael S. Tsirkin be17dc90b5 configure: use correct cflags in compiler checks
linux-user build on fedora 11 breaks because fallocate
is broken on that system if -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
are specified, which is what QEMU uses.

We do have a configure check to catch this and disable fallocate,
however, it turns out that default QEMU_CFLAGS/LDFLAGS were assigned in
script *after* all compiler checks: so during checks we were not running
compiler with same flags that we used for build later.

Fix this by moving QEMU_CFLAGS to before compiler checks, and using
comple_prog when checking for fallocate.  This also fixes the fact that
we do some compiler checks while assigning the flags, right below a
comment that says "no cc tests beyond this point".

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:57:42 -06:00
Stefan Weil 1062977b97 vga-pci: Fix access to linear framebuffer
Anthony Liguori's patch fixes the problems with
vga display in graphical mode and SeaBIOS.

I only adapted some values for vga-pci.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:47:08 -06:00
Stefan Weil a73e8e4309 Makefile: Remove unneeded prerequisites
Thanks to f527c57935
(fix parallel build), these prerequisites
are redundant now and can be removed.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-02 08:47:07 -06:00
Anthony Liguori 365369847f Merge commit 'mst/for_anthony' into mst 2009-12-01 11:54:39 -06:00
Michael S. Tsirkin 98304c846d msix: clear pending bit of an unused vector
PCI spec states:
if a masked vector has its Pending bit set, and the associated
underlying interrupt events are somehow satisfied (usually by software
though the exact manner is function-specific), the function must clear
the Pending bit, to avoid sending a spurious interrupt message later
when software unmasks the vector.

In our case this happens if vector becomes unused.
Clear pending bit in this case.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 18:00:14 +02:00
Michael S. Tsirkin 1f944c661a msix: fix reset value for enable bit
On reset, we currently clear all bits in msix control register *except*
enable bit.  This is wrong: the spec says we should clear writeable
bits: function mask and enable bit.
Correct this.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 18:00:00 +02:00
Michael S. Tsirkin ae1be0bbc1 msix: fix mask bit state after reset
PCI spec states that mask bit must be 1 after reset.
Make it so.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:59:54 +02:00
Michael S. Tsirkin 1b8e9b2742 virtio: do not reset msix state on soft reset
msix state is managed by OS, not the
driver, so it's wrong to touch it
on io from driver.
Mark all vectors unused instead.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:58:48 +02:00
Michael S. Tsirkin b5f28bcaee msix: add helper to unuse all msix entries
will be used by virtio on soft reset

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:58:27 +02:00
Michael S. Tsirkin 88a9556430 pci: convert goto into scope in bridge_filter
goto into scope is evil. rearrange pci_bridge_filter
so that we always go to end of function on error.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Isaku Yamahata <yamahata@valinux.co.jp>
2009-12-01 17:52:51 +02:00
Isaku Yamahata d46636b883 pci: pci bridge related clean up.
- fix bridge prefetchable memory accesser to check 64bit or not.
- use pcibus_t consistently instead mixing pcibus_t and uint64_t.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:52:47 +02:00
Isaku Yamahata 10c9c329da pci: fix pci_config_get_io_base().
fix typo in pci_config_get_io_base().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:52:43 +02:00
Isaku Yamahata b47b0706f1 pci: remove magic number, 256 in pci.c
This patch replaces magic number, 256, with ARRAY_SIZE().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:52:39 +02:00
Michael S. Tsirkin 876a350d3d pci: split up up pci_update mappings
Split bar address math into a separate function.
In particular, this gets rid of an ugly forward goto
into scope that we have there.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Isaku Yamahata <yamahata@valinux.co.jp>
2009-12-01 17:52:35 +02:00
Isaku Yamahata ec50344230 pci: clean up of pci_update_mappings()
This patch converts r->size == 0 to !r_size.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:52:28 +02:00
Isaku Yamahata 2c56b44b88 pci: remove unused constants
This patch removes unused constants committed by
fb23162885.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:52:15 +02:00
Isaku Yamahata fb47a2e983 pci: move typedef, PCIHostState, PCIExpressHost to qemu-common.h.
This patch moves two typedefs, PCIHostState and PCIExpressHost to
qemu-common.h for consistency as PCIBus and PCIDevice are typedefed
in qemu-common.h.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:52:08 +02:00
Isaku Yamahata 3c217c14f5 pci: remove some unnecessary comment in pci.h
This patch removes some comment which should go into commit log
in pci.h.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:52:04 +02:00
Isaku Yamahata 3e21ffc954 pci: clean up of pci_init_wmask().
This patch replaces for loop by memset in pci_init_wmask().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:52:01 +02:00
Isaku Yamahata c34369d48c pci: kill unnecessary included in pci.c
including pci_host.h isn't needed by pci.c.
This patch kills it.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:58 +02:00
Isaku Yamahata 42331e9f2f pci_host: remove unnecessary & 0xff.
This patch removes unnecessary & 0xff in pci_dev_find_by_addr().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:53 +02:00
Isaku Yamahata c469e1dd63 pci: s/pci_find_host_bus/pci_find_root_bus/g
This patch renames pci_find_host_bus() to pci_find_root_bus()
as suggested by "Michael S. Tsirkin" <mst@redhat.com>.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:49 +02:00
Isaku Yamahata 070297d260 pci: remove pci_sub_bus() by open coding.
Because pci_sub_bus() is used only once so eliminate it
by open coding as suggested by "Michael S. Tsirkin" <mst@redhat.com>.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:43 +02:00
Isaku Yamahata f08b32fe95 pci: shorten pci_host_{conf, data}_register_xxx function a bit.
pci_host_data_register_io_memory and its variants are too long a bit.
So shorten them. Now they are
pci_host_{conf, data}_register_{mmio, mmio_noswap, ioport}()

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:37 +02:00
Isaku Yamahata 8d6514f8dd pci: rename (pci_/pcie_mmcfg_)addr_to_dev
This patch renames pci_addr_to_dev(), pcie_mmcfg_addr_to_dev()
to pci_dev_find_by_addr(), pcie_dev_find_by_mmcfg_addr()
as "Michael S. Tsirkin" <mst@redhat.com> suggested.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:31 +02:00
Isaku Yamahata 7ac901cd18 pci: remove pci_addr_to_config() by open code
This patch removes pci_addr_to_config() and open code it
as suggested by Michael S. Tsirkin <mst@redhat.com>.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:26 +02:00
Michael S. Tsirkin 4677d8ed9d pci: simplify (pci_/pcie_mmcfg_)data_read()
Remove switch on length: we don't care about
high bits for value, so just return all ones
if no device.  And add one assert().

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Isaku Yamahata <yamahata@valinux.co.jp>
2009-12-01 17:51:21 +02:00
Isaku Yamahata b6243d991a pci: move pci_data_{read, write}() declaration from pci.h to pci_host.h
Now pci host stuff has been moved from pci.[hc] to pci_host.[hc]
so the declaration of pci_data_{read, write}() should be in
pci_host.h
This patch moves them from pci.h to pci_host.h for consistency.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:15 +02:00
Isaku Yamahata f88d7509b4 pci: fix pci_info_device().
It printed wrong limit value of bridge.
This patch fixes it.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:10 +02:00
Michael S. Tsirkin 18e08a5529 pci: pci.h cleanup: move out stuff not in pci.c
pci.h declares some functions which aren't
defined in pci.h. Clean up moving things
to appropriate headers, and update all users.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2009-12-01 17:51:04 +02:00