aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2017-12-05 23:15:53 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2018-01-12 09:54:12 +0100
commitd9bcd6f7f23a13ea627d8edb85c0706525da0b75 (patch)
tree12873c9d5ad25c4e48f5e71bde8a37dfc7b974cc /hw/scsi
parent997eba28a3ed5400a80f754bf3a1c8044b75b9ff (diff)
downloadqemu-d9bcd6f7f23a13ea627d8edb85c0706525da0b75.zip
qemu-d9bcd6f7f23a13ea627d8edb85c0706525da0b75.tar.gz
qemu-d9bcd6f7f23a13ea627d8edb85c0706525da0b75.tar.bz2
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 <famz@redhat.com> Message-Id: <20171205151553.7834-1-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/scsi')
-rw-r--r--hw/scsi/scsi-generic.c9
1 files changed, 9 insertions, 0 deletions
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(),
};