scsi-disk: restruct emulation: SYNCHRONIZE_CACHE

Move SYNCHRONIZE_CACHE emulation from scsi_send_command() to
scsi_disk_emulate_command().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Gerd Hoffmann 2009-11-26 15:34:10 +01:00 committed by Anthony Liguori
parent e7e25e3269
commit fc903943f8

View File

@ -705,6 +705,9 @@ static int scsi_disk_emulate_command(SCSIRequest *req, uint8_t *outbuf)
outbuf[7] = 0; outbuf[7] = 0;
buflen = 8; buflen = 8;
break; break;
case SYNCHRONIZE_CACHE:
bdrv_flush(bdrv);
break;
default: default:
goto illegal_request; goto illegal_request;
} }
@ -819,6 +822,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
case START_STOP: case START_STOP:
case ALLOW_MEDIUM_REMOVAL: case ALLOW_MEDIUM_REMOVAL:
case READ_CAPACITY: case READ_CAPACITY:
case SYNCHRONIZE_CACHE:
rc = scsi_disk_emulate_command(&r->req, outbuf); rc = scsi_disk_emulate_command(&r->req, outbuf);
if (rc > 0) { if (rc > 0) {
r->iov.iov_len = rc; r->iov.iov_len = rc;
@ -847,10 +851,6 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
r->sector_count = len * s->cluster_size; r->sector_count = len * s->cluster_size;
is_write = 1; is_write = 1;
break; break;
case SYNCHRONIZE_CACHE:
DPRINTF("Synchronise cache (sector %" PRId64 ", count %d)\n", lba, len);
bdrv_flush(s->qdev.dinfo->bdrv);
break;
case READ_TOC: case READ_TOC:
{ {
int start_track, format, msf, toclen; int start_track, format, msf, toclen;