static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type)

{

    int is_read = (type == SCSI_REQ_STATUS_RETRY_READ);

    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);

    BlockErrorAction action = bdrv_get_on_error(s->bs, is_read);



    if (action == BLOCK_ERR_IGNORE) {

        bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, is_read);

        return 0;

    }



    if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)

            || action == BLOCK_ERR_STOP_ANY) {



        type &= SCSI_REQ_STATUS_RETRY_TYPE_MASK;

        r->status |= SCSI_REQ_STATUS_RETRY | type;



        bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);

        vm_stop(VMSTOP_DISKFULL);

    } else {

        if (type == SCSI_REQ_STATUS_RETRY_READ) {

            scsi_req_data(&r->req, 0);

        }

        if (error == ENOMEM) {

            scsi_command_complete(r, CHECK_CONDITION,

                                  SENSE_CODE(TARGET_FAILURE));

        } else {

            scsi_command_complete(r, CHECK_CONDITION,

                                  SENSE_CODE(IO_ERROR));

        }

        bdrv_mon_event(s->bs, BDRV_ACTION_REPORT, is_read);

    }



    return 1;

}

static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type)

{

    int is_read = (type == SCSI_REQ_STATUS_RETRY_READ);

    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);

    BlockErrorAction action = bdrv_get_on_error(s->bs, is_read);



    if (action == BLOCK_ERR_IGNORE) {

        bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, is_read);

        return 0;

    }



    if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)

            || action == BLOCK_ERR_STOP_ANY) {



        type &= SCSI_REQ_STATUS_RETRY_TYPE_MASK;

        r->status |= SCSI_REQ_STATUS_RETRY | type;



        bdrv_mon_event(s->bs, BDRV_ACTION_STOP, is_read);

        vm_stop(VMSTOP_DISKFULL);

    } else {

        if (type == SCSI_REQ_STATUS_RETRY_READ) {

            scsi_req_data(&r->req, 0);

        }

        if (error == ENOMEM) {

            scsi_command_complete(r, CHECK_CONDITION,

                                  SENSE_CODE(TARGET_FAILURE));

        } else {

            scsi_command_complete(r, CHECK_CONDITION,

                                  SENSE_CODE(IO_ERROR));

        }

        bdrv_mon_event(s->bs, BDRV_ACTION_REPORT, is_read);

    }



    return 1;

}

static int FUNC_0(SCSIDiskReq *VAR_0, int VAR_1, int VAR_2)

{

    int VAR_3 = (VAR_2 == SCSI_REQ_STATUS_RETRY_READ);

    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->req.dev);

    BlockErrorAction action = bdrv_get_on_error(s->bs, VAR_3);



    if (action == BLOCK_ERR_IGNORE) {

        bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, VAR_3);

        return 0;

    }



    if ((VAR_1 == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)

            || action == BLOCK_ERR_STOP_ANY) {



        VAR_2 &= SCSI_REQ_STATUS_RETRY_TYPE_MASK;

        VAR_0->status |= SCSI_REQ_STATUS_RETRY | VAR_2;



        bdrv_mon_event(s->bs, BDRV_ACTION_STOP, VAR_3);

        vm_stop(VMSTOP_DISKFULL);

    } else {

        if (VAR_2 == SCSI_REQ_STATUS_RETRY_READ) {

            scsi_req_data(&VAR_0->req, 0);

        }

        if (VAR_1 == ENOMEM) {

            scsi_command_complete(VAR_0, CHECK_CONDITION,

                                  SENSE_CODE(TARGET_FAILURE));

        } else {

            scsi_command_complete(VAR_0, CHECK_CONDITION,

                                  SENSE_CODE(IO_ERROR));

        }

        bdrv_mon_event(s->bs, BDRV_ACTION_REPORT, VAR_3);

    }



    return 1;

}

static int FUNC_0(SCSIDiskReq *VAR_0, int VAR_1, int VAR_2)
{ int VAR_3 = (VAR_2 == SCSI_REQ_STATUS_RETRY_READ); SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->req.dev); BlockErrorAction action = bdrv_get_on_error(s->bs, VAR_3); if (action == BLOCK_ERR_IGNORE) { bdrv_mon_event(s->bs, BDRV_ACTION_IGNORE, VAR_3); return 0; } if ((VAR_1 == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)
|| action == BLOCK_ERR_STOP_ANY) { VAR_2 &= SCSI_REQ_STATUS_RETRY_TYPE_MASK; VAR_0->status |= SCSI_REQ_STATUS_RETRY | VAR_2; bdrv_mon_event(s->bs, BDRV_ACTION_STOP, VAR_3); vm_stop(VMSTOP_DISKFULL); } else { if (VAR_2 == SCSI_REQ_STATUS_RETRY_READ) { scsi_req_data(&VAR_0->req, 0); } if (VAR_1 == ENOMEM) { scsi_command_complete(VAR_0, CHECK_CONDITION,
SENSE_CODE(TARGET_FAILURE)); } else { scsi_command_complete(VAR_0, CHECK_CONDITION,
SENSE_CODE(IO_ERROR)); } bdrv_mon_event(s->bs, BDRV_ACTION_REPORT, VAR_3); } return 1; }