diff options
author | Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> | 2011-11-24 04:39:18 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-12-27 04:17:37 -0500 |
commit | be6ba0f0962a39091c52eb9167ddea201fe80716 (patch) | |
tree | 52e46aad8cce4857def4dc03fc75955677027054 /virt/kvm/kvm_main.c | |
parent | be593d6286075801bba6d60fa466a39c24cc7616 (diff) |
KVM: introduce kvm_for_each_memslot macro
Introduce kvm_for_each_memslot to walk all valid memslot
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index b5ed7770ced3..4c2900c5d81d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -547,11 +547,11 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free, | |||
547 | 547 | ||
548 | void kvm_free_physmem(struct kvm *kvm) | 548 | void kvm_free_physmem(struct kvm *kvm) |
549 | { | 549 | { |
550 | int i; | ||
551 | struct kvm_memslots *slots = kvm->memslots; | 550 | struct kvm_memslots *slots = kvm->memslots; |
551 | struct kvm_memory_slot *memslot; | ||
552 | 552 | ||
553 | for (i = 0; i < slots->nmemslots; ++i) | 553 | kvm_for_each_memslot(memslot, slots) |
554 | kvm_free_physmem_slot(&slots->memslots[i], NULL); | 554 | kvm_free_physmem_slot(memslot, NULL); |
555 | 555 | ||
556 | kfree(kvm->memslots); | 556 | kfree(kvm->memslots); |
557 | } | 557 | } |
@@ -975,15 +975,13 @@ EXPORT_SYMBOL_GPL(kvm_is_error_hva); | |||
975 | static struct kvm_memory_slot *__gfn_to_memslot(struct kvm_memslots *slots, | 975 | static struct kvm_memory_slot *__gfn_to_memslot(struct kvm_memslots *slots, |
976 | gfn_t gfn) | 976 | gfn_t gfn) |
977 | { | 977 | { |
978 | int i; | 978 | struct kvm_memory_slot *memslot; |
979 | |||
980 | for (i = 0; i < slots->nmemslots; ++i) { | ||
981 | struct kvm_memory_slot *memslot = &slots->memslots[i]; | ||
982 | 979 | ||
980 | kvm_for_each_memslot(memslot, slots) | ||
983 | if (gfn >= memslot->base_gfn | 981 | if (gfn >= memslot->base_gfn |
984 | && gfn < memslot->base_gfn + memslot->npages) | 982 | && gfn < memslot->base_gfn + memslot->npages) |
985 | return memslot; | 983 | return memslot; |
986 | } | 984 | |
987 | return NULL; | 985 | return NULL; |
988 | } | 986 | } |
989 | 987 | ||