static int kvm_put_vcpu_events(CPUState *env, int level)

{

    struct kvm_vcpu_events events;



    if (!kvm_has_vcpu_events()) {

        return 0;

    }



    events.exception.injected = (env->exception_injected >= 0);

    events.exception.nr = env->exception_injected;

    events.exception.has_error_code = env->has_error_code;

    events.exception.error_code = env->error_code;




    events.interrupt.injected = (env->interrupt_injected >= 0);

    events.interrupt.nr = env->interrupt_injected;

    events.interrupt.soft = env->soft_interrupt;



    events.nmi.injected = env->nmi_injected;

    events.nmi.pending = env->nmi_pending;

    events.nmi.masked = !!(env->hflags2 & HF2_NMI_MASK);

    events.nmi.pad = 0;



    events.sipi_vector = env->sipi_vector;



    events.flags = 0;

    if (level >= KVM_PUT_RESET_STATE) {

        events.flags |=

            KVM_VCPUEVENT_VALID_NMI_PENDING | KVM_VCPUEVENT_VALID_SIPI_VECTOR;

    }



    return kvm_vcpu_ioctl(env, KVM_SET_VCPU_EVENTS, &events);

}
static int kvm_put_vcpu_events(CPUState *env, int level)

{

    struct kvm_vcpu_events events;



    if (!kvm_has_vcpu_events()) {

        return 0;

    }



    events.exception.injected = (env->exception_injected >= 0);

    events.exception.nr = env->exception_injected;

    events.exception.has_error_code = env->has_error_code;

    events.exception.error_code = env->error_code;




    events.interrupt.injected = (env->interrupt_injected >= 0);

    events.interrupt.nr = env->interrupt_injected;

    events.interrupt.soft = env->soft_interrupt;



    events.nmi.injected = env->nmi_injected;

    events.nmi.pending = env->nmi_pending;

    events.nmi.masked = !!(env->hflags2 & HF2_NMI_MASK);

    events.nmi.pad = 0;



    events.sipi_vector = env->sipi_vector;



    events.flags = 0;

    if (level >= KVM_PUT_RESET_STATE) {

        events.flags |=

            KVM_VCPUEVENT_VALID_NMI_PENDING | KVM_VCPUEVENT_VALID_SIPI_VECTOR;

    }



    return kvm_vcpu_ioctl(env, KVM_SET_VCPU_EVENTS, &events);

}
static int FUNC_0(CPUState *VAR_0, int VAR_1)

{

    struct kvm_vcpu_events VAR_2;



    if (!kvm_has_vcpu_events()) {

        return 0;

    }



    VAR_2.exception.injected = (VAR_0->exception_injected >= 0);

    VAR_2.exception.nr = VAR_0->exception_injected;

    VAR_2.exception.has_error_code = VAR_0->has_error_code;

    VAR_2.exception.error_code = VAR_0->error_code;




    VAR_2.interrupt.injected = (VAR_0->interrupt_injected >= 0);

    VAR_2.interrupt.nr = VAR_0->interrupt_injected;

    VAR_2.interrupt.soft = VAR_0->soft_interrupt;



    VAR_2.nmi.injected = VAR_0->nmi_injected;

    VAR_2.nmi.pending = VAR_0->nmi_pending;

    VAR_2.nmi.masked = !!(VAR_0->hflags2 & HF2_NMI_MASK);

    VAR_2.nmi.pad = 0;



    VAR_2.sipi_vector = VAR_0->sipi_vector;



    VAR_2.flags = 0;

    if (VAR_1 >= KVM_PUT_RESET_STATE) {

        VAR_2.flags |=

            KVM_VCPUEVENT_VALID_NMI_PENDING | KVM_VCPUEVENT_VALID_SIPI_VECTOR;

    }



    return kvm_vcpu_ioctl(VAR_0, KVM_SET_VCPU_EVENTS, &VAR_2);

}
static int FUNC_0(CPUState *VAR_0, int VAR_1)
{ struct kvm_vcpu_events VAR_2; if (!kvm_has_vcpu_events()) { return 0; } VAR_2.exception.injected = (VAR_0->exception_injected >= 0); VAR_2.exception.nr = VAR_0->exception_injected; VAR_2.exception.has_error_code = VAR_0->has_error_code; VAR_2.exception.error_code = VAR_0->error_code; VAR_2.interrupt.injected = (VAR_0->interrupt_injected >= 0); VAR_2.interrupt.nr = VAR_0->interrupt_injected; VAR_2.interrupt.soft = VAR_0->soft_interrupt; VAR_2.nmi.injected = VAR_0->nmi_injected; VAR_2.nmi.pending = VAR_0->nmi_pending; VAR_2.nmi.masked = !!(VAR_0->hflags2 & HF2_NMI_MASK); VAR_2.nmi.pad = 0; VAR_2.sipi_vector = VAR_0->sipi_vector; VAR_2.flags = 0; if (VAR_1 >= KVM_PUT_RESET_STATE) { VAR_2.flags |=
KVM_VCPUEVENT_VALID_NMI_PENDING | KVM_VCPUEVENT_VALID_SIPI_VECTOR; } return kvm_vcpu_ioctl(VAR_0, KVM_SET_VCPU_EVENTS, &VAR_2); }