On Fri, Mar 08, 2013 at 09:23:20AM +0800, Yang Zhang wrote: > From: Yang Zhang <yang.z.zhang@xxxxxxxxx> > > Only deliver the posted interrupt when target vcpu is running > and there is no previous interrupt pending in pir. > > Signed-off-by: Yang Zhang <yang.z.zhang@xxxxxxxxx> > +static bool vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu, int vector) > +{ > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + > + if (!vmx_vm_has_apicv(vcpu->kvm)) > + return false; > + > + if (pi_test_and_set_pir(vector, &vmx->pi_desc)) > + return true; > + > + kvm_make_request(KVM_REQ_EVENT, vcpu); > + if ((vcpu->mode == IN_GUEST_MODE)) { > + if (!pi_test_and_set_on(&vmx->pi_desc)) > + apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), > + POSTED_INTR_VECTOR); > + } else > + kvm_vcpu_kick(vcpu); > + > + return true; > +} Meaning of return value is unclear. > + > +static bool vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu, bool sync) > +{ > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + > + if (!vmx_vm_has_apicv(vcpu->kvm)) > + return false; > + > + if (bitmap_empty((unsigned long *)vmx->pi_desc.pir, 256)) > + return false; > + > + if (sync) > + kvm_apic_update_irr(vcpu, vmx->pi_desc.pir); > + return true; > +} Please split in two kvm_x86_ops functions: one to query whether PIR is empty the other to perform the sync. Perhaps "->hwapic_has_interrupt" is a good name. -- 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