From d9bcd6f7f23a13ea627d8edb85c0706525da0b75 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Tue, 5 Dec 2017 23:15:53 +0800 Subject: scsi-generic: Add share-rw option Add the property to the device model, then parse it by calling blkconf_apply_backend_options(). In addition to blk_set_perm(), the called function also handles error options and wce. For error options we've already checked that the default values are used, for wce we don't have the option either so it is always the default (true). In other words there is no change of behavior in these regards. Signed-off-by: Fam Zheng Message-Id: <20171205151553.7834-1-famz@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-generic.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'hw/scsi') diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c index bd0d9ff..ba70c0d 100644 --- a/hw/scsi/scsi-generic.c +++ b/hw/scsi/scsi-generic.c @@ -482,6 +482,7 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp) int rc; int sg_version; struct sg_scsi_id scsiid; + Error *local_err = NULL; if (!s->conf.blk) { error_setg(errp, "drive property not set"); @@ -515,6 +516,13 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp) error_setg(errp, "SG_GET_SCSI_ID ioctl failed"); return; } + blkconf_apply_backend_options(&s->conf, + blk_is_read_only(s->conf.blk), + true, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } /* define device state */ s->type = scsiid.scsi_type; @@ -565,6 +573,7 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun, static Property scsi_generic_properties[] = { DEFINE_PROP_DRIVE("drive", SCSIDevice, conf.blk), + DEFINE_PROP_BOOL("share-rw", SCSIDevice, conf.share_rw, false), DEFINE_PROP_END_OF_LIST(), }; -- cgit v1.1 From 24355b79bdaf6ab12f7c610b032fc35ec045cd55 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 4 Jan 2018 14:25:02 +0000 Subject: scsi-disk: release AioContext in unaligned WRITE SAME case scsi_write_same_complete() can retry the write if the request was unaligned. Make sure to release the AioContext when that code path is taken! This patch fixes a hang when QEMU terminates after an unaligned WRITE SAME request has been processed with dataplane. The hang occurs because iothread_stop_all() cannot acquire the AioContext lock that was leaked by the IOThread in scsi_write_same_complete(). Fixes: b9e413dd37 ("block: explicitly acquire aiocontext in aio callbacks that need it"). Cc: Paolo Bonzini Cc: qemu-stable@nongnu.org Reported-by: Cong Li Signed-off-by: Stefan Hajnoczi Message-Id: <20180104142502.15175-1-stefanha@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 1 + 1 file changed, 1 insertion(+) (limited to 'hw/scsi') diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e58833a..49d2559 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -1755,6 +1755,7 @@ static void scsi_write_same_complete(void *opaque, int ret) data->sector << BDRV_SECTOR_BITS, &data->qiov, 0, scsi_write_same_complete, data); + aio_context_release(blk_get_aio_context(s->qdev.conf.blk)); return; } -- cgit v1.1