diff mbox series

[2/6] usb-storage: add commandlog property

Message ID 20201105134112.25119-3-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series usb: fix some guest-triggerable asserts | expand

Commit Message

Gerd Hoffmann Nov. 5, 2020, 1:41 p.m. UTC
Add property so scsi command logging can be switched
at runtime instead of compile time.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-storage.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Philippe Mathieu-Daudé Nov. 5, 2020, 2:27 p.m. UTC | #1
On 11/5/20 2:41 PM, Gerd Hoffmann wrote:
> Add property so scsi command logging can be switched
> at runtime instead of compile time.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/usb/dev-storage.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index e317cde8fd48..d5cc6137443c 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -25,8 +25,6 @@ 
 #include "qom/object.h"
 #include "trace.h"
 
-//#define DEBUG_MSD
-
 /* USB requests.  */
 #define MassStorageReset  0xff
 #define GetMaxLun         0xfe
@@ -59,6 +57,7 @@  struct MSDState {
     /* usb-storage only */
     BlockConf conf;
     uint32_t removable;
+    bool commandlog;
     SCSIDevice *scsi_dev;
 };
 typedef struct MSDState MSDState;
@@ -451,9 +450,9 @@  static void usb_msd_handle_data(USBDevice *dev, USBPacket *p)
             assert(le32_to_cpu(s->csw.residue) == 0);
             s->scsi_len = 0;
             s->req = scsi_req_new(scsi_dev, tag, cbw.lun, cbw.cmd, NULL);
-#ifdef DEBUG_MSD
-            scsi_req_print(s->req);
-#endif
+            if (s->commandlog) {
+                scsi_req_print(s->req);
+            }
             len = scsi_req_enqueue(s->req);
             if (len) {
                 scsi_req_continue(s->req);
@@ -684,6 +683,7 @@  static Property msd_properties[] = {
     DEFINE_BLOCK_PROPERTIES(MSDState, conf),
     DEFINE_BLOCK_ERROR_PROPERTIES(MSDState, conf),
     DEFINE_PROP_BIT("removable", MSDState, removable, 0, false),
+    DEFINE_PROP_BOOL("commandlog", MSDState, commandlog, false),
     DEFINE_PROP_END_OF_LIST(),
 };