* [Qemu-devel] [PATCH v1 1/1] scsi-disk: Block Device Characteristics emulation fix
@ 2018-07-11 20:58 Daniel Henrique Barboza
2018-07-12 14:53 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Henrique Barboza @ 2018-07-11 20:58 UTC (permalink / raw)
To: qemu-devel; +Cc: famz, pbonzini, Daniel Henrique Barboza
The current BDC VPD page (page 0xb1) is too short. This can be
seen running sg_utils:
$ sg_vpd --page=bdc /dev/sda
Block device characteristics VPD page (SBC):
Block device characteristics VPD page length too short=8
By the SCSI spec, the expected size of the SBC page is 0x40.
There is no telling how the guest will behave with a shorter
message - it can ignore it, or worse, make (wrong)
assumptions.
This patch fixes the emulation by setting the size to 0x40.
This is the output of the previous sg_vpd command after
applying it:
$ sg_vpd --page=bdc /dev/sda -v
inquiry cdb: 12 01 b1 00 fc 00
Block device characteristics VPD page (SBC):
[PQual=0 Peripheral device type: disk]
Medium rotation rate is not reported
Product type: Not specified
WABEREQ=0
WACEREQ=0
Nominal form factor not reported
FUAB=0
VBULS=0
To improve readability, this patch also adds the VBULS value
explictly and add comments on the existing fields we're
setting.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/scsi/scsi-disk.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 32f3f96ff8..5ae7baa082 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -775,11 +775,12 @@ int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf)
}
case 0xb1: /* block device characteristics */
{
- buflen = 8;
+ buflen = 0x40;
outbuf[4] = (s->rotation_rate >> 8) & 0xff;
outbuf[5] = s->rotation_rate & 0xff;
- outbuf[6] = 0;
- outbuf[7] = 0;
+ outbuf[6] = 0; /* PRODUCT TYPE */
+ outbuf[7] = 0; /* WABEREQ | WACEREQ | NOMINAL FORM FACTOR */
+ outbuf[8] = 0; /* VBULS */
break;
}
case 0xb2: /* thin provisioning */
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v1 1/1] scsi-disk: Block Device Characteristics emulation fix
2018-07-11 20:58 [Qemu-devel] [PATCH v1 1/1] scsi-disk: Block Device Characteristics emulation fix Daniel Henrique Barboza
@ 2018-07-12 14:53 ` Paolo Bonzini
2018-07-12 15:04 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2018-07-12 14:53 UTC (permalink / raw)
To: Daniel Henrique Barboza, qemu-devel; +Cc: famz, Kevin Wolf, qemu block
On 11/07/2018 22:58, Daniel Henrique Barboza wrote:
> The current BDC VPD page (page 0xb1) is too short. This can be
> seen running sg_utils:
>
> $ sg_vpd --page=bdc /dev/sda
> Block device characteristics VPD page (SBC):
> Block device characteristics VPD page length too short=8
>
> By the SCSI spec, the expected size of the SBC page is 0x40.
> There is no telling how the guest will behave with a shorter
> message - it can ignore it, or worse, make (wrong)
> assumptions.
>
> This patch fixes the emulation by setting the size to 0x40.
> This is the output of the previous sg_vpd command after
> applying it:
>
> $ sg_vpd --page=bdc /dev/sda -v
> inquiry cdb: 12 01 b1 00 fc 00
> Block device characteristics VPD page (SBC):
> [PQual=0 Peripheral device type: disk]
> Medium rotation rate is not reported
> Product type: Not specified
> WABEREQ=0
> WACEREQ=0
> Nominal form factor not reported
> FUAB=0
> VBULS=0
>
> To improve readability, this patch also adds the VBULS value
> explictly and add comments on the existing fields we're
> setting.
>
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Kevin kindly agreed to take this through the block tree, so
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Thanks,
Paolo
> ---
> hw/scsi/scsi-disk.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index 32f3f96ff8..5ae7baa082 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -775,11 +775,12 @@ int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf)
> }
> case 0xb1: /* block device characteristics */
> {
> - buflen = 8;
> + buflen = 0x40;
> outbuf[4] = (s->rotation_rate >> 8) & 0xff;
> outbuf[5] = s->rotation_rate & 0xff;
> - outbuf[6] = 0;
> - outbuf[7] = 0;
> + outbuf[6] = 0; /* PRODUCT TYPE */
> + outbuf[7] = 0; /* WABEREQ | WACEREQ | NOMINAL FORM FACTOR */
> + outbuf[8] = 0; /* VBULS */
> break;
> }
> case 0xb2: /* thin provisioning */
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v1 1/1] scsi-disk: Block Device Characteristics emulation fix
2018-07-12 14:53 ` Paolo Bonzini
@ 2018-07-12 15:04 ` Kevin Wolf
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2018-07-12 15:04 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Daniel Henrique Barboza, qemu-devel, famz, qemu block
Am 12.07.2018 um 16:53 hat Paolo Bonzini geschrieben:
> On 11/07/2018 22:58, Daniel Henrique Barboza wrote:
> > The current BDC VPD page (page 0xb1) is too short. This can be
> > seen running sg_utils:
> >
> > $ sg_vpd --page=bdc /dev/sda
> > Block device characteristics VPD page (SBC):
> > Block device characteristics VPD page length too short=8
> >
> > By the SCSI spec, the expected size of the SBC page is 0x40.
> > There is no telling how the guest will behave with a shorter
> > message - it can ignore it, or worse, make (wrong)
> > assumptions.
> >
> > This patch fixes the emulation by setting the size to 0x40.
> > This is the output of the previous sg_vpd command after
> > applying it:
> >
> > $ sg_vpd --page=bdc /dev/sda -v
> > inquiry cdb: 12 01 b1 00 fc 00
> > Block device characteristics VPD page (SBC):
> > [PQual=0 Peripheral device type: disk]
> > Medium rotation rate is not reported
> > Product type: Not specified
> > WABEREQ=0
> > WACEREQ=0
> > Nominal form factor not reported
> > FUAB=0
> > VBULS=0
> >
> > To improve readability, this patch also adds the VBULS value
> > explictly and add comments on the existing fields we're
> > setting.
> >
> > Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>
> Kevin kindly agreed to take this through the block tree, so
>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-12 15:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-11 20:58 [Qemu-devel] [PATCH v1 1/1] scsi-disk: Block Device Characteristics emulation fix Daniel Henrique Barboza
2018-07-12 14:53 ` Paolo Bonzini
2018-07-12 15:04 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).