diff options
author | Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> | 2011-11-14 04:23:34 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-12-27 04:17:19 -0500 |
commit | 7850ac5420803996e2960d15b924021f28e0dffc (patch) | |
tree | dc4ed43a8e5ffcfbf45b48c8d78228ffe9762efa /arch/x86 | |
parent | 9b9b1492364758de82c19c36f07baa9ae162c7e5 (diff) |
KVM: Count the number of dirty pages for dirty logging
Needed for the next patch which uses this number to decide how to write
protect a slot.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/x86.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a3b25a524c9b..220c83b0fbda 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3466,10 +3466,9 @@ static int kvm_vm_ioctl_reinject(struct kvm *kvm, | |||
3466 | int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | 3466 | int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, |
3467 | struct kvm_dirty_log *log) | 3467 | struct kvm_dirty_log *log) |
3468 | { | 3468 | { |
3469 | int r, i; | 3469 | int r; |
3470 | struct kvm_memory_slot *memslot; | 3470 | struct kvm_memory_slot *memslot; |
3471 | unsigned long n; | 3471 | unsigned long n; |
3472 | unsigned long is_dirty = 0; | ||
3473 | 3472 | ||
3474 | mutex_lock(&kvm->slots_lock); | 3473 | mutex_lock(&kvm->slots_lock); |
3475 | 3474 | ||
@@ -3484,11 +3483,8 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
3484 | 3483 | ||
3485 | n = kvm_dirty_bitmap_bytes(memslot); | 3484 | n = kvm_dirty_bitmap_bytes(memslot); |
3486 | 3485 | ||
3487 | for (i = 0; !is_dirty && i < n/sizeof(long); i++) | ||
3488 | is_dirty = memslot->dirty_bitmap[i]; | ||
3489 | |||
3490 | /* If nothing is dirty, don't bother messing with page tables. */ | 3486 | /* If nothing is dirty, don't bother messing with page tables. */ |
3491 | if (is_dirty) { | 3487 | if (memslot->nr_dirty_pages) { |
3492 | struct kvm_memslots *slots, *old_slots; | 3488 | struct kvm_memslots *slots, *old_slots; |
3493 | unsigned long *dirty_bitmap; | 3489 | unsigned long *dirty_bitmap; |
3494 | 3490 | ||
@@ -3503,6 +3499,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
3503 | goto out; | 3499 | goto out; |
3504 | memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots)); | 3500 | memcpy(slots, kvm->memslots, sizeof(struct kvm_memslots)); |
3505 | slots->memslots[log->slot].dirty_bitmap = dirty_bitmap; | 3501 | slots->memslots[log->slot].dirty_bitmap = dirty_bitmap; |
3502 | slots->memslots[log->slot].nr_dirty_pages = 0; | ||
3506 | slots->generation++; | 3503 | slots->generation++; |
3507 | 3504 | ||
3508 | old_slots = kvm->memslots; | 3505 | old_slots = kvm->memslots; |