KVM: leverage change to adjust slots->used_slots in update_memslots()
authorWei Yang <richard.weiyang@gmail.com>
Wed, 22 Aug 2018 13:57:11 +0000 (21:57 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 16 Oct 2018 22:29:48 +0000 (00:29 +0200)
commit31fc4f95dddc4ebc9f9596a2720662e15e5d444e
tree222a3c04a58bfdfbbd58d72bdc9da3f665b92998
parent3c6e099fa15fdb6fb1892199ed8709012e1294f2
KVM: leverage change to adjust slots->used_slots in update_memslots()

update_memslots() is only called by __kvm_set_memory_region(), in which
"change" is calculated and indicates how to adjust slots->used_slots

  * increase by one if it is KVM_MR_CREATE
  * decrease by one if it is KVM_MR_DELETE
  * not change for others

This patch adjusts slots->used_slots in update_memslots() based on "change"
value instead of re-calculate those states again.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c