static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,

                                           struct XenDevOps *ops)

{

    struct XenDevice *xendev;

    char *dom0;



    xendev = xen_be_find_xendev(type, dom, dev);

    if (xendev) {

        return xendev;

    }



    /* init new xendev */

    xendev = g_malloc0(ops->size);

    xendev->type  = type;

    xendev->dom   = dom;

    xendev->dev   = dev;

    xendev->ops   = ops;



    dom0 = xs_get_domain_path(xenstore, 0);

    snprintf(xendev->be, sizeof(xendev->be), "%s/backend/%s/%d/%d",

             dom0, xendev->type, xendev->dom, xendev->dev);

    snprintf(xendev->name, sizeof(xendev->name), "%s-%d",

             xendev->type, xendev->dev);

    free(dom0);



    xendev->debug      = debug;

    xendev->local_port = -1;



    xendev->evtchndev = xen_xc_evtchn_open(NULL, 0);

    if (xendev->evtchndev == XC_HANDLER_INITIAL_VALUE) {

        xen_be_printf(NULL, 0, "can't open evtchn device\n");

        g_free(xendev);

        return NULL;

    }

    fcntl(xc_evtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);



    if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {

        xendev->gnttabdev = xen_xc_gnttab_open(NULL, 0);

        if (xendev->gnttabdev == XC_HANDLER_INITIAL_VALUE) {

            xen_be_printf(NULL, 0, "can't open gnttab device\n");

            xc_evtchn_close(xendev->evtchndev);

            g_free(xendev);

            return NULL;

        }

    } else {

        xendev->gnttabdev = XC_HANDLER_INITIAL_VALUE;

    }



    QTAILQ_INSERT_TAIL(&xendevs, xendev, next);



    if (xendev->ops->alloc) {

        xendev->ops->alloc(xendev);

    }



    return xendev;

}

static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,

                                           struct XenDevOps *ops)

{

    struct XenDevice *xendev;

    char *dom0;



    xendev = xen_be_find_xendev(type, dom, dev);

    if (xendev) {

        return xendev;

    }



    

    xendev = g_malloc0(ops->size);

    xendev->type  = type;

    xendev->dom   = dom;

    xendev->dev   = dev;

    xendev->ops   = ops;



    dom0 = xs_get_domain_path(xenstore, 0);

    snprintf(xendev->be, sizeof(xendev->be), "%s/backend/%s/%d/%d",

             dom0, xendev->type, xendev->dom, xendev->dev);

    snprintf(xendev->name, sizeof(xendev->name), "%s-%d",

             xendev->type, xendev->dev);

    free(dom0);



    xendev->debug      = debug;

    xendev->local_port = -1;



    xendev->evtchndev = xen_xc_evtchn_open(NULL, 0);

    if (xendev->evtchndev == XC_HANDLER_INITIAL_VALUE) {

        xen_be_printf(NULL, 0, "can't open evtchn device\n");

        g_free(xendev);

        return NULL;

    }

    fcntl(xc_evtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);



    if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {

        xendev->gnttabdev = xen_xc_gnttab_open(NULL, 0);

        if (xendev->gnttabdev == XC_HANDLER_INITIAL_VALUE) {

            xen_be_printf(NULL, 0, "can't open gnttab device\n");

            xc_evtchn_close(xendev->evtchndev);

            g_free(xendev);

            return NULL;

        }

    } else {

        xendev->gnttabdev = XC_HANDLER_INITIAL_VALUE;

    }



    QTAILQ_INSERT_TAIL(&xendevs, xendev, next);



    if (xendev->ops->alloc) {

        xendev->ops->alloc(xendev);

    }



    return xendev;

}

    char *dom0;     dom0 = xs_get_domain_path(xenstore, 0);     snprintf(xendev->be, sizeof(xendev->be), "%s/backend/%s/%d/%d",              dom0, xendev->type, xendev->dom, xendev->dev);     free(dom0);     dom0 = xs_get_domain_path(xenstore, 0);     free(dom0);     dom0 = xs_get_domain_path(xenstore, 0);     free(dom0);
static struct XenDevice *FUNC_0(const char *VAR_0, int VAR_1, int VAR_2,

                                           struct XenDevOps *VAR_3)

{

    struct XenDevice *VAR_4;

    char *VAR_5;



    VAR_4 = xen_be_find_xendev(VAR_0, VAR_1, VAR_2);

