Commit Graph

8482 Commits

Author SHA1 Message Date
Juan Quintela 273a214217 eepro100: Remove unused indirection of PCIDevice
Once there, there is no way that we don't have a PCI Device at save/load time. Remove the check

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:46:58 -05:00
Juan Quintela 769cf7a50e eepro100: cast a void * makes no sense
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:46:58 -05:00
Juan Quintela d986bd5086 eepro100: convert casts to DO_UPCAST()
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:46:58 -05:00
Ed Swierk df7a86ed73 slirp: Read host DNS config on demand
Currently the qemu user-mode networking stack reads the host DNS
configuration (/etc/resolv.conf or the Windows equivalent) only once
when qemu starts.  This causes name lookups in the guest to fail if the
host is moved to a different network from which the original DNS servers
are unreachable, a common occurrence when the host is a laptop.

This patch changes the slirp code to read the host DNS configuration on
demand, caching the results for at most 1 second to avoid unnecessary
overhead if name lookups occur in rapid succession.  On non-Windows
hosts, /etc/resolv.conf is re-read only if the file has been replaced or
if its size or mtime has changed.

Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:46:58 -05:00
Ed Swierk ce0bd027df slirp: Remove our_addr code
Three problems with our_addr:

- It's determined only once when qemu starts, but the address can change
(just like the DNS configuration can).

- It's supposed to be the IP address of a host network interface, but
there's no guarantee that gethostbyname(gethostname()) actually does
that: the host might be a laptop that has only a loopback interface up,
or the hostname might be localhost.localdomain, etc.

- It's useless at best: get_dns_addr() calls it, there's no reason to
send DNS requests to a different IP address if you're running a DNS
server on the host and resolv.conf points to 127.0.0.1.

These problems are easily solved by removing the code.

Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:46:58 -05:00
Gerd Hoffmann 382f074371 switch balloon initialization to -device.
With that patch applied "-balloon virtio,args" becomes a shortcut for
"-device virtio-balloon-pci,args".

Side effects:
 - ballon device gains support for id=<tag>.
 - ballon device is off by default now.
 - initialization order changes, which may in different pci slot
   assignment depending on the VM configuration.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:46:58 -05:00
Gerd Hoffmann 59f2a78793 ide: move code to hw/ide/
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:46:50 -05:00
Gerd Hoffmann 2bcbf7e4dd ide: add save/restore support for mmio
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:34 -05:00
Gerd Hoffmann cebbe6d4d1 ide: add save/restore support for isa
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:34 -05:00
Gerd Hoffmann 3f221c8d02 ide: split away ide-microdrive.c
create ide-microdrive.c and place microdrive support there.
only build ide-microdrive support for platforms using it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann 3d2bf4a109 ide: split away ide-mmio.c
create ide-mmio.c and place mmio support there.
only build ide-mmio support for platforms using it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann b884220990 ide: split away ide-macio.c
create ide-macio.c and place macio support there.
only build ide-macio support for platforms using it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann 977e1244e8 ide: split away ide-pci.c
create ide-pci.c and place pci bus support there.
only build ide-pci support for platforms using it.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Fix build (merge with isa mmio split)
2009-08-27 20:43:33 -05:00
Gerd Hoffmann ec82026c97 ide: split away ide-isa.c
create ide-isa.c and place isa bus support there.
only build ide-isa support for platforms using it.
also create ide.h header file.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann 356721aede ide: split away ide-internal.h
move lots of IDE defines to the new file.
also make a bunch of functions non-static
and add declaration for them.  Needed by
the following patches of this series.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann bcbdc4d354 ide: add IDEBus struct, cleanups
The current IDE code uses an array of two IDEState structs to maintain
the IDE bus.  This patch adds a IDEBus to be used instead and does a
bunch of cleanups:

 * move ide bus state from IDEState to IDEBus.
 * drop a bunch of ugly pointer arithmetics to figure the active
   interface, explicitly save the interface number instead.
 * add helper functions to save/restore idebus state.

It also fixes a save/restore bug: loadvm allways stores the command in
the master's IDEState, even when it was saved from the slave.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann 286c2321ec qdev error logging
Use the new qemu_error() function in qdev.c

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann 84fc5589f8 virtio-pci error logging
Use the new qemu_error() function for virtio-blk-pci.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann ac7531ecdc add qemu_error() + friends
This patch adds some functions for error reporting to address the
problem that error messages should be routed to different destinations
depending on the context of the caller, i.e. monitor command errors
should go to the monitor, command line errors to stderr.

qemu_error() is a printf-like function to report errors.

