diff options
author | Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp> | 2013-01-11 04:26:55 -0500 |
---|---|---|
committer | Gleb Natapov <gleb@redhat.com> | 2013-01-17 07:27:50 -0500 |
commit | 0a706beefb1de71bf8551f9860dc529ef14d6753 (patch) | |
tree | a4873b1deb1d4a9d5f95b00dc73effdf34683dcc /virt | |
parent | 0ea75e1d26dd4ccbbfe4d1a5931903b15b82ba2a (diff) |
KVM: set_memory_region: Don't check for overlaps unless we create or move a slot
Don't need the check for deleting an existing slot or just modifiying
the flags.
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 28eb160fd487..fca64879f967 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -782,14 +782,16 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
782 | if (!npages && !old.npages) | 782 | if (!npages && !old.npages) |
783 | goto out; | 783 | goto out; |
784 | 784 | ||
785 | /* Check for overlaps */ | 785 | if ((npages && !old.npages) || (base_gfn != old.base_gfn)) { |
786 | r = -EEXIST; | 786 | /* Check for overlaps */ |
787 | kvm_for_each_memslot(slot, kvm->memslots) { | 787 | r = -EEXIST; |
788 | if (slot->id >= KVM_USER_MEM_SLOTS || slot == memslot) | 788 | kvm_for_each_memslot(slot, kvm->memslots) { |
789 | continue; | 789 | if (slot->id >= KVM_USER_MEM_SLOTS || slot == memslot) |
790 | if (!((base_gfn + npages <= slot->base_gfn) || | 790 | continue; |
791 | (base_gfn >= slot->base_gfn + slot->npages))) | 791 | if (!((base_gfn + npages <= slot->base_gfn) || |
792 | goto out; | 792 | (base_gfn >= slot->base_gfn + slot->npages))) |
793 | goto out; | ||
794 | } | ||
793 | } | 795 | } |
794 | 796 | ||
795 | /* Free page dirty bitmap if unneeded */ | 797 | /* Free page dirty bitmap if unneeded */ |