    if (VAR_4) {

        return VAR_4;

    }



    

    VAR_4 = g_malloc0(VAR_3->size);

    VAR_4->VAR_0  = VAR_0;

    VAR_4->VAR_1   = VAR_1;

    VAR_4->VAR_2   = VAR_2;

    VAR_4->VAR_3   = VAR_3;



    VAR_5 = xs_get_domain_path(xenstore, 0);

    snprintf(VAR_4->be, sizeof(VAR_4->be), "%s/backend/%s/%d/%d",

             VAR_5, VAR_4->VAR_0, VAR_4->VAR_1, VAR_4->VAR_2);

    snprintf(VAR_4->name, sizeof(VAR_4->name), "%s-%d",

             VAR_4->VAR_0, VAR_4->VAR_2);

    free(VAR_5);



    VAR_4->debug      = debug;

    VAR_4->local_port = -1;



    VAR_4->evtchndev = xen_xc_evtchn_open(NULL, 0);

    if (VAR_4->evtchndev == XC_HANDLER_INITIAL_VALUE) {

        xen_be_printf(NULL, 0, "can't open evtchn device\n");

        g_free(VAR_4);

        return NULL;

    }

    fcntl(xc_evtchn_fd(VAR_4->evtchndev), F_SETFD, FD_CLOEXEC);



    if (VAR_3->flags & DEVOPS_FLAG_NEED_GNTDEV) {

        VAR_4->gnttabdev = xen_xc_gnttab_open(NULL, 0);

        if (VAR_4->gnttabdev == XC_HANDLER_INITIAL_VALUE) {

            xen_be_printf(NULL, 0, "can't open gnttab device\n");

            xc_evtchn_close(VAR_4->evtchndev);

            g_free(VAR_4);

            return NULL;

        }

    } else {

        VAR_4->gnttabdev = XC_HANDLER_INITIAL_VALUE;

    }



    QTAILQ_INSERT_TAIL(&xendevs, VAR_4, next);



    if (VAR_4->VAR_3->alloc) {

        VAR_4->VAR_3->alloc(VAR_4);

    }



    return VAR_4;

}

static struct XenDevice *FUNC_0(const char *VAR_0, int VAR_1, int VAR_2,
struct XenDevOps *VAR_3)
{ struct XenDevice *VAR_4; char *VAR_5; VAR_4 = xen_be_find_xendev(VAR_0, VAR_1, VAR_2); if (VAR_4) { return VAR_4; } VAR_4 = g_malloc0(VAR_3->size); VAR_4->VAR_0  = VAR_0; VAR_4->VAR_1   = VAR_1; VAR_4->VAR_2   = VAR_2; VAR_4->VAR_3   = VAR_3; VAR_5 = xs_get_domain_path(xenstore, 0); snprintf(VAR_4->be, sizeof(VAR_4->be), "%s/backend/%s/%d/%d",
VAR_5, VAR_4->VAR_0, VAR_4->VAR_1, VAR_4->VAR_2); snprintf(VAR_4->name, sizeof(VAR_4->name), "%s-%d",
VAR_4->VAR_0, VAR_4->VAR_2); free(VAR_5); VAR_4->debug      = debug; VAR_4->local_port = -1; VAR_4->evtchndev = xen_xc_evtchn_open(NULL, 0); if (VAR_4->evtchndev == XC_HANDLER_INITIAL_VALUE) { xen_be_printf(NULL, 0, "can't open evtchn device\n"); g_free(VAR_4); return NULL; } fcntl(xc_evtchn_fd(VAR_4->evtchndev), F_SETFD, FD_CLOEXEC); if (VAR_3->flags & DEVOPS_FLAG_NEED_GNTDEV) { VAR_4->gnttabdev = xen_xc_gnttab_open(NULL, 0); if (VAR_4->gnttabdev == XC_HANDLER_INITIAL_VALUE) { xen_be_printf(NULL, 0, "can't open gnttab device\n"); xc_evtchn_close(VAR_4->evtchndev); g_free(VAR_4); return NULL; } } else { VAR_4->gnttabdev = XC_HANDLER_INITIAL_VALUE; } QTAILQ_INSERT_TAIL(&xendevs, VAR_4, next); if (VAR_4->VAR_3->alloc) { VAR_4->VAR_3->alloc(VAR_4); } return VAR_4; }