Commit graph

9512 commits

Author SHA1 Message Date
Mark McLoughlin 893379efd0 net: disable receiving if client returns zero
If a receiver returns zero, that means its queue is full and it will
notify us when room is available using qemu_flush_queued_packets().

Take note of that and disable that receiver until it flushes its queue.

This is a first step towards allowing can_receive() handlers to return
true even if no buffer space is available.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:02 -06:00
Mark McLoughlin be1636b3ab tap: disable draining queue in one go
If qemu_send_packet_async() returns zero, it means the packet has been
queued and the sent callback will be invoked once it has been flushed.

This is only possible where the NIC's receive() handler returns zero
and promises to notify the networking core that room is available in its
queue again.

In the case where the receive handler does not have this capability
(and its queue fills up) it returns -1 and the networking core does not
queue up the packet. This condition is indicated by a -1 return from
qemu_send_packet_async().

Currently, tap handles this condition simply by dropping the packet. It
should do its best to avoid getting into this situation by checking such
NIC's have room for a packet before copying the packet from the tap
interface.

tap_send() used to achieve this by only reading a single packet before
returning to the mainloop. That way, tap_can_send() is called before
reading each packet.

tap_send() was changed to completely drain the tap interface queue
without taking into account the situation where the NIC returns an
error and the packet is not queued. Let's start fixing this by
reverting to the previous behaviour of reading one packet at a time.

Reported-by: Scott Tsai <scottt.tw@gmail.com>
Tested-by: Sven Rudolph <Sven_Rudolph@drewag.de>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:02 -06:00
Markus Armbruster eb852011ab Configurable block format whitelist
We have code for a quite a few block formats.  While I trust that all
of these formats are useful at least for some people in some
circumstances, some of them are of a kind that friends don't let
friends use in production.

This patch provides an optional block format whitelist, default off.
If a whitelist is configured with --block-drv-whitelist, QEMU proper
can use only whitelisted formats.  Other programs, like qemu-img, are
not affected.

Drivers for formats off the whitelist still participate in format
probing, to ensure all programs probe exactly the same.  Without that,
QEMU proper would be prone to treat images with a format off the
whitelist as raw when the image's format is probed.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:02 -06:00
Markus Armbruster 39a51dfda8 qdev: Tag isa-fdc, PIIX3 IDE and PIIX4 IDE as no-user
These devices are created automatically, and attempting to create
another one with -device fails with "qemu: hardware error:
register_ioport_write: invalid opaque".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:02 -06:00
Naphtali Sprei c79662f7f7 Pass the drive's readonly attribute to the guest OS
Implemented for virtio-blk and for scsi

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:01 -06:00
Naphtali Sprei 59f2689d90 Added readonly flag to -drive command
This is a slightly revised patch for adding readonly flag to the -drive command.
Even though this patch is "stand-alone", it assumes a previous related patch (in Anthony staging tree), that passes
the readonly attribute of the drive to the guest OS, applied first.

This enables sharing same image between guests, with readonly access.
Implementaion mark the drive as read_only and changes the flags when actually opening the file.
The readonly attribute of a qcow also passed to it's base file.
For ide that cannot pass the readonly attribute to the guest OS, disallow the readonly flag.

Also, return error code from bdrv_truncate for readonly drive.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:01 -06:00
Stefan Weil d191d12d5f qcow2: Allow qcow2 disk images with size zero
Images with disk size 0 may be used for
VM snapshots, but not to save normal block data.

It is possible to create such images using
qemu-img, but opening them later fails.

So even "qemu-img info image.qcow2" is not
possible for an image created with
"qemu-img create -f qcow2 image.qcow2 0".

This is fixed here.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:01 -06:00
Blue Swirl b4558d7481 (x86/Sparc/PPC)-user: fix cpu_copy
b55a37c981 moved the call to cpu_reset
to user emulators. But cpu_copy also initializes a CPU structure, so add the
call also there.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 16:34:12 +00:00
Blue Swirl 4a64356397 IDE: Fix reset handling
Problem: x86 systems could not survive a few system_resets.

Clear most of IDE state when reset. Implement the missing reset handlers.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 14:13:05 +00:00
Blue Swirl b55a37c981 user: move CPU reset call to main.c for x86/PPC/Sparc
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 10:37:06 +00:00
Blue Swirl d84bda46de PPC: rename cpu_ppc_reset to cpu_reset for consistency
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 10:36:04 +00:00
Blue Swirl 44a9935465 Sparc64/x86: remove unneeded calls to device reset
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 10:05:03 +00:00
Blue Swirl e43941318d PPC: remove unneeded calls to device reset
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 09:32:21 +00:00
Blue Swirl a01d6ef446 sparc32 (mostly): remove unneeded calls to device reset
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 08:55:24 +00:00
Glauber Costa c169998802 v3: don't call reset functions on cpu initialization
There is absolutely no need to call reset functions when initializing
devices. Since we are already registering them, calling qemu_system_reset()
should suffice. Actually, it is what happens when we reboot the machine,
and using the same process instead of a special case semantics will even
allow us to find bugs easier.

