Revision 78ced65e hw/scsi-disk.c

b/hw/scsi-disk.c
45 45
#define SCSI_REQ_STATUS_RETRY_TYPE_MASK 0x06
46 46
#define SCSI_REQ_STATUS_RETRY_READ      0x00
47 47
#define SCSI_REQ_STATUS_RETRY_WRITE     0x02
48
#define SCSI_REQ_STATUS_RETRY_FLUSH     0x04
48 49

  
49 50
typedef struct SCSIDiskState SCSIDiskState;
50 51

  
......
74 75
};
75 76

  
76 77
static int scsi_handle_rw_error(SCSIDiskReq *r, int error, int type);
78
static int scsi_disk_emulate_command(SCSIDiskReq *r, uint8_t *outbuf);
77 79

  
78 80
static SCSIDiskReq *scsi_new_request(SCSIDiskState *s, uint32_t tag,
79 81
        uint32_t lun)
......
316 318
        r = DO_UPCAST(SCSIDiskReq, req, req);
317 319
        if (r->status & SCSI_REQ_STATUS_RETRY) {
318 320
            int status = r->status;
321
            int ret;
322

  
319 323
            r->status &=
320 324
                ~(SCSI_REQ_STATUS_RETRY | SCSI_REQ_STATUS_RETRY_TYPE_MASK);
321 325

  
......
326 330
            case SCSI_REQ_STATUS_RETRY_WRITE:
327 331
                scsi_write_request(r);
328 332
                break;
333
            case SCSI_REQ_STATUS_RETRY_FLUSH:
334
                ret = scsi_disk_emulate_command(r, r->iov.iov_base);
335
                if (ret == 0) {
336
                    scsi_command_complete(r, GOOD, NO_SENSE);
337
                }
329 338
            }
330 339
        }
331 340
    }
......
790 799
    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
791 800
    uint64_t nb_sectors;
792 801
    int buflen = 0;
802
    int ret;
793 803

  
794 804
    switch (req->cmd.buf[0]) {
795 805
    case TEST_UNIT_READY:
......
880 890
        buflen = 8;
881 891
	break;
882 892
    case SYNCHRONIZE_CACHE:
883
        bdrv_flush(s->bs);
893
        ret = bdrv_flush(s->bs);
894
        if (ret < 0) {
895
            if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_FLUSH)) {
896
                return -1;
897
            }
898
        }
884 899
        break;
885 900
    case GET_CONFIGURATION:
886 901
        memset(outbuf, 0, 8);

Also available in: Unified diff