qemu_errors_to_file() and qemu_errors_to_mon() switch the destination
for the error message to the specified file or monitor.  When setting a
new destination the old one will be kept.  One can switch back using
qemu_errors_to_previous().  i.e. it works like a stack.

main() calls qemu_errors_to_file(stderr), so errors go to stderr by
default.  monitor callbacks are wrapped into qemu_errors_to_mon() +
qemu_errors_to_previous(), so any errors triggered by monitor commands
will go to the monitor.

Each thread has its own error message destination.  qemu-kvm probably
should add a qemu_errors_to_file(stderr) call to the i/o-thread
initialization code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:33 -05:00
Gerd Hoffmann 81a322d4a1 qdev: add return value to init() callbacks.
Sorry folks, but it has to be.  One more of these invasive qdev patches.

We have a serious design bug in the qdev interface:  device init
callbacks can't signal failure because the init() callback has no
return value.  This patch fixes it.

We have already one case in-tree where this is needed:
Try -device virtio-blk-pci (without drive= specified) and watch qemu
segfault.  This patch fixes it.

With usb+scsi being converted to qdev we'll get more devices where the
init callback can fail for various reasons.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:43:28 -05:00
Reimar Döffinger 24e6f3551f fix stack buffer overflows in eepro100.c tx
Hello,
the real world issue is that the hardware allows sends up to 2600 bytes,
and for some reason FreeBSD sometimes sends frames larger than the
ethernet frame size (102+1460 is the maximum I have seen so far),
overflowing the on-stack tx buffer of the driver.
Independent of that, the code should avoid allowing the guest to
overwrite the stack.
This is a minimal patch to fix the issue (you could leave out the size
change of the buf array as well, networking still seems to work either
way). Obviously there are better ways to handle it, but a proper fix IMO
would involve first getting rid of the code duplication and given the
number of patches pending for that code I see no point in working on that now.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:35:30 -05:00
Vijay Kumar d0e7605ee0 Check block driver read error in pflash_cfi0x
If a flash file of size smaller than the flash size is specified in
the -pflash option, the block driver returns error. But the
pflash_cfi0x ignores the error. This results in a flash content of all
zeroes. And the simulation aborts while executing code.

This patch adds the checks for errors from bdrv_read and escalates it
to the calling code.

Signed-off-by: Vijay Kumar B. <vijaykumar@bravegnu.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:35:30 -05:00
Avi Kivity 4c0960c0c4 kvm: Simplify cpu_synchronize_state()
cpu_synchronize_state() is a little unreadable since the 'modified'
argument isn't self-explanatory.  Simplify it by making it always
synchronize the kernel state into qemu, and automatically flush the
registers back to the kernel if they've been synchronized on this
exit.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:35:30 -05:00
Markus Armbruster 09aaa1602f qdev: convert watchdogs
-watchdog NAME is now equivalent to -device NAME, except it treats
option argument '?' specially, and supports only one watchdog.

A side effect is that a device created with -watchdog may now receive
a different PCI address.

i6300esb is now available on any machine with a PCI bus, not just PCs.
ib700 is still PC only, but that could be changed easily.

The only remaining use of struct WatchdogTimerModel and
watchdog_add_model() is supporting '-watchdog ?'.  Should be replaced
by searching device_info_list for watchdog devices when we can
identify them there.

Also fixes ib700 not to use vm_clock before it is initialized: in
wdt_ib700_init(), called from register_watchdogs(), which runs before
init_timers().  The bug made ib700_write_enable_reg() crash in
qemu_del_timer().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:35:24 -05:00
Markus Armbruster 9d472d51ea Clean up upcast from PCIDevice to I6300State
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:23 -05:00
Markus Armbruster 88b3be201a Move watchdog, watchdog_action, give them internal linkage
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:23 -05:00
Christoph Hellwig 87b245db05 virtio-blk: handle NULL returns from bdrv_aio_{read, write}
The bdrv_aio_{read,write} routines can return a NULL pointer when the
I/O submission fails.  Currently we ignore this and will wait forever
for an I/O completion and leading to a hang of the guest.

I can easily reproduce this using the native Linux AIO patch, but it's
also possible using normal pthreads-based AIO.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:23 -05:00
Christoph Hellwig 5c6c3a6c54 raw-posix: add Linux native AIO support
Now that do have a nicer interface to work against we can add Linux native
AIO support.  It's an extremly thing layer just setting up an iocb for
the io_submit system call in the submission path, and registering an
eventfd with the qemu poll handler to do complete the iocbs directly
from there.

This started out based on Anthony's earlier AIO patch, but after
estimated 42,000 rewrites and just as many build system changes
there's not much left of it.

