int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)

{

    struct kvm_msi msi;

    KVMMSIRoute *route;



    if (s->direct_msi) {

        msi.address_lo = (uint32_t)msg.address;

        msi.address_hi = msg.address >> 32;

        msi.data = le32_to_cpu(msg.data);

        msi.flags = 0;

        memset(msi.pad, 0, sizeof(msi.pad));



        return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi);

    }



    route = kvm_lookup_msi_route(s, msg);

    if (!route) {

        int virq;



        virq = kvm_irqchip_get_virq(s);

        if (virq < 0) {

            return virq;

        }



        route = g_malloc(sizeof(KVMMSIRoute));

        route->kroute.gsi = virq;

        route->kroute.type = KVM_IRQ_ROUTING_MSI;

        route->kroute.flags = 0;

        route->kroute.u.msi.address_lo = (uint32_t)msg.address;

        route->kroute.u.msi.address_hi = msg.address >> 32;

        route->kroute.u.msi.data = le32_to_cpu(msg.data);



        kvm_add_routing_entry(s, &route->kroute);

        kvm_irqchip_commit_routes(s);



        QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(msg.data)], route,

                           entry);

    }



    assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);



    return kvm_set_irq(s, route->kroute.gsi, 1);

}

int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)

{

    struct kvm_msi msi;

    KVMMSIRoute *route;



    if (s->direct_msi) {

        msi.address_lo = (uint32_t)msg.address;

        msi.address_hi = msg.address >> 32;

        msi.data = le32_to_cpu(msg.data);

        msi.flags = 0;

        memset(msi.pad, 0, sizeof(msi.pad));



        return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi);

    }



    route = kvm_lookup_msi_route(s, msg);

    if (!route) {

        int virq;



        virq = kvm_irqchip_get_virq(s);

        if (virq < 0) {

            return virq;

        }



        route = g_malloc(sizeof(KVMMSIRoute));

        route->kroute.gsi = virq;

        route->kroute.type = KVM_IRQ_ROUTING_MSI;

        route->kroute.flags = 0;

        route->kroute.u.msi.address_lo = (uint32_t)msg.address;

        route->kroute.u.msi.address_hi = msg.address >> 32;

        route->kroute.u.msi.data = le32_to_cpu(msg.data);



        kvm_add_routing_entry(s, &route->kroute);

        kvm_irqchip_commit_routes(s);



        QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(msg.data)], route,

                           entry);

    }



    assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);



    return kvm_set_irq(s, route->kroute.gsi, 1);

}

        route = g_malloc(sizeof(KVMMSIRoute));
int FUNC_0(KVMState *VAR_0, MSIMessage VAR_1)

{

    struct kvm_msi VAR_2;

    KVMMSIRoute *route;



    if (VAR_0->direct_msi) {

        VAR_2.address_lo = (uint32_t)VAR_1.address;

        VAR_2.address_hi = VAR_1.address >> 32;

        VAR_2.data = le32_to_cpu(VAR_1.data);

        VAR_2.flags = 0;

        memset(VAR_2.pad, 0, sizeof(VAR_2.pad));



        return kvm_vm_ioctl(VAR_0, KVM_SIGNAL_MSI, &VAR_2);

    }



    route = kvm_lookup_msi_route(VAR_0, VAR_1);

    if (!route) {

        int VAR_3;



        VAR_3 = kvm_irqchip_get_virq(VAR_0);

        if (VAR_3 < 0) {

            return VAR_3;

        }



        route = g_malloc(sizeof(KVMMSIRoute));

        route->kroute.gsi = VAR_3;

        route->kroute.type = KVM_IRQ_ROUTING_MSI;

        route->kroute.flags = 0;

        route->kroute.u.VAR_2.address_lo = (uint32_t)VAR_1.address;

        route->kroute.u.VAR_2.address_hi = VAR_1.address >> 32;

        route->kroute.u.VAR_2.data = le32_to_cpu(VAR_1.data);



        kvm_add_routing_entry(VAR_0, &route->kroute);

        kvm_irqchip_commit_routes(VAR_0);



        QTAILQ_INSERT_TAIL(&VAR_0->msi_hashtab[kvm_hash_msi(VAR_1.data)], route,

                           entry);

    }



    assert(route->kroute.type == KVM_IRQ_ROUTING_MSI);



    return kvm_set_irq(VAR_0, route->kroute.gsi, 1);

}

int FUNC_0(KVMState *VAR_0, MSIMessage VAR_1)
{ struct kvm_msi VAR_2; KVMMSIRoute *route; if (VAR_0->direct_msi) { VAR_2.address_lo = (uint32_t)VAR_1.address; VAR_2.address_hi = VAR_1.address >> 32; VAR_2.data = le32_to_cpu(VAR_1.data); VAR_2.flags = 0; memset(VAR_2.pad, 0, sizeof(VAR_2.pad)); return kvm_vm_ioctl(VAR_0, KVM_SIGNAL_MSI, &VAR_2); } route = kvm_lookup_msi_route(VAR_0, VAR_1); if (!route) { int VAR_3; VAR_3 = kvm_irqchip_get_virq(VAR_0); if (VAR_3 < 0) { return VAR_3; } route = g_malloc(sizeof(KVMMSIRoute)); route->kroute.gsi = VAR_3; route->kroute.type = KVM_IRQ_ROUTING_MSI; route->kroute.flags = 0; route->kroute.u.VAR_2.address_lo = (uint32_t)VAR_1.address; route->kroute.u.VAR_2.address_hi = VAR_1.address >> 32; route->kroute.u.VAR_2.data = le32_to_cpu(VAR_1.data); kvm_add_routing_entry(VAR_0, &route->kroute); kvm_irqchip_commit_routes(VAR_0); QTAILQ_INSERT_TAIL(&VAR_0->msi_hashtab[kvm_hash_msi(VAR_1.data)], route,
entry); } assert(route->kroute.type == KVM_IRQ_ROUTING_MSI); return kvm_set_irq(VAR_0, route->kroute.gsi, 1); }