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@xxxxxxxxxxxxx> > kvm_arch_free_vm(kvm); > return ERR_PTR(r); > } Takuya -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html