Re: [PATCH 5/8] KVM: Add kvm_get_irq_routing_entry() func

Avi Kivity
2010-10-20T09:32:53Z

On 10/20/2010 11:17 AM, Sheng Yang wrote:
> }
>
> +int kvm_get_irq_routing_entry(struct kvm *kvm, int gsi,
> + struct kvm_kernel_irq_routing_entry *entry)
> +{
> + int count = 0;
> + struct kvm_kernel_irq_routing_entry *ei = NULL;
> + struct kvm_irq_routing_table *irq_rt;
> + struct hlist_node *n;
> +
> + rcu_read_lock();
> + irq_rt = rcu_dereference(kvm->irq_routing);
> + if (gsi< irq_rt->nr_rt_entries)
> + hlist_for_each_entry(ei, n,&irq_rt->map[gsi], link)
> + count++;
> + rcu_read_unlock();
> + if (count == 1)
> + memcpy(entry, ei, sizeof(*ei));

Need to be before the unlock.

> +
> + return (count != 1);
> +}
> +

"*entry = *ei" is clearer and safer. But is it correct? we might be
using outdated data.

--
error compiling committee.c: too many arguments to function