On Tue, Jan 29, 2013 at 11:00:07AM +0900, Takuya Yoshikawa wrote: > KVM_SET_USER_MEMORY_REGION forces __kvm_set_memory_region() to identify > what kind of change is being requested by checking the arguments. The > current code does this checking at various points in code and each > condition being used there is not easy to understand at first glance. > > This patch consolidates these checks and introduces an enum to name the > possible changes to clean up the code. > > Although this does not introduce any functional changes, there is one > change which optimizes the code a bit: if we have nothing to change, the > new code returns 0 immediately. > > Note that the return value for this case cannot be changed since QEMU > relies on it: we noticed this when we changed it to -EINVAL and got a > section mismatch error at the final stage of live migration. > > Signed-off-by: Takuya Yoshikawa <yoshikawa_takuya_b1@xxxxxxxxxxxxx> > --- > v2: updated iommu related parts > v3: converted !(A == B) to A != B > Note: based on this patch, disallowing RO change will become trivial: > check such changes when we identify KVM_MR_FLAGS_ONLY. > > virt/kvm/kvm_main.c | 64 +++++++++++++++++++++++++++++++++++---------------- > 1 files changed, 44 insertions(+), 20 deletions(-) Applied, thanks. It would be good to propagate the enum into kvm_arch_prepare/commit memory region. -- 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