summaryrefslogtreecommitdiffstats
path: root/hw/virtio-balloon.c
Commit message (Collapse)AuthorAgeFilesLines
* disable guest-provided stats on "info balloon" commandEduardo Habkost2010-10-011-1/+7
| | | | | | | | | | | | | | | The addition of memory stats reporting to the virtio balloon causes the 'info balloon' command to become asynchronous. This is a regression because in some cases it can hang the user monitor. This is an alternative to Adam Litke's patch. Adam's patch disabled the corresponding (guest-visible) virtio feature bit, causing issues for migration. Original discussion is available at: http://marc.info/?l=qemu-devel&m=128448124328314&w=2 Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Acked-by: Adam Litke <agl@us.ibm.com Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* Introduce qemu_madvise()Andreas Färber2010-09-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vl.c has a Sun-specific hack to supply a prototype for madvise(), but the call site has apparently moved to arch_init.c. Haiku doesn't implement madvise() in favor of posix_madvise(). OpenBSD and Solaris 10 don't implement posix_madvise() but madvise(). MinGW implements neither. Check for madvise() and posix_madvise() in configure and supply qemu_madvise() as wrapper. Prefer madvise() over posix_madvise() due to flag availability. Convert all callers to use qemu_madvise() and QEMU_MADV_*. Note that on Solaris the warning is fixed by moving the madvise() prototype, not by qemu_madvise() itself. It helps with porting though, and it simplifies most call sites. v7 -> v8: * Some versions of MinGW have no sys/mman.h header. Reported by Blue Swirl. v6 -> v7: * Adopt madvise() rather than posix_madvise() semantics for returning errors. * Use EINVAL in place of ENOTSUP. v5 -> v6: * Replace two leftover instances of POSIX_MADV_NORMAL with QEMU_MADV_INVALID. Spotted by Blue Swirl. v4 -> v5: * Introduce QEMU_MADV_INVALID, suggested by Alexander Graf. Note that this relies on -1 not being a valid advice value. v3 -> v4: * Eliminate #ifdefs at qemu_advise() call sites. Requested by Blue Swirl. This will currently break the check in kvm-all.c by calling madvise() with a supported flag, which will not fail. Ideas/patches welcome. v2 -> v3: * Reuse the *_MADV_* defines for QEMU_MADV_*. Suggested by Alexander Graf. * Add configure check for madvise(), too. Add defines to Makefile, not QEMU_CFLAGS. Convert all callers, untested. Suggested by Blue Swirl. * Keep Solaris' madvise() prototype around. Pointed out by Alexander Graf. * Display configure check results. v1 -> v2: * Don't rely on posix_madvise() availability, add qemu_madvise(). Suggested by Blue Swirl. Signed-off-by: Andreas Färber <afaerber@opensolaris.org> Cc: Blue Swirl <blauwirbel@gmail.com> Cc: Alexander Graf <agraf@suse.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* savevm: Add DeviceState paramAlex Williamson2010-07-061-1/+2
| | | | | | | | | | When available, we'd like to be able to access the DeviceState when registering a savevm. For buses with a get_dev_path() function, this will allow us to create more unique savevm id strings. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* iov: Add iov_to_buf and iov_size helpersAmit Shah2010-04-281-31/+4
| | | | | | | | | | | | iov_to_buf() puts the buffer contents in the iov in a linearized buffer. iov_size() gets the length of the contents in the iov. The iov_to_buf() function is the memcpy_to_iovec() function that was used in virtio-ballon.c. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* balloon: Fix overflow when reporting actual memory sizeAdam Litke2010-03-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Beginning with its introduction, the virtio balloon has had an overflow error that causes 'info balloon' to misreport the actual memory size when the balloon itself becomes larger than 4G. Use a cast when converting dev->actual from pages to kB to prevent overflows. Before: (qemu) info balloon balloon: actual=5120 (qemu) balloon 1025 (qemu) info balloon balloon: actual=1025 (qemu) balloon 1024 (qemu) info balloon balloon: actual=5120 After: (qemu) info balloon balloon: actual=5120 (qemu) balloon 1025 (qemu) info balloon balloon: actual=1025 (qemu) balloon 1024 (qemu) info balloon balloon: actual=1024 Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* balloon: Do not save VM state wrt asynchronous virtio operationsAdam Litke2010-03-171-9/+0
| | | | | | | | | | | | | | | | When working with the VM state (for loadvm/savevm and migration), it is not valid to load and store pointers since the validity of those pointers cannot be assured in the new qemu address space. Therefore, virtio_balloon_save() and virtio_balloon_load() must not handle the stats-related fields in struct VirtIOBalloon. If a memory stats request is in-flight at the time of a migration or savevm, the request will not complete and should be resubmitted once migration or loadvm completes. Note that this extremely small race window can only be triggered using QMP so it is not possible to hang the user monitor. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio: Add memory statistics reporting to the balloon driverAdam Litke2010-01-261-4/+123
| | | | | | | | | | | | | | | | When using ballooning to manage overcommitted memory on a host, a system for guests to communicate their memory usage to the host can provide information that will minimize the impact of ballooning on the guests. The current method employs a daemon running in each guest that communicates memory statistics to a host daemon at a specified time interval. The host daemon aggregates this information and inflates and/or deflates balloons according to the level of host memory pressure. This approach is effective but overly complex since a daemon must be installed inside each guest and coordinated to communicate with the host. A simpler approach is to collect memory statistics in the virtio balloon driver and communicate them directly to the hypervisor. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* virtio: add features as qdev propertiesMichael S. Tsirkin2010-01-111-2/+2
| | | | | | | | | | | | | Add feature bits as properties to virtio. This makes it possible to e.g. define machine without indirect buffer support, which is required for 0.10 compatibility, or without hardware checksum support, which is required for 0.11 compatibility. Since default values for optional features are now set by qdev, get_features callback has been modified: it sets non-optional bits, and clears bits not supported by host. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Revert "Get rid of _t suffix"Anthony Liguori2009-10-011-4/+4
| | | | | | | | | | | | 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. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Get rid of _t suffixmalc2009-10-011-4/+4
| | | | | | | Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
* Separate virtio PCI codePaul Brook2009-05-181-15/+5
| | | | | | Split the PCI host bindings from the VRing transport implementation. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Virtio-balloon qdev conversionPaul Brook2009-05-141-9/+9
| | | | Signed-off-by: Paul Brook <paul@codesourcery.com>
* Virtio-net qdev conversionPaul Brook2009-05-141-4/+8
| | | | Signed-off-by: Paul Brook <paul@codesourcery.com>
* Yet more phys_ram_base elimination.pbrook2009-04-101-1/+3
| | | | | | | Signed-off-by: Paul Brook <paul@cofdesourcery.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7067 c046a42c-6fe2-441c-8c8c-71466251a162
* Add and use #defines for PCI device classesblueswir12009-02-011-1/+1
| | | | | | | | | | | | | This patch adds and uses #defines for PCI device classes and subclases, using a new pci_config_set_class() function, similar to the recently added pci_config_set_vendor_id() and pci_config_set_device_id(). Change since v1: fixed compilation of hw/sun4u.c Signed-off-by: Stuart Brady <stuart.brady@gmail.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6491 c046a42c-6fe2-441c-8c8c-71466251a162
* Use the default subsystem vendor ID for virtio devices (Mark McLoughlin)aliguori2009-01-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A subsystem vendor ID of zero isn't allowed, so we use our default ID. Gerd points out that although the PCI subsystem vendor ID is treated by the guest as the virtio vendor ID: /* we use the subsystem vendor/device id as the virtio vendor/device * id. this allows us to use the same PCI vendor/device id for all * virtio devices and to identify the particular virtio driver by * the subsytem ids */ vp_dev->vdev.id.vendor = pci_dev->subsystem_vendor; vp_dev->vdev.id.device = pci_dev->subsystem_device; it looks like only the device ID is used right now: # grep virtio modules.alias alias virtio:d00000001v* virtio_net alias virtio:d00000002v* virtio_blk alias virtio:d00000003v* virtio_console alias virtio:d00000004v* virtio-rng alias virtio:d00000005v* virtio_balloon alias pci:v00001AF4d*sv*sd*bc*sc*i* virtio_pci alias virtio:d00000009v* 9pnet_virtio so setting the subsystem vendor id to something != zero shouldn't cause trouble. 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@6440 c046a42c-6fe2-441c-8c8c-71466251a162
* pci: virtio: use pci id defines (Gerd Hoffman)aliguori2008-12-111-1/+2
| | | | | | | | | | | | | Use the defines added by the previous patch in the virtio drivers. Also remove the pointless vendor and device args from the virtio_blk_init() function. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5987 c046a42c-6fe2-441c-8c8c-71466251a162
* Add virtio-balloon supportaliguori2008-12-041-0/+194
This adds a VirtIO based balloon driver. It uses madvise() to actually balloon the memory when possible. Until 2.6.27, KVM forced memory pinning so we must disable ballooning unless the kernel actually supports it when using KVM. It's always safe when using TCG. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5874 c046a42c-6fe2-441c-8c8c-71466251a162
OpenPOWER on IntegriCloud