Furthermore, the fact that we initialize things like the cpu quite early,
leads to the need to introduce synchronization stuff like qemu_system_cond.
This patch removes it entirely. All we need to do is call qemu_system_reset()
only when we're already sure the system is up and running

I tested it with qemu (with and without io-thread) and qemu-kvm, and it
seems to be doing okay - although qemu-kvm uses a slightly different patch.

[ v2: user mode still needs cpu_reset, so put it in ifdef. ]
[ v3: leave qemu_system_cond for now. ]

Signed-off-by: Glauber Costa <glommer@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 08:06:58 +00:00
malc cae334cd6b vga: fix line comparison
Line counter doesn't wrap.

Signed-off-by: malc <av1474@comtv.ru>
2009-11-06 16:08:41 +03:00
malc d1984194f3 vga: Respect Line Compare Register in text modes
Unbreaks setup screen of Act1/PL

Signed-off-by: malc <av1474@comtv.ru>
2009-11-06 03:46:12 +03:00
Artyom Tarasenko 3e6ba50340 Sparc: fix carry flag handling (Solaris bootblk fix)
The page 108 of the SPARC Version 8 Architecture Manual describes
that addcc and addxcc shall compute carry flag the same way.
The page 110 claims the same about subcc and subxcc instructions.
This patch fixes carry computation in corner cases and removes redundant code.
The most visible effect of the patch is enabling Solaris boot when using OBP.

Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
[blauwirbel@gmail.com: cleaned up formatting]
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-04 19:38:26 +00:00
Andrzej Zaborowski 2d7adea4fe hw/sd: Support SDHC size cards
This patch adds SHDC support (-sd sd.img, where sd.img is
larger than 1GB) to qemu.

Signed-off-by: Jason S. McMullan <jason.mcmullan@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
2009-11-03 15:28:19 +01:00
Anthony Liguori 2d9f27d2fd Fix the build when srcdir == objdir
You would only see this error on a fresh clone when srcdir == objdir.  configure
will fail because roms/pcbios doesn't exist.

git submodule integration doesn't cleanup very well when switching between
branches so you'll get an roms/pcbios directory from normal operations if you
switch between old branches.

Thanks to a mistake in configure, if you build outside of srcdir, you'll also
get a valid roms/pcbios.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-02 15:50:27 -06:00
Anthony Liguori ed7193ec1d Unbreak Linux build
commit 71f4effce7
  Author: Alexander Graf <agraf@suse.de>
  Date:   Fri Oct 30 22:27:00 2009 +0100

      Unbreak tap compilation on OS X

Broke the build on Linux due to a bad #if guard

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 16:45:20 -05:00
Anthony Liguori ec9f735638 Update gpxe roms to have BANNER_TIMEOUT=0
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 16:44:26 -05:00
Alexander Graf 71f4effce7 Unbreak tap compilation on OS X
Currently compiling the tap sources breaks on Mac OS X. This is because of:

  1) tap-linux.h requiring Linux includes
  2) typos
  3) missing #includes

This patch adds what's necessary to compile tap happily on Mac OS X.
I haven't tested if using tap actually works, but I don't think that's a
major issue as that code was probably seriously untested before already.

I didn't split the patch, because it's only a few lines of code and
splitting is probably not worth the effort here.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 16:38:15 -05:00
Anthony Liguori 195325a4c1 Revert "Fall back to network boot as the last possible boot option"
This reverts commit 94ca5a9859.
2009-10-30 12:42:29 -05:00
Anthony Liguori 94ca5a9859 Fall back to network boot as the last possible boot option
This is similiar to the default with most bare metal systems.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 09:42:36 -05:00
Anthony Liguori 04095e5ff3 Remove e1000 rom loading hack
The gPXE rom supports BEV properly.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 09:42:36 -05:00
Anthony Liguori 74b12befba Switch from etherboot to gPXE
etherboot is deprecated and not under active development anymore.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 09:42:36 -05:00
Anthony Liguori fd64612241 Switch pc bios from pc-bios to seabios
SeaBIOS is a port of pc-bios to GCC.  Besides using a more modern tool chain,
SeaBIOS introduces a number of new features including PMM support, better
BEV and BCV support, and better PnP support.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 09:42:36 -05:00
Anthony Liguori 65e59a08f6 Update SeaBIOS to latest upstream
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 09:42:35 -05:00
Mark McLoughlin 3cbe04c442 virtio-net: fix macaddr config regression
This commit:

    commit 97b15621
    virtio: use qdev properties for configuration.

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

makes a guest using virtio-net see an empty macaddr because we never
copy the macaddr into the location that virtio_net_get_config() uses.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 09:42:35 -05:00
Michael S. Tsirkin 76f5159d7f qemu/msix: fix table access issues
Fixes a couple of issues with msix table access:
- With misbehaving guests, misaligned 4 byte access could overflow
  msix table and cause qemu to segfault. Since PCI spec requires
  host to only issue dword-aligned accesses, as a fix,
  it's enough to mask the address low bits.
- Tables use pci format, not native format, and so
  we must use pci_[sg]et_long on read/write.

Reported-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:34 -05:00
Michael S. Tsirkin 79758e95d7 qemu/virtio: make wmb compiler barrier + comments
wmb must be at least a compiler barrier, even without SMP.
Further, we likely need some rmb()/mb() as well:
I have not audited the code but lguest has mb(),
add a comment for now.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:34 -05:00
Kevin Wolf 1e5b9d2fcc Remove aio_ctx from paio_* interface
The context parameter in paio_submit isn't used anyway, so there is no reason
why block drivers should need to remember it. This also avoids passing a Linux
AIO context to paio_submit (which doesn't do any harm as long as the parameter
is unused, but it is highly confusing).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:34 -05:00
Peter Hjalmarsson fa39472763 Add *CFLAGS to LINK in rules.mak
Sometimes when linking with gcc to get a predictable result you are suggested to also apply the compiler flags to the linker command.

For reference, please read:
http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Link-Options.html

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:33 -05:00
Stefan Weil 718b8aec62 serial: Add missing bit
Serial frames always start with a start bit.
This bit was missing in frame size calculation.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:32 -05:00
Stefan Weil 45eea13b24 serial: Support additional serial speed values
* Allow any speed value which is defined for Linux
  (and possibly other systems).
* Compare int values instead of double values.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:32 -05:00
Gerd Hoffmann 66a6593a8c usb: print attached status in info qtree
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:32 -05:00
Gerd Hoffmann 26a9e82ac4 usb-host: use qdev for -usbdevice + rework.
Changes:

 * We don't create/delete devices, we attach/detach them instead.
 * The separate autofilter list is gone, we simply walk the list
   of devices directly instead.
 * Autofiltering is done unconditionally now.  Non-auto device scan
   code got dropped.
 * Autofiltering turns off the timer if there is nothing to do, it
   runs only in case there are unattached host devices.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:32 -05:00
Gerd Hoffmann b3e461d3d6 usb-storage: use qdev for -usbdevice
Hook up usb_msd_init.

Also rework handling of encrypted block devices,
move the code out vl.c.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:31 -05:00
Gerd Hoffmann 61e094c049 usb: make attach optional.
Add a auto_attach field to USBDevice, which is enabled by default.
USB drivers can clear this field in case they do *not* want the device
being attached (i.e. plugged into a usb port) automatically after
successfull init().

Use cases (see next patches):
 * attaching encrypted mass storage devices.
 * -usbdevice host:...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:31 -05:00
Gerd Hoffmann 2b0efdc3e1 usb-serial and braille: use qdev for -usbdevice
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:31 -05:00
Gerd Hoffmann fa7c70c35a usb-hid: use qdev for -usbdevice
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:30 -05:00
Gerd Hoffmann 0958b4cc8f usb core: use qdev for -usbdevice
This patchs adds infrastructure to handle -usbdevice via qdev callbacks.
USBDeviceInfo gets a name field (for the -usbdevice driver name) and a
callback for -usbdevice parameter parsing.

The new usbdevice_create() function walks the qdev driver list and looks
for a usb driver with a matching name.  When a parameter parsing
callback is present it is called, otherwise the device is created via
usb_create_simple().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:30 -05:00
Gerd Hoffmann 51edd4e6b5 use rom loader for pc bios.
The pc bios shows up in 'info roms' now.

Note that the BIOS is mapped to two places: The complete rom at the top
of the memory, and the first 128k at 0xe0000.  Only the first place is
listed in 'info roms'.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:29 -05:00
Gerd Hoffmann 5245d57a7a vga roms: move loading from pc.c to vga drivers.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:29 -05:00
Gerd Hoffmann de2aff17a3 rom loader: make vga+rom loading configurable.
The rom_add_vga() and rom_add_option() macros are transformed into
functions.  They look at the new rom_enable_driver_roms variable
and only do something if it is set to non-zero, making vga+option rom
loading runtime option.  pc_init() sets rom_enable_driver_roms to 1.

With this in place we can move the rom loading calls from pc.c to the
individual drivers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:29 -05:00
Gerd Hoffmann 14a3f32d9e rom loader: use qemu_strdup.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:29 -05:00
Mark McLoughlin 9c282718aa net: move UFO support detection to tap-linux.c
Only supported on Linux

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:29 -05:00
Mark McLoughlin 1faac1f7d4 net: move tap_set_offload() code into tap-linux.c
TUNSETOFFLOAD is only available on Linux

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:28 -05:00
Mark McLoughlin dc69004c7d net: move tap_probe_vnet_hdr() to tap-linux.c
Only Linux has support for IFF_VNET_HDR

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30 08:39:28 -05:00