Skip to content

Commit

Permalink
KVM: set_memory_region: Don't check for overlaps unless we create or …
Browse files Browse the repository at this point in the history
…move a slot

Don't need the check for deleting an existing slot or just modifiying
the flags.

Reviewed-by: Marcelo Tosatti <[email protected]>
Signed-off-by: Takuya Yoshikawa <[email protected]>
Signed-off-by: Gleb Natapov <[email protected]>
  • Loading branch information
Takuya Yoshikawa authored and Gleb Natapov committed Jan 17, 2013
1 parent 0ea75e1 commit 0a706be
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,14 +782,16 @@ int __kvm_set_memory_region(struct kvm *kvm,
if (!npages && !old.npages)
goto out;

/* Check for overlaps */
r = -EEXIST;
kvm_for_each_memslot(slot, kvm->memslots) {
if (slot->id >= KVM_USER_MEM_SLOTS || slot == memslot)
continue;
if (!((base_gfn + npages <= slot->base_gfn) ||
(base_gfn >= slot->base_gfn + slot->npages)))
goto out;
if ((npages && !old.npages) || (base_gfn != old.base_gfn)) {
/* Check for overlaps */
r = -EEXIST;
kvm_for_each_memslot(slot, kvm->memslots) {
if (slot->id >= KVM_USER_MEM_SLOTS || slot == memslot)
continue;
if (!((base_gfn + npages <= slot->base_gfn) ||
(base_gfn >= slot->base_gfn + slot->npages)))
goto out;
}
}

/* Free page dirty bitmap if unneeded */
Expand Down

0 comments on commit 0a706be

Please sign in to comment.