render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0007-virtio-scsi-move-request-related-items-from-.h-to-.c.patch

a575c5
From: Stefan Hajnoczi <stefanha@redhat.com>
a575c5
Date: Tue, 17 May 2022 09:28:26 +0100
a575c5
Subject: [PATCH] virtio-scsi: move request-related items from .h to .c
a575c5
Content-type: text/plain
a575c5
a575c5
There is no longer a need to expose the request and related APIs in
a575c5
virtio-scsi.h since there are no callers outside virtio-scsi.c.
a575c5
a575c5
Note the block comment in VirtIOSCSIReq has been adjusted to meet the
a575c5
coding style.
a575c5
a575c5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
a575c5
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
a575c5
Message-id: 20220427143541.119567-7-stefanha@redhat.com
a575c5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
a575c5
(cherry picked from commit 3dc584abeef0e1277c2de8c1c1974cb49444eb0a)
a575c5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
a575c5
---
a575c5
 hw/scsi/virtio-scsi.c           | 45 ++++++++++++++++++++++++++++++---
a575c5
 include/hw/virtio/virtio-scsi.h | 40 -----------------------------
a575c5
 2 files changed, 41 insertions(+), 44 deletions(-)
a575c5
a575c5
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
a575c5
index 12c6a21202..db54d104be 100644
a575c5
--- a/hw/scsi/virtio-scsi.c
a575c5
+++ b/hw/scsi/virtio-scsi.c
a575c5
@@ -29,6 +29,43 @@
a575c5
 #include "hw/virtio/virtio-access.h"
a575c5
 #include "trace.h"
a575c5
 
a575c5
+typedef struct VirtIOSCSIReq {
a575c5
+    /*
a575c5
+     * Note:
a575c5
+     * - fields up to resp_iov are initialized by virtio_scsi_init_req;
a575c5
+     * - fields starting at vring are zeroed by virtio_scsi_init_req.
a575c5
+     */
a575c5
+    VirtQueueElement elem;
a575c5
+
a575c5
+    VirtIOSCSI *dev;
a575c5
+    VirtQueue *vq;
a575c5
+    QEMUSGList qsgl;
a575c5
+    QEMUIOVector resp_iov;
a575c5
+
a575c5
+    union {
a575c5
+        /* Used for two-stage request submission */
a575c5
+        QTAILQ_ENTRY(VirtIOSCSIReq) next;
a575c5
+
a575c5
+        /* Used for cancellation of request during TMFs */
a575c5
+        int remaining;
a575c5
+    };
a575c5
+
a575c5
+    SCSIRequest *sreq;
a575c5
+    size_t resp_size;
a575c5
+    enum SCSIXferMode mode;
a575c5
+    union {
a575c5
+        VirtIOSCSICmdResp     cmd;
a575c5
+        VirtIOSCSICtrlTMFResp tmf;
a575c5
+        VirtIOSCSICtrlANResp  an;
a575c5
+        VirtIOSCSIEvent       event;
a575c5
+    } resp;
a575c5
+    union {
a575c5
+        VirtIOSCSICmdReq      cmd;
a575c5
+        VirtIOSCSICtrlTMFReq  tmf;
a575c5
+        VirtIOSCSICtrlANReq   an;
a575c5
+    } req;
a575c5
+} VirtIOSCSIReq;
a575c5
+
a575c5
 static inline int virtio_scsi_get_lun(uint8_t *lun)
a575c5
 {
a575c5
     return ((lun[2] << 8) | lun[3]) & 0x3FFF;
a575c5
@@ -45,7 +82,7 @@ static inline SCSIDevice *virtio_scsi_device_get(VirtIOSCSI *s, uint8_t *lun)
a575c5
     return scsi_device_get(&s->bus, 0, lun[1], virtio_scsi_get_lun(lun));
a575c5
 }
a575c5
 
