def METHOD_NAME(self, pre_vm, post_vm):
    """
    Compare pre_vm and post_vm, restore VM memory devices.
    """
    mem_devs_post = set(post_vm.params.objects("mem_devs"))
    mem_devs_origin = set(pre_vm.params.objects("mem_devs"))
    if mem_devs_post == mem_devs_origin:
        return
    if len(mem_devs_origin) > len(mem_devs_post):
        mem_devs = mem_devs_origin - mem_devs_post
        vm, operation = post_vm, "hotplug"
    elif len(mem_devs_origin) < len(mem_devs_post):
        mem_devs = mem_devs_post - mem_devs_origin
        vm, operation = pre_vm, "unplug"
    func = getattr(self, "%s_memory" % operation)
    for mem_dev in mem_devs:
        func(vm, mem_dev)