lkml.org 
[lkml]   [2015]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/9] KVM: introduce kvm_alloc/free_memslots
On 2015/05/20 2:25, Paolo Bonzini wrote:

> +static void kvm_free_memslots(struct kvm *kvm, struct kvm_memslots *slots)
> +{
> + struct kvm_memory_slot *memslot;
> +
> + if (!slots)
> + return;
> +
> + kvm_for_each_memslot(memslot, slots)
> + kvm_free_memslot(kvm, memslot, NULL);
> +
> + kvfree(slots);
> }
>
> static struct kvm *kvm_create_vm(unsigned long type)
> @@ -472,17 +519,10 @@ static struct kvm *kvm_create_vm(unsigned long type)
> BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX);
>
> r = -ENOMEM;
> - kvm->memslots = kvm_kvzalloc(sizeof(struct kvm_memslots));
> + kvm->memslots = kvm_alloc_memslots();
> if (!kvm->memslots)
> goto out_err_no_srcu;
>
> - /*
> - * Init kvm generation close to the maximum to easily test the
> - * code of handling generation number wrap-around.
> - */
> - kvm->memslots->generation = -150;
> -
> - kvm_init_memslots_id(kvm);
> if (init_srcu_struct(&kvm->srcu))
> goto out_err_no_srcu;
> if (init_srcu_struct(&kvm->irq_srcu))
> @@ -523,7 +563,7 @@ out_err_no_srcu:
> out_err_no_disable:
> for (i = 0; i < KVM_NR_BUSES; i++)
> kfree(kvm->buses[i]);
> - kvfree(kvm->memslots);
> + kvm_free_memslots(kvm, kvm->memslots);

Newly added code
+ kvm_for_each_memslot(memslot, slots)
+ kvm_free_memslot(kvm, memslot, NULL);
does nothing in effect, but looks better to be here since this
corresponds to kvm_alloc_memslots() part and may be safer for
future changes.

Other changes look like trivial transitions to the new
kvm_alloc/free_memslots.

Reviewed-by: Takuya Yoshikawa <yoshikawa_takuya_b1@lab.ntt.co.jp>

> kvm_arch_free_vm(kvm);
> return ERR_PTR(r);
> }

Takuya



\
 
 \ /
  Last update: 2015-05-20 10:21    [W:0.071 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site