All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-block@nongnu.org, pkrempa@redhat.com,
	libvir-list@redhat.com, qemu-devel@nongnu.org,
	pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/3] scsi-disk: Don't use empty string as device id
Date: Wed, 30 Jan 2019 12:39:07 +0100	[thread overview]
Message-ID: <20190130113907.GA892@localhost.localdomain> (raw)
In-Reply-To: <87a7jjqv2l.fsf@dusky.pond.sub.org>

Am 29.01.2019 um 17:37 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
> 
> > scsi-disk includes in the Device Identification VPD page, depending on
> > configuration amongst others, a vendor specific designator that consists
> > either of the serial number if given or the BlockBackend name (which is
> > a host detail that better shouldn't have been leaked to the guest, but
> > now we have to maintain it for compatibility).
> >
> > With anonymous BlockBackends, i.e. scsi-disk devices constructed with
> > drive=<node-name>, and no serial number explicitly specified, this ends
> > up as an empty string. If this happens to more than one disk, we have
> > accidentally signalled to the OS that this is a multipath setup, which
> > is obviously not what was intended.
> >
> > Instead of using an empty string for the vendor specific designator,
> > simply leave out that designator, which makes Linux detect such setups
> > as separate disks again.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  hw/scsi/scsi-disk.c | 14 ++++++++------
> >  1 file changed, 8 insertions(+), 6 deletions(-)
> >
> > diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> > index 0e9027c8f3..93eef40b87 100644
> > --- a/hw/scsi/scsi-disk.c
> > +++ b/hw/scsi/scsi-disk.c
> > @@ -652,12 +652,14 @@ static int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf)
> >          DPRINTF("Inquiry EVPD[Device identification] "
> >                  "buffer size %zd\n", req->cmd.xfer);
> >  
> > -        outbuf[buflen++] = 0x2; /* ASCII */
> > -        outbuf[buflen++] = 0;   /* not officially assigned */
> > -        outbuf[buflen++] = 0;   /* reserved */
> > -        outbuf[buflen++] = id_len; /* length of data following */
> > -        memcpy(outbuf + buflen, str, id_len);
> > -        buflen += id_len;
> > +        if (id_len) {
> > +            outbuf[buflen++] = 0x2; /* ASCII */
> > +            outbuf[buflen++] = 0;   /* not officially assigned */
> > +            outbuf[buflen++] = 0;   /* reserved */
> > +            outbuf[buflen++] = id_len; /* length of data following */
> > +            memcpy(outbuf + buflen, str, id_len);
> > +            buflen += id_len;
> > +        }
> >  
> >          if (s->qdev.wwn) {
> >              outbuf[buflen++] = 0x1; /* Binary */
> 
> Before the patch, we always add this descriptor, but as you explain in
> your commit message, its contents can be wrong.
> 
> After the patch, we add this descriptor only when we have a suitable
> name (we use serial number, else falling back to BlockBackend name).
> It's possible we add *no* descriptors.  I wonder whether that's okay.  I
> consulted section SPC-4 section 7.8.5 Device Identification VPD page,
> but failed to penetrate the dense prose there.

I wasn't completely sure about the interpretation either, but to me the
most likely one is that according to SPC-4 not having a descriptor is
illegal because 7.8.5.2.1 requires that at least one descriptor of type
1, 2, 3 or 8 shall be included (all of them contain some sort of a
registered vendor ID, which we don't have).

The one that I'm removing is type 0, so it didn't meet the requirement
even before and I concluded that if this patch doesn't make things worse
in terms of spec compliance and fixes things in practice, it can't be
completely wrong.

Kevin

  reply	other threads:[~2019-01-30 11:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25 17:46 [Qemu-devel] [PATCH 0/3] scsi-disk: Device Identification fixes Kevin Wolf
2019-01-25 17:46 ` [Qemu-devel] [PATCH 1/3] scsi-disk: Don't use empty string as device id Kevin Wolf
2019-01-29 12:30   ` Philippe Mathieu-Daudé
2019-01-29 16:37   ` Markus Armbruster
2019-01-30 11:39     ` Kevin Wolf [this message]
2019-01-25 17:46 ` [Qemu-devel] [PATCH 2/3] scsi-disk: Add device_id property Kevin Wolf
2019-01-28  8:50   ` Peter Krempa
2019-01-28  9:08     ` Peter Krempa
2019-01-28 14:41     ` Kevin Wolf
2019-01-28 16:55       ` Markus Armbruster
2019-01-28 17:49         ` Kevin Wolf
2019-01-29  7:10           ` Markus Armbruster
2019-01-29 12:25             ` [Qemu-devel] [libvirt] " Peter Krempa
2019-01-29  9:40         ` [Qemu-devel] " Peter Krempa
2019-01-25 17:46 ` [Qemu-devel] [PATCH 3/3] scsi-disk: Deprecate device_id fallback to BlockBackend name Kevin Wolf
2019-01-29 15:58   ` Daniel P. Berrangé
2019-02-04  9:56     ` Kevin Wolf
2019-02-04 10:06       ` Daniel P. Berrangé
2019-01-25 20:52 ` [Qemu-devel] [PATCH 0/3] scsi-disk: Device Identification fixes Eric Blake
2019-02-01 12:51 ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190130113907.GA892@localhost.localdomain \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.