Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356784
b: refs/heads/master
c: f0736cf
h: refs/heads/master
v: v3
  • Loading branch information
Alex Williamson authored and Marcelo Tosatti committed Dec 14, 2012
1 parent 3df1df6 commit 1f979a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f3200d00ea42e485772ff92d6d649aa8eeb640c0
refs/heads/master: f0736cf0550b349a5d5a374d65ca0488cc2eee40
9 changes: 7 additions & 2 deletions trunk/virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,15 @@ int __kvm_set_memory_region(struct kvm *kvm,
new.npages = npages;
new.flags = mem->flags;

/* Disallow changing a memory slot's size. */
/*
* Disallow changing a memory slot's size or changing anything about
* zero sized slots that doesn't involve making them non-zero.
*/
r = -EINVAL;
if (npages && old.npages && npages != old.npages)
goto out_free;
if (!npages && !old.npages)
goto out_free;

/* Check for overlaps */
r = -EEXIST;
Expand All @@ -780,7 +785,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
r = -ENOMEM;

/* Allocate if a slot is being created */
if (npages && !old.npages) {
if (!old.npages) {
new.user_alloc = user_alloc;
new.userspace_addr = mem->userspace_addr;

Expand Down

0 comments on commit 1f979a2

Please sign in to comment.