To enable native kernel aio use the aio=native sub-command on the
drive command line.  I have also added an option to qemu-io to
test the aio support without needing a guest.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Christoph Hellwig 9ef91a6771 raw-posix: refactor AIO support
Currently the raw-posix.c code contains a lot of knowledge about the
asynchronous I/O scheme that is mostly implemented in posix-aio-compat.c.
All this code does not really belong here and is getting a bit in the
way of implementing native AIO on Linux.

So instead move all the guts of the AIO implementation into
posix-aio-compat.c (which might need a better name, btw).

There's now a very small interface between the AIO providers and raw-posix.c:

 - an init routine is called from raw_open_common to return an AIO context
   for this drive.  An AIO implementation may either re-use one context
   for all drives, or use a different one for each as the Linux native
   AIO support will do.
 - an submit routine is called from the aio_reav/writev methods to submit
   an AIO request

There are no indirect calls involved in this interface as we need to
decide which one to call manually.  We will only call the Linux AIO native
init function if we were requested to by vl.c, and we will only call
the native submit function if we are asked to and the request is properly
aligned.  That's also the reason why the alignment check actually does
the inverse move and now goes into raw-posix.c.

The old posix-aio-compat.h headers is removed now that most of it's
content is private to posix-aio-compat.c, and instead we add a new
block/raw-posix-aio.h headers is created containing only the tiny interface
between raw-posix.c and the AIO implementation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Amit Shah bf0cb498c5 virtio-console: rename dvq to ovq
It isn't obvious what 'dvq' stands for. Since it's the output queue and
the corresponding input queue is called 'ivq', call this 'ovq'

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Amit Shah 0f2065a19b pci ids: remove redundant defines
Remove some redundant definitions for PCI classes:
PCI_CLASS_SERIAL_OTHER already exists as PCI_CLASS_COMMUNICATION_OTHER
and PCI_CLASS_PROCESSOR_CO is redefined.

PCI_CLASS_SERIAL_OTHER is not used anywhere.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela 452e6a7dd3 multiboot.raw is a generated file
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela 76dec49f1b Port ACPI to VMState
This uses a run_after_load() function, and VMSTATE_PCI_DEVICE()
It could be made smaller changing the type of pm_io_space_update()
to return an int.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela cff09e9239 Add VMState support to run a function after load
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela 73534f2f68 Port PCIDevice state to VMState
This uses a variant of buffer, with extra checks. Also uses the new
support for cheking that a read value is less or equal than a field.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela f16c4abfad Add version_id to PCIDevice.
It is needed for VMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela 0a031e0ac6 Add VMState support for int32_t check value
We read the saved value and check that it is less or equal than the one
stored in the structure.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela b31442c31e Port PS2 devices to VMState design
This uses STRUCT and BUFFER

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela 6f67c50ff4 Add VMState support for static sized buffers (uint_8)
This patch adds support for static sized buffer and typecheks that the buffer is right.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela 2d1e9f96a2 Port PCI Bus to VMState design
This uses VARRAY and INT32_EQUAL values

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela b00319a9df Add VMState support for variable sized arrays
This patch add supports for variable sized arrays whose size is
another field of the state.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:22 -05:00
Juan Quintela 8250166039 Add VMState support for int32_t check value
We read the saved value and check that it is the same that the one
is stored in the structure.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00
Juan Quintela 5122b431c6 Port i8254 to new VMState design
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00
Juan Quintela 79c451b9d8 Add VMState support for arrays of structs
This patch add supports for arrays of structs

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00
Juan Quintela ec245e2111 Add VMState support for structs
This patch adds support for saving one VMStateDescription from other
VMStateDescription.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00
Juan Quintela 695dcf71eb Port apic to new VMState design
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00
Juan Quintela f752a6aae7 Add VMState support for arrays
This patch adds support for saving arrays inside the struct

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00
Juan Quintela dde0463b4e Add VMState support for pointers
This patch adds support for saving pointers to values

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00
Juan Quintela 9ed7d6ae0f New VMstate save/load infrastructure
This patch introduces VMState infrastructure, to convert the save/load
functions of devices to a table approach.  This new approach has the
following advantages:
- it is type-safe
- you can't have load/save functions out of sync
- will allows us to have new interesting commands, like dump <device>, that
  shows all its internal state.
- Just now, the only added type is arrays, but we can add structures.
- Uses old load_state() function for loading old state.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00
Juan Quintela 4082be4df4 Add vmstate_load() and vmstate_save() functions
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-27 20:30:21 -05:00