a575c5
-void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
a575c5
+static void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
a575c5
 {
a575c5
     VirtIODevice *vdev = VIRTIO_DEVICE(s);
a575c5
     const size_t zero_skip =
a575c5
@@ -58,7 +95,7 @@ void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
a575c5
     memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip);
a575c5
 }
a575c5
 
a575c5
-void virtio_scsi_free_req(VirtIOSCSIReq *req)
a575c5
+static void virtio_scsi_free_req(VirtIOSCSIReq *req)
a575c5
 {
a575c5
     qemu_iovec_destroy(&req->resp_iov);
a575c5
     qemu_sglist_destroy(&req->qsgl);
a575c5
@@ -801,8 +838,8 @@ static void virtio_scsi_reset(VirtIODevice *vdev)
a575c5
     s->events_dropped = false;
a575c5
 }
a575c5
 
a575c5
-void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
a575c5
-                            uint32_t event, uint32_t reason)
a575c5
+static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
a575c5
+                                   uint32_t event, uint32_t reason)
a575c5
 {
a575c5
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
a575c5
     VirtIOSCSIReq *req;
a575c5
diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
a575c5
index 2497530064..abdda2cbd0 100644
a575c5
--- a/include/hw/virtio/virtio-scsi.h
a575c5
+++ b/include/hw/virtio/virtio-scsi.h
a575c5
@@ -94,42 +94,6 @@ struct VirtIOSCSI {
a575c5
     uint32_t host_features;
a575c5
 };
a575c5
 
a575c5
-typedef struct VirtIOSCSIReq {
a575c5
-    /* Note:
a575c5
-     * - fields up to resp_iov are initialized by virtio_scsi_init_req;
a575c5
-     * - fields starting at vring are zeroed by virtio_scsi_init_req.
a575c5
-     * */
a575c5
-    VirtQueueElement elem;
a575c5
-
a575c5
-    VirtIOSCSI *dev;
a575c5
-    VirtQueue *vq;
a575c5
-    QEMUSGList qsgl;
a575c5
-    QEMUIOVector resp_iov;
a575c5
-
a575c5
-    union {
a575c5
-        /* Used for two-stage request submission */
a575c5
-        QTAILQ_ENTRY(VirtIOSCSIReq) next;
a575c5
-
a575c5
-        /* Used for cancellation of request during TMFs */
a575c5
-        int remaining;
a575c5
-    };
a575c5
-
a575c5
-    SCSIRequest *sreq;
a575c5
-    size_t resp_size;
a575c5
-    enum SCSIXferMode mode;
a575c5
-    union {
a575c5
-        VirtIOSCSICmdResp     cmd;
a575c5
-        VirtIOSCSICtrlTMFResp tmf;
a575c5
-        VirtIOSCSICtrlANResp  an;
a575c5
-        VirtIOSCSIEvent       event;
a575c5
-    } resp;
a575c5
-    union {
a575c5
-        VirtIOSCSICmdReq      cmd;
a575c5
-        VirtIOSCSICtrlTMFReq  tmf;
a575c5
-        VirtIOSCSICtrlANReq   an;
a575c5
-    } req;
a575c5
-} VirtIOSCSIReq;
a575c5
-
a575c5
 static inline void virtio_scsi_acquire(VirtIOSCSI *s)
a575c5
 {
a575c5
     if (s->ctx) {
a575c5
@@ -151,10 +115,6 @@ void virtio_scsi_common_realize(DeviceState *dev,
a575c5
                                 Error **errp);
a575c5
 
a575c5
 void virtio_scsi_common_unrealize(DeviceState *dev);
a575c5
-void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req);
a575c5
-void virtio_scsi_free_req(VirtIOSCSIReq *req);
a575c5
-void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
a575c5
-                            uint32_t event, uint32_t reason);
a575c5
 
a575c5
 void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp);
a575c5
 int virtio_scsi_dataplane_start(VirtIODevice *s);