KVM: set_memory_region: Remove unnecessary variable memslot
One such variable, slot, is enough for holding a pointer temporarily. We also remove another local variable named slot, which is limited in a block, since it is confusing to have the same name in this function. 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>
This commit is contained in:
parent
0a706beefb
commit
a843fac253
@ -728,7 +728,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
|
|||||||
int r;
|
int r;
|
||||||
gfn_t base_gfn;
|
gfn_t base_gfn;
|
||||||
unsigned long npages;
|
unsigned long npages;
|
||||||
struct kvm_memory_slot *memslot, *slot;
|
struct kvm_memory_slot *slot;
|
||||||
struct kvm_memory_slot old, new;
|
struct kvm_memory_slot old, new;
|
||||||
struct kvm_memslots *slots = NULL, *old_memslots;
|
struct kvm_memslots *slots = NULL, *old_memslots;
|
||||||
|
|
||||||
@ -754,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
|
|||||||
if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr)
|
if (mem->guest_phys_addr + mem->memory_size < mem->guest_phys_addr)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
memslot = id_to_memslot(kvm->memslots, mem->slot);
|
slot = id_to_memslot(kvm->memslots, mem->slot);
|
||||||
base_gfn = mem->guest_phys_addr >> PAGE_SHIFT;
|
base_gfn = mem->guest_phys_addr >> PAGE_SHIFT;
|
||||||
npages = mem->memory_size >> PAGE_SHIFT;
|
npages = mem->memory_size >> PAGE_SHIFT;
|
||||||
|
|
||||||
@ -765,7 +765,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
|
|||||||
if (!npages)
|
if (!npages)
|
||||||
mem->flags &= ~KVM_MEM_LOG_DIRTY_PAGES;
|
mem->flags &= ~KVM_MEM_LOG_DIRTY_PAGES;
|
||||||
|
|
||||||
new = old = *memslot;
|
new = old = *slot;
|
||||||
|
|
||||||
new.id = mem->slot;
|
new.id = mem->slot;
|
||||||
new.base_gfn = base_gfn;
|
new.base_gfn = base_gfn;
|
||||||
@ -786,7 +786,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
|
|||||||
/* Check for overlaps */
|
/* Check for overlaps */
|
||||||
r = -EEXIST;
|
r = -EEXIST;
|
||||||
kvm_for_each_memslot(slot, kvm->memslots) {
|
kvm_for_each_memslot(slot, kvm->memslots) {
|
||||||
if (slot->id >= KVM_USER_MEM_SLOTS || slot == memslot)
|
if ((slot->id >= KVM_USER_MEM_SLOTS) ||
|
||||||
|
(slot->id == mem->slot))
|
||||||
continue;
|
continue;
|
||||||
if (!((base_gfn + npages <= slot->base_gfn) ||
|
if (!((base_gfn + npages <= slot->base_gfn) ||
|
||||||
(base_gfn >= slot->base_gfn + slot->npages)))
|
(base_gfn >= slot->base_gfn + slot->npages)))
|
||||||
@ -822,8 +823,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!npages || base_gfn != old.base_gfn) {
|
if (!npages || base_gfn != old.base_gfn) {
|
||||||
struct kvm_memory_slot *slot;
|
|
||||||
|
|
||||||
r = -ENOMEM;
|
r = -ENOMEM;
|
||||||
slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
|
slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
Loading…
Reference in New Issue
Block a user