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

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