QEMU KVM balloon support (v2)
PATCH 1/1 QEMU KVM balloon support (v2)
QEMU support for ballooning.
Changes:
- Use int64_t for memory size input, otherwise it wraps around at 2GB (Daniel Berrange)
- Use virtio_update_config()
- Remove save/load hooks, they will be rewritten after Anthony introduces proper virtio s/l support
libkvm/libkvm.c +11 -0
@@ -886,6 +886,17 @@ int kvm_is_ready_for_interrupt_injectionreturn run->ready_for_interrupt_injection; } +int kvm_sync_shadow_with_user (kvm_context_t kvm) +{ +int r =0 ; +#ifdef KVM_CAP_SYNC_SHADOW_WITH_USER + r =ioctl (kvm->fd,KVM_CHECK_EXTENSION ,KVM_CAP_SYNC_SHADOW_WITH_USER ); +if (r >0 ) + r =ioctl (kvm->vm_fd,KVM_SYNC_SHADOW_WITH_USER ); +#endif +return r; +} +int kvm_run (kvm_context_t kvm,int vcpu) {int r;
libkvm/libkvm.h +2 -0
@@ -423,6 +423,8 @@ int kvm_get_dirty_pages_range(kvm_contexint (*cb)(unsigned long start,unsigned long len, void*bitmap, void *opaque)); +int kvm_sync_shadow_with_user (kvm_context_t kvm); +/*! * \brief Create a memory alias *
qemu/Makefile.target +1 -1
@@ -464,7 +464,7 @@ VL_OBJS += rtl8139.o VL_OBJS+= hypercall.o # virtio devices -VL_OBJS += virtio.o virtio-net.o virtio-blk.o +VL_OBJS += virtio.o virtio-net.o virtio-blk.o virtio-balloon.o ifeq ($(TARGET_BASE_ARCH), i386) # Hardware support
qemu/hw/pc.c +2 -0
@@ -1029,6 +1029,8 @@ static void pc_init1(ram_addr_t ram_size } } +virtio_balloon_init (pci_bus); +#define USE_HYPERCALL #ifdef USE_HYPERCALL pci_hypercall_init (pci_bus);
qemu/hw/pc.h +3 -0
@@ -155,4 +155,7 @@ void *virtio_blk_init(PCIBus *bus, uint1void extboot_init (BlockDriverState *bs,int cmd); +/* virtio-balloon.c */ +void *virtio_balloon_init (PCIBus *bus); +#endif
qemu/hw/virtio-balloon.c new file +84 -0
84 lines not on this page · raw message
qemu/migration.c +4 -0
@@ -34,6 +34,7 @@#endif #include <sys/wait.h> +#include <sys/mman.h> #define MIN_FINALIZE_SIZE (200 << 10)#define MAX_ITERATIONS 30
@@ -765,6 +766,9 @@ static void migrate_incoming_homogeneousfor (i=0 ; i<n; i++) p[i] = v; + +if (v ==0 ) +madvise (phys_ram_base + addr,TARGET_PAGE_SIZE ,MADV_DONTNEED ); }static int migrate_incoming_page (QEMUFile *f,uint32_t addr)
qemu/monitor.c +2 -0
@@ -1339,6 +1339,8 @@ static term_cmd_t term_cmds[] = { "", "cancel the current VM migration" }, {"migrate_set_speed" ,"s" , do_migrate_set_speed, "value", "set maximum speed (in bytes) for migrations" }, + { "setmem", "s", do_setmemory, "value", + "set memory for the guest (in bytes)" }, { NULL, NULL, }, };
qemu/qemu-kvm.c +94 -1
113 lines not on this page · raw message
qemu/qemu-kvm.h +3 -0
@@ -39,6 +39,9 @@ void kvm_arch_post_kvm_run(void *opaque,int kvm_arch_has_work (CPUState *env);int kvm_arch_try_push_interrupts (void *opaque);void kvm_arch_update_regs_for_sipi (CPUState *env); +int kvm_handle_ballooning_call (void *data,size_t len); + +void do_setmemory (const char *value);extern int kvm_allowed;extern int kvm_irqchip;
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace