Re: [RFC PATCH 3/9] kvm_main.c: introduce kvm_internal_memory_region_list

Paolo Bonzini
2022-09-28T16:48:26Z

On 9/9/22 12:45, Emanuele Giuseppe Esposito wrote:
> +struct kvm_internal_memory_region_list {
> + /* Fields initialized in __kvm_set_memory_region() */
> + struct kvm_memory_slot *old;
> + struct kvm_memory_slot *new;
> + struct kvm_memory_slot *invalid;
> + enum kvm_mr_change change;
> +};
> +

Alternative name: kvm_memslot_change

> int __kvm_set_memory_region(struct kvm *kvm,
> - const struct kvm_userspace_memory_region *mem);
> + const struct kvm_userspace_memory_region *mem,
> + struct kvm_internal_memory_region_list *batch);

A bit weird to have this passed by the caller. I'd rather have
__kvm_set_memory_region with the *batch argument (which I'd call instead
*change), and design kvm_set_memory_region so that, at the end of the
series, it is something like:

int kvm_set_memory_region(struct kvm *kvm,
const struct kvm_userspace_memory_region *mem)
{
struct kvm_memslot_change change = {};
r = __kvm_set_memory_region(kvm, mem, &change);
if (r < 0)
return r;
r = invalidate_memslot_for_change(kvm, &change);
if (r < 0)
return r;
return commit_memslot_change(kvm, &change);
}

Paolo