summaryrefslogtreecommitdiffstats
path: root/hw/vhost.c
Commit message (Collapse)AuthorAgeFilesLines
* hw: move virtio devices to hw/ subdirectoriesPaolo Bonzini2013-04-081-1042/+0
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* hw: move headers to include/Paolo Bonzini2013-04-081-1/+1
| | | | | | | | | Many of these should be cleaned up with proper qdev-/QOM-ification. Right now there are many catch-all headers in include/hw/ARCH depending on cpu.h, and this makes it necessary to compile these files per-target. However, fixing this does not belong in these patches. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Merge remote-tracking branch 'bonzini/hw-dirs' into stagingAnthony Liguori2013-03-101-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bonzini/hw-dirs: sh: move files referencing CPU to hw/sh4/ ppc: move more files to hw/ppc ppc: move files referencing CPU to hw/ppc/ m68k: move files referencing CPU to hw/m68k/ i386: move files referencing CPU to hw/i386/ arm: move files referencing CPU to hw/arm/ hw: move boards and other isolated files to hw/ARCH ppc: express FDT dependency of pSeries and e500 boards via default-configs/ build: always link device_tree.o into emulators if libfdt available hw: include hw header files with full paths ppc: do not use ../ in include files vt82c686: vt82c686 is not a PCI host bridge virtio-9p: remove PCI dependencies from hw/9pfs/ virtio-9p: use CONFIG_VIRTFS, not CONFIG_LINUX hw: move device-hotplug.o to toplevel, compile it once hw: move qdev-monitor.o to toplevel directory hw: move fifo.[ch] to libqemuutil hw: move char backends to backends/ Conflicts: backends/baum.c backends/msmouse.c hw/a15mpcore.c hw/arm/Makefile.objs hw/arm/pic_cpu.c hw/dataplane/event-poll.c hw/dataplane/virtio-blk.c include/char/baum.h include/char/msmouse.h qemu-char.c vl.c Resolve conflicts caused by header movements. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
| * hw: include hw header files with full pathsPaolo Bonzini2013-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Done with this script: cd hw for i in `find . -name '*.h' | sed 's/^..//'`; do echo '\,^#.*include.*["<]'$i'[">], s,'$i',hw/&,' done | sed -i -f - `find . -type f` This is so that paths remain valid as files are moved. Instead, files in hw/dataplane are referenced with the relative path. We know they are not going to move to include/, and they are the only include files that are in subdirectories _and_ move. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | vhost: memory sync fixesMichael S. Tsirkin2013-02-261-17/+32
|/ | | | | | | | | | | | | | This fixes two bugs related to memory sync during migration: - ram address calculation was missing the chunk address, so the wrong page was dirtied - one after last was used instead of the end address of a region, which might overflow to 0 and cause us to skip the region when the region ends at ~0x0ull. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Jason Wang <jasowang@redhat.com>
* vhost: multiqueue supportJason Wang2013-02-011-46/+36
| | | | | | | | | | | | | | | | | | | | This patch lets vhost support multiqueue. The idea is simple, just launching multiple threads of vhost and let each of vhost thread processing a subset of the virtqueues of the device. After this change each emulated device can have multiple vhost threads as its backend. To do this, a virtqueue index were introduced to record to first virtqueue that will be handled by this vhost_net device. Based on this and nvqs, vhost could calculate its relative index to setup vhost_net device. Since we may have many vhost/net devices for a virtio-net device. The setting of guest notifiers were moved out of the starting/stopping of a specific vhost thread. The vhost_net_{start|stop}() were renamed to vhost_net_{start|stop}_one(), and a new vhost_net_{start|stop}() were introduced to configure the guest notifiers and start/stop all vhost/vhost_net devices. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* g_malloc(0) and g_malloc0(0) return NULL; simplifyMarkus Armbruster2013-01-301-5/+2
| | | | | | | | | | | Once upon a time, it was decided that qemu_malloc(0) should abort. Switching to glib retired that bright idea. Some code that was added to cope with it (e.g. in commits 702ef63, b76b6e9) is still around. Bury it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* vhost: backend masking supportMichael S. Tsirkin2013-01-071-13/+82
| | | | | | | | | Support backend guest notifier masking in vhost-net: create eventfd at device init, when masked, make vhost use that as eventfd instead of sending an interrupt. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: set started flag while start is in progressMichael S. Tsirkin2013-01-071-2/+5
| | | | | | | This makes it possible to use started flag for sanity checking of callbacks that happen during start/stop. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: don't waste irqfds on control vqsMichael S. Tsirkin2013-01-071-3/+7
| | | | | | | | Pass nvqs to set_guest_notifiers. This makes it possible to save on irqfds by not allocating one for the control vq for virtio-net. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* exec: move include files to include/exec/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Rename target_phys_addr_t to hwaddrAvi Kivity2012-10-231-8/+8
| | | | | | | | | | | | | | | target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are reserved) and its purpose doesn't match the name (most target_phys_addr_t addresses are not target specific). Replace it with a finger-friendly, standards conformant hwaddr. Outstanding patchsets can be fixed up with the command git rebase -i --exec 'find -name "*.[ch]" | xargs s/target_phys_addr_t/hwaddr/g' origin Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* memory: use AddressSpace for MemoryListener filteringAvi Kivity2012-10-221-1/+1
| | | | | | | | Using the AddressSpace type reduces confusion, as you can't accidentally supply the MemoryRegion you're interested in. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* vhost: use MemoryListener filtering to only monitor RAM address spaceAvi Kivity2012-10-151-3/+2
| | | | | | | Instead of checking manually, let the listener filter for us. This prepares us for DMA address spaces. Signed-off-by: Avi Kivity <avi@redhat.com>
* vhost: Pass device path to vhost_dev_init()Stefan Hajnoczi2012-09-071-2/+3
| | | | | | | | | | | | The path to /dev/vhost-net is currently hardcoded in vhost_dev_init(). This needs to be changed so that /dev/vhost-scsi can be used. Pass in the device path instead of hardcoding it. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* memory: pass EventNotifier, not eventfdPaolo Bonzini2012-07-121-2/+2
| | | | | | | | | Under Win32, EventNotifiers will not have event_notifier_get_fd, so we cannot call it in common code such as hw/virtio-pci.c. Pass a pointer to the notifier, and only retrieve the file descriptor in kvm-specific code. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* vhost: readd assert statementMichael S. Tsirkin2012-04-111-0/+1
| | | | | | | | | It's clear from the surrounding code that start < end so it's enough to assert end < log_size. However, it's better to make this explicit in case we refactor the code again. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: Fix size of dirty log sync on resizeAlex Williamson2012-04-111-4/+5
| | | | | | | | | | | | | | | | | | | | | | | When the vhost log is resized, we want to sync up to the size of the old log. With that end address in place, ignore regions that start after then end rather than hitting assert. This also addresses the following crash report: When migrating a vm using vhost-net we hit the following assertion: qemu-kvm: /usr/src/packages/BUILD/qemu-kvm-0.15.1/hw/vhost.c:30: vhost_dev_sync_region: Assertion `start / (0x1000 * (8 * sizeof(vhost_log_chunk_t))) < dev->log_size' failed. The cases which the end < start check is intended to catch, such as for vga video memory, will also likely trigger the assertion. Reorder the code to handle this correctly. Reported-by: Josh Durgin <josh.durgin@dreamhost.com> Signed-off-by: Bruce Rogers <brogers@suse.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* memory: support stateless memory listenersAvi Kivity2012-02-291-0/+16
| | | | | | | | | | | | | Current memory listeners are incremental; that is, they are expected to maintain their own state, and receive callbacks for changes to that state. This patch adds support for stateless listeners; these work by receiving a ->begin() callback (which tells them that new state is coming), a sequence of ->region_add() and ->region_nop() callbacks, and then a ->commit() callback which signifies the end of the new state. They should ignore ->region_del() callbacks. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: allow MemoryListeners to observe a specific address spaceAvi Kivity2012-02-291-1/+1
| | | | | | Ignore any regions not belonging to a specified address space. Signed-off-by: Avi Kivity <avi@redhat.com>
* memory: move ioeventfd ops to MemoryListenerAvi Kivity2012-02-291-0/+14
| | | | | | | This way the accelerator (kvm) can handle them directly. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: switch memory listeners to a QTAILQAvi Kivity2012-02-291-0/+1
| | | | | | | | | | | | | This allows reverse iteration, which in turns allows consistent ordering among multiple listeners: l1->add l2->add l2->del l1->del Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* memory: change dirty setting APIs to take a sizeBlue Swirl2012-01-251-1/+1
| | | | | | | Instead of each target knowing or guessing the guest page size, just pass the desired size of dirtied memory area. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* prepare for future GPLv2+ relicensingPaolo Bonzini2012-01-131-0/+3
| | | | | | | | | All files under GPLv2 will get GPLv2+ changes starting tomorrow. event_notifier.c and exec-obsolete.h were only ever touched by Red Hat employees and can be relicensed now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vhost: improve region filteringAvi Kivity2012-01-091-4/+15
| | | | | | | | | vhost memory management doesn't care about non-memory (e.g. PIO) or non-RAM regions. Adjust the filtering to reflect that, and move it earlier so it applies to mem_sections too. Signed-off-by: Avi Kivity <avi@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: fix mem_sections memory corruptionAvi Kivity2012-01-091-1/+1
| | | | | | | | A memset() used to delete an entry in an array did not take into account the array element's size. Signed-off-by: Avi Kivity <avi@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: fix incorrect userspace addressAvi Kivity2012-01-091-1/+1
| | | | | | | | MemoryListener::region_add() gives us a slice of a MemoryRegion, not a region. Adjust the userspace address to reflect that. Signed-off-by: Avi Kivity <avi@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: avoid cpu_get_physical_page_desc()Avi Kivity2012-01-031-8/+39
| | | | | | | This reaches into the innards of the memory core, which are being changed. Switch to a memory API version. Signed-off-by: Avi Kivity <avi@redhat.com>
* vhost: convert to MemoryListener APIAvi Kivity2011-12-201-32/+94
| | | | | | | | | Drop the use of cpu_register_phys_memory_client() in favour of the new MemoryListener API. The new API simplifies the caller, since there is no need to deal with splitting and merging slots; however this is not exploited in this patch. Signed-off-by: Avi Kivity <avi@redhat.com>
* vhost-net: cleanup host notifiers at last stepMichael S. Tsirkin2011-08-261-19/+55
| | | | | | | | | | | | | | | | When the vhost notifier is disabled, the userspace handler runs immediately: virtio_pci_set_host_notifier_internal might call virtio_queue_notify_vq. Since the VQ state and the tap backend state aren't recovered yet, this causes "Guest moved used index from XXX to YYY" assertions. The solution is to split out host notifier handling from vhost VQ setup and disable notifiers as our last step when we stop vhost-net. For symmetry enable them first thing on start. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-201-8/+8
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vhost: remove an incorrect assertMichael S. Tsirkin2011-08-031-1/+0
| | | | | | | | | | The 'to' can go negative when the first region gets removed (it gets incremented by to 0 immediately afterward), which makes the assertion fail. Nothing breaks if to < 0 here so just remove the assert. Tested-by: David Ahern <daahern@cisco.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: fix double free on device stopMichael S. Tsirkin2011-07-171-0/+1
| | | | | | | | | vhost dev stop failed to clear the log field. Typically not an issue as dev start overwrites this field, but if logging gets disabled before the following start, it doesn't so this causes a double free. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: optimize out no-change assignmentMichael S. Tsirkin2011-04-071-0/+54
| | | | | | | | | Cirrus VGA (at least) calls register memory region with the same values again and again. The registration in vhost-net slows this a lot, optimize by checking that the same data is already registered. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: skip memory which needs dirty loggingMichael S. Tsirkin2011-04-061-0/+4
| | | | | | | vhost doesn't support write logging (except for migration), anyway. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* cpu: add set_memory flag to request dirty loggingMichael S. Tsirkin2011-04-061-1/+2
| | | | | | | | Pass the flag to all cpu notifiers, doing nothing at this point. Will be used by follow-up patches. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: fix dirty page handlingMichael S. Tsirkin2011-03-281-1/+3
| | | | | | | | | | vhost was passing a physical address to cpu_physical_memory_set_dirty, which is wrong: we need to translate to ram address first. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Note: this lead to crashes during migration, so the patch is needed on the stable branch too.
* Introduce log_start/log_stop in CPUPhysMemoryClientAnthony PERARD2011-02-141-0/+2
| | | | | | | | | | | | | | | In order to use log_start/log_stop with Xen as well in the vga code, this two operations have been put in CPUPhysMemoryClient. The two new functions cpu_physical_log_start,cpu_physical_log_stop are used in hw/vga.c and replace the kvm_log_start/stop. With this, vga does no longer depends on kvm header. [ Jan: rebasing and style fixlets ] Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* vhost: force vhost off for non-MSI guestsmst@redhat.com2011-02-011-1/+9
| | | | | | | | | | | | | | | When MSI is off, each interrupt needs to be bounced through the io thread when it's set/cleared, so vhost-net causes more context switches and higher CPU utilization than userspace virtio which handles networking in the same thread. We'll need to fix this by adding level irq support in kvm irqfd, for now disable vhost-net in these configurations. Added a vhostforce flag to force vhost-net back on. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vhost: Fix address calculation in vhost_dev_sync_region()Jason Wang2010-12-021-0/+1
| | | | | | | | We still need advance address even we find there's no dirty pages in current chunk. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: error codeMichael S. Tsirkin2010-10-071-0/+2
| | | | | | fix up errors returned to include errno, not just -1 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: change set guest notifier to per-deviceMichael S. Tsirkin2010-10-071-24/+28
| | | | | | | | | When using irqfd with vhost-net to inject interrupts, a single evenfd might inject multiple interrupts. Implementing this is much easier with a single per-device callback to set guest notifiers. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* Introduce range.hBlue Swirl2010-09-181-2/+1
| | | | | | | Extract range functions from pci.h. These will be used by later patches by non-PCI devices. Adjust current users. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Remove unused eventfd.hMike McCormack2010-07-301-1/+0
| | | | | | | | This header is not present on my system and causes a build failure, but is also not used in these files, so remove it. Signed-off-by: Mike McCormack <mikem@ring3k.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* vhost: fix miration during device startMichael S. Tsirkin2010-07-191-10/+11
| | | | | | | | | | | | We need to know ring layout to allocate log buffer. So init rings first. Also fixes a theoretical memory-leak-on-error. https://bugzilla.redhat.com/show_bug.cgi?id=615228 Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Gerd Hoffmann <kraxel@redhat.com>
* vhost.c: include <linux/vhost.h> lastMarcelo Tosatti2010-04-141-1/+1
| | | | | | | | | So the userspace headers define KERNEL_STRICT_NAMES and there's no conflict on type definition for older kernels. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* win32: Fix compiler errors from u_int64_tStefan Weil2010-04-011-3/+3
| | | | | | | | | | | | | | | | | 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) /qemu/ar7/hw/virtio.c:776: error: (Each undeclared identifier is reported only once /qemu/ar7/hw/virtio.c:776: error: for each function it appears in.) Replacing u_int64_t by uint64_t helps. Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* vhost: vhost net supportMichael S. Tsirkin2010-04-011-0/+711
This adds vhost net device support in qemu. Will be tied to tap device and virtio by following patches. Raw backend is currently missing, will be worked on/submitted separately. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud