static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)

{

    struct ioreq *ioreq = NULL;



    if (LIST_EMPTY(&blkdev->freelist)) {

	if (blkdev->requests_total >= max_requests)

	    goto out;

	/* allocate new struct */

	ioreq = qemu_mallocz(sizeof(*ioreq));

	ioreq->blkdev = blkdev;

	blkdev->requests_total++;

        qemu_iovec_init(&ioreq->v, BLKIF_MAX_SEGMENTS_PER_REQUEST);

    } else {

	/* get one from freelist */

	ioreq = LIST_FIRST(&blkdev->freelist);

	LIST_REMOVE(ioreq, list);

        qemu_iovec_reset(&ioreq->v);

    }

    LIST_INSERT_HEAD(&blkdev->inflight, ioreq, list);

    blkdev->requests_inflight++;



out:

    return ioreq;

}

static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)

{

    struct ioreq *ioreq = NULL;



    if (LIST_EMPTY(&blkdev->freelist)) {

	if (blkdev->requests_total >= max_requests)

	    goto out;

	

	ioreq = qemu_mallocz(sizeof(*ioreq));

	ioreq->blkdev = blkdev;

	blkdev->requests_total++;

        qemu_iovec_init(&ioreq->v, BLKIF_MAX_SEGMENTS_PER_REQUEST);

    } else {

	

	ioreq = LIST_FIRST(&blkdev->freelist);

	LIST_REMOVE(ioreq, list);

        qemu_iovec_reset(&ioreq->v);

    }

    LIST_INSERT_HEAD(&blkdev->inflight, ioreq, list);

    blkdev->requests_inflight++;



out:

    return ioreq;

}

static struct VAR_1 *FUNC_0(struct XenBlkDev *VAR_0)

{

    struct VAR_1 *VAR_1 = NULL;



    if (LIST_EMPTY(&VAR_0->freelist)) {

	if (VAR_0->requests_total >= max_requests)

	    goto out;

	

	VAR_1 = qemu_mallocz(sizeof(*VAR_1));

	VAR_1->VAR_0 = VAR_0;

	VAR_0->requests_total++;

        qemu_iovec_init(&VAR_1->v, BLKIF_MAX_SEGMENTS_PER_REQUEST);

    } else {

	

	VAR_1 = LIST_FIRST(&VAR_0->freelist);

	LIST_REMOVE(VAR_1, list);

        qemu_iovec_reset(&VAR_1->v);

    }

    LIST_INSERT_HEAD(&VAR_0->inflight, VAR_1, list);

    VAR_0->requests_inflight++;



out:

    return VAR_1;

}

static struct VAR_1 *FUNC_0(struct XenBlkDev *VAR_0)
{ struct VAR_1 *VAR_1 = NULL; if (LIST_EMPTY(&VAR_0->freelist)) { if (VAR_0->requests_total >= max_requests)
goto out; VAR_1 = qemu_mallocz(sizeof(*VAR_1)); VAR_1->VAR_0 = VAR_0; VAR_0->requests_total++; qemu_iovec_init(&VAR_1->v, BLKIF_MAX_SEGMENTS_PER_REQUEST); } else { VAR_1 = LIST_FIRST(&VAR_0->freelist); LIST_REMOVE(VAR_1, list); qemu_iovec_reset(&VAR_1->v); } LIST_INSERT_HEAD(&VAR_0->inflight, VAR_1, list); VAR_0->requests_inflight++; out:
return VAR_1; }