diff options
author | Zhang Xiantao <xiantao.zhang@intel.com> | 2007-11-18 07:29:43 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:53:05 -0500 |
commit | 5bb064dcdeb7ab341e2f8a3e2fc34faa63b1662c (patch) | |
tree | abb976bd8e6f79fca02aeadad31269f281f71c16 /drivers/kvm/x86.c | |
parent | 9327fd1195b77e67b86db8c1c1c4c4f7db009b00 (diff) |
KVM: Portability: Move kvm_vcpu_ioctl_get_dirty_log to arch-specific file
Meanwhile keep the interface in common, and leave as more logic in common
as possible.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/x86.c')
-rw-r--r-- | drivers/kvm/x86.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c index 9618fcba887e..935e2769b787 100644 --- a/drivers/kvm/x86.c +++ b/drivers/kvm/x86.c | |||
@@ -937,6 +937,37 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip) | |||
937 | return r; | 937 | return r; |
938 | } | 938 | } |
939 | 939 | ||
940 | /* | ||
941 | * Get (and clear) the dirty memory log for a memory slot. | ||
942 | */ | ||
943 | int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | ||
944 | struct kvm_dirty_log *log) | ||
945 | { | ||
946 | int r; | ||
947 | int n; | ||
948 | struct kvm_memory_slot *memslot; | ||
949 | int is_dirty = 0; | ||
950 | |||
951 | mutex_lock(&kvm->lock); | ||
952 | |||
953 | r = kvm_get_dirty_log(kvm, log, &is_dirty); | ||
954 | if (r) | ||
955 | goto out; | ||
956 | |||
957 | /* If nothing is dirty, don't bother messing with page tables. */ | ||
958 | if (is_dirty) { | ||
959 | kvm_mmu_slot_remove_write_access(kvm, log->slot); | ||
960 | kvm_flush_remote_tlbs(kvm); | ||
961 | memslot = &kvm->memslots[log->slot]; | ||
962 | n = ALIGN(memslot->npages, BITS_PER_LONG) / 8; | ||
963 | memset(memslot->dirty_bitmap, 0, n); | ||
964 | } | ||
965 | r = 0; | ||
966 | out: | ||
967 | mutex_unlock(&kvm->lock); | ||
968 | return r; | ||
969 | } | ||
970 | |||
940 | long kvm_arch_vm_ioctl(struct file *filp, | 971 | long kvm_arch_vm_ioctl(struct file *filp, |
941 | unsigned int ioctl, unsigned long arg) | 972 | unsigned int ioctl, unsigned long arg) |
942 | { | 973 | { |