History | View | Annotate | Download (27.7 kB)
virtio: limit avail bytes lookahead
Commit 0d8d7690850eb0cf2b2b60933cf47669a6b6f18f introduceda regression in virtio-net performance because it looksinto the ring aggressively while we really only careabout a single packet worth of buffers.Reported as bugzilla 1066055 in launchpad....
Rename target_phys_addr_t to hwaddr
target_phys_addr_t is unwieldly, violates the C standard (_t suffixes arereserved) and its purpose doesn't match the name (most target_phys_addr_taddresses are not target specific). Replace it with a finger-friendly,...
virtio: don't mark unaccessed memory as dirty
offset of accessed buffer is calculated using iov_length, so itcan exceed accessed len. If that happensmath in len - offset wraps around, and size becomes wrong.As real value is 0, so this is harmless but unnecessary....
virtio: use unsigned int for counting bytes in vq
The virtqueue_avail_bytes() function counts bytes in an int. Use anunsigned int instead.
Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
virtio: Introduce virtqueue_get_avail_bytes()
The current virtqueue_avail_bytes() is oddly named, and checks if aparticular number of bytes are available in a vq. A better API is tofetch the number of bytes available in the vq, and let the caller dowhat's interesting with the numbers....
virtio: fix vhost handling
Commit b1f416aa8d870fab71030abc9401cfc77b948e8e breaks vhost_netbecause it always registers the virtio_pci_host_notifier_read() handlerfunction on the ioeventfd, even when vhost_net.ko is using the ioeventfd.The result is both QEMU and vhost_net.ko polling on the same eventfd...
virtio: move common ioeventfd handling out of virtio-pci
All transports can use the same event handler for the ioeventfd, thoughthe exact setup (address/memory region) will be specific.
This lets virtio use event_notifier_set_handler.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
virtio: move common irqfd handling out of virtio-pci
All transports can use the same event handler for the irqfd, though theexact mechanics of the assignment will be specific. Note that thereare three states: handled by the kernel, handled in userspace, disabled....
virtio: add missing mb() on enable notification
This fixes an issue dual to the one fixed bypatch 'virtio: add missing mb() on notification'and applies on top.
In this case, to enable vq kick to exit to host,qemu writes out used flag then reads theavail index. if these are reordered we get a race:...
virtio: order index/descriptor reads
virtio has the equivalent of:
if (vq->last_avail_index != vring_avail_idx(vq)) { read descriptor head at vq->last_avail_index; }
In theory, processor can reorder descriptor headread to happen speculatively before the index read....
virtio: add missing mb() on notification
During normal operation, virtio first writes a used indexand then checks whether it should interrupt the guestby reading guest avail index/flag values.
Guest does the reverse: writes the index/flag,then checks the used ring....
virtio: add virtio_queue_get_id
Serializing virtio-scsi requests needs a simple way to get from aVirtQueue to the number of the queue. The virtio_queue_get_idprovides this.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virtio: Remove unneeded g_free() check in virtio_cleanup()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
virtio: change memcpy to guest reads
When accessing the device specific virtio config space, we memcpythe data into a variable in QEMU. At that point we're basicallypulling host endianness into the game which is a really bad idea.
So instead, let's use the target specific load/store helpers for...
virtio: add and use virtio_set_features
vdev->guest_features is not masking features that are not supported bythe guest. Fix this by introducing a common wrapper to be used by allvirtio bus implementations.
virtio: Use global memory barrier macros
The virtio code uses wmb() macros in several places, as required by theSMP-aware virtio protocol. However the wmb() macro is locally definedto be a compiler barrier only. This is probably sufficient on x86due to its strong storage ordering model, but it certainly isn't on other...
Merge remote-tracking branch 'qmp/queue/qmp' into staging
trace: add virtio_set_status() trace event
The virtio device lifecycle can be observed by looking at the sequenceof set status operations. This is especially important for catching thereset operation (status value 0), which resets the device and allvirtqueues....
Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(),we pass a VMSTOP macro as the 'reason' argument. This is not idealbecause the VMSTOP macros tell why qemu stopped and not exactlywhat the current VM state is....
Drop the vm_running global variable
Use runstate_is_running() instead, which is introduced by this commit.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio: Plug memleak by freeing vdev
virtio_common_init() allocates RAM for the vdev struct (and anyadditional memory, depending on the size passed to the function). Thismemory wasn't being freed until now.
Signed-off-by: Amit Shah <amit.shah@redhat.com>...
virtio: fix indirect descriptor buffer overflow
We were previously allowing arbitrarily-long indirect descriptors, whichcould lead to a buffer overflow in qemu-kvm process.
CVE-2011-2212
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Strip trailing '\n' from error_report()'s first argument
error_report() prepends location, and appends a newline. The messageconstructed from the arguments should not contain a newline. Fix theobvious offenders.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
virtio: event index support
Add support for event_idx feature, and utilize it toreduce the number of interrupts and exits for the guest.
virtio: guard against negative vq notifies
The virtio_queue_notify() function checks that the virtqueue number isless than the maximum number of virtqueues. A signed comparison is usedbut the virtqueue number could be negative if a buggy or malicious guest...
virtio: correctly initialize vm_running
Current vm_running was not explicitly initialized and its value was changed byvm state notifier, this may confuse the virtio device being hotplugged such asvirtio-net with vhost backend as it may think the vm was not running. Solve this...
Remove unused sysemu.h include directives
Remove unused sysemu.h include directives to speed up buildwith the following patches.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
virtio-pci: Use ioeventfd for virtqueue notify
Virtqueue notify is currently handled synchronously in userspace virtio. Thisprevents the vcpu from executing guest code while hardware emulation codehandles the notify.
On systems that support KVM, the ioeventfd mechanism can be used to make...
virtio: move vmstate change tracking to core
Move tracking vmstate change from virtio-net to virtio.cas it is going to be used by virito-blk and virtio-pcifor the ioeventfd support.
virtio: fix up VQ checks
When migration triggers before a VQ is initialized,base pa is 0 and last_used_index must be 0 too:we don't have a ring to compare to.
Reported-by: Juan Quintela <quintela@redhat.com>Tested-by: Juan Quintela <quintela@redhat.com>...
virtio: Convert fprintf() to error_report()
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>(cherry picked from commit cd92f4cc22fbe12a7bf60c9430731f768dc1537c)
virtio: sanity-check available index
Checking available index upon load instead ofonly when vm is running makes is easier todebug failures.
virtio: invoke set_status callback on reset
As status is set to 0 on reset, invoke the relevant callback. This makesfor a cleaner code in devices as they don't need to duplicate the codein their reset routine, as well as excercises this path a little more....
trace: Trace virtqueue operations
This patch adds trace events for virtqueue operations includingadding/removing buffers, notifying the guest, and receiving a notifyfrom the guest.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
virtio: Factor virtqueue_map_sg out
Separate the mapping of requests to host memory from the descriptor iteration.The next patch will make use of it in a different context.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
virtio: invoke set_features on load
After migration, vhost was not getting featuresacked because set_features callback was never invoked.The fix is just to invoke that callback.
Reported-by: David L Stevens <dlstevens@us.ibm.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>...
win32: Fix compiler errors from u_int64_t
u_int64_t raises compiler error messages:
CC libhw32/virtio.o/qemu/ar7/hw/virtio.c: In function ‘virtio_queue_get_avail_size’:/qemu/ar7/hw/virtio.c:776: error: ‘u_int64_t’ undeclared (first use in this function)...
virtio: notifier support + APIs for queue fields
vhost needs physical addresses for ring and other queue fields,so add APIs for these. In particular, add binding API to sethost/guest notifiers. Will be used by vhost.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>...
virtio: Remove duplicate macro definition for max. virtqueues, bump up the max
VIRTIO_PCI_QUEUE_MAX is redefined in hw/virtio.c. Let's just keep it inhw/virtio.h.
Also, bump up the value of the maximum allowed virtqueues to 64. This isin preparation to allow multiple ports per virtio-console device....
virtio: rename features -> guest_features
Rename features->guest_features. This iswhat they are, avoid confusion withhost features which we also need to keep around.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio: add features as qdev properties
Add feature bits as properties to virtio. This makes it possible to e.g. definemachine without indirect buffer support, which is required for 0.10compatibility, or without hardware checksum support, which is required for 0.11...
virtio: verify features on load
migrating between hosts which have different featuresmight break silently, if the migration destinationdoes not support some features supported by source.
Prevent this from happening by comparing acked featurebits with the mask supported by the device....
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.
Revert "Get rid of _t suffix"
In the very least, a change like this requires discussion on the list.
The naming convention is goofy and it causes a massive merge problem. Somethinglike this must be presented on the list first so people can provide input...
Get rid of _t suffix
Some not so obvious bits, slirp and Xen were left alone for the timebeing.
Signed-off-by: malc <av1474@comtv.ru>
qemu: init all queues to NO_VECTOR value
initialize vectors for all vqs to VIRTIO_NO_VECTOR rather than 0 whichis a valid vector. This fixes migration which happened before driverwas loaded.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Reported-by: Amit Shah <amit.shah@redhat.com>...
qemu: remove control vector save
control vector is saved/restored by virtio-pci,it does not belong in virtio.
qemu/virtio: virtio save/load bindings
Implement bindings for virtio save/load. Use them in virtio pci.
qemu/virtio: virtio support for many interrupt vectors
Extend virtio to support many interrupt vectors, and rearrange code inpreparation for multi-vector support (mostly move reset out to bindings,because we will have to reset the vectors in transport-specific code)....
virtio: make vring_desc_*() take phys addrs
Change the vring descriptor helpers to take the physicaladdress of the descriptor table rather than a virtqueue.
This is needed in order to allow these helpers to be usedwith an indirect descriptor table.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>...
virtio: add support for indirect ring entries
Support a new feature flag for indirect ring entries. These are ringentries which point to a table of buffer descriptors.
The idea here is to increase the ring capacity by allowing a largereffective ring size whereby the ring size dictates the number of...
Introduce reset notifier order
Add the parameter 'order' to qemu_register_reset and sort callbacks onregistration. On system reset, callbacks with lower order will beinvoked before those with higher order. Update all existing users to thestandard order 0....
Separate virtio PCI code
Split the PCI host bindings from the VRing transport implementation.
Signed-off-by: Paul Brook <paul@codesourcery.com>
Virtio-net qdev conversion
use PCI_HEADER_TYPE.
use symbolic value instead of 0x0e and related value.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Introduce VLANClientState::cleanup() (Mark McLoughlin)
We're currently leaking memory and file descriptors on devicehot-unplug.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7150 c046a42c-6fe2-441c-8c8c-71466251a162
Fix oops on 2.6.25 guest (Rusty Russell)
I believe this is behind the following:https://bugs.edge.launchpad.net/ubuntu/jaunty/+source/linux/+bug/331128
virtio_pci in 2.6.25 didn't do feature negotiation correctly: it acked everybit. Fortunately, we can detect this....
Use the DMA api to map virtio elements.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6904 c046a42c-6fe2-441c-8c8c-71466251a162
virtio: Allow guest to defer VIRTIO_F_NOTIFY_ON_EMPTY (Alex Williamson)
There may be cases where the guest does not want the avail queueinterrupt, even when it's empty. For the virtio-net case, theguest may use a different buffering scheme or decide polling for...
hw: remove error handling from qemu_malloc() callers (Avi Kivity)
Signed-off-by: Avi Kivity <avi@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6529 c046a42c-6fe2-441c-8c8c-71466251a162
Add and use #defines for PCI device classes
This patch adds and uses #defines for PCI device classes and subclases,using a new pci_config_set_class() function, similar to the recentlyadded pci_config_set_vendor_id() and pci_config_set_device_id().
Change since v1: fixed compilation of hw/sun4u.c...
Don't notify virtio devices before S_DRIVER_OK (Mark McLoughlin)
Current Linux guests oops if the host notifies of aconfig change before a driver has been bound to thedevice.
It's pretty pointless for us to do notify of configchanges before status is S_DRIVER_OK anyway, so let's...
Define PCI vendor and device IDs in pci.h (Stuart Brady)
This patch defines PCI vendor and device IDs in pci.h (matching thosefrom Linux's pci_ids.h), and uses those definitions where appropriate.
Change from v1: Introduces pci_config_set_vendor_id() / pci_config_set_device_id()...
Rename fls to qemu_fls
Fix compiler warning on OSX, reported by Andreas Faerber.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5982 c046a42c-6fe2-441c-8c8c-71466251a162
Fix some new warnings introduced after r5022
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5933 c046a42c-6fe2-441c-8c8c-71466251a162
Fix windows build after virtio changes
Windows does not have sys/uio.h and does not have err.h.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5877 c046a42c-6fe2-441c-8c8c-71466251a162
Remove TARGET_PAGE_SIZE from virtio interface (Hollis Blanchard)
TARGET_PAGE_SIZE should only be used internal to qemu, not in guest/hostinterfaces. The virtio frontend code in Linux uses two constants (PFN shiftand vring alignment) for the interface, so update qemu to match....
Virtio core support
This patch adds core support for VirtIO. VirtIO is a paravirtualizationframework that has been in Linux since 2.6.21. A PCI transport has beenavailable since 2.6.25. Network drivers are also available for Windows.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>...