Blame SOURCES/kvm-scsi-generic-Add-share-rw-option.patch

4a2fec
From 7d6eed4b197081fa324e42f7624d6ab0a27bab6d Mon Sep 17 00:00:00 2001
4a2fec
From: Fam Zheng <famz@redhat.com>
4a2fec
Date: Wed, 17 Jan 2018 06:08:34 +0100
4a2fec
Subject: [PATCH 04/21] scsi-generic: Add share-rw option
4a2fec
4a2fec
RH-Author: Fam Zheng <famz@redhat.com>
4a2fec
Message-id: <20180117060834.17481-3-famz@redhat.com>
4a2fec
Patchwork-id: 78652
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 2/2] scsi-generic: Add share-rw option
4a2fec
Bugzilla: 1518482
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
4a2fec
4a2fec
Add the property to the device model, then parse it by calling
4a2fec
blkconf_apply_backend_options().
4a2fec
4a2fec
In addition to blk_set_perm(), the called function also handles error
4a2fec
options and wce. For error options we've already checked that the
4a2fec
default values are used, for wce we don't have the option either so it
4a2fec
is always the default (true). In other words there is no change of
4a2fec
behavior in these regards.
4a2fec
4a2fec
Signed-off-by: Fam Zheng <famz@redhat.com>
4a2fec
Message-Id: <20171205151553.7834-1-famz@redhat.com>
4a2fec
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
(cherry picked from commit d9bcd6f7f23a13ea627d8edb85c0706525da0b75)
4a2fec
Signed-off-by: Fam Zheng <famz@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/scsi/scsi-generic.c | 9 +++++++++
4a2fec
 1 file changed, 9 insertions(+)
4a2fec
4a2fec
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
4a2fec
index bd0d9ff..ba70c0d 100644
4a2fec
--- a/hw/scsi/scsi-generic.c
4a2fec
+++ b/hw/scsi/scsi-generic.c
4a2fec
@@ -482,6 +482,7 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp)
4a2fec
     int rc;
4a2fec
     int sg_version;
4a2fec
     struct sg_scsi_id scsiid;
4a2fec
+    Error *local_err = NULL;
4a2fec
 
4a2fec
     if (!s->conf.blk) {
4a2fec
         error_setg(errp, "drive property not set");
4a2fec
@@ -515,6 +516,13 @@ static void scsi_generic_realize(SCSIDevice *s, Error **errp)
4a2fec
         error_setg(errp, "SG_GET_SCSI_ID ioctl failed");
4a2fec
         return;
4a2fec
     }
4a2fec
+    blkconf_apply_backend_options(&s->conf,
4a2fec
+                                  blk_is_read_only(s->conf.blk),
4a2fec
+                                  true, &local_err);
4a2fec
+    if (local_err) {
4a2fec
+        error_propagate(errp, local_err);
4a2fec
+        return;
4a2fec
+    }
4a2fec
 
4a2fec
     /* define device state */
4a2fec
     s->type = scsiid.scsi_type;
4a2fec
@@ -565,6 +573,7 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun,
4a2fec
 
4a2fec
 static Property scsi_generic_properties[] = {
4a2fec
     DEFINE_PROP_DRIVE("drive", SCSIDevice, conf.blk),
4a2fec
+    DEFINE_PROP_BOOL("share-rw", SCSIDevice, conf.share_rw, false),
4a2fec
     DEFINE_PROP_END_OF_LIST(),
4a2fec
 };
4a2fec
 
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec