qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] about qemu crash in scsi_handle_rw_error


From: Wangguang
Subject: [Qemu-devel] about qemu crash in scsi_handle_rw_error
Date: Fri, 12 Oct 2018 08:05:44 +0000

Hi
qemu had a assert when we use scsi-3 reservation。
This happen when scsi sence is recoverd error。
And which lead scsi_req_complete twice.


static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed)
{
    bool is_read = (r->req.cmd.mode == SCSI_XFER_FROM_DEV);
    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
    BlockErrorAction action = blk_get_error_action(s->qdev.conf.blk,
                                                   is_read, error);

    if (action == BLOCK_ERROR_ACTION_REPORT) {
        if (acct_failed) {
            block_acct_failed(blk_get_stats(s->qdev.conf.blk), &r->acct);
        }
        switch (error) {
        case 0:
            /* The command has run, no need to fake sense.  */
            assert(r->status && *r->status);
            scsi_req_complete(&r->req, *r->status);                      the  
first complete
            break;
        case ENOMEDIUM:
            scsi_check_condition(r, SENSE_CODE(NO_MEDIUM));
            break;
        case ENOMEM:
            scsi_check_condition(r, SENSE_CODE(TARGET_FAILURE));
            break;
        case EINVAL:
            scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
            break;
        case ENOSPC:
            scsi_check_condition(r, SENSE_CODE(SPACE_ALLOC_FAILED));
            break;
        default:
            scsi_check_condition(r, SENSE_CODE(IO_ERROR));
            break;
        }
    }
    if (!error) {
        assert(r->status && *r->status);
        error = scsi_sense_buf_to_errno(r->req.sense, sizeof(r->req.sense));

        if (error == ECANCELED || error == EAGAIN || error == ENOTCONN ||
            error == 0)  {
            /* These errors are handled by guest. */
           scsi_req_complete(&r->req, *r->status);                      
complete again when error==0;
            return true;
        }
    }




Shall we delete error==0  at the second scsi_req_complete ??
-------------------------------------------------------------------------------------------------------------------------------------
本邮件及其附件含有新华三集团的保密信息,仅限于发送给上面地址中列出
的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、
或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本
邮件!
This e-mail and its attachments contain confidential information from New H3C, 
which is
intended only for the person or entity whose address is listed above. Any use 
of the
information contained herein in any way (including, but not limited to, total 
or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify 
the sender
by phone or email immediately and delete it!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]