Blame SOURCES/kvm-usb-storage-Add-rerror-werror-properties.patch

383d26
From 222934faee20b22e77f711d6bc5d986c2e1fd297 Mon Sep 17 00:00:00 2001
383d26
From: Kevin Wolf <kwolf@redhat.com>
383d26
Date: Mon, 2 Jul 2018 12:20:17 +0200
383d26
Subject: [PATCH 51/57] usb-storage: Add rerror/werror properties
383d26
383d26
RH-Author: Kevin Wolf <kwolf@redhat.com>
383d26
Message-id: <20180702122017.29664-2-kwolf@redhat.com>
383d26
Patchwork-id: 81183
383d26
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/1] usb-storage: Add rerror/werror properties
383d26
Bugzilla: 1595180
383d26
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
383d26
RH-Acked-by: Max Reitz <mreitz@redhat.com>
383d26
RH-Acked-by: John Snow <jsnow@redhat.com>
383d26
383d26
The error handling policy was traditionally set with -drive, but with
383d26
-blockdev it is no longer possible to set frontend options. scsi-disk
383d26
(and other block devices) have long supported qdev properties to
383d26
configure the error handling policy, so let's add these options to
383d26
usb-storage as well and just forward them to the internal scsi-disk
383d26
instance.
383d26
383d26
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
383d26
Reviewed-by: Markus Armbruster <armbru@redhat.com>
383d26
(cherry picked from commit b8efb36b9e99dbea7370139c0866b97a933f78d4)
383d26
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 hw/scsi/scsi-bus.c     | 11 ++++++++++-
383d26
 hw/usb/dev-storage.c   |  2 ++
383d26
 include/hw/scsi/scsi.h |  2 ++
383d26
 3 files changed, 14 insertions(+), 1 deletion(-)
383d26
383d26
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
383d26
index 9646743..5905f6b 100644
383d26
--- a/hw/scsi/scsi-bus.c
383d26
+++ b/hw/scsi/scsi-bus.c
383d26
@@ -226,6 +226,8 @@ static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp)
383d26
 SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
383d26
                                       int unit, bool removable, int bootindex,
383d26
                                       bool share_rw,
383d26
+                                      BlockdevOnError rerror,
383d26
+                                      BlockdevOnError werror,
383d26
                                       const char *serial, Error **errp)
383d26
 {
383d26
     const char *driver;
383d26
@@ -262,6 +264,10 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
383d26
         object_unparent(OBJECT(dev));
383d26
         return NULL;
383d26
     }
383d26
+
383d26
+    qdev_prop_set_enum(dev, "rerror", rerror);
383d26
+    qdev_prop_set_enum(dev, "werror", werror);
383d26
+
383d26
     object_property_set_bool(OBJECT(dev), true, "realized", &err;;
383d26
     if (err != NULL) {
383d26
         error_propagate(errp, err);
383d26
@@ -285,7 +291,10 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
383d26
         }
383d26
         qemu_opts_loc_restore(dinfo->opts);
383d26
         scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo),
383d26
-                                  unit, false, -1, false, NULL, &error_fatal);
383d26
+                                  unit, false, -1, false,
383d26
+                                  BLOCKDEV_ON_ERROR_AUTO,
383d26
+                                  BLOCKDEV_ON_ERROR_AUTO,
383d26
+                                  NULL, &error_fatal);
383d26
     }
383d26
     loc_pop(&loc;;
383d26
 }
383d26
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
383d26
index b56c75a..68e2062 100644
383d26
--- a/hw/usb/dev-storage.c
383d26
+++ b/hw/usb/dev-storage.c
383d26
@@ -634,6 +634,7 @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
383d26
                  &usb_msd_scsi_info_storage, NULL);
383d26
     scsi_dev = scsi_bus_legacy_add_drive(&s->bus, blk, 0, !!s->removable,
383d26
                                          s->conf.bootindex, s->conf.share_rw,
383d26
+                                         s->conf.rerror, s->conf.werror,
383d26
                                          dev->serial,
383d26
                                          errp);
383d26
     blk_unref(blk);
383d26
@@ -687,6 +688,7 @@ static const VMStateDescription vmstate_usb_msd = {
383d26
 
383d26
 static Property msd_properties[] = {
383d26
     DEFINE_BLOCK_PROPERTIES(MSDState, conf),
383d26
+    DEFINE_BLOCK_ERROR_PROPERTIES(MSDState, conf),
383d26
     DEFINE_PROP_BIT("removable", MSDState, removable, 0, false),
383d26
     DEFINE_PROP_END_OF_LIST(),
383d26
 };
383d26
diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
383d26
index e35137e..1a7290d 100644
383d26
--- a/include/hw/scsi/scsi.h
383d26
+++ b/include/hw/scsi/scsi.h
383d26
@@ -154,6 +154,8 @@ static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
383d26
 SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
383d26
                                       int unit, bool removable, int bootindex,
383d26
                                       bool share_rw,
383d26
+                                      BlockdevOnError rerror,
383d26
+                                      BlockdevOnError werror,
383d26
                                       const char *serial, Error **errp);
383d26
 void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
383d26
 void scsi_legacy_handle_cmdline(void);
383d26
-- 
383d26
1.8.3.1
383d26