/*
- * if change is DELETE or MOVE, invalid is in active memslots
- * and old in inactive, so replace old with new.
+ * if change is DELETE or MOVE, invalid is in both active and inactive
+ * memslot list. This means that we don't need old anymore, and
+ * we should replace invalid with new.
*/
- kvm_replace_memslot(kvm, batch->old, batch->new);
+ if (batch->change == KVM_MR_DELETE || batch->change == KVM_MR_MOVE)
+ kvm_replace_memslot(kvm, batch->invalid, batch->new);
+ else
+ kvm_replace_memslot(kvm, batch->old, batch->new);