static int virtio_scsi_parse_req(VirtIOSCSIReq *req,

                                 unsigned req_size, unsigned resp_size)

{

    VirtIODevice *vdev = (VirtIODevice *) req->dev;

    size_t in_size, out_size;



    if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,

                   &req->req, req_size) < req_size) {

        return -EINVAL;

    }



    if (qemu_iovec_concat_iov(&req->resp_iov,

                              req->elem.in_sg, req->elem.in_num, 0,

                              resp_size) < resp_size) {

        return -EINVAL;

    }



    req->resp_size = resp_size;



    /* Old BIOSes left some padding by mistake after the req_size/resp_size.

     * As a workaround, always consider the first buffer as the virtio-scsi

     * request/response, making the payload start at the second element

     * of the iovec.

     *

     * The actual length of the response header, stored in req->resp_size,

     * does not change.

     *

     * TODO: always disable this workaround for virtio 1.0 devices.

     */

    if (!virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) {

        req_size = req->elem.out_sg[0].iov_len;

        resp_size = req->elem.in_sg[0].iov_len;

    }



    out_size = qemu_sgl_concat(req, req->elem.out_sg,

                               &req->elem.out_addr[0], req->elem.out_num,

                               req_size);

    in_size = qemu_sgl_concat(req, req->elem.in_sg,

                              &req->elem.in_addr[0], req->elem.in_num,

                              resp_size);



    if (out_size && in_size) {

        return -ENOTSUP;

    }



    if (out_size) {

        req->mode = SCSI_XFER_TO_DEV;

    } else if (in_size) {

        req->mode = SCSI_XFER_FROM_DEV;

    }



    return 0;

}

static int virtio_scsi_parse_req(VirtIOSCSIReq *req,

                                 unsigned req_size, unsigned resp_size)

{

    VirtIODevice *vdev = (VirtIODevice *) req->dev;

    size_t in_size, out_size;



    if (iov_to_buf(req->elem.out_sg, req->elem.out_num, 0,

                   &req->req, req_size) < req_size) {

        return -EINVAL;

    }



    if (qemu_iovec_concat_iov(&req->resp_iov,

                              req->elem.in_sg, req->elem.in_num, 0,

                              resp_size) < resp_size) {

        return -EINVAL;

    }



    req->resp_size = resp_size;



    



















    if (!virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) {

        req_size = req->elem.out_sg[0].iov_len;

        resp_size = req->elem.in_sg[0].iov_len;

    }



    out_size = qemu_sgl_concat(req, req->elem.out_sg,

                               &req->elem.out_addr[0], req->elem.out_num,

                               req_size);

    in_size = qemu_sgl_concat(req, req->elem.in_sg,

                              &req->elem.in_addr[0], req->elem.in_num,

                              resp_size);



    if (out_size && in_size) {

        return -ENOTSUP;

    }



    if (out_size) {

        req->mode = SCSI_XFER_TO_DEV;

    } else if (in_size) {

        req->mode = SCSI_XFER_FROM_DEV;

    }



    return 0;

}

        req_size = req->elem.out_sg[0].iov_len;         resp_size = req->elem.in_sg[0].iov_len;
static int FUNC_0(VirtIOSCSIReq *VAR_0,

                                 unsigned VAR_1, unsigned VAR_2)

{

    VirtIODevice *vdev = (VirtIODevice *) VAR_0->dev;

    size_t in_size, out_size;



    if (iov_to_buf(VAR_0->elem.out_sg, VAR_0->elem.out_num, 0,

                   &VAR_0->VAR_0, VAR_1) < VAR_1) {

        return -EINVAL;

    }



    if (qemu_iovec_concat_iov(&VAR_0->resp_iov,

                              VAR_0->elem.in_sg, VAR_0->elem.in_num, 0,

                              VAR_2) < VAR_2) {

        return -EINVAL;

    }



    VAR_0->VAR_2 = VAR_2;



    



















    if (!virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) {

        VAR_1 = VAR_0->elem.out_sg[0].iov_len;

        VAR_2 = VAR_0->elem.in_sg[0].iov_len;

    }



    out_size = qemu_sgl_concat(VAR_0, VAR_0->elem.out_sg,

                               &VAR_0->elem.out_addr[0], VAR_0->elem.out_num,

                               VAR_1);

    in_size = qemu_sgl_concat(VAR_0, VAR_0->elem.in_sg,

                              &VAR_0->elem.in_addr[0], VAR_0->elem.in_num,

                              VAR_2);



    if (out_size && in_size) {

        return -ENOTSUP;

    }



    if (out_size) {

        VAR_0->mode = SCSI_XFER_TO_DEV;

    } else if (in_size) {

        VAR_0->mode = SCSI_XFER_FROM_DEV;

    }



    return 0;

}

static int FUNC_0(VirtIOSCSIReq *VAR_0,
unsigned VAR_1, unsigned VAR_2)
{ VirtIODevice *vdev = (VirtIODevice *) VAR_0->dev; size_t in_size, out_size; if (iov_to_buf(VAR_0->elem.out_sg, VAR_0->elem.out_num, 0,
&VAR_0->VAR_0, VAR_1) < VAR_1) { return -EINVAL; } if (qemu_iovec_concat_iov(&VAR_0->resp_iov,
VAR_0->elem.in_sg, VAR_0->elem.in_num, 0,
VAR_2) < VAR_2) { return -EINVAL; } VAR_0->VAR_2 = VAR_2; if (!virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) { VAR_1 = VAR_0->elem.out_sg[0].iov_len; VAR_2 = VAR_0->elem.in_sg[0].iov_len; } out_size = qemu_sgl_concat(VAR_0, VAR_0->elem.out_sg,
&VAR_0->elem.out_addr[0], VAR_0->elem.out_num,
VAR_1); in_size = qemu_sgl_concat(VAR_0, VAR_0->elem.in_sg,
&VAR_0->elem.in_addr[0], VAR_0->elem.in_num,
VAR_2); if (out_size && in_size) { return -ENOTSUP; } if (out_size) { VAR_0->mode = SCSI_XFER_TO_DEV; } else if (in_size) { VAR_0->mode = SCSI_XFER_FROM_DEV; } return 0; }