Patchwork [09/10] usb-storage: add scsi_off, remove scsi_buf

login
register
mail settings
Submitter Gerd Hoffmann
Date May 25, 2012, 9:44 a.m.
Message ID <1337939061-13629-10-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/161264/
State New
Headers show

Comments

Gerd Hoffmann - May 25, 2012, 9:44 a.m.
Repace the running buffer pointer (scsi_buf) with a buffer offset
field (scsi_off).  The later is alot easier to live-migrate.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-storage.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
Paolo Bonzini - May 25, 2012, 10:09 a.m.
Il 25/05/2012 11:44, Gerd Hoffmann ha scritto:
> Repace the running buffer pointer (scsi_buf) with a buffer offset
> field (scsi_off).  The later is alot easier to live-migrate.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/usb/dev-storage.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
> index 1477599..1975d26 100644
> --- a/hw/usb/dev-storage.c
> +++ b/hw/usb/dev-storage.c
> @@ -48,8 +48,8 @@ struct usb_msd_csw {
>  typedef struct {
>      USBDevice dev;
>      enum USBMSDMode mode;
> +    uint32_t scsi_off;
>      uint32_t scsi_len;
> -    uint8_t *scsi_buf;
>      uint32_t data_len;
>      struct usb_msd_csw csw;
>      SCSIRequest *req;
> @@ -178,9 +178,9 @@ static void usb_msd_copy_data(MSDState *s, USBPacket *p)
>      len = p->iov.size - p->result;
>      if (len > s->scsi_len)
>          len = s->scsi_len;
> -    usb_packet_copy(p, s->scsi_buf, len);
> +    usb_packet_copy(p, scsi_req_get_buf(s->req) + s->scsi_off, len);
>      s->scsi_len -= len;
> -    s->scsi_buf += len;
> +    s->scsi_off += len;
>      s->data_len -= len;
>      if (s->scsi_len == 0 || s->data_len == 0) {
>          scsi_req_continue(s->req);
> @@ -219,7 +219,7 @@ static void usb_msd_transfer_data(SCSIRequest *req, uint32_t len)
>  
>      assert((s->mode == USB_MSDM_DATAOUT) == (req->cmd.mode == SCSI_XFER_TO_DEV));
>      s->scsi_len = len;
> -    s->scsi_buf = scsi_req_get_buf(req);
> +    s->scsi_off = 0;
>      if (p) {
>          usb_msd_copy_data(s, p);
>          p = s->packet;

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Patch

diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index 1477599..1975d26 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -48,8 +48,8 @@  struct usb_msd_csw {
 typedef struct {
     USBDevice dev;
     enum USBMSDMode mode;
+    uint32_t scsi_off;
     uint32_t scsi_len;
-    uint8_t *scsi_buf;
     uint32_t data_len;
     struct usb_msd_csw csw;
     SCSIRequest *req;
@@ -178,9 +178,9 @@  static void usb_msd_copy_data(MSDState *s, USBPacket *p)
     len = p->iov.size - p->result;
     if (len > s->scsi_len)
         len = s->scsi_len;
-    usb_packet_copy(p, s->scsi_buf, len);
+    usb_packet_copy(p, scsi_req_get_buf(s->req) + s->scsi_off, len);
     s->scsi_len -= len;
-    s->scsi_buf += len;
+    s->scsi_off += len;
     s->data_len -= len;
     if (s->scsi_len == 0 || s->data_len == 0) {
         scsi_req_continue(s->req);
@@ -219,7 +219,7 @@  static void usb_msd_transfer_data(SCSIRequest *req, uint32_t len)
 
     assert((s->mode == USB_MSDM_DATAOUT) == (req->cmd.mode == SCSI_XFER_TO_DEV));
     s->scsi_len = len;
-    s->scsi_buf = scsi_req_get_buf(req);
+    s->scsi_off = 0;
     if (p) {
         usb_msd_copy_data(s, p);
         p = s->packet;