qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] scsi-bus: fix endianness bug in store_lun()


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] scsi-bus: fix endianness bug in store_lun()
Date: Sat, 16 Mar 2013 09:13:38 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3

Il 16/03/2013 08:16, Alexey Kardashevskiy ha scritto:
> SCSI protocol is defined as big endian. The SCSI command REPORT_LUNS
> returns the list of LUNs, 8 bytes each.
> 
> The store_lun() function is called from scsi_target_emulate_report_luns()
> to fill the LUNs list which is sent later to a guest a response. However
> it puts the 2 bytes long big-endian value while it is 8 bytes long.

No, LUNs are composed of four 2-byte big-endian values.

What bug are you trying to fix?

Paolo

> The patch fixes it. Tested on PPC64 platform.
> 
> Signed-off-by: Alexey Kardashevskiy <address@hidden>
> ---
>  hw/scsi-bus.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
> index a97f1cd..7059dc2 100644
> --- a/hw/scsi-bus.c
> +++ b/hw/scsi-bus.c
> @@ -310,11 +310,11 @@ struct SCSITargetReq {
>  static void store_lun(uint8_t *outbuf, int lun)
>  {
>      if (lun < 256) {
> -        outbuf[1] = lun;
> +        outbuf[7] = lun;
>          return;
>      }
> -    outbuf[1] = (lun & 255);
> -    outbuf[0] = (lun >> 8) | 0x40;
> +    outbuf[7] = (lun & 255);
> +    outbuf[6] = (lun >> 8) | 0x40;
>  }
>  
>  static bool scsi_target_emulate_report_luns(SCSITargetReq *r)
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]