[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] event channels in minios



I try to implement event channels in two minios domains. I call the evtchn_alloc_unbound function to allocate a unbounded channel, then I check channel's status and found it is not correct. The state should be unbound(1),and the remote_dom is wrong, too. Where is my mistake?

Below are the two domains' output and the code. Please help me to check it. Thanks.

parent dom console output:
xs_daemon_open -> 3, 0x94dc8
---> xs_deamon_open OK!
---> domid : 21
---> I am parent DomU!
alloc_unbound rc: 0
local port: 5

unbound chn:
domid: 21
local_port: 5
state: 4
remote_dom: 25408


bind_vcpu rc: -14

unbound chn:
state: 4
vcpu: 0
remote_dom: 25408

child dom console output:
xs_daemon_open -> 3, 0x94dc8
---> xs_deamon_open OK!
---> domid : 22
---> I am child DomU!
bind_interdomain rc: 0
local port: 5

interdomain lchn:
state: 322320
remote_dom: 50614
remote_port: 0

interdomain rchn:
state: 463702
remote_dom: 65416
remote_port: 0
vcpu: 0

---> send the event

Code:
unsigned int get_domid(struct xs_handle * xs)
{
    //unsigned int domid;
    char *buf;
    unsigned int len, domid;
    buf = xs_read(xs, XBT_NULL, "domid", &len);
    domid = atoi(buf);
    printf( "---> domid : %d\n" , domid);
    return domid;
}


//the event handler
void evt_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
{
    printk("[Port %d] - event received\n", port);
}

int main()
{
    sleep(1);
    struct xs_handle *xs;
    unsigned int domid, remote_dom;
    evtchn_port_t local_port, remote_port;

    /* Get a connection to the daemon */
    xs = xs_daemon_open();
    if(xs == NULL)
    {
        perror( "---> xs_deamon_open:" );
    }
    printf( "---> xs_deamon_open OK!\n" );

    domid = get_domid(xs);
    int is_parent = domid % 2 == 0 ? 0 : 1;
   
   
    if(is_parent == 1)
        goto parent;
    else
        goto child;

parent:
    printf( "---> I am parent DomU!\n" );
    //wait the next dom to start
    sleep(30);

    //alloc a unbounded event channel
    remote_dom = domid + 1;
    int rc;
    rc = evtchn_alloc_unbound(remote_dom, evt_handler, NULL, &local_port);
    printf("alloc_unbound rc: %d\n", rc);
    printf("local port: %d\n\n", local_port);

    //check the channel status
        evtchn_status_t chn;
        chn.dom = domid;
        chn.port = local_port;
        HYPERVISOR_event_channel_op(EVTCHNOP_status, &chn);
        printf("unbound chn: \n");
        printf("domid: %d\n", chn.dom);
        printf("local_port: %d\n", chn.port);
        printf("state: %d\n", chn.status);
        printf("remote_dom: %d\n\n", chn.u.unbound.dom);

    //bind the event chanel to VCPU 0
    evtchn_bind_vcpu_t bind_vcpu;
    bind_vcpu.port = local_port;
    bind_vcpu.vcpu = 0;
    rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu);
    printf("bind_vcpu rc: %d\n\n", rc);

    //check the channel status
    HYPERVISOR_event_channel_op(EVTCHNOP_status, &chn);
        printf("unbound chn: \n");
        printf("state: %d\n", chn.status);   
        printf("vcpu: %d\n", chn.vcpu);   
        printf("remote_dom: %d\n\n", chn.u.unbound.dom);   

    //write the port to xenstore
    //write_xenstore(domid, "evtchn_port", local_port);
   
    //wait the event
    while(1)
     {
         sleep(5);
     }
     return 0;

child:
    printf( "---> I am child DomU!\n" );
    remote_dom = domid - 1;
   
    //Wait the remote event channel to be allocated
    sleep(40);

    //get the remote port from xenstore
    //remote_port = read_xenstore(remote_dom, "evtchn_port");
    remote_port = 5;

    //bind the interdomain
    int rc2;
    rc2 = evtchn_bind_interdomain(remote_dom, remote_port, evt_handler, NULL, &local_port);
    printf("bind_interdomain rc: %d\n", rc2);
    printf("local port: %d\n\n", local_port);

    //check the status
        evtchn_status_t lchn, rchn;
        lchn.dom = domid;
        lchn.port = local_port;
        rchn.dom = remote_dom;
        rchn.port = remote_port;
        HYPERVISOR_event_channel_op(EVTCHNOP_status, &lchn);
        HYPERVISOR_event_channel_op(EVTCHNOP_status, &rchn);
        printf("interdomain lchn: \n");
        printf("state: %d\n", lchn.status);
        printf("remote_dom: %d\n", lchn.u.interdomain.dom);
        printf("remote_port: %d\n\n", lchn.u.interdomain.port);

        printf("interdomain rchn: \n");
        printf("state: %d\n", rchn.status);
        printf("remote_dom: %d\n", rchn.u.interdomain.dom);
        printf("remote_port: %d\n", rchn.u.interdomain.port);
        printf("vcpu: %d\n\n", rchn.vcpu);
    
    //send the event
     evtchn_send_t send;
     send.port = local_port;
     HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
    printf("---> send the event\n");

     int i = 0;
     while(1)
     {
         sleep(1);
     }
     return 0;
}